big refactoring
This commit is contained in:
@@ -1,30 +1,68 @@
|
||||
setglobal('aux', aux_module('core'))
|
||||
import 'util'
|
||||
|
||||
public.version = '4.0.0'
|
||||
public.version = '5.0.0'
|
||||
|
||||
module_envs = {}
|
||||
function public.module(path)
|
||||
local env
|
||||
if path == 'core' then
|
||||
env = getfenv()
|
||||
elseif module_envs[path] then
|
||||
env = module_envs[path]
|
||||
else
|
||||
local prefix
|
||||
for name in string.gfind(path, '[%a_][%w_]*') do
|
||||
local qualified_name = prefix and prefix..'.'..name or name
|
||||
env = module_envs[qualified_name]
|
||||
if not env then
|
||||
(prefix and module_envs[prefix].public or public)[name], env = (function() return aux_module(qualified_name), getfenv() end)()
|
||||
env.import 'util'
|
||||
env.LOAD = nil
|
||||
module_envs[qualified_name] = env
|
||||
do
|
||||
local setn = g.table.setn
|
||||
local table_pool, locked = {}
|
||||
local function wipe(t) -- like with a cloth or something
|
||||
for k in t do t[k] = nil end
|
||||
setn(t, 0)
|
||||
return t
|
||||
end
|
||||
local function release(t)
|
||||
locked[t] = nil
|
||||
tinsert(table_pool, t)
|
||||
end
|
||||
local function temp()
|
||||
local t = tremove(table_pool)
|
||||
t = t and wipe(t) or {}
|
||||
locked[t] = true
|
||||
end
|
||||
public.temp = temp
|
||||
end
|
||||
local temp = temp
|
||||
--do
|
||||
-- local table_pool = {}
|
||||
-- onupdate clear tables TODO
|
||||
-- local setn = g.table.setn
|
||||
|
||||
-- public.wipe = wipe
|
||||
--end
|
||||
|
||||
do
|
||||
local aux_module, getfenv, setfenv, gfind, tinsert = g.aux_module, g.getfenv, g.setfenv, g.string.gfind, g.tinsert
|
||||
local interface, env = (function() return aux_module('interfaces'), getfenv() end)()
|
||||
function public.module(path)
|
||||
local parts = gfind(path, '[%a_][%w_]*')
|
||||
local name = parts() or ''
|
||||
for part in parts do
|
||||
interface[(function() return aux_module(name), getfenv() end)()
|
||||
name = name..'.'..part
|
||||
end
|
||||
|
||||
local env
|
||||
if path == 'core' then
|
||||
env = getfenv()
|
||||
elseif module_envs[path] then
|
||||
env = module_envs[path]
|
||||
else
|
||||
local prefix
|
||||
for name in gfind(path, '[%a_][%w_]*') do
|
||||
local qualified_name = prefix and prefix..'.'..name or name
|
||||
env = module_envs[qualified_name]
|
||||
if not env then
|
||||
(prefix and module_envs[prefix].public or public)[name], env = (function() return aux_module(qualified_name), getfenv() end)()
|
||||
env.import('core', 'util')
|
||||
env.mutable.LOAD = nil
|
||||
module_envs[qualified_name] = env
|
||||
end
|
||||
prefix = qualified_name
|
||||
end
|
||||
prefix = qualified_name
|
||||
end
|
||||
setfenv(2, env)
|
||||
end
|
||||
setfenv(2, env)
|
||||
end
|
||||
|
||||
local event_frame = CreateFrame 'Frame'
|
||||
@@ -49,3 +87,11 @@ event_frame:SetScript('OnEvent', function()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function public.log(...)
|
||||
local msg = '[aux]'
|
||||
for i=1,arg.n do
|
||||
msg = msg..' '..tostring(arg[i])
|
||||
end
|
||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user