This commit is contained in:
Manuel Simon Hirsig
2016-09-03 18:35:41 +02:00
parent 9826acf9bc
commit 05fd1587cd
37 changed files with 140 additions and 201 deletions
+7 -5
View File
@@ -5,10 +5,12 @@ do
local modules = {}
aux = function(name)
if not modules[name] then
module()
modules[name] = M
import (green_t)
private.aux = setmetatable({}, {__metatable=false, __index=function(_, key) return modules[key].I end, __newindex=error})
(function()
_ = module
modules[name] = M
import (green_t)
private.aux = setmetatable({}, {__metatable=false, __index=function(_, key) return modules[key].I end, __newindex=error})
end)()
end
modules[name].import (modules.core.I)
setfenv(2, modules[name])
@@ -59,7 +61,7 @@ end
-- end
--end
aux 'core'
aux 'core' private()
public.version = '5.0.0'
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'core'
aux 'core' private()
event_frame = CreateFrame('Frame')
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'cache' local info, persistence = aux.info, aux.persistence
aux 'cache' private() local info, persistence = aux.info, aux.persistence
MIN_ITEM_ID = 1
MAX_ITEM_ID = 30000
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'disenchant'
aux 'disenchant' private()
UNCOMMON, RARE, EPIC = 2, 3, 4
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'history' local persistence = aux.persistence
aux 'history' private() local persistence = aux.persistence
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}} }
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'post'
aux 'post' private()
local state = nil
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'scan' local info, history = aux.info, aux.history
aux 'scan' private() local info, history = aux.info, aux.history
PAGE_SIZE = 50
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'slash' local persistence = aux.persistence
aux 'slash' private() local persistence = aux.persistence
_G.SLASH_AUX1 = '/aux'
function _G.SlashCmdList.AUX(command)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'stack' local info = aux.info
aux 'stack' private() local info = aux.info
local state
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'tooltip' local info, disenchant, cache, money, history = aux.info, aux.disenchant, aux.cache, aux.money, aux.history
aux 'tooltip' private() local info, disenchant, cache, money, history = aux.info, aux.disenchant, aux.cache, aux.money, aux.history
_G.aux_tooltip_value = true
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'core' local gui = aux.gui
aux 'core' private() local gui = aux.gui
function LOAD()
for _, info in tab_info do tabs:create_tab(info.name) end
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'auction_listing' local gui, sorting, money, info = aux.gui, aux.sorting, aux.money, aux.info
aux 'auction_listing' private() local gui, sorting, money, info = aux.gui, aux.sorting, aux.money, aux.info
_G.aux_price_per_unit = false
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'gui'
aux 'gui' private()
function LOAD()
do
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'item_listing' local gui, info = aux.gui, aux.info
aux 'item_listing' private() local gui, info = aux.gui, aux.info
local ROW_HEIGHT = 39
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'listing' local gui = aux.gui
aux 'listing' private() local gui = aux.gui
local ST_COUNT = 0
+50 -97
View File
@@ -1,138 +1,91 @@
--__.green_t = function()
green_t = module
if module 'green_t' then return end
local next, setn, type, setmetatable = next, table.setn, type, setmetatable
local wipe, recycle, table, temp_table
local wipe_chunk = [[
local pool, pool_size, overflow_pool, tmp = {}, 0, setmetatable({}, {__mode='k'}), {}
CreateFrame('Frame'):SetScript('OnUpdate', function()
for t in tmp do recycle(t) end; wipe(tmp)
end)
function wipe(t)
setmetatable(t, nil); setn(t, 0)
for k in t do t[k] = nil end
t.reset, t.reset = nil, 1
setn(t, 0)
setmetatable(t, nil)
]]
end
public.wipe = wipe
local recycle_chunk = wipe_chunk..[[
function recycle(t)
wipe(t); tmp[wipe(t)] = nil
if pool_size < 50 then
pool_size = pool_size + 1
pool[pool_size] = t
else
overflow_pool[t] = true
end
]]
end
public.recycle = recycle
local acquire_chunk = [[
local t
function table()
if pool_size > 0 then
t = pool[pool_size]
pool_size = pool_size - 1
else
t = next(overflow_pool)
if t then
overflow_pool[t] = nil
else
t = {}
end
return pool[pool_size + 1]
end
]]
local t = next(overflow_pool)
if t then overflow_pool[t] = nil; return t end
return {}
end
public.t.get = table
pool, pool_size, overflow_pool, tmp = {}, 0, setmetatable({}, {__mode='k'}), {}
function temp_table() local t = table(); tmp[t] = true; return t end
public.tt.get = temp_table
public.empty = setmetatable({}, {__metatable=false, __newindex=nop})
--select(1, 2, 3, END, kek()) -- TODO
do
local f = loadstring([[
local setmetatable, setn = setmetatable, table.setn
return function(t)
]]..wipe_chunk..'return t end')
setfenv(f, M)
public.wipe = f()
do local mt = {__metatable=false, __newindex=error}
function public.empty.get() return setmetatable(temp_table, mt) end
end
do
local f = loadstring([[
local setmetatable, setn, pool, pool_size, overflow_pool = setmetatable, table.setn, pool, pool_size, overflow_pool
return function(t)
]]..recycle_chunk..'end')
setfenv(f, M)
public.recycle = f()
do local f, mt
f = function(_, v) if type(v) == 'table' then tmp[v] = true end return v end
mt = {__metatable=false, __call=f, __sub=f}
public.temp {get=function() return setmetatable(temp_table(), mt) end, set=function(t) tmp[t] = true end}
end
do
local f = loadstring(format([[
local setmetatable, setn, pool, pool_size, overflow_pool, t = setmetatable, table.setn, pool, pool_size, overflow_pool, tmp
return function() for t in t do %s end %s end
]], recycle_chunk, wipe_chunk))
setfenv(f, M)
CreateFrame'Frame':SetScript('OnUpdate', f())
end
do
local f = loadstring(format([[
local next, pool, pool_size, overflow_pool, tmp = next, pool, pool_size, overflow_pool, tmp
return function() %s; tmp[t] = true; return t end
]], acquire_chunk))
setfenv(f, M)
public.tt.get = f()
end
do local next, pool, pool_size, overflow_pool = next, pool, pool_size, overflow_pool
function public.t.get()
if pool_size > 0 then
pool_size = pool_size - 1
return pool[pool_size + 1]
end
local t = next(overflow_pool)
if t then
overflow_pool[t] = nil
return t
end
return {}
end
end
do local setmetatable, type, tmp = setmetatable, type, tmp
do local f, mt
f = function(_, v) if type(v) == 'table' then tmp[v] = true end return v end
mt = {__call=f, __sub=f}
public.temp {get=function() return setmetatable(tt, mt) end, set=function(t) tmp[t] = true end}
end
do local f, mt
f = function(_, v) if type(v) == 'table' then tmp[v] = nil end return v end
mt = {__call=f, __sub=f}
public.perm {get=function() return setmetatable(tt, mt) end, set=function(t) tmp[t] = nil end}
end
do local f, mt
f = function(_, v) if type(v) == 'table' then tmp[v] = nil end return v end
mt = {__metatable=false, __call=f, __sub=f}
public.perm {get=function() return setmetatable(temp_table(), mt) end, set=function(t) tmp[t] = nil end}
end
do
local SET, ARRAY, ARRAY0, TABLE = 1, 2, 3, 4
local function insert(type)
local chunk = 'local setn, error = table.setn, error; return function('
for i = 1, 99 do chunk = chunk..'a'..i..',' end
chunk = chunk..'overflow)'..acquire_chunk
local chunk = 'setmetatable(t, nil); local setn, error = table.setn, error; return function(t'
for i = 1, 98 do chunk = chunk..',a'..i end
chunk = chunk..',overflow)'
if type == SET then
for i = 1, 99 do
for i = 1, 98 do
chunk = chunk..format('if a%d == nil then return t end t[a%d] = true;', i, i)
end
elseif type == ARRAY then
chunk = chunk..'setn(t, 99); if a1 == nil then return t end t[1] = a1;'
for i = 2, 99 do
for i = 2, 98 do
chunk = chunk..format('if a%d == nil then setn(t, %d); return t end t[%d] = a%d;', i, i - 1, i, i)
end
elseif type == ARRAY0 then
chunk = chunk..'setn(t, 99);'
for i = 1, 99 do
chunk = chunk..format('t[%d] = a%d;', i, i)
end
for i = 1, 98 do chunk = chunk..format('t[%d] = a%d;', i, i) end
elseif type == TABLE then
for i = 1, 97, 2 do
chunk = chunk..format('if a%d == nil then return t end t[a%d] = a%d;', i, i, i + 1)
end
end
chunk = chunk..'return overflow ~= nil and error("Overflow.") or t end'
local f = loadstring(chunk)
setfenv(f, M)
return f()
local f = loadstring(chunk); setfenv(f, M); return f()
end
public(); S, A, A0, T = insert(SET), insert(ARRAY), insert(ARRAY0), insert(TABLE)
end
--end
local function getter(type)
local mt = {__metatable=false, __newindex=error, __call=insert(type)}
function mt:__index(t) recycle(self); return setmetatable(mt, t) end
return function() return setmetatable(t, mt) end
end
public(); S, A, A0, T = {get=getter(SET)}, {get=getter(ARRAY)}, {get=getter(ARRAY0)}, {get=getter(TABLE)}
end
+49 -65
View File
@@ -1,20 +1,19 @@
if module then return end
local type, getmetatable, setmetatable, setfenv, unpack, next, _G = type, getmetatable, setmetatable, setfenv, unpack, next, getfenv(0)
local setfenv, getmetatable, setmetatable, type, unpack, next, _G = setfenv, getmetatable, setmetatable, type, unpack, next, getfenv(0)
local PUBLIC, PRIVATE = 1, 2
local CALL, INDEX, NEWINDEX = 1, 2, 3
local FIELD, INDEX, NEWINDEX = 1, 2, 3
do
local function print(msg) DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE..msg) end
p = setmetatable({}, {
local inspect
do local function print(msg) DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE..msg) end
inspect = setmetatable({}, {
__call=function(_, ...)
for i = 1, arg.n do
if type(arg[i]) == 'table' then
print('arg'..i..' = {')
for k, v in arg[i] do print(format(' %s: %s = %s', type(k) == 'string' and k or '['..tostring(k)..']', type(v), tostring(v))) end
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('}')
else
print(format('arg%d: %s = %s', i, type(arg[i]), tostring(arg[i])))
end
end
return unpack(arg)
@@ -22,6 +21,7 @@ do
__pow=function(self, v) self(v); return v end,
})
end
p = inspect -- TODO
local function error(msg, ...) return _G.error(format(msg or '', unpack(arg))..'\n'..debugstack(), 0) end
local function import_error() error('Import error.') end
@@ -29,9 +29,9 @@ local function declaration_error() error('Declaration error.') end
local function collision_error(key) error('"%s" already exists.', key) end
local function nil_error(key) if key then error('"%s" is nil.', key) else error('Callee is nil') end end
local nop, const = function() end, function(v) return function() return v end end
local nop = function() end
local function prototype() local eq = const(true)
local function prototype() local eq = function() return true end
return setmetatable({__metatable=false, __eq=eq}, {__metatable=false, __eq=eq, __call=function(self, t) return setmetatable(t, self) end})
end
@@ -40,38 +40,26 @@ local INTERFACE, ENVIRONMENT, DECLARATOR = prototype(), prototype(), prototype()
local state = {}
function INTERFACE:__index(key) self=state[self]
if self.access[key] == PUBLIC then
local getter = self[INDEX][key]
if getter then return getter() else return self[CALL][key] end
end
return (self.access[key] == PUBLIC or nil) and self[FIELD][key] or (self[INDEX][key] or nop)()
end
function INTERFACE:__newindex(key, value) self=state[self]
if self.access[key] == PUBLIC then (self[NEWINDEX][key] or nop)(value) end
return (self.access[key] == PUBLIC or nil) and (self[NEWINDEX][key] or nop)(value)
end
function ENVIRONMENT:__index(key) self=state[self]
local getter = self[INDEX][key]
if getter then return getter() end
return self[CALL][key] or _G[key] or self.declarator[key]
function ENVIRONMENT:__index(key) self=state[self] local getter = self[INDEX][key]
return self[FIELD][key] or getter and getter() or not getter and (_G[key] or self.declarator[key])
end
function ENVIRONMENT:__newindex(key, value) self=state[self]
if self.access[key] then
local setter = self[NEWINDEX][key] or collision_error(key)
setter(value)
else
self.declarator[key] = value
end
if self.access[key] then (self[NEWINDEX][key] or collision_error(key))(value) else self.declarator[key] = value end
end
ENVIRONMENT.__call = nop -- TODO
do
local ACCESS, EVENT = {public=PUBLIC, private=PRIVATE}, {call=CALL, get=INDEX, set=NEWINDEX}
local function declare(self, access, name, handlers)
self.access[name] = self.access[name] and collision_error(name) or access or self.default_access
for event, handler in handlers do
if type(handler) ~= 'function' and (event == INDEX or declaration_error()) then
handler = const(handler)
end
self[event][name] = handler
local ACCESS, EVENT = {public=PUBLIC, private=PRIVATE}, {value=FIELD, get=INDEX, set=NEWINDEX}
local function declare(self, access, name, value)
self.access[name] = (not self.access[name] or collision_error(name)) and access or self.default_access or declaration_error()
for k, v in value do
if v and (k == FIELD or type(v) == 'function') or declaration_error() then self[k][name] = v end
end
end
function DECLARATOR:__index(key) self=state[self]; local name, access = self.declaration_name, self.declaration_access
@@ -82,50 +70,46 @@ do
end
return self.declarator
end
function DECLARATOR:__newindex(key, value) self=state[self]
local name, event = self.declaration_name, nil
if name then
event = EVENT[key] or nil_error(name)
else
name, event = key, type(value) == 'function' and CALL or INDEX
end
declare(self, self.declaration_access, name, {[event]=value})
function DECLARATOR:__newindex(key, value) self=state[self]; local name, access = self.declaration_name, self.declaration_access
if name then declare(self, access, name, {[EVENT[key] or nil_error(name)]=value})
elseif access or self.default_access then declare(self, access, key, {[FIELD]=value})
else _G[key] = (not _G[key] or collision_error(key)) and value end -- G.error(nil) TODO silent error?
self.declaration_access, self.declaration_name = nil, nil
end
function DECLARATOR:__call(v) self=state[self]; local name, access = self.declaration_name, self.declaration_access
if name then
if type(v) ~= 'table' or getmetatable(v) ~= nil then (access and declaration_error() or nil_error)(name) end
local f, getter, setter; f, getter, setter, v.call, v.get, v.set = v.call, v.get, v.set, nil, nil, nil
if next(v) or f ~= nil and getter ~= nil then (access and declaration_error() or nil_error)(name) end
declare(self, access, name, {[CALL]=f, [INDEX]=getter, [NEWINDEX]=setter})
elseif access or nil_error() then
self.default_access = access
end
local value, getter, setter; value, getter, setter, v.value, v.get, v.set = v.value, v.get, v.set, nil, nil, nil
if next(v) or value ~= nil and getter ~= nil then (access and declaration_error() or nil_error)(name) end
declare(self, access, name, {[FIELD]=value, [INDEX]=getter, [NEWINDEX]=setter})
elseif access or nil_error() then self.default_access = access end
self.declaration_access, self.declaration_name = nil, nil
end
DECLARATOR.__tostring = function() return 'NIL' end
end
local function import(self, interface)
local module = (interface == INTERFACE or import_error()) and state[interface]
for k, v in module.access do
if v == PUBLIC and not self.access[k] then
self.access[k], self[CALL][k], self[INDEX][k], self[NEWINDEX][k] = PRIVATE, module[CALL][k], module[INDEX][k], module[NEWINDEX][k]
self.access[k], self[FIELD][k], self[INDEX][k], self[NEWINDEX][k] = PRIVATE, module[FIELD][k], module[INDEX][k], module[NEWINDEX][k]
end
end
end
function module(name)
if name and _G[name] then return true end
local interface, env, declarator = INTERFACE {}, ENVIRONMENT {}, DECLARATOR {}
local self; self = {
access = {p=PRIVATE, _=PRIVATE, error=PRIVATE, nop=PRIVATE, _G=PRIVATE, M=PRIVATE, I=PRIVATE, public=PRIVATE, private=PRIVATE},
[CALL] = {p=p, import=function(interface) import(self, interface) end, error=error, nop=nop},
[INDEX] = {_G=const(_G), M=const(env), I=const(interface), public=function() return declarator.public end, private=function() return declarator.private end},
[NEWINDEX] = {p=p, _=nop},
declarator = declarator,
default_access = PRIVATE,
}
state[interface], state[env], state[declarator] = self, self, self
if name then _G[name] = interface end
setfenv(2, env)
end
setmetatable(_G, {
__index = function(_, key)
if key ~= 'module' then return nil end
local interface, environment, declarator = INTERFACE {}, ENVIRONMENT {}, DECLARATOR {}
local self; self = {
access = {_G=PRIVATE, I=PRIVATE, M=PRIVATE, public=PRIVATE, private=PRIVATE, import=PRIVATE, _=PRIVATE, p=PRIVATE, error=PRIVATE, nop=PRIVATE},
[FIELD] = {_G=_G, I=interface, M=environment, import=function(interface) import(self, interface) end, p=inspect, error=error, nop=nop},
[INDEX] = {public=function() return declarator.public end, private=function() return declarator.private end},
[NEWINDEX] = {p=inspect, _=nop},
declarator = declarator,
}
state[interface], state[environment], state[declarator] = self, self, self
setfenv(2, environment)
return interface
end,
})
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'auctions_tab' local scan = aux.scan
aux 'auctions_tab' private() local scan = aux.scan
auction_records = t
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'auctions_tab' local gui, auction_listing = aux.gui, aux.auction_listing
aux 'auctions_tab' private() local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'bids_tab' local scan = aux.scan
aux 'bids_tab' private() local scan = aux.scan
auction_records = t
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'bids_tab' local gui, auction_listing = aux.gui, aux.auction_listing
aux 'bids_tab' private() local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'post_tab' local scan, scan_util, history, info, persistence, item_listing, al, sorting = aux.scan, aux.scan_util, aux.history, aux.info, aux.persistence, aux.item_listing, aux.auction_listing, aux.sorting
aux 'post_tab' private() local scan, scan_util, history, info, persistence, item_listing, al, sorting = aux.scan, aux.scan_util, aux.history, aux.info, aux.persistence, aux.item_listing, aux.auction_listing, aux.sorting
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'post_tab' local gui, listing, item_listing, money, search_tab = aux.gui, aux.listing, aux.item_listing, aux.money, aux.search_tab
aux 'post_tab' private() local gui, listing, item_listing, money, search_tab = aux.gui, aux.listing, aux.item_listing, aux.money, aux.search_tab
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'search_tab' local scan, scan_util = aux.scan, aux.scan_util
aux 'search_tab' private() local scan, scan_util = aux.scan, aux.scan_util
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'search_tab' local filter_util = aux.filter_util
aux 'search_tab' private() local filter_util = aux.filter_util
function valid_level(str)
local level = tonumber(str)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'search_tab' local gui, completion, listing, auction_listing, filter_util = aux.gui, aux.completion, aux.listing, aux.auction_listing, aux.filter_util
aux 'search_tab' private() local gui, completion, listing, auction_listing, filter_util = aux.gui, aux.completion, aux.listing, aux.auction_listing, aux.filter_util
FILTER_SPACING = 28.5
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'search_tab' local info, scan = aux.info, aux.scan
aux 'search_tab' private() local info, scan = aux.info, aux.scan
_G.aux_auto_buy_filter = ''
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'search_tab'
aux 'search_tab' private()
_G.aux_favorite_searches = t
_G.aux_recent_searches = t
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'core'
aux 'core' private()
COLORS = {
text = {enabled = {255, 254, 250, 1}, disabled = {147, 151, 139, 1}},
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'completion' local filter_util = aux.filter_util
aux 'completion' private() local filter_util = aux.filter_util
function public:complete_filter()
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'core'
aux 'core' private()
public.join = _G.table.concat
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'filter_util' local info = aux.info
aux 'filter_util' private() local info = aux.info
function default_filter(str)
return {
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'info'
aux 'info' private()
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
AuxTooltip:SetScript('OnTooltipAddMoney', function()
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'money'
aux 'money' private()
public()
GOLD_TEXT = '|cffffd70ag|r'
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'persistence'
aux 'persistence' private()
_G.aux_datasets = t
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'scan_util' local info , filter_util = aux.info, aux.filter_util
aux 'scan_util' private() local info , filter_util = aux.info, aux.filter_util
function public.find(auction_record, status_bar, on_abort, on_failure, on_success)
+1 -1
View File
@@ -1,4 +1,4 @@
aux 'sorting'
aux 'sorting' private()
public()