library change

This commit is contained in:
Manuel Simon Hirsig
2016-11-08 06:07:52 +01:00
parent 18300e3d1b
commit 14a9ba3ef8
9 changed files with 86 additions and 94 deletions
+9 -12
View File
@@ -13,14 +13,12 @@ local scan = require 'aux.core.scan'
--aux_account_settings = {} -- TODO clean up the mess of savedvariables
--aux_character_settings = {}
M.version = '5.0.0'
function M.set_p(v)
inspect(nil, v)
end
function M.print(...)
auto_release(arg, true)
temp(arg)
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '[aux] ' .. join(map(arg, tostring), ' '))
end
@@ -52,7 +50,6 @@ do
for _, f in handlers do f() end
elseif event == 'PLAYER_LOGIN' then
for _, f in handlers2 do f() end
print('v' .. version .. ' loaded.')
else
_M[event]()
end
@@ -82,7 +79,7 @@ do
end
function SetItemRef(...)
auto_release(arg, true)
temp(arg)
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
return orig.SetItemRef(unpack(arg))
end
@@ -92,7 +89,7 @@ function SetItemRef(...)
end
function UseContainerItem(...)
auto_release(arg, true)
temp(arg)
if modified or not index(active_tab, 'USE_ITEM') then
return orig.UseContainerItem(unpack(arg))
end
@@ -103,7 +100,7 @@ end
M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end})
function M.hook(...)
auto_release(arg, true)
temp(arg)
local name, object, handler
if arg.n == 3 then
name, object, handler = unpack(arg)
@@ -200,7 +197,7 @@ end
do
local last_owner_page_requested
function GetOwnerAuctionItems(...)
auto_release(arg, true)
temp(arg)
local page = arg[1]
last_owner_page_requested = page
return orig.GetOwnerAuctionItems(unpack(arg))
@@ -214,7 +211,7 @@ function ADDON_LOADED.Blizzard_AuctionUI()
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
AuctionFrame:SetScript('OnHide', nil)
hook('ShowUIPanel', function(...)
auto_release(arg, true)
temp(arg)
if arg[1] == AuctionFrame then return AuctionFrame:Show() end
return orig.ShowUIPanel(unpack(arg))
end)
@@ -230,7 +227,7 @@ do
end
function ADDON_LOADED.Blizzard_CraftUI()
hook('CraftFrame_SetSelection', function(...)
auto_release(arg, true)
temp(arg)
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
local id = GetCraftSelectionIndex()
local reagent_count = GetCraftNumReagents(id)
@@ -258,7 +255,7 @@ do
end
function ADDON_LOADED.Blizzard_TradeSkillUI()
hook('TradeSkillFrame_SetSelection', function(...)
auto_release(arg, true)
temp(arg)
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
local id = GetTradeSkillSelectionIndex()
local reagent_count = GetTradeSkillNumReagents(id)
@@ -287,7 +284,7 @@ do
end
function AuctionFrameAuctions_OnEvent(...)
auto_release(arg, true)
temp(arg)
if AuctionFrameAuctions:IsVisible() then
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
end
+3 -3
View File
@@ -86,13 +86,13 @@ end
do
local mt = {
__call = function(self)
auto_release(self, true)
temp(self)
return self.f(unpack(self))
end,
}
M.thread = vararg-function(arg)
auto_release(arg, false)
static(arg)
arg.f = tremove(arg, 1)
local thread_id = unique_id
threads[thread_id] = O('k', setmetatable(arg, mt))
@@ -100,7 +100,7 @@ do
end
M.wait = vararg-function(arg)
auto_release(arg, false)
static(arg)
arg.f = tremove(arg, 1)
threads[thread_id].k = setmetatable(arg, mt)
end
+2 -1
View File
@@ -144,7 +144,8 @@ function merchant_buy_scan()
end
function merchant_sell_scan()
for slot in info.inventory do auto_release(slot, true)
for slot in info.inventory do
temp(slot)
local item_info = temp-info.container_item(unpack(slot))
if item_info then
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
+2 -1
View File
@@ -209,7 +209,8 @@ end
function game_tooltip_hooks:SetAuctionSellItem()
local name, _, quantity = GetAuctionSellItemInfo()
if name then
for slot in info.inventory do auto_release(slot, true)
for slot in info.inventory do
temp(slot)
local link = GetContainerItemLink(unpack(slot))
if link and select(5, info.parse_link(link)) == name then
extend_tooltip(GameTooltip, link, quantity)
+1 -1
View File
@@ -919,7 +919,7 @@ local methods = {
end,
SetSort = function(self, ...)
auto_release(arg, true)
temp(arg)
for k = 1, arg.n do
for i, sort in self.sorts do
if sort.index == abs(arg[k]) then
+2 -2
View File
@@ -25,7 +25,7 @@ function LOAD()
aux_background:SetAllPoints(DropDownList1Backdrop)
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
hook('ToggleDropDownMenu', function(...)
auto_release(arg, true)
temp(arg)
local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
local dropdown = _G[arg[4] or ''] or this:GetParent()
if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
@@ -110,7 +110,7 @@ do
return orig()
end)
M.menu = vararg-function(arg)
auto_release(arg, false)
static(arg)
structure = arg
local x, y = GetCursorPosition()
menu:ClearAllPoints()
+63 -71
View File
@@ -1,80 +1,72 @@
library 'T'
local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable
local next, getn, setn, tremove, setmetatable = next, getn, table.setn, tremove, setmetatable
local wipe, acquire, release
local pool, pool_size, overflow_pool, auto_release, dep_release = {}, 0, setmetatable({}, {__mode='k'}), {}, setmetatable({}, {__mode='k'})
function wipe(t)
setmetatable(t, nil)
for k, v in t do
if dep_release[v] then release(v) end
t[k] = nil
end
t.reset, t.reset = nil, 1
setn(t, 0)
end
M.wipe = wipe
CreateFrame'Frame':SetScript('OnUpdate', function()
for t in auto_release do release(t) end
wipe(auto_release)
end)
function acquire()
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
M.acquire = acquire
function release(t)
wipe(t)
auto_release[t] = nil
dep_release[t] = nil
if pool_size < 50 then
pool_size = pool_size + 1
pool[pool_size] = t
else
overflow_pool[t] = true
end
end
M.release = release
local wipe, acquire, release, auto_release, dep_release
do
local pool, pool_size, overflow_pool, is_auto_release, is_dep_release = {}, 0, setmetatable({}, {__mode='k'}), {}, setmetatable({}, {__mode='k'})
function wipe(t)
setmetatable(t, nil)
for k, v in t do
if is_dep_release[v] then release(v) end
t[k] = nil
end
t.reset, t.reset = nil, 1
setn(t, 0)
end
M.wipe = wipe
CreateFrame'Frame':SetScript('OnUpdate', function()
for t in is_auto_release do release(t) end
wipe(is_auto_release)
end)
function acquire()
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
M.acquire = acquire
function release(t)
wipe(t)
is_auto_release[t] = nil
is_dep_release[t] = nil
if pool_size < 50 then
pool_size = pool_size + 1
pool[pool_size] = t
else
overflow_pool[t] = true
end
end
M.release = release
function auto_release(v, enable)
if type(v) ~= 'table' then return end
is_auto_release[v] = enable and true or nil
end
M.auto_release = auto_release
function dep_release(v, enable)
if type(v) ~= 'table' then return end
is_dep_release[v] = enable and true or nil
end
M.dep_release = dep_release
local function f(_, v) if v then auto_release[v] = true; return v end end
M.temp = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
end
do
local function f(_, v) if v then auto_release[v] = nil; return v end end
M.static = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
end
do
local function f(_, v) if v then dep_release[v] = true; return v end end
M.weak = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
end
do
local function f(_, v) if v then dep_release[v] = nil; return v end end
M.strong = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
end
M.get_T = acquire
M.temp = setmetatable({}, {
__metatable = false,
__newindex = nop,
__sub = function(_, v) auto_release(v, true); return v end,
})
M.weak = setmetatable({}, {
__metatable = false,
__newindex = nop,
__sub = function(_, v) dep_release(v, true); return v end,
})
do
local function ret(t)
if getn(t) > 0 then
@@ -111,7 +103,7 @@ do
code = code .. [[
until true
local t = acquire()
auto_release(t, true)
auto_release[t] = true
setn(t, n)
repeat
]]
@@ -136,7 +128,7 @@ do
end
M.A = vararg(function(arg)
auto_release(arg, false)
auto_release[arg] = nil
return arg
end)
M.S = vararg(function(arg)
+3 -2
View File
@@ -348,7 +348,7 @@ end
function unit_vendor_price(item_key)
for slot in info.inventory do
auto_release(slot, true)
temp(slot)
local item_info = temp-info.container_item(unpack(slot))
if item_info and item_info.item_key == item_key then
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
@@ -412,7 +412,8 @@ end
function update_inventory_records()
local auctionable_map = temp-T
for slot in info.inventory do auto_release(slot, true)
for slot in info.inventory do
temp(slot)
for item_info in present(temp-info.container_item(unpack(slot))) do
local charge_class = item_info.charges or 0
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
+1 -1
View File
@@ -174,7 +174,7 @@ end
function M.signal()
local params
return vararg-function(arg)
auto_release(arg, false)
static(arg)
params = arg
end, function()
return params