summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-02-26 15:36:15 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2015-02-26 15:36:15 +0000
commitb4dee8db54816b7325629a65e94dc75c0ce9ebf0 (patch)
treeae431ca4ab94e5c241305ba2a75051e2720c948b /src/bindings
parent55ba0dfa4ba68b5bb568670b3b1dbd1360935528 (diff)
elua: update eo bindings for lualian generated code
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/luajit/eo.lua82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua
index 8ebbb383e4..09add8b402 100644
--- a/src/bindings/luajit/eo.lua
+++ b/src/bindings/luajit/eo.lua
@@ -174,19 +174,52 @@ M.eo_class_get = function(name)
174 return eo_classes[name] 174 return eo_classes[name]
175end 175end
176 176
177M.class_register = function(name, parent, body, eocl) 177local inherit_meta = function(body, field, parents, mixins)
178 parent = classes[parent] 178 local o = body[field]
179 if body.__events then 179 if o then
180 body.__events = parent.__events:clone(body.__events) 180 o = parents[1][field]:clone(o)
181 for i = 2, #parents do o:add_parent(parents[i][field]) end
182 for i = 1, #mixins do o:add_mixin (mixins [i][field]) end
183 body[field] = o
181 end 184 end
182 if body.__properties then 185end
183 body.__properties = parent.__properties:clone(body.__properties) 186
187M.class_register = function(name, parents, mixins, body, eocl)
188 -- map given names to objects
189 local pars = {}
190 for i = 1, #parents do pars[i] = classes[parents[i]] end
191 -- for mixins, we need to check if it hasn't already been mixed in
192 -- in some parent (doesn't matter how deep down the tree), because
193 -- if it has, we need to skip it (for proper inheritance lookup order)
194 local mins = {}
195 local midx = 1
196 for i = 1, #mixins do
197 local mixin = mixins[i]
198 local ck, hasmi = "__mixin_" .. mixin, false
199 if mixin[ck] then
200 for i = 1, #pars do
201 if pars[i][ck] then
202 hasmi = true
203 break
204 end
205 end
206 end
207 if not hasmi then
208 mins[midx] = mixin
209 midx = midx + 1
210 end
184 end 211 end
212
213 inherit_meta(body, "__events" , pars, mins)
214 inherit_meta(body, "__properties", pars, mins)
215
216 local lcl = pars[1]:clone(body)
217 for i = 2, #pars do lcl:add_parent(pars[i]) end
218 for i = 1, #mins do lcl:add_mixin (mins[i]) end
219
185 local addr = eo_class_addr_get(eocl) 220 local addr = eo_class_addr_get(eocl)
186 classes[name] = parent:clone(body) 221 classes [name], classes [addr] = lcl , lcl
187 classes[addr] = classes[name] 222 eo_classes[name], eo_classes[addr] = eocl, eocl
188 eo_classes[name] = eocl
189 eo_classes[addr] = eocl
190end 223end
191 224
192M.class_unregister = function(name) 225M.class_unregister = function(name)
@@ -197,35 +230,6 @@ M.class_unregister = function(name)
197 eo_classes[addr] = nil 230 eo_classes[addr] = nil
198end 231end
199 232
200local mixin_tbl = function(cl, mixin, field)
201 local mxt = mixin[field]
202 if mxt then
203 local clt = rawget(cl, field)
204 if not clt then
205 -- will always succeed, even if it means deep lookups
206 clt = cl.__protos[1][field]:clone()
207 rawset(cl, field, clt)
208 end
209 for k, v in pairs(mxt) do clt[k] = v end
210 end
211end
212
213M.class_mixin = function(name, mixin)
214 local cl = classes[name]
215 local mi = classes[mixin]
216 local ck = "__mixin_" .. mixin
217 -- do not mixin if it already has been mixed in previously
218 -- but only do it for mixins, not for ifaces, for proper lookup order
219 if mi[ck] and cl[ck] then
220 return
221 end
222 -- mixin properties/events
223 mixin_tbl(cl, mi, "__properties")
224 mixin_tbl(cl, mi, "__events")
225 -- mixin the rest
226 cl:mixin(classes[mixin])
227end
228
229local obj_gccb = function(obj) 233local obj_gccb = function(obj)
230 eo.eo_unref(obj) 234 eo.eo_unref(obj)
231end 235end