refactoring
This commit is contained in:
+53
-15
@@ -41,7 +41,7 @@ end
|
||||
public.empty = setmetatable({}, {__metatable=false, __newindex=error})
|
||||
|
||||
do
|
||||
local pool, weak_pool, transient = {}, setmetatable({}, {__mode='v'}), {}
|
||||
local pool, overflow_pool, transient = {}, setmetatable({}, {__mode='v'}), {}
|
||||
CreateFrame'Frame':SetScript('OnUpdate', function()
|
||||
-- local t = tremove(transient)
|
||||
for _, t in transient do recycle(t) end
|
||||
@@ -53,8 +53,7 @@ do
|
||||
return t
|
||||
end
|
||||
function public.recycle(t)
|
||||
while getn(t) > 0 do tremove(t) end -- TODO or is setn enough?
|
||||
if next(t) then return end -- no hashtables, they can't be shrunk -- TODO "n" field?
|
||||
wipe(t)
|
||||
if getn(pool) < 50 then
|
||||
tinsert(pool, t)
|
||||
else
|
||||
@@ -79,16 +78,47 @@ do
|
||||
return {__unm=function(self) self.raw = true end, __call=apply, __sub=apply}
|
||||
end
|
||||
do
|
||||
local make_transient, temp_mt
|
||||
function make_transient(t) tinsert(transient, t) return t end
|
||||
local make_transient, make_persistent, temp_mt, perm_mt
|
||||
function make_transient(t) transient[t] = true return t end
|
||||
function make_persistent(t) transient[t] = nil return t end
|
||||
temp_mt = operator_mt(make_transient)
|
||||
perm_mt = operator_mt(make_persistent)
|
||||
public.temp
|
||||
{
|
||||
get = function() return setmetatable(t, temp_mt) end,
|
||||
set = function(t) return make_transient(t) end,
|
||||
}
|
||||
public.perm
|
||||
{
|
||||
get = function() return setmetatable(t, perm_mt) end,
|
||||
set = function(t) return make_persistent(t) end,
|
||||
}
|
||||
end
|
||||
local function fill(t,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,overflow)
|
||||
local function insert_keys(t,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,k20,overflow)
|
||||
if overflow ~= nil then error 'Overflow.' end
|
||||
if k1 ~= nil then t[k1] = true end
|
||||
if k2 ~= nil then t[k2] = true end
|
||||
if k3 ~= nil then t[k3] = true end
|
||||
if k4 ~= nil then t[k4] = true end
|
||||
if k5 ~= nil then t[k5] = true end
|
||||
if k6 ~= nil then t[k6] = true end
|
||||
if k7 ~= nil then t[k7] = true end
|
||||
if k8 ~= nil then t[k8] = true end
|
||||
if k9 ~= nil then t[k9] = true end
|
||||
if k10 ~= nil then t[k10] = true end
|
||||
if k11 ~= nil then t[k11] = true end
|
||||
if k12 ~= nil then t[k12] = true end
|
||||
if k13 ~= nil then t[k13] = true end
|
||||
if k14 ~= nil then t[k14] = true end
|
||||
if k15 ~= nil then t[k15] = true end
|
||||
if k16 ~= nil then t[k16] = true end
|
||||
if k17 ~= nil then t[k17] = true end
|
||||
if k18 ~= nil then t[k18] = true end
|
||||
if k19 ~= nil then t[k19] = true end
|
||||
if k20 ~= nil then t[k20] = true end
|
||||
return t
|
||||
end
|
||||
local function insert_values(t,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,overflow)
|
||||
if overflow ~= nil then error 'Overflow.' end
|
||||
if v1 ~= nil then tinsert(t, v1) end
|
||||
if v2 ~= nil then tinsert(t, v2) end
|
||||
@@ -112,24 +142,32 @@ do
|
||||
if v20 ~= nil then tinsert(t, v20) end
|
||||
return t
|
||||
end
|
||||
local function insert_pairs(t,k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9,k10,v10,overflow)
|
||||
if overflow ~= nil then error 'Overflow.' end
|
||||
if k1 ~= nil then t[k1] = v1 end
|
||||
if k2 ~= nil then t[k2] = v2 end
|
||||
if k3 ~= nil then t[k3] = v3 end
|
||||
if k4 ~= nil then t[k4] = v4 end
|
||||
if k5 ~= nil then t[k5] = v5 end
|
||||
if k6 ~= nil then t[k6] = v6 end
|
||||
if k7 ~= nil then t[k7] = v7 end
|
||||
if k8 ~= nil then t[k8] = v8 end
|
||||
if k9 ~= nil then t[k9] = v9 end
|
||||
if k10 ~= nil then t[k10] = v10 end
|
||||
return t
|
||||
end
|
||||
local function collector_mt(f)
|
||||
return {__call=f, __unm=function(self) return setmetatable(self, nil) end}
|
||||
end
|
||||
local object_mt = {
|
||||
__newindex()
|
||||
}
|
||||
-- table-from(1,2,3)
|
||||
local set_mt, list_mt, object_mt = collector_mt(keys), collector_mt(values), collector_mt(pairs)
|
||||
modifier = public.property
|
||||
local set_mt, list_mt, object_mt = collector_mt(insert_keys), collector_mt(insert_values), collector_mt(insert_pairs)
|
||||
public.property()
|
||||
-- list, object = {get=function() return setmetatable(t, list_mt) end}, {get=function() return setmetatable(t, object_mt) end}
|
||||
modifier = nil
|
||||
set, list, object = {get=function() return setmetatable(t, set_mt) end}, {get=function() return setmetatable(t, list_mt) end}, {get=function() return setmetatable(t, object_mt) end}
|
||||
private()
|
||||
-- TODO or 'auto' 'transient'?
|
||||
end
|
||||
|
||||
local event_frame = CreateFrame 'Frame'
|
||||
for _, event in -temp-list('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE') do
|
||||
for event in -temp-set('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE') do
|
||||
event_frame:RegisterEvent(event)
|
||||
end
|
||||
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
aux 'cache' import 'info'
|
||||
aux 'cache' local info, persistence = aux.info, aux.persistence
|
||||
|
||||
MIN_ITEM_ID = 1
|
||||
MAX_ITEM_ID = 30000
|
||||
@@ -16,7 +16,6 @@ _G.aux_merchant_sell = t
|
||||
_G.aux_characters = t
|
||||
|
||||
function LOAD()
|
||||
import 'persistence' 'info'
|
||||
scan_wdb()
|
||||
|
||||
event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ do
|
||||
end
|
||||
|
||||
function LOAD()
|
||||
ARMOR = set(
|
||||
ARMOR = -set(
|
||||
'INVTYPE_HEAD',
|
||||
'INVTYPE_NECK',
|
||||
'INVTYPE_SHOULDER',
|
||||
@@ -56,7 +56,7 @@ function LOAD()
|
||||
'INVTYPE_CLOAK',
|
||||
'INVTYPE_HOLDABLE'
|
||||
)
|
||||
WEAPON = set(
|
||||
WEAPON = -set(
|
||||
'INVTYPE_2HWEAPON',
|
||||
'INVTYPE_WEAPONMAINHAND',
|
||||
'INVTYPE_WEAPON',
|
||||
|
||||
+1
-7
@@ -1,10 +1,4 @@
|
||||
aux 'history' import 'persistence'
|
||||
|
||||
--local history_schema = tuple('#')
|
||||
-- :next_push 'number'
|
||||
-- :daily_min_buyout 'number'
|
||||
-- :daily_max_price 'number'
|
||||
-- :data_points (list(';') (tuple('@') :market_value 'number' :time 'number'))
|
||||
aux 'history' 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
-5
@@ -1,8 +1,4 @@
|
||||
aux 'scan' import 'info'
|
||||
|
||||
function LOAD()
|
||||
import 'history'
|
||||
end
|
||||
aux 'scan' local info, history = aux.info, aux.history
|
||||
|
||||
PAGE_SIZE = 50
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'slash' import 'persistence'
|
||||
aux 'slash' local persistence = aux.persistence
|
||||
|
||||
_G.SLASH_AUX1 = '/aux'
|
||||
function _G.SlashCmdList.AUX(command)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'stack' import 'info'
|
||||
aux 'stack' local info = aux.info
|
||||
|
||||
state = nil
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'tooltip' import 'info' 'disenchant' 'cache' 'money' 'history'
|
||||
aux 'tooltip' local info, disenchant, cache, money, history = aux.info, aux.disenchant, aux.cache, aux.money, aux.history
|
||||
|
||||
_G.aux_tooltip_value = true
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'core' import 'gui'
|
||||
aux 'core' local gui = aux.gui
|
||||
|
||||
function LOAD()
|
||||
for _, info in tab_info do tabs:create_tab(info.name) end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'auction_listing' import 'gui' 'sorting' 'history' 'money' 'info'
|
||||
aux 'auction_listing' local gui, sorting, history, money, info = aux.gui, aux.sorting, aux.history, aux.money, aux.info
|
||||
|
||||
_G.aux_price_per_unit = false
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'item_listing' import 'gui' 'info'
|
||||
aux 'item_listing' local gui, info = aux.gui, aux.info
|
||||
|
||||
local ROW_HEIGHT = 39
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'listing' import 'gui'
|
||||
aux 'listing' local gui = aux.gui
|
||||
|
||||
local ST_COUNT = 0
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if module then return end
|
||||
local type, setmetatable, setfenv, unpack, next, intersection, union, pcall, _G = type, setmetatable, setfenv, unpack, next, bit.band, bit.bor, pcall, getfenv(0)
|
||||
local error, import_error, declaration_error, collision_error, mutability_error
|
||||
local pass, start_declaration, advance_declaration, env_mt, interface_mt, metadata_mt, property_mt
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'auctions_tab' import 'scan'
|
||||
aux 'auctions_tab' local scan = aux.scan
|
||||
|
||||
auction_records = {}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'auctions_tab' import 'gui' 'auction_listing'
|
||||
aux 'auctions_tab' local gui, auction_listing = aux.gui, aux.auction_listing
|
||||
|
||||
function create_frames()
|
||||
frame = CreateFrame('Frame', nil, aux_frame)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'bids_tab' import 'scan'
|
||||
aux 'bids_tab' local scan = aux.scan
|
||||
|
||||
auction_records = {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'bids_tab' import 'gui' 'auction_listing'
|
||||
aux 'bids_tab' local gui, auction_listing = aux.gui, aux.auction_listing
|
||||
|
||||
function create_frames()
|
||||
frame = CreateFrame('Frame', nil, aux_frame)
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
aux 'post_tab' import 'scan' 'scan_util' 'post' 'history' 'info' 'persistence' 'item_listing' :al 'auction_listing' 'sorting'
|
||||
aux 'post_tab' local scan, scan_util, post, history, info, persistence, item_listing, al, sorting = aux.scan, aux.scan_util, aux.post, aux.history, aux.info, aux.persistence, aux.item_listing, aux.auction_listing, aux.sorting
|
||||
|
||||
|
||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'post_tab' import [''] 'core' 'gui' 'listing' 'item_listing' 'money' 'search_tab'
|
||||
aux 'post_tab' 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,4 +1,4 @@
|
||||
aux 'search_tab' import 'scan' 'scan_util'
|
||||
aux 'search_tab' 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,4 +1,4 @@
|
||||
aux 'search_tab' import 'filter_util'
|
||||
aux 'search_tab' local filter_util = aux.filter_util
|
||||
|
||||
function valid_level(str)
|
||||
local level = tonumber(str)
|
||||
@@ -72,14 +72,14 @@ function update_form()
|
||||
end
|
||||
|
||||
if blizzard_query.exact then
|
||||
for _, key in -temp-list('class', 'subclass', 'slot', 'quality') do
|
||||
for key in -temp-set('class', 'subclass', 'slot', 'quality') do
|
||||
M[key..'_dropdown'].button:Disable()
|
||||
end
|
||||
else
|
||||
class_dropdown.button:Enable()
|
||||
quality_dropdown.button:Enable()
|
||||
end
|
||||
for _, key in -temp-list('min_level', 'max_level') do
|
||||
for key in -temp-set('min_level', 'max_level') do
|
||||
if blizzard_query.exact then
|
||||
M[key..'_input']:Disable()
|
||||
else
|
||||
@@ -313,7 +313,7 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
for _, filter in -temp-list('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do
|
||||
for filter in -temp-set('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do
|
||||
UIDropDownMenu_AddButton(-object(
|
||||
'text', filter,
|
||||
'value', filter,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'search_tab' import 'gui' [''] 'core' 'completion' 'listing' 'auction_listing' 'filter_util'
|
||||
aux 'search_tab' 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,4 +1,4 @@
|
||||
aux 'search_tab' import 'info'
|
||||
aux 'search_tab' local info = aux.info
|
||||
|
||||
_G.aux_auto_buy_filter = ''
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
aux 'completion' import 'filter_util'
|
||||
aux 'completion' local filter_util = aux.filter_util
|
||||
|
||||
function public:complete_filter()
|
||||
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
||||
|
||||
@@ -64,14 +64,6 @@ function public.index(t, ...) temp=arg
|
||||
return t
|
||||
end
|
||||
|
||||
function public.set(...) temp=arg
|
||||
local t = t
|
||||
for i=1,arg.n do
|
||||
t[arg[i]] = true
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
public.huge = 1.8*10^308
|
||||
|
||||
function public.modified.get() return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() end
|
||||
|
||||
+4
-8
@@ -1,8 +1,4 @@
|
||||
aux 'filter_util' import 'info'
|
||||
|
||||
function LOAD()
|
||||
import 'cache'
|
||||
end
|
||||
aux 'filter_util' local info, cache = aux.info, aux.cache
|
||||
|
||||
function default_filter(str)
|
||||
return {
|
||||
@@ -208,7 +204,7 @@ public.filters = {
|
||||
|
||||
function operator(str)
|
||||
local operator = str == 'not' and -list('operator', 'not', 1)
|
||||
for _, name in -temp-list('and', 'or') do
|
||||
for name in -temp-set('and', 'or') do
|
||||
for arity in present(select(3, strfind(str, '^'..name..'(%d*)$'))) do
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and -list('operator', name, arity)
|
||||
@@ -229,7 +225,7 @@ do
|
||||
end
|
||||
for number in present(tonumber(select(3, strfind(str, '^(%d+)$')))) do
|
||||
if number >= 1 and number <= 60 then
|
||||
for _, filter in -temp-list('min_level', 'max_level') do
|
||||
for filter in -temp-set('min_level', 'max_level') do
|
||||
if not self[filter] then
|
||||
self[filter] = {str, number}
|
||||
return true
|
||||
@@ -517,7 +513,7 @@ function blizzard_query(components)
|
||||
query.slot = slot_index
|
||||
query.quality = item_info.quality
|
||||
else
|
||||
for _, key in -temp-list('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
|
||||
for key in -temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
|
||||
query[key] = index(filters[key], 2)
|
||||
end
|
||||
end
|
||||
|
||||
+1
-5
@@ -1,8 +1,4 @@
|
||||
aux 'scan_util' import 'info'
|
||||
|
||||
function LOAD()
|
||||
import 'filter_util' 'scan'
|
||||
end
|
||||
aux 'scan_util' local info , filter_util, scan = aux.info, aux.filter_util, aux.scan
|
||||
|
||||
function public.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user