summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-02-25 15:11:52 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2015-02-25 15:11:52 +0000
commit212571c40618f0b3a1c336d73548fd021e6cd278 (patch)
tree7578284882d7aa5a841263392a857f8f0d270a8f
parent4ecedc519866cdb56fc5d566cea17deb3401a01f (diff)
elua: guarantee multiple inheritance availability on any object
-rw-r--r--src/bindings/luajit/eina/accessor.lua2
-rw-r--r--src/bindings/luajit/eo.lua2
-rw-r--r--src/scripts/elua/core/util.lua19
3 files changed, 7 insertions, 16 deletions
diff --git a/src/bindings/luajit/eina/accessor.lua b/src/bindings/luajit/eina/accessor.lua
index 7634590d0e..55afa62427 100644
--- a/src/bindings/luajit/eina/accessor.lua
+++ b/src/bindings/luajit/eina/accessor.lua
@@ -102,7 +102,7 @@ M.Accessor = util.Readonly_Object:clone {
102 clone = function(self) 102 clone = function(self)
103 self = dgetmt(self) 103 self = dgetmt(self)
104 if not self.__accessor then return nil end 104 if not self.__accessor then return nil end
105 return self.__proto(self.__accessor:clone()) 105 return self.__protos[1](self.__accessor:clone())
106 end, 106 end,
107 107
108 data_get = function(self, pos) 108 data_get = function(self, pos)
diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua
index 9067a057b0..8ebbb383e4 100644
--- a/src/bindings/luajit/eo.lua
+++ b/src/bindings/luajit/eo.lua
@@ -203,7 +203,7 @@ local mixin_tbl = function(cl, mixin, field)
203 local clt = rawget(cl, field) 203 local clt = rawget(cl, field)
204 if not clt then 204 if not clt then
205 -- will always succeed, even if it means deep lookups 205 -- will always succeed, even if it means deep lookups
206 clt = cl.__proto[field]:clone() 206 clt = cl.__protos[1][field]:clone()
207 rawset(cl, field, clt) 207 rawset(cl, field, clt)
208 end 208 end
209 for k, v in pairs(mxt) do clt[k] = v end 209 for k, v in pairs(mxt) do clt[k] = v end
diff --git a/src/scripts/elua/core/util.lua b/src/scripts/elua/core/util.lua
index 841ceb08ca..533389904f 100644
--- a/src/scripts/elua/core/util.lua
+++ b/src/scripts/elua/core/util.lua
@@ -15,6 +15,7 @@ local getmetatable, setmetatable = getmetatable, setmetatable
15 15
16-- multiple inheritance index with depth-first search 16-- multiple inheritance index with depth-first search
17local proto_lookup = function(protos, name) 17local proto_lookup = function(protos, name)
18 if not protos then return nil end
18 for i = 1, #protos do 19 for i = 1, #protos do
19 local proto = protos[i] 20 local proto = protos[i]
20 local v = proto[name] 21 local v = proto[name]
@@ -40,7 +41,8 @@ M.Object = {
40 41
41 clone = function(self, o) 42 clone = function(self, o)
42 o = o or {} 43 o = o or {}
43 o.__index, o.__proto, o.__call = self, self, self.__call 44 o.__index, o.__protos, o.__mixins, o.__call =
45 multi_index, { self }, {}, self.__call
44 if not o.__tostring then 46 if not o.__tostring then
45 o.__tostring = self.__tostring 47 o.__tostring = self.__tostring
46 end 48 end
@@ -61,23 +63,12 @@ M.Object = {
61 63
62 add_parent = function(self, parent) 64 add_parent = function(self, parent)
63 local protos = self.__protos 65 local protos = self.__protos
64 if protos then 66 protos[#protos + 1] = parent
65 -- we have multiple inheritance set up
66 protos[#protos + 1] = parent
67 else
68 self.__protos = { self.__proto, parent }
69 self.__proto = nil
70 self.__index = multi_index
71 end
72 end, 67 end,
73 68
74 add_mixin = function(self, mixin) 69 add_mixin = function(self, mixin)
75 local mixins = self.__mixins 70 local mixins = self.__mixins
76 if mixins then 71 mixins[#mixins + 1] = mixin
77 mixins[#mixins + 1] = mixin
78 else
79 self.__mixins = { mixin }
80 end
81 end, 72 end,
82 73
83 __tostring = function(self) 74 __tostring = function(self)