Prev | Current Page 1038 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

When
passing a class instance from the Neko layer to the C/C++ library, each of the member functions and
variables from that class instance are then directly accessible by the C/C++ library. Likewise, any object
constructed within the C/C++ layer can be cast into a haXe class instance when returned to Neko. This
creates for incredibly flexible data management between the C/C++ library and the Neko Virtual
Machine, and opens up a world of possibilities in terms of Neko to C/C++ interaction. The only issue
one need remember is data structure preservation with regard to minimizing possible runtime errors.
Objects are a little less straightforward than dealing with individual value structs. Neko does provide
the needed flexibility, as always, though the readability of your C/C++ code may suffer slightly through
their use. The following is an example of an object being passed from Neko to a C/C++ library:
class Object
{
public var myInt : Int;
public var myStr : String;
public var myObj : Dynamic;
public function new()
{
myInt = 78;
myStr = ???Neko rocks!???;
myObj = { one: 12, two: 22 };
}
}
class ObjectHandler
{
public static function main()
{
var obj = new Object();
printObject( obj );
}
static var printObject = neko.


Pages:
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050