vararg change for tbc compatibility

This commit is contained in:
Manuel Simon Hirsig
2017-06-02 19:01:16 +02:00
parent 109a0f1578
commit 116f65f109
2 changed files with 13 additions and 18 deletions
+10 -15
View File
@@ -20,7 +20,7 @@ _G.aux = {
account = {}, account = {},
} }
function M.print(...) M.print = vararg-function(arg)
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '<aux> ' .. join(map(arg, tostring), ' ')) DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '<aux> ' .. join(map(arg, tostring), ' '))
end end
@@ -122,8 +122,7 @@ do
end end
end end
function SetItemRef(...) SetItemRef = vararg-function(arg)
temp(arg)
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
return orig.SetItemRef(unpack(arg)) return orig.SetItemRef(unpack(arg))
end end
@@ -133,8 +132,7 @@ function SetItemRef(...)
end end
end end
function UseContainerItem(...) UseContainerItem = vararg-function(arg)
temp(arg)
if modified or not active_tab then if modified or not active_tab then
return orig.UseContainerItem(unpack(arg)) return orig.UseContainerItem(unpack(arg))
end end
@@ -145,15 +143,14 @@ function UseContainerItem(...)
end end
M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end}) M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end})
function M.hook(...) M.hook = vararg-function(arg)
temp(arg)
local name, object, handler local name, object, handler
if arg.n == 3 then if getn(arg) == 3 then
name, object, handler = unpack(arg) name, object, handler = unpack(arg)
else else
object, name, handler = _G, unpack(arg) object, name, handler = _G, unpack(arg)
end end
handler = handler or getfenv(2)[name] handler = handler or getfenv(3)[name]
orig[object] = orig[object] or T orig[object] = orig[object] or T
assert(not orig[object][name], '"' .. name .. '" is already hooked into.') assert(not orig[object][name], '"' .. name .. '" is already hooked into.')
orig[object][name], object[name] = object[name], handler orig[object][name], object[name] = object[name], handler
@@ -246,8 +243,7 @@ end
function Blizzard_AuctionUI() function Blizzard_AuctionUI()
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW') AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
AuctionFrame:SetScript('OnHide', nil) AuctionFrame:SetScript('OnHide', nil)
hook('ShowUIPanel', function(...) hook('ShowUIPanel', vararg-function(arg)
temp(arg)
if arg[1] == AuctionFrame then return AuctionFrame:Show() end if arg[1] == AuctionFrame then return AuctionFrame:Show() end
return orig.ShowUIPanel(unpack(arg)) return orig.ShowUIPanel(unpack(arg))
end) end)
@@ -273,7 +269,7 @@ do
end) end)
end end
function Blizzard_CraftUI() function Blizzard_CraftUI()
hook('CraftFrame_SetSelection', function(...) hook('CraftFrame_SetSelection', vararg-function(arg)
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg))) local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
local id = GetCraftSelectionIndex() local id = GetCraftSelectionIndex()
local reagent_count = GetCraftNumReagents(id) local reagent_count = GetCraftNumReagents(id)
@@ -303,7 +299,7 @@ do
end end
end end
function Blizzard_TradeSkillUI() function Blizzard_TradeSkillUI()
hook('TradeSkillFrame_SetSelection', function(...) hook('TradeSkillFrame_SetSelection', vararg-function(arg)
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg))) local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
local id = GetTradeSkillSelectionIndex() local id = GetTradeSkillSelectionIndex()
local reagent_count = GetTradeSkillNumReagents(id) local reagent_count = GetTradeSkillNumReagents(id)
@@ -334,8 +330,7 @@ do
end end
end end
function AuctionFrameAuctions_OnEvent(...) AuctionFrameAuctions_OnEvent = vararg-function(arg)
temp(arg)
if AuctionFrameAuctions:IsVisible() then if AuctionFrameAuctions:IsVisible() then
return orig.AuctionFrameAuctions_OnEvent(unpack(arg)) return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
end end
+3 -3
View File
@@ -875,9 +875,9 @@ local methods = {
end end
end, end,
SetSort = function(self, ...) SetSort = vararg-function(arg)
temp(arg) local self = tremove(arg, 1)
for k = 1, arg.n do for k = 1, getn(arg) do
for i, sort in self.sorts do for i, sort in self.sorts do
if sort.index == abs(arg[k]) then if sort.index == abs(arg[k]) then
tremove(self.sorts, i) tremove(self.sorts, i)