|
I need to be able to do the following, where objectA is full user data: objectA:add(arg1, arg2) -and- objectA.x = objectA.x + 2; This requires __index, __newindex, and method calling. I tried a couple different approaches: Method A
What's Working - Setting and getting properties (objectA.x = objectA.x + 2) What's Not Working - The functions contained in the methods metatable are not automatically called. I added some code to the methods.__index C function to catch the function calls, but the arguments only include the methods table, and function key - no function arguments are included (self, arg1, and arg2 are missing). Method B
What's Working - The functions contained in the methods metatable are automatically called with the correct arguments What's Not Working - Setting and getting properties (objectA.x = objectA.x + 2) does not work as the attrbutes.__index and attrbutes.__newindex custom C functions are not getting the proper arguments. This would seem to be a common requirement: a userdata object requiring functions on self, along with custom setter and getter routines. This is all in C as I need to manipulate an Objective C object through it's methods and properties. The Obj-C object is pointed to by the userdata object. Does it make more sense to use a table vs userdata? I'm literally on day #4 with this problem and would greatly appreciate the group's input. Thanks in advance! -Tom |