Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: add methods in dynpmc

2 views
Skip to first unread message

Leopold Toetsch

unread,
Feb 7, 2006, 7:53:22 AM2/7/06
to François PERRAD, perl6-i...@perl.org
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);

The plan is to attach the namespace aka methodhash to the class itself,
then this hackery isn't necessary anymore.

>
> Françoi
> s.

leo


Francois PERRAD

unread,
Feb 7, 2006, 11:31:37 AM2/7/06
to Leopold Toetsch, perl6-i...@perl.org
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.

0 new messages