refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-07-15 22:47:20 +02:00
parent 54eb2a67ef
commit b524214f65
28 changed files with 90 additions and 86 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'control'
local m, public, private = Aux.module'control'
private.event_listeners = {}
private.threads = {}
+50 -55
View File
@@ -19,83 +19,91 @@ do
end
function Aux_module(name)
local interface, data, private, public, is_public = {}, {}, {}, {}, {}
setmetatable(interface, {
local data, is_public, public_interface, private_interface, public, private = {}, {}, {}, {}, {}, {}
setmetatable(public_interface, {
__newindex = function(_, key)
error('Illegal write of attribute "'..key..'" on interface of "'..name..'"!')
error('Illegal write of attribute "'..key..'" on public interface of "'..name..'"!')
end,
__index = function(_, key)
if data[key] == nil then
error('Access of undeclared attribute "'..key..'" on public interface of "'..name..'"!')
end
if is_public[key] then
return data[key]
return Aux_unwrap(data[key])
end
end,
__call = function(_, key)
return is_public[key]
end
})
setmetatable(data, {
setmetatable(private_interface, {
__newindex = function(_, key, value)
if rawget(data, key) == nil then
error('Assignment of undeclared attribute "'..key..'" of module"'..name..'"!')
if data[key] == nil then
error('Assignment of undeclared attribute "'..key..'" on private interface of "'..name..'"!')
end
rawset(data, key, Aux_wrap(value))
data[key] = Aux_wrap(value)
end,
__index = function(_, key)
if rawget(data, key) == nil then
error('Access of undeclared attribute "'..key..'" of module"'..name..'"!')
else
return Aux_unwrap(rawget(data, key))
if data[key] == nil then
error('Access of undeclared attribute "'..key..'" on private interface of "'..name..'"!')
end
return Aux_unwrap(data[key])
end,
__call = function(_, key)
return data[key] ~= nil
end
})
setmetatable(public, {
__newindex = function(_, key, value)
if data[key] ~= nil then
error('Multiple declarations of "'..key..'" in "'..name..'"!')
end
data[key] = Aux_wrap(value)
is_public[key] = true
end,
__index = function(_, key)
error('Illegal read of attribute "'..key..'" on public keyword in "'..name..'"!')
end,
})
setmetatable(private, {
__newindex = function(_, key, value)
if rawget(data, key) ~= nil then
error('Multiple declarations of "'..key..'" in module"'..name..'"!')
if data[key] ~= nil then
error('Multiple declarations of "'..key..'" in "'..name..'"!')
end
rawset(data, key, Aux_wrap(value))
data[key] = Aux_wrap(value)
is_public[key] = nil
end,
__index = function()
error('Illegal read on "private" keyword in"'..name..'"!')
__index = function(_, key)
error('Illegal read of attribute "'..key..'" on private keyword in "'..name..'"!')
end,
})
setmetatable(public, {
__newindex = function(_, key, value)
if rawget(data, key) ~= nil then
error('Multiple declarations of "'..key..'" in module"'..name..'"!')
end
rawset(data, key, Aux_wrap(value))
is_public[key] = true
end,
__index = function()
error('Illegal read on "public" keyword in"'..name..'"!')
end,
})
return { interface, data, private, public }
return { public_interface, private_interface, public, private }
end
function Aux_addon(name)
local interface, data, private, public = unpack(Aux_module(name))
local public_interface, private_interface, public, private = unpack(Aux_module(name))
private.modules = { interface }
private.modules = { public_interface }
function public.module(name)
local module = Aux_module(name)
local interface = tremove(module, 1)
tinsert(data.modules, interface)
public[name] = interface
local public_interface = tremove(module, 1)
tinsert(private_interface.modules, public_interface)
public[name] = public_interface
return unpack(module)
end
return { interface, data, private, public }
return { public_interface, private_interface, public, private }
end
local addon = Aux_addon('Aux')
Aux = tremove(addon, 1)
local m, private, public = unpack(addon)
local m, public, private = unpack(addon)
private.tabs = {}
function public.tab(index, name)
local ret = { m.module(name) }
m.tabs[index] = m.modules[name]
m.tabs[index] = m[name]
return unpack(ret)
end
@@ -118,9 +126,7 @@ function public.on_load()
tab_group:create_tab('Post')
tab_group:create_tab('Auctions')
tab_group:create_tab('Bids')
tab_group.on_select = function()
m.on_tab_click()
end
tab_group.on_select = m.on_tab_click
public.tab_group = tab_group
end
@@ -154,7 +160,7 @@ function public.on_load()
end
for _, module in m.modules do
if module.LOAD then
if module('LOAD') then
module.LOAD()
end
end
@@ -376,28 +382,17 @@ function private.on_auction_house_closed()
end
function private.on_tab_click(index)
local y = m.active_tab
if m.active_tab then
m.tabs[m.active_tab].CLOSE()
end
AuxSearchFrame:Hide()
AuxPostFrame:Hide()
AuxAuctionsFrame:Hide()
AuxBidsFrame:Hide()
m.tabs[index].OPEN()
-- if index == 1 then
-- AuxSearchFrame:Show()
-- Aux.search_frame.on_open()
-- elseif index == 2 then
-- AuxPostFrame:Show()
-- Aux.post_frame.on_open()
-- elseif index == 3 then
-- AuxAuctionsFrame:Show()
-- Aux.auctions_frame.on_open()
-- elseif index == 4 then
-- AuxBidsFrame:Show()
-- Aux.bids_frame.on_open()
-- end
m.active_tab = index
end
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'gui'
local m, public, private = Aux.module'gui'
--TSM.designDefaults = {
-- frameColors = {
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'cache'
local m, public, private = Aux.module'cache'
local MIN_ITEM_ID, MAX_ITEM_ID = 1, 30000
local items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'disenchant'
local m, public, private = Aux.module'disenchant'
function public.source(item_id)
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'history'
local m, public, private = Aux.module'history'
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}}}
private.value_cache = {}
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'post'
local m, public, private = Aux.module'post'
local state
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'scan'
local m, public, private = Aux.module'scan'
local PAGE_SIZE = 50
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'stack'
local m, public, private = Aux.module'stack'
local state
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'tooltip'
local m, public, private = Aux.module'tooltip'
aux_tooltip_value = true
+4 -2
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.tab(3, 'auctions_frame')
local m, public, private = Aux.tab(3, 'auctions_frame')
local auction_records
@@ -7,14 +7,16 @@ function public.FRAMES(f)
end
function public.LOAD()
m.create_frames(m, private, public)
m.create_frames(m, public, private)
end
function public.OPEN()
AuxAuctionsFrame:Show()
m.scan_auctions()
end
function public.CLOSE()
AuxAuctionsFrame:Hide()
end
function private.update_listing()
+1 -1
View File
@@ -1,4 +1,4 @@
Aux.auctions_frame.FRAMES(function(m, private, public)
Aux.auctions_frame.FRAMES(function(m, public, private)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
m.listing:SetSort(1,2,3,4,5,6,7,8)
m.listing:Reset()
+4 -2
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.tab(4, 'bids_frame')
local m, public, private = Aux.tab(4, 'bids_frame')
local auction_records
@@ -7,14 +7,16 @@ function public.FRAMES(f)
end
function public.LOAD()
m.create_frames(m, private, public)
m.create_frames(m, public, private)
end
function public.OPEN()
AuxBidsFrame:Show()
m.scan_bids()
end
function public.CLOSE()
AuxBidsFrame:Hide()
end
function private.update_listing()
+1 -1
View File
@@ -1,4 +1,4 @@
Aux.bids_frame.FRAMES(function(m, private, public)
Aux.bids_frame.FRAMES(function(m, public, private)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
m.listing:SetSort(1,2,3,4,5,6,7,8)
m.listing:Reset()
+5 -2
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.tab(2, 'post_frame')
local m, public, private = Aux.tab(2, 'post_frame')
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'}}
@@ -15,10 +15,12 @@ function public.FRAMES(f)
end
function public.LOAD()
m.create_frames(m, private, public)
m.create_frames(m, public, private)
end
function public.OPEN()
AuxPostFrame:Show()
m.deposit:SetText('Deposit: '..Aux.money.to_string(0, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
m.set_unit_start_price(0)
@@ -31,6 +33,7 @@ end
function public.CLOSE()
m.selected_item = nil
AuxPostFrame:Hide()
end
function private.default_settings()
+1 -1
View File
@@ -1,4 +1,4 @@
Aux.post_frame.FRAMES(function(m, private, public)
Aux.post_frame.FRAMES(function(m, public, private)
Aux.gui.vertical_line(AuxPostFrameContent, 219)
AuxPostParametersItem:EnableMouse()
+4 -2
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.tab(1, 'search_frame')
local m, public, private = Aux.tab(1, 'search_frame')
aux_favorite_searches = {}
aux_recent_searches = {}
@@ -74,18 +74,20 @@ function public.FRAMES(f)
end
function public.LOAD()
m.create_frames(m, private, public)
m.create_frames(m, public, private)
m:disable_sniping()
m.update_search()
m.update_tab(m.SAVED)
end
function public.OPEN()
AuxSearchFrame:Show()
m.update_search_listings()
end
function public.CLOSE()
m.results_listing:SetSelectedRecord()
AuxSearchFrame:Hide()
end
function private.update_search_listings()
+1 -1
View File
@@ -1,4 +1,4 @@
Aux.search_frame.FRAMES(function(m, private, public)
Aux.search_frame.FRAMES(function(m, public, private)
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPLEFT', 5, -8)
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'auction_listing'
local m, public, private = Aux.module'auction_listing'
local RT_COUNT = 1
local HEAD_HEIGHT = 27
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'item_listing'
local m, public, private = Aux.module'item_listing'
local ROW_HEIGHT = 38
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'listing'
local m, public, private = Aux.module'listing'
local ST_COUNT = 0
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'completion'
local m, public, private = Aux.module'completion'
function public:complete()
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'util'
local m, public, private = Aux.module'util'
function public.pass()
end
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'info'
local m, public, private = Aux.module'info'
local TOOLTIP_LENGTH = 30
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'money'
local m, public, private = Aux.module'money'
local GOLD_TEXT = '|cffffd70ag|r'
local SILVER_TEXT = '|cffc7c7cfs|r'
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'persistence'
local m, public, private = Aux.module'persistence'
aux_datasets = {}
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'scan_util'
local m, public, private = Aux.module'scan_util'
function public.default_filter(str)
return {
+1 -1
View File
@@ -1,4 +1,4 @@
local m, private, public = Aux.module'sort'
local m, public, private = Aux.module'sort'
public.LT = {}
public.EQ = {}