refactoring
This commit is contained in:
+5
-5
@@ -39,15 +39,15 @@ end
|
||||
ADDON_LOADED = t
|
||||
do
|
||||
local handlers, handlers2 = t, t
|
||||
function public.LOAD.set(f) tinsert(handlers, f) end
|
||||
function public.LOAD2.set(f) tinsert(handlers2, f) end
|
||||
function public.LOAD.set(f) handlers[f] = true end
|
||||
function public.LOAD2.set(f) handlers2[f] = true end
|
||||
event_frame:SetScript('OnEvent', function()
|
||||
if event == 'ADDON_LOADED' then
|
||||
if ADDON_LOADED[arg1] then ADDON_LOADED[arg1]() end
|
||||
(ADDON_LOADED[arg1] or nop)()
|
||||
elseif event == 'VARIABLES_LOADED' then
|
||||
for _, f in handlers do f() end
|
||||
for f in handlers do f() end
|
||||
elseif event == 'PLAYER_LOGIN' then
|
||||
for _, f in handlers2 do f() end
|
||||
for f in handlers2 do f() end
|
||||
print('v' .. version .. ' loaded.')
|
||||
else
|
||||
M[event]()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
## SavedVariablesPerCharacter: aux_auto_buy_filter, aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
|
||||
## SavedVariables: aux_datasets, aux_items, aux_item_ids, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell, aux_characters, aux_recent_searches, aux_favorite_searches, aux_ignore_owner, aux_price_per_unit
|
||||
|
||||
libs\inspect.lua
|
||||
libs\module.lua
|
||||
libs\green_t.lua
|
||||
|
||||
|
||||
+8
-10
@@ -90,15 +90,15 @@ function public.pseudo_vararg_function(body, upvals)
|
||||
end
|
||||
|
||||
local function insert_chunk(mode)
|
||||
local body = ''
|
||||
local body = 'repeat '
|
||||
if mode == 'k' then
|
||||
for i = 2, 99 do
|
||||
body = body .. format('if a%1$d == nil then return end; a1[a%1$d] = true;', i)
|
||||
body = body .. format('if a%1$d == nil then break end; a1[a%1$d] = true;', i)
|
||||
end
|
||||
elseif mode == 'v' then
|
||||
body = body .. 'if a2 == nil then return end; a1[1] = a2;'
|
||||
body = body .. 'if a2 == nil then break end; a1[1] = a2;'
|
||||
for i = 3, 99 do
|
||||
body = body .. format('if a%1$d == nil then setn(a1, %d); return end; a1[%d] = a%1$d;', i, i-2, i-1)
|
||||
body = body .. format('if a%1$d == nil then setn(a1, %d); break end; a1[%d] = a%1$d;', i, i-2, i-1)
|
||||
end
|
||||
elseif mode == 'v0' then
|
||||
body = body .. 'setn(a1, 98);'
|
||||
@@ -107,19 +107,16 @@ local function insert_chunk(mode)
|
||||
end
|
||||
elseif mode == 'kv' then
|
||||
for i = 2, 98, 2 do
|
||||
body = body .. format('if a%1$d == nil then return end; a1[a%1$d] = a%d;', i, i+1)
|
||||
body = body .. format('if a%1$d == nil then break end; a1[a%1$d] = a%d;', i, i+1)
|
||||
end
|
||||
end
|
||||
return body .. 'if a100 ~= nil then error"Overflow." end;'
|
||||
return body .. 'if a100 ~= nil then error"Overflow." end until false;'
|
||||
end
|
||||
|
||||
do
|
||||
local function pseudo_literal(mode)
|
||||
local upvals = {setmetatable=setmetatable, setn=table.setn, error=error}
|
||||
local mt = {
|
||||
__newindex = nop,
|
||||
__call = pseudo_vararg_function(insert_chunk(mode) .. 'setmetatable(a1, nil); return a1', upvals)
|
||||
}
|
||||
local mt = {__call = pseudo_vararg_function(insert_chunk(mode) .. 'setmetatable(a1, nil); return a1', upvals)}
|
||||
return function() return setmetatable(acquire_temp(), mt) end
|
||||
end
|
||||
public.S.get = pseudo_literal'k'
|
||||
@@ -128,6 +125,7 @@ do
|
||||
public.T.get = pseudo_literal'kv'
|
||||
end
|
||||
|
||||
p = T('koo', 1, 5, 'mooo')
|
||||
do
|
||||
local body = ''
|
||||
for i = 2, 100 do
|
||||
|
||||
@@ -4,23 +4,6 @@ local setfenv, getmetatable, setmetatable, type, unpack, next, _G = setfenv, get
|
||||
local PUBLIC, PRIVATE = 1, 2
|
||||
local CALL, INDEX, NEWINDEX = 1, 2, 3
|
||||
|
||||
local inspect
|
||||
do local function print(msg) DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE .. msg) end
|
||||
local mt = {__metatable=false, __pow=function(self, v) self(v); return v end}
|
||||
function mt:__call(...)
|
||||
for i = 1, arg.n do
|
||||
print('arg' .. i..' = ' .. (type(arg[i]) == 'string' and '"' .. arg[i] .. '"' or tostring(arg[i])))
|
||||
if type(arg[i]) == 'table' and next(arg[i]) then
|
||||
print('{')
|
||||
for k, v in arg[i] do print(' ' .. (type(k) == 'string' and k or '[' .. tostring(k) .. ']') .. ' = ' .. (type(v) == 'string' and '"' .. v..'"' or tostring(v))) end
|
||||
print('}')
|
||||
end
|
||||
end
|
||||
return unpack(arg)
|
||||
end
|
||||
inspect = setmetatable({}, mt)
|
||||
end
|
||||
|
||||
local function error(msg, ...) return _G.error(format(msg or '', unpack(arg)) .. '\n' .. debugstack(), 0) end
|
||||
local function import_error() error('Import error.') end
|
||||
local function declaration_error() error('Declaration error.') end
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ do
|
||||
end
|
||||
function color_accessor(callback)
|
||||
return function()
|
||||
return index_function(__(tt) :callback(callback) :table(COLORS), index_handler)
|
||||
return index_function({callback=callback, table=COLORS}, index_handler)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user