Prev | Current Page 1034 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


value myAbstract = alloc_abstract( MY_ABSTRACT_KIND, & someData );
The value MY_ABSTRACT_KIND is an identifier for the particular type of data you are wrapping. This is
not needed by Neko, but is very important for future use within your C/C++ library. For example,
imagine having several different types of abstract data you want wrapped and passed to the Neko layer.
Without some way to distinguish each value, you could quite easily misuse the data and cause the
virtual machine to crash, or worse.
Abstract type identifiers are known by the Neko language, and indeed its community, as kinds . You can
call a kind anything you like, but you must be sure to declare the kind in every C/C++ file in which it is
used. You declare a kind using the macro DECLARE_KIND . Normally, this will occur inside a header file
and that file will then be included within each C/C++ file that the particular abstract value is used:
DECLARE_KIND( MY_ABSTRACT_KIND );
DECLARE_KIND is only useful for signifying the type identifier ??™ s existence to the C/C++ compiler.


Pages:
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046