diff --git a/aux-addon.lua b/aux-addon.lua index b72f5aa..2cf7350 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -29,8 +29,8 @@ do tinsert(table_pool, t) end - function public.accessor.t() return - tremove(table_pool) or {} + function public.accessor.t() + return tremove(table_pool) or {} end function public.accessor.tt() -- TODO or 'tmp'? t (and t -> T)? @@ -46,13 +46,12 @@ do __newindex=function(_, _, value) return f(value) end, __unm=function(self) return self end, }) end - local temp, perm = modifier(function(t) temporary[t] = true; return t end), modifier(function(t) temporary[t] = false; return t end) + local temp, perm = modifier(function(t) temporary[t] = true; return t end), modifier(function(t) temporary[t] = nil; return t end) public.temp() -- TODO or 'auto'? - function accessor() return setmetatable(tt, mt) end - function mutator(value) return temp(value) end - public.perm() -- TODO or 'keep'? - function accessor() return setmetatable(tt, mt) end - function mutator(value) return perm(value) end + function accessor() return temp end + function mutator(t) return temp(t) end + public.perm() -- TODO or 'keep' 'hold'?? + function mutator(t) return perm(t) end function public.collector_mt(f) return { @@ -129,20 +128,19 @@ function public.log(...) temp=arg DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg) end - tab_info = t -for k, v in -object :search_tab 'Search' :post_tab 'Post' :auctions_tab 'Auctions' :bids_tab 'Bids' do - local m, tab = _m, -object :name(v); - log(tab.name); - (function() - module(k) - function mutator.OPEN(f) tab.OPEN = f end - function mutator.CLOSE(f) tab.CLOSE = f end - function mutator.USE_ITEM(f) tab.USE_ITEM = f end - function mutator.CLICK_LINK(f) tab.CLICK_LINK = f end - function public.accessor.ACTIVE() return tab == m.active_tab end - end)() - tinsert(tab_info, tab) +do + local data = -list :search_tab 'Search' :post_tab 'Post' :auctions_tab 'Auctions' :bids_tab 'Bids' + for i=1,7,2 do + local tab = perm<-object :name(data[i + 1]); + local env = (function() module(data[i]) return _m end)() + function env.mutator.OPEN(f) tab.OPEN = f end + function env.mutator.CLOSE(f) tab.CLOSE = f end + function env.mutator.USE_ITEM(f) tab.USE_ITEM = f end + function env.mutator.CLICK_LINK(f) tab.CLICK_LINK = f end + function env.public.accessor.ACTIVE() return tab == active_tab end + tinsert(tab_info, tab) + end end do @@ -174,7 +172,7 @@ function UseContainerItem(...) temp=arg end public.orig = setmetatable({[_g]=t}, {__index=function(self, key) return self[_g][key] end}) -function public.hook(...) +function public.hook(...) temp=arg local name, object, handler if arg.n == 3 then name, object, handler = unpack(arg) diff --git a/module.lua b/module.lua index 7de8af9..8e1cb11 100644 --- a/module.lua +++ b/module.lua @@ -29,9 +29,10 @@ function importer_mt.__call(self, arg1, arg2) end return self end -function set_property(data, property, value) - if property and not data[property] and type(value) == 'function' or property_error() then - data[property] = value +function set_property(metadata, data, modifier, key, f) + if key and not data[key] and type(f) == 'function' or property_error() then + metadata[key] = metadata[key] + modifier + data[key] = f end end declarator_mt = {__metatable=false} @@ -67,6 +68,7 @@ do local function index(access, default) return function(self, key) local state = _state[self]; local modifiers = state.metadata[key] or 0 + if key == 'perm' then DEFAULT_CHAT_FRAME:AddMessage(tostring(key)) end if mask(access+ACCESSOR, modifiers) == access+ACCESSOR then return state.accessors[key]() end return state.data[key] or default[key] end @@ -101,7 +103,7 @@ function module(name) private=function() state.modifiers = PRIVATE return declarator end, public=function() state.modifiers = PUBLIC return declarator end, mutable=function() state.modifiers = MUTABLE return declarator end, accessor=function() state.modifiers = PROPERTY+ACCESSOR return declarator end, mutator=function() state.modifiers = PROPERTY+MUTATOR return declarator end} - mutators = {accessor=function(value) set_property(accessors, state.property, value) end, mutator=function(value) set_property(mutators, state.property, value) end} + mutators = {accessor=function(f) set_property(state.metadata, accessors, ACCESSOR, state.property, f) end, mutator=function(f) set_property(state.metadata, mutators, MUTATOR, state.property, f) end} state = { env=env, interface=interface, modifiers=PRIVATE, metadata = {_g=PRIVATE, _m=PRIVATE, _i=PRIVATE, import=PRIVATE, private=PROPERTY+ACCESSOR, public=PROPERTY+ACCESSOR, mutable=PROPERTY+ACCESSOR, accessor=PROPERTY+ACCESSOR+MUTATOR, mutator=PROPERTY+ACCESSOR+MUTATOR}, diff --git a/util/filter.lua b/util/filter.lua index 6922d71..b74810d 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -374,7 +374,7 @@ function suggestions(components) if components.blizzard.name and size(components.blizzard) == 1 then tinsert(suggestions, 'exact') end - tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tt') + tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tooltip') for key in filters do tinsert(suggestions, key) end