q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=c18b1704a94f6a6d6db552a0e2c5f23b720fca82
commit c18b1704a94f6a6d6db552a0e2c5f23b720fca82 Author: Daniel Kolesa <d.kol...@samsung.com> Date: Wed Feb 25 13:03:00 2015 +0000 elua: delegative multiple inheritance support in util object system --- src/scripts/elua/core/util.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/scripts/elua/core/util.lua b/src/scripts/elua/core/util.lua index b273054..7b7120f 100644 --- a/src/scripts/elua/core/util.lua +++ b/src/scripts/elua/core/util.lua @@ -13,6 +13,18 @@ local M = {} local getmetatable, setmetatable = getmetatable, setmetatable +-- multiple inheritance index with depth-first search +local multi_index = function(self, name) + local protos = self.__protos + for i = 1, #protos do + local proto = protos[i] + local v = proto[name] + if v ~= nil then + return v + end + end +end + M.Object = { __call = function(self, ...) local r = self:clone() @@ -41,6 +53,18 @@ M.Object = { return is end, + add_parent = function(self, parent) + local protos = self.__protos + if protos then + -- we have multiple inheritance set up + protos[#protos + 1] = parent + else + self.__protos = { self.__proto, parent } + self.__proto = nil + self.__index = multi_index + end + end, + mixin = function(self, obj) for k, v in pairs(obj) do self[k] = v end end, --