Prev | Current Page 1056 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This
function takes two parameters: The first parameter is the value struct you wish to mark for the callback,
while the second parameter is a function pointer to the function that will handle the custom garbage
collection. Here is an example of how this might work:
void dispose( value v ) {
cleanup( val_data(v) );
}
value create() {
void *ptr = ....
value v = alloc_abstract(k_somekind,ptr);
val_gc(v,dispose);
return v;
}
Now, at the time when the garbage collector is set in motion, which is often the time when the Neko
script ends, the callback function is fired, thus activating your own cleanup code.
Error Handling
Handling errors is an important factor of any programming, but with regard to C/C++ libraries
extending the Neko Virtual Machine, where should they be handled? For the most part, a return value
for the offending code can easily be useful to determine whether a function was successful or not, but
often you ??™ ll want to be a bit more extreme should the fault be of a serious nature.


Pages:
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068