Prev | Current Page 1046 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


value val_func = alloc_function( pFunc, intParams, strName );
alloc_function accepts three parameters: The first is the C function pointer you wish to send to Neko,
the second is the number of parameters the function accepts, and the third is a string value depicting the
name of the function, for use by Neko. As the third parameter will be used as the function name within
Neko, it must follow the same rules for Neko function naming conventions.
When the function is retrieved by Neko, you can store it into a variable, ready to call when needed. At
this point, there is no error checking on the data types passed to the function, so it pays to do this when
typing the variable containing the function reference. For example:
var cFunction : Int - > String - > Void = getCFunc();
If you ??™ re writing the haXe classes and C/C++ library for others to use, it should fall as your
responsibility to see that users of the library do not make needless mistakes.
Executing Neko Functions in C/C++
There is no way to extract a function pointer from a value struct, so to call a Neko function, or a function
stored into a value struct by C/C++, you will need to make use of one of a series of helper functions.


Pages:
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058