Lib.load( ???ObjectLib???, ???PrintObject???, 1 );
}
Part III: Extending the Possibilities
566
And the C/C++ code:
#include ???neko.h???
#include < stdio.h >
value PrintObject( value obj )
{
value nestedObj;
int myInt;
char* myStr;
int one, two;
val_check( obj, object );
nestedObj = val_field( obj, val_id( ???myObj??? ) );
myInt = val_int( val_field( obj, val_id( ???myInt??? ) ) );
myStr = val_string( val_field( val_field( obj, val_id( ???myStr??? ) ),
val_id( ???__s??? ) ) );
one = val_int( val_field( nestedObj, val_id( ???one??? ) ) );
two = val_int( val_field( nestedObj, val_id( ???two??? ) ) );
printf( ???%i, %s, %i, %i???, myInt, myStr, one, two );
return val_null;
}
DEFINE_PRIM( PrintObject, 1 );
From this example, there is very little that should appear as new within the actual haXe code, but the
C/C++ code should be a different kettle of fish. As you can probably make out, the fields of the passed
haXe class instance are accessed using the val_field function. This function returns a value struct, so
it needs to be de - referenced before its values can be used by C/C++ functions.
Pages:
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051