summaryrefslogtreecommitdiff
path: root/src/scripts/elua/core/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripts/elua/core/util.lua')
-rw-r--r--src/scripts/elua/core/util.lua19
1 files changed, 5 insertions, 14 deletions
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)