View Single Post
09-12-10, 04:16 PM   #15
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Would it be too much to ask for a function to hook API (within reason) and alter behavior before it actually runs the arguments trough the function?

For example some addon uses UnitName and you would like to alter the input arguments at specific conditions, so that when UnitName(...) actually runs it uses the modified arguments and not the original once.
I guess what I am getting at is something like a:
Code:
phooksecurefunc("UnitName", function(arg1)
return true, arg1 == "player" and "target" or arg1
end);
Calling /dump UnitName("player") would actually run UnitName("target").
Code:
phooksecurefunc("UnitName", function(arg1, arg2)
return false, arg1, arg2 ~= "" and arg2 or "MyRealm"
end);
In this situation, calling /dump UnitName("player") would return {"Playername", "MyRealm"} and avoid running the original "UnitName". Problem here is that using multiple addons that do this on UnitName would clash but it's just a suggestion and there are probably other ways that this problem can be avoided.

In short, this could be used to alter simple default UI function behavior in a efficient way (no proof to backup my statement, I just suspect it could be if we can avoid making those "local orig = FuncName and re-declaring the function over again).

It's just a suggestion, I think you understand what I am trying to get across.
Thanks for reading my rant.