test
This commit is contained in:
parent
f3881af24f
commit
9189cbcd92
1 changed files with 42 additions and 37 deletions
|
|
@ -7,7 +7,7 @@ function module.init(shared)
|
|||
local mount = {};
|
||||
mount.__index = mount;
|
||||
function mount:unmount()
|
||||
local this = self.this;
|
||||
for _,this in ipairs(self.items) do
|
||||
local typeThis = type(this);
|
||||
if typeThis == "userdata" then
|
||||
this:Destroy();
|
||||
|
|
@ -23,13 +23,17 @@ function module.init(shared)
|
|||
-- todo for remove child on parent
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function new.getHolder(item)
|
||||
return (type(item) == "table") and (item._holder or item.holder or item.__holder) or item;
|
||||
end
|
||||
local getHolder = new.getHolder
|
||||
-- we should add plugin support
|
||||
function new.mount(to,this,inst)
|
||||
local pack = table.pack;
|
||||
function new.mount(to,...)
|
||||
local items = pack(...);
|
||||
for _,this in ipairs(items) do
|
||||
local thisO = this;
|
||||
if type(this) == "table" then
|
||||
thisO = this.__object;
|
||||
|
|
@ -47,7 +51,7 @@ function module.init(shared)
|
|||
rawset(this,"__parent",to);
|
||||
end
|
||||
if thisO then
|
||||
thisO.Parent = inst or getHolder(to);
|
||||
thisO.Parent = getHolder(to);
|
||||
end
|
||||
if type(to) == "table" then
|
||||
local child = rawget(to,"__child");
|
||||
|
|
@ -57,7 +61,8 @@ function module.init(shared)
|
|||
end
|
||||
insert(child,this);
|
||||
end
|
||||
return setmetatable({to = to,this = this},mount);
|
||||
end
|
||||
return setmetatable({to = to,this = items},mount);
|
||||
end
|
||||
|
||||
setmetatable(new,{
|
||||
|
|
|
|||
Loading…
Reference in a new issue