diff --git a/multi/init.lua b/multi/init.lua index a23ddd2..7069931 100644 --- a/multi/init.lua +++ b/multi/init.lua @@ -29,9 +29,10 @@ local thread = {} if not _G["$multi"] then _G["$multi"] = {multi=multi,thread=thread} end + multi.Version = "14.2.0" multi.stage = "stable" -multi.__index = multi +--multi.__index = multi multi.Name = "multi.root" multi.Mainloop = {} multi.Garbage = {} @@ -312,9 +313,9 @@ function multi:newBase(ins) if not(self.Type=='mainprocess' or self.Type=='process' or self.Type=='queue') then error('Can only create an object on multi or an interface obj') return false end local c = {} if self.Type=='process' or self.Type=='queue' then - setmetatable(c, self.Parent) + setmetatable(c, {__index = multi}) -- setmetatable(c, {__index = multi}) else - setmetatable(c, self) + setmetatable(c, {__index = multi}) end c.Active=true c.func={} @@ -519,7 +520,7 @@ ignoreconn = false function multi:newProcessor(file) if not(self.Type=='mainprocess') then error('Can only create an interface on the multi obj') return false end local c = {} - setmetatable(c, self) + setmetatable(c, {__index = multi}) c.Parent=self c.Active=true c.func={} diff --git a/test.lua b/test.lua index 5f5d685..d6e4a91 100644 --- a/test.lua +++ b/test.lua @@ -1,54 +1,79 @@ package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path -- local sterilizer = require("multi.integration.sterilization") multi,thread = require("multi"):init() +local function inList(t,o,n) + local c = 1 + if not o["$__COUNTER__$"] then + o["$__COUNTER__$"] = 1 + end + if o["$__COUNTER__$"]==n then + return o + end + for i,v in pairs(t) do + if v==o then + o["$__COUNTER__$"] = o["$__COUNTER__$"] + 1 + if o["$__COUNTER__$"]==n then + return o + end + end + end +end +function initLoop(t,max) + for i,v in pairs(t) do + v["$__COUNTER__$"] = max + end + return t +end +function _getPath(tbl, obj, conn, loop, path, orig) + local max = 100 + if not loop then loop = initLoop({package,_G,math,io,os,debug,string,table,coroutine},max) end + if not path then path = {} end + if not ref then ref = {} end + for k, v in pairs(tbl) do + if type(v) == "table" and type(k)~="number" and not inList(loop,v,max) then -- Only go this deep + if v~=orig and k=="Parent" then + -- + else + --print(table.concat(path,".").."."..k) + table.insert(ref,v) + table.insert(loop,v) + table.insert(path,k) + if v==obj then + conn(table.concat(path,".").."."..k,ref) + end + _getPath(v, obj, conn, loop, path, orig) + table.remove(path) + table.remove(ref) + end + end + if v==obj and orig[k] then + conn(k,ref) + elseif v==obj then + if type(k)=="number" then return end + local str = table.concat(path,".").."."..k + conn(str,ref) + end + end +end +function getPath(tbl,obj) + local instances = {} + _getPath(tbl, obj, function(ins) + table.insert(instances,ins) + end,nil,nil,tbl) + local min = math.huge + local ins + for i,v in pairs(instances) do + if #v