Hi,

you can find some examples in my pascal4neko at googlecodes
http://code.google.com/p/pascal4neko/

since i am a pascal programmer i can give some hints using pascal syntax:

if you have a class Foo in haXe:

class  Foo {
}

you can add a static function bar in your code like this:

you have a pascal function somewhere:

function Foo_bar(): value; cdecl;
begin
    result:= val_true
end;

to initialize you need the value of the Foo class ->  when foo is the
value of the Foo class:

    alloc_field(foo, val_id('bar'), alloc_function(@Foo_bar, 0, 'bar'));

in haXe you can call it:

Foo.bar();

if you want to add a non static function barOfObject:

function Foo_barOfObject(): value; cdecl;
begin
    result:= val_true
end;

and to initialize you need again the value of the Foo class:

var p: value;
begin
    p:= val_field(foo, val_id('prototype'));
    alloc_field(p, val_id('barOfObject'),
alloc_function(@Foo_barOfObject, 0, 'barOfObject'));

in haXe you can call it:

var f = new Foo();
f.barOfObject();

hope this helps.

cheers,

Adrian.



Am 18.08.2011 19:19, schrieb Jorge Luis Zapata Muga:
> On Thu, Aug 18, 2011 at 4:15 PM, Adrian Veith <[email protected]> wrote:
>> Am 18.08.2011 14:06, schrieb Jorge Luis Zapata Muga:
>>> Is it possible to handle this with neko? does it support this kind of
>>> dynamic function creation?
>> more or less - yes.
>>
>> static function have to be added to the class object.
>>
>> object methods have to be added to the prototype of the class object.
>>
> Could you please elaborate a little bit more on this? i'm not used to
> neko, maybe some example code would be useful
>
> Regards
>
>> regards,
>>
>> Adrian.
>>
>>
>> --
>> Neko : One VM to run them all
>> (http://nekovm.org)
>>
-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to