mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-21 23:26:56 +00:00
Route hooksecurefunc callers through pfUI.hooksecurefunc; global belongs to ClassicAPI
pfUI's Lua hooksecurefunc lived in pfUI.env and shadowed ClassicAPI's C global for all pfUI code. Replace it with a thin pfUI.hooksecurefunc shim that keeps the missing-target no-op our call sites rely on (ClassicAPI errors on a nil target) and delegates the actual hook to _G.hooksecurefunc. Migrated all 70 internal call sites (modules/libs/skins) to pfUI.hooksecurefunc; bare hooksecurefunc now resolves to ClassicAPI's C version everywhere. Dropped the unused prepend path and the orphaned pfUI.hooks table.
This commit is contained in:
+10
-26
@@ -28,32 +28,16 @@ ACTIONBAR_SECURE_TEMPLATE_BUTTON = nil
|
||||
UNITFRAME_SECURE_TEMPLATE = nil
|
||||
|
||||
--[[ Vanilla API Extensions ]]--
|
||||
function hooksecurefunc(tbl, name, func, prepend)
|
||||
if type(tbl) == "string" then
|
||||
prepend, func, name, tbl = func, name, tbl, _G
|
||||
end
|
||||
|
||||
if not tbl or not tbl[name] then return end
|
||||
|
||||
pfUI.hooks[tostring(func)] = {}
|
||||
pfUI.hooks[tostring(func)]["old"] = tbl[name]
|
||||
pfUI.hooks[tostring(func)]["new"] = func
|
||||
|
||||
if prepend then
|
||||
pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
return pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
end
|
||||
else
|
||||
pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
local ok, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16 = pcall(pfUI.hooks[tostring(func)]["old"], a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
if not ok then return end
|
||||
pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
||||
return r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16
|
||||
end
|
||||
end
|
||||
|
||||
tbl[name] = pfUI.hooks[tostring(func)]["function"]
|
||||
-- Safe post-hook helper. The global `hooksecurefunc` belongs to ClassicAPI
|
||||
-- (its C implementation); this wrapper only adds pfUI's missing-target guard:
|
||||
-- ClassicAPI errors when target[name] isn't a function, whereas a lot of our
|
||||
-- call sites hook optional/late-loaded frames and rely on a silent no-op.
|
||||
-- Normalizes the string form, skips when the target is absent, then delegates
|
||||
-- to the C version (uncapped args, callback-pcall, taint parity).
|
||||
function pfUI.hooksecurefunc(tbl, name, func)
|
||||
if type(tbl) == "string" then tbl, name, func = _G, tbl, name end
|
||||
if not tbl or type(tbl[name]) ~= "function" then return end
|
||||
return _G.hooksecurefunc(tbl, name, func)
|
||||
end
|
||||
|
||||
do -- GetItemInfo
|
||||
|
||||
Reference in New Issue
Block a user