Thanks for your reply Danny, you cleared a lot of things to me.

How does this change the c++ code in the example?

------------
void execute( value module ) {
     value x = val_field(module,val_id("x"));

--------

I tried the . : :: => between object name nad variable and nothing of these
seemed to work.

------------
void execute( value module ) {
     value x = val_field(module,val_id("Main.x")); // this didn't work

--------

This is my code otherwise. I tried to make it first work with object in pure
neko as the n that I compiled from haxe exited my app, so I figure if I
manage to make it work with neko with exported variables inside object first
... then I can start solving the the other thing.

--- NEKO CODE WITH OBJECT ---

var x = 0;
var dir = 1;

$exports.NekoPtkGame = {
    cb_quickLoad => function() {
        var load = $loader.loadprim("loadImg", 1);
        load("img\\bg\\golf_s.jpg");
        load("img\\spr\\tank1.png");
    },

    cb_update => function() {
        var draw = $loader.loadprim("drawImg", 5);
        draw(800, 600, 0, 0, 0);
        draw(105, 95,  x, 500, 1);
        x = 3 * dir + x;
        if ( x < 0 ) dir = 1;
        if ( x > 700 ) dir = -1;
    }
}

--- C ++ CODE NOW :

void ncb_quickLoad(value module)
{
    value f = val_field(module,val_id("NekoPtkGame.cb_quickLoad"));
    if( !val_is_function(f) ) return;
    val_call0(f);
}

void ncb_update(value module)
{
    value f = val_field(module,val_id("NekoPtkGame.cb_update"));
    if( !val_is_function(f) ) return;
    val_call0(f);
}

-----

val_is_function() returned false in both times (now when I added object,
witout it directly it works)

Best regards, Thanks so far!

Janko


I tried the object.

> Op Thu, 09 Oct 2008 23:08:46 +0200 schreef janko metelko <
> [EMAIL PROTECTED]>:
>
>  $exports.x = 33;
>> $exports.f = function(x) { return x * 2 + 1; }
>>
>> This is all no problem to me, C and neko side works and all. But can you
>> Nicolas or anybody else please show me what would the Haxe version of this
>> small example be. A Haxe code that after compiled to .n exports some value x
>> and some function f that calculates something. If such thing is possible?
>>
>
> haXe requires variables to be in classes, so the closest would be:
>
> // ------------
> // haXe
> class Main {
>  static var x = 33;
> }
>
> // ------------
>
> // Neko output
> $exports.Main.x = 33;
> // ------------
>
>
> Every haXe class is an object in Neko. So all statics are accessible in the
> exports.
>
> That's why Nicolas wrote:
>
> Op Thu, 09 Oct 2008 09:59:58 +0200 schreef Nicolas Cannasse <
> [EMAIL PROTECTED]>:
>
>   $exports.my.package.MyClass
>>  (or the equivalent by using Neko API)
>>  You can create an instance by calling  MyClass.new(p1,p2,...) and the
>> call the methods etc.
>>
>
>
> Kind regards,
>
>        Danny Wilson
>
> deCube - design and development
>
> Mobile  [ 06 - 5232 1813
> e-Mail  [ [EMAIL PROTECTED]
> web URL [ http://www.decube.net/
>
>
> --
> Neko : One VM to run them all
> (http://nekovm.org)
>
-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to