So, how do you type check a value type? Well, as one would expect, Neko provides a number of
functions for just such a purpose. In fact, there is quite a considerable number, at least one for each Neko
data type, plus a generic function for almost all values as detailed in the HelloWorld example.
Table 20 - 2 provides a complete list of the type checking functions and the types they verify.
Most of these functions should be pretty self - explanatory. Those functions that do require further
explanation will be discussed later in this chapter.
Chapter 20: Extending ha X e with C/C++
561
The most common function you will use when type checking is val_check , as it allows for the broadest
possible use while also providing the simplest of input. The type values it can accept for comparison are
detailed in Table 20 - 3 .
Table 20 - 2
Function Description
val_check( value v,
void * t )
Compares the C data type held in the value struct with the
passed type
val_is_null( value v ) Returns true if the value is null, or else false
val_is_int( value v ) Returns true if the value is an int type, or else false
val_is_float( value v ) Returns true if the value is a float type, or else false
val_is_number( value v ) Returns true if the value is a either an int type or a float
type, or else false
val_is_string( value v ) Returns true if the value is a pointer of type char , or else
false
val_is_bool( value v ) Returns true if the value is a bool type, or else false
val_is_array( value v ) Returns true if the value is an array of values, or else false
val_is_object( value v ) Returns true if the value is a Neko object type, or else false
val_is_function( value v ) Returns true if the value is a function, or else false
val_is_abstract( value v ) Returns true if the value is an abstract (miscellaneous) type, or
else false
val_is_kind( value v,
void * t )
Returns true if the value is an abstract (miscellaneous) type and
has been flagged with a given identifier, or else false
Table 20 - 3
Type haXe Mapping C/C++ Mapping
string untyped String.
Pages:
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041