The Neko value Struct
If you recall from Chapter 3 when haXe types were discussed, it was noted that all Neko base value
types were defined internally as a C struct containing two values, the data of the value and the type of
the value. Dealing with values in this way enables the Neko run time to work at an optimized rate, while
providing extremely flexible extensibility to the developer wishing to extend the language.
struct value {
int value_type;
void *value_data;
};
The value struct is a great way to seamlessly pass data from Neko to C/C++ and back again. This is
because, although absolutely any data type can be contained within the struct, both C/C++ and Neko
have a way to assume the data type where possible. Also, passing data to functions where all data types
are known as value means that absolutely any data type can be passed as a function parameter if so
wished. Though of course, without proper error checking in each of your C/C++ and haXe functions,
you may be setting yourself up for trouble.
Pages:
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036