Passing
functions to and from C/C++ is almost criminally simple, and only boosts the power and simplicity of
Neko on the whole. Neko functions can be applied to Neko objects as fields, stored in an Array, or
passed individually. Once acquired in C/C++, the Neko API provides a series of helper functions to aid
in querying a function ??™ s requirements and to actually make calls to the function.
Passing Functions from haXe to C/C++
Functions in Neko are passed to C/C++ by reference, much like objects. The structure of the function is
unchanged when passed to and from C/C++, as the passed data can be thought of as being merely
C code stored within a value struct, much like everything else. This means that, just as you can pass
a C integer into and out of a Neko script, so can you pass a C function into and out of a Neko script.
Both C and Neko functions are interchangeable and can be called from practically anywhere.
To pass a function to the C/C++ layer is as simple as passing an integer value, too. You can even construct
the function as the parameter to be sent to the C/C++ layer rather than first assigning the function
reference to a variable, though it would only be recommended if the function were small, for readability
sake.
Pages:
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056