At 13:53 07/02/2006 +0100, Leopold Toetsch wrote:
François PERRAD wrote:
Hi all,
With the following patch, I try to add two methods (tostring & tonumber)
at each Lua PMC.
With the first new test, I obtain :
Method 'tostring' not found
current instr.: '_main' pc 13 (languages\lua\t\pmc\number_10.pir:6)
What is it wrong or what have I forget to do ?
The problem is that methods are stored into e.g. 'LuaNumber' namspace and
you classname is 'number', used during methodlookup. A current workaround
would be to alias the name into the other namespace:
meth = Parrot_find_global(INTERP,
const_string(INTERP, "LuaNumber"),
const_string(INTERP, "tostring"));
Parrot_store_global(INTERP,
const_string(INTERP, "number"),
const_string(INTERP, "tostring"),
meth);
I add with success this code in class_init().
Thank for your help.
The plan is to attach the namespace aka methodhash to the class itself,
then this hackery isn't necessary anymore.
François.
leo