summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/luajit/eo.lua21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua
index dec4ec9050..856de56ca6 100644
--- a/src/bindings/luajit/eo.lua
+++ b/src/bindings/luajit/eo.lua
@@ -147,6 +147,13 @@ eo_event_del = ffi.cast("Eo_Event_Cb", function(data, obj, desc, einfo)
147end) 147end)
148 148
149eo_event_cb = ffi.cast("Eo_Event_Cb", function(data, obj, desc, einfo) 149eo_event_cb = ffi.cast("Eo_Event_Cb", function(data, obj, desc, einfo)
150 local addr = eo_obj_addr_get(obj)
151 local cbs = callbacks[addr]
152 assert(cbs)
153 local cidx = tonumber(ffi.cast("intptr_t", cbs))
154 local fun = cbs[cidx]
155 assert(fun)
156 return fun() ~= false
150end) 157end)
151 158
152local connect = function(self, ename, func, priority) 159local connect = function(self, ename, func, priority)
@@ -156,11 +163,17 @@ local connect = function(self, ename, func, priority)
156 end 163 end
157 local cl = eo_classes["Eo_Base"] 164 local cl = eo_classes["Eo_Base"]
158 M.__do_start(self, cl) 165 M.__do_start(self, cl)
166 -- add the callback to the respective array
167 local addr = eo_obj_addr_get(self)
168 local cbs = callbacks[addr]
169 if not cbs then
170 cbs = {}
171 callbacks[addr] = cbs
172 end
173 local cidx = #cbs + 1
174 cbs[cidx] = func
159 eo.eo_event_callback_priority_add(ev, priority or 0, 175 eo.eo_event_callback_priority_add(ev, priority or 0,
160 function(data, obj, desc, einfo) 176 eo_event_cb, ffi.cast("void *", cidx))
161 return func(obj, einfo) ~= false
162 end,
163 nil)
164 M.__do_end() 177 M.__do_end()
165end 178end
166 179