refactoring, removed tooltip source
This commit is contained in:
+4
-5
@@ -1,12 +1,11 @@
|
||||
if module then return end
|
||||
local strfind, type, setmetatable, setfenv, _G = strfind, type, setmetatable, setfenv, getfenv(0)
|
||||
local error, nop, id, define, include, create_module, nop_default_mt, public_modifier_mt, proxy_mt
|
||||
local error, nop, define, include, create_module, nop_default_mt, public_modifier_mt, proxy_mt
|
||||
local loaded, defined, interfaces, environments = {}, {}, {}, {}
|
||||
|
||||
function nop() end
|
||||
function error(msg, ...) return _G.error(format(msg or '', unpack(arg)) .. '\n' .. debugstack(), 0) end
|
||||
|
||||
nop, id = function() end, function(v) return v end
|
||||
|
||||
function define(self, k, v, private)
|
||||
if type(k) ~= 'string' or not strfind(k, '^[_%a][_%w]*') then error('Invalid identifier "%s".', k) end
|
||||
local _, _, prefix, suffix = strfind(k, '^(.?.?.?.?)([_%a].*)')
|
||||
@@ -43,7 +42,7 @@ function create_module(name)
|
||||
accessors = {M=function() return public_modifier end}
|
||||
mutators = setmetatable({_=nop}, {__index=function(_, k) return function(v) define(name, k, v, true) end end})
|
||||
fields = setmetatable(
|
||||
{_M=environment, _G=_G, include=function(interface) include(name, interface) end, error=error, nop=nop, id=id},
|
||||
{_M=environment, _G=_G, include=function(interface) include(name, interface) end, nop=nop},
|
||||
{__index=function(_, k) local accessor = accessors[k]; if accessor then return accessor() else return _G[k] end end}
|
||||
)
|
||||
public_accessors = setmetatable({}, nop_default_mt)
|
||||
@@ -52,7 +51,7 @@ function create_module(name)
|
||||
setmetatable(environment, proxy_mt(fields, mutators))
|
||||
setmetatable(interface, proxy_mt(public_fields, public_mutators))
|
||||
P = {
|
||||
defined = {['-_M']=true, ['-_G']=true, ['-include']=true, ['-error']=true, ['-nop']=true, ['-id']=true, ['-M']=true, ['-set__']=true, ['-require']=true},
|
||||
defined = {['-_M']=true, ['-_G']=true, ['-include']=true, ['-nop']=true, ['-M']=true, ['-set__']=true, ['-require']=true},
|
||||
fields = fields, accessors = accessors, mutators = mutators,
|
||||
public_fields = public_fields, public_accessors = public_accessors, public_mutators = public_mutators,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user