View Single Post
07-17-05, 08:18 PM   #24
Legorol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 79
Originally Posted by Littlejohn
You really think it's a good idea to limit the number of arguments a function takes? I convinced myself that 5 return results is unlikely to break things, but I'm not sure what to use as the upper limit to the number of arguments. You think 20 is ok?
I think 20 arguments should be more than sufficient. I don't know if the ellipsis argument is skewing results or not, if it isn't you could just leave it as it is. I am certain that it's generating garbage though.

There is another thread http://www.wowinterface.com/forums/s...5&page=2&pp=10
where Kaelten asked for method call tracing on particular instances. After I thought about that, I realized I made the mistake you point out. I've decided to use "class.method" syntax to trace functions in a table (works for class methods and package namespaces) and "object:method" syntax to trace method calls on specific objects.
If you have been asked already, then there is not much to add. To be honest, I don't see the difference between "object", "table" or "class", since in Lua they are the same thing, they are all just tables. GameTooltip is just as much a Lua-table as say MyAddOnClass.

Honestly I didn't know people used that style. It's no big deal to add arbitrary nesting. I should also change the table search code to allow name patterns for tables. (In v1.3 only method names allow patterns; tables must be named precisely.)
They do, although not very often. One prime example is the Sea function library which has tables such as Sea.io, Sea.util etc. with functions in each such as Sea.io.print and Sea.util.hook.

Thanks, I definitely wasn't aware of that.

Are you sure Bliz isn't using Lua metatables? I could automatically search __index if it's a table. If __index is a function or if Bliz is using non-Lua method dispatch then I'm pretty much hosed. I'm past the Lua-newbie phase, but I'm not an expert yet... If you have any advice on OO and/or metatables I'd love to hear it.
As you have guessed, Blizzard uses a natively (read, in C) implemented __index function in a metatable attached to every XML-generated object that's using a non-Lua method to dispatch calls, so you are hosed, in principle. In practice however, complete lists of methods for all known XML-generated object types are available, e.g. at
http://www.wowwiki.com/Widget_API
So as you have suggested (and as Iriel has suggested to me in a thread on the WoW forums), you can build a list of these functions, and match any regexp patterns against such a list. The difficulty unfortunately lies in determining what type of UI object a particular Lua table corresponds to, in other words what set of methods it has. There is no good way that I know of to do this For example, given the name SomeRandomFrame, there is no known way to tell that the global Lua table called "SomeRandomFrame" is attached to a UI element of type Frame, Button or something else.

One of the things that I've sketched out for v1.4 is a more robust way of entering the functions to trace. People (especially gamers without Lua experience) are making mistakes entering the function name patterns. I'm planning on having a GUI to build the table and function patterns with check boxes to turn them on and off.
This sounds like a great idea!
  Reply With Quote