refactoring
This commit is contained in:
+32
-25
@@ -3,18 +3,19 @@ public.version = '5.0.0'
|
|||||||
|
|
||||||
do
|
do
|
||||||
local bids_loaded
|
local bids_loaded
|
||||||
public.property.bids_loaded{
|
public.bids_loaded
|
||||||
|
{
|
||||||
get = function() return bids_loaded end,
|
get = function() return bids_loaded end,
|
||||||
set = function(value) bids_loaded = value end,
|
set = function(value) bids_loaded = value end,
|
||||||
}
|
}
|
||||||
-- function public.bids_loaded.get()
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local current_owner_page
|
local current_owner_page
|
||||||
public.current_owner_page()
|
public.current_owner_page
|
||||||
function accessor() return current_owner_page end
|
{
|
||||||
function mutator(value) current_owner_page = value end
|
get = function() return current_owner_page end,
|
||||||
|
set = function(value) current_owner_page = value end,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
public.empty = {}
|
public.empty = {}
|
||||||
@@ -41,10 +42,10 @@ do
|
|||||||
end
|
end
|
||||||
log(getn(table_pool), '-', getn(overflow_pool))
|
log(getn(table_pool), '-', getn(overflow_pool))
|
||||||
end
|
end
|
||||||
function public.accessor.t()
|
function public.t.get()
|
||||||
return tremove(pool) or tremove(overflow_pool) or {}
|
return tremove(pool) or tremove(overflow_pool) or {}
|
||||||
end
|
end
|
||||||
function public.accessor.tt()
|
function public.tt.get()
|
||||||
local t = tremove(pool) or tremove(overflow_pool) or {}
|
local t = tremove(pool) or tremove(overflow_pool) or {}
|
||||||
transient[t] = true
|
transient[t] = true
|
||||||
return t
|
return t
|
||||||
@@ -63,10 +64,16 @@ do
|
|||||||
function make_persistent(t) transient[t] = nil return t end
|
function make_persistent(t) transient[t] = nil return t end
|
||||||
temp_mt = operator_mt(make_transient)
|
temp_mt = operator_mt(make_transient)
|
||||||
perm_mt = operator_mt(make_persistent)
|
perm_mt = operator_mt(make_persistent)
|
||||||
function public.accessor.temp() return setmetatable(t, temp_mt) end
|
public.temp
|
||||||
function mutator(t) return make_transient(t) end
|
{
|
||||||
function public.accessor.perm() return setmetatable(t, perm_mt) end
|
get = function() return setmetatable(t, temp_mt) end,
|
||||||
function mutator(t) return make_persistent(t) 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
|
end
|
||||||
local function keys(t,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,k20,overflow)
|
local function 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 overflow ~= nil then error 'Overflow.' end
|
||||||
@@ -137,9 +144,9 @@ do
|
|||||||
-- public.accessor()
|
-- public.accessor()
|
||||||
-- set, list, object = function() return setmetatable(t, set_mt) end, function() return setmetatable(t, list_mt) end, function() return setmetatable(t, object_mt) end
|
-- set, list, object = function() return setmetatable(t, set_mt) end, function() return setmetatable(t, list_mt) end, function() return setmetatable(t, object_mt) end
|
||||||
-- private()
|
-- private()
|
||||||
function public.accessor.set() return setmetatable(t, set_mt) end
|
function public.set.get() return setmetatable(t, set_mt) end
|
||||||
function public.accessor.list() return setmetatable(t, list_mt) end
|
function public.list.get() return setmetatable(t, list_mt) end
|
||||||
function public.accessor.object() return setmetatable(t, object_mt) end
|
function public.object.get() return setmetatable(t, object_mt) end
|
||||||
-- TODO or 'auto' 'transient'?
|
-- TODO or 'auto' 'transient'?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -151,8 +158,8 @@ end
|
|||||||
ADDON_LOADED = t
|
ADDON_LOADED = t
|
||||||
do
|
do
|
||||||
local handlers, handlers2 = t, t
|
local handlers, handlers2 = t, t
|
||||||
function public.mutator.LOAD(f) tinsert(handlers, f) end
|
function public.LOAD.set(f) tinsert(handlers, f) end
|
||||||
function public.mutator.LOAD2(f) tinsert(handlers2, f) end
|
function public.LOAD2.set(f) tinsert(handlers2, f) end
|
||||||
event_frame:SetScript('OnEvent', function()
|
event_frame:SetScript('OnEvent', function()
|
||||||
if event == 'ADDON_LOADED' then
|
if event == 'ADDON_LOADED' then
|
||||||
if ADDON_LOADED[arg1] then ADDON_LOADED[arg1]() end
|
if ADDON_LOADED[arg1] then ADDON_LOADED[arg1]() end
|
||||||
@@ -182,18 +189,18 @@ do
|
|||||||
log(data[i], data[i + 1])
|
log(data[i], data[i + 1])
|
||||||
local tab = -object('name', data[i + 1])
|
local tab = -object('name', data[i + 1])
|
||||||
local env = (function() module(data[i]) return M end)()
|
local env = (function() module(data[i]) return M end)()
|
||||||
function env.mutator.OPEN(f) tab.OPEN = f end
|
function env.OPEN.set(f) tab.OPEN = f end
|
||||||
function env.mutator.CLOSE(f) tab.CLOSE = f end
|
function env.CLOSE.set(f) tab.CLOSE = f end
|
||||||
function env.mutator.USE_ITEM(f) tab.USE_ITEM = f end
|
function env.USE_ITEM.set(f) tab.USE_ITEM = f end
|
||||||
function env.mutator.CLICK_LINK(f) tab.CLICK_LINK = f end
|
function env.CLICK_LINK.set(f) tab.CLICK_LINK = f end
|
||||||
function env.public.accessor.ACTIVE() return tab == active_tab end
|
function env.public.ACTIVE.get() return tab == active_tab end
|
||||||
tinsert(tab_info, tab)
|
tinsert(tab_info, tab)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local active_tab_index
|
local active_tab_index
|
||||||
function accessor.active_tab() return tab_info[active_tab_index] end
|
function property.active_tab.get() return tab_info[active_tab_index] end
|
||||||
function on_tab_click(index)
|
function on_tab_click(index)
|
||||||
call(active_tab_index and active_tab.CLOSE)
|
call(active_tab_index and active_tab.CLOSE)
|
||||||
active_tab_index = index
|
active_tab_index = index
|
||||||
@@ -236,7 +243,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local locked
|
local locked
|
||||||
function public.accessor.bid_in_progress() return locked end
|
function public.bid_in_progress.get() return locked end
|
||||||
function public.place_bid(type, index, amount, on_success)
|
function public.place_bid(type, index, amount, on_success)
|
||||||
if locked then return end
|
if locked then return end
|
||||||
local money = GetMoney()
|
local money = GetMoney()
|
||||||
@@ -256,7 +263,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local locked
|
local locked
|
||||||
function public.accessor.cancel_in_progress() return locked end
|
function public.cancel_in_progress.get() return locked end
|
||||||
function public.cancel_auction(index, on_success)
|
function public.cancel_auction(index, on_success)
|
||||||
if locked then return end
|
if locked then return end
|
||||||
locked = true
|
locked = true
|
||||||
|
|||||||
+7
-4
@@ -6,9 +6,12 @@ mutable.threads = t
|
|||||||
|
|
||||||
do
|
do
|
||||||
local thread_id
|
local thread_id
|
||||||
public.thread_id()
|
public.thread_id
|
||||||
function accessor() return thread_id end
|
{
|
||||||
function mutator(value) thread_id = value end
|
get = function() return thread_id end,
|
||||||
|
set = function(value) thread_id = value end,
|
||||||
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function LOAD()
|
function LOAD()
|
||||||
@@ -50,7 +53,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local id = 0
|
local id = 0
|
||||||
function accessor.id() id = id + 1; return id end
|
function property.id.get() id = id + 1; return id end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.kill_listener(listener_id)
|
function public.kill_listener(listener_id)
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,7 @@ value_cache = t
|
|||||||
|
|
||||||
do
|
do
|
||||||
local data
|
local data
|
||||||
function accessor.data()
|
function property.data.get()
|
||||||
if not data then
|
if not data then
|
||||||
local dataset = persistence.dataset
|
local dataset = persistence.dataset
|
||||||
data = dataset.history or t
|
data = dataset.history or t
|
||||||
@@ -24,7 +24,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local next_push = 0
|
local next_push = 0
|
||||||
function accessor.next_push()
|
function property.next_push.get()
|
||||||
if time() > next_push then
|
if time() > next_push then
|
||||||
local date = date '*t'
|
local date = date '*t'
|
||||||
date.hour, date.min, date.sec = 24, 0, 0
|
date.hour, date.min, date.sec = 24, 0, 0
|
||||||
@@ -34,7 +34,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function accessor.new_record()
|
function property.new_record.get()
|
||||||
return -object('next_push', next_push, 'data_points', t)
|
return -object('next_push', next_push, 'data_points', t)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -41,13 +41,13 @@ do
|
|||||||
call(on_complete)
|
call(on_complete)
|
||||||
end
|
end
|
||||||
|
|
||||||
function accessor.state()
|
function property.state.get()
|
||||||
local _, state = next(filter(scan_states, function(state) return state.id == thread_id end))
|
local _, state = next(filter(scan_states, function(state) return state.id == thread_id end))
|
||||||
return state
|
return state
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function accessor.query() return state.params.queries[state.query_index] end
|
function property.query.get() return state.params.queries[state.query_index] end
|
||||||
|
|
||||||
function wait_for_callback(...) temp=arg
|
function wait_for_callback(...) temp=arg
|
||||||
local send_signal, signal_received = signal()
|
local send_signal, signal_received = signal()
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ public.font_size = {
|
|||||||
|
|
||||||
do
|
do
|
||||||
local id = 1
|
local id = 1
|
||||||
function public.accessor.name()
|
function public.name.get()
|
||||||
id = id + 1
|
id = id + 1
|
||||||
return 'aux_frame'..id
|
return 'aux_frame'..id
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -3,13 +3,13 @@ module 'post_tab' import 'scan' 'scan_util' 'post' 'history' 'info' 'persistence
|
|||||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
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'}}
|
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||||
|
|
||||||
function accessor.default_settings()
|
function property.default_settings.get()
|
||||||
return -object('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
return -object('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local data
|
local data
|
||||||
function accessor.data()
|
function property.data.get()
|
||||||
if not data then
|
if not data then
|
||||||
local dataset = persistence.dataset
|
local dataset = persistence.dataset
|
||||||
data = dataset.post or t
|
data = dataset.post or t
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ do
|
|||||||
local searches = t
|
local searches = t
|
||||||
local search_index = 1
|
local search_index = 1
|
||||||
|
|
||||||
function accessor.current_search() return searches[search_index] end
|
function current_search.get() return searches[search_index] end
|
||||||
|
|
||||||
function update_search(index)
|
function update_search(index)
|
||||||
searches[search_index].status_bar:Hide()
|
searches[search_index].status_bar:Hide()
|
||||||
|
|||||||
+2
-2
@@ -49,13 +49,13 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
public.accessor.color = color_accessor(function(color)
|
public.color.get = color_accessor(function(color)
|
||||||
local r, g, b, a = unpack(color)
|
local r, g, b, a = unpack(color)
|
||||||
return setmetatable({r/255, g/255, b/255, a}, mt)
|
return setmetatable({r/255, g/255, b/255, a}, mt)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
public.accessor.inline_color = color_accessor(function(color)
|
public.inline_color.get = color_accessor(function(color)
|
||||||
local r, g, b, a = unpack(color)
|
local r, g, b, a = unpack(color)
|
||||||
return format('|c%02X%02X%02X%02X', a, r, g, b)
|
return format('|c%02X%02X%02X%02X', a, r, g, b)
|
||||||
end)
|
end)
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ end
|
|||||||
|
|
||||||
public.huge = 1.8*10^308
|
public.huge = 1.8*10^308
|
||||||
|
|
||||||
function public.accessor.modified() return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() end
|
function public.modified.get() return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() end
|
||||||
|
|
||||||
--do TODO
|
--do TODO
|
||||||
-- local _state = setmetatable({}, {__mode='kv'})
|
-- local _state = setmetatable({}, {__mode='kv'})
|
||||||
|
|||||||
+1
-1
@@ -403,7 +403,7 @@ function public.item_quality_index(item_quality)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.accessor.inventory()
|
function public.inventory.get()
|
||||||
local bag, slot = 0, 0
|
local bag, slot = 0, 0
|
||||||
return function()
|
return function()
|
||||||
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
|
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ _G.aux_datasets = t
|
|||||||
|
|
||||||
do
|
do
|
||||||
local dataset
|
local dataset
|
||||||
function public.accessor.dataset()
|
function public.dataset.get()
|
||||||
if not dataset then
|
if not dataset then
|
||||||
local dataset_key = format('%s|%s', GetCVar 'realmName', UnitFactionGroup 'player')
|
local dataset_key = format('%s|%s', GetCVar 'realmName', UnitFactionGroup 'player')
|
||||||
dataset = _G.aux_datasets[dataset_key] or t
|
dataset = _G.aux_datasets[dataset_key] or t
|
||||||
|
|||||||
Reference in New Issue
Block a user