Q for Ansca about remove() vs removeSelf()

The display remove function is accessed in dot format:

display.remove(numObjs[3])

If you look into the display table, you see the remove function

ELEMENT remove VALUE function: 02E7BE20 TYPE IS function

Knowing this you can overwrite the function address with your own.
The removeSelf function is in colon format :

numObjs[3]:removeSelf()

In this format, you do not know what the 'class' is, and can not goto the table to find the function. If you look in the table for the object instance, you see:

-- Number 1 table: 02E5FFA8 --
ELEMENT _class VALUE table: 02E45000 TYPE IS table
-- _class table: 02E45000 --
ELEMENT __index VALUE table: 02E45000 TYPE IS table
ELEMENT addBehavior VALUE function: 02E4AD40 TYPE IS function
ELEMENT hasBehavior VALUE function: 02E6EBC0 TYPE IS function
ELEMENT initProxy VALUE function: 02E6B060 TYPE IS function
ELEMENT removeBehavior VALUE function: 02E83738 TYPE IS function
ELEMENT _functionListeners VALUE table: 02E60020 TYPE IS table
-- _functionListeners table: 02E60020 --
ELEMENT tap VALUE table: 02E60230 TYPE IS table
-- tap table: 02E60230 --
ELEMENT 1 VALUE function: 02E4AEF0 TYPE IS function
ELEMENT _proxy VALUE userdata: 02E51BA8 TYPE IS userdata
-- Meta table: 02E77018 --
ELEMENT __gc VALUE function: 02E5AA68 TYPE IS function
---------------------

no removeSelf in sight. I played around a little with removeBehavior but nothing good came of it. I have two questions.

1. How is the call to removeSelf executed if the routine is not listed in the table? Or is it that I am just not allowed to see it?

2. Is there a way I can work backwards from colon format function calls to find the 'class' table they are in and overwrite then with my own function?

If you are wondering why I want to do this, I have a little utility for monitoring texture memory. It uses this technique to keep track of what is allocated and released to inform you of what is still allocated. It works fine if you only used dot format function calls. But it would be more thorough if it could cover the colon format function calls too.

I look forward to an educating answer.
Thank you

views:1327 update:2011/9/27 18:14:54
corona forums © 2003-2011