Joy Online Manual
NAME |
Pointer - Represents a pointer or C array |
DESCRIPTION |
Both C pointers and arrays are reflected to JavaScript as objects of the Pointer type. Pointer objects are created automatically by Joy whenever a pointer or array needs to be passed to JavaScript (as a return value or from a variable access). Another way to create Pointer objects is by using the Joy address operator &, or a type cast. Joy can manipulate pointers to any type, including function pointers, and pointers to arrays.
You can dereference pointers using the * operator, as in C. You can use pointer arithmetic exactly as in C. Passing JavaScript functions as function pointers (i.e., JavaScript call back functions) is not yet supported. Calling out to C via function pointers works, though. |
PROPERTIES |
Like in C, you can access the data value at the pointer location by writing pointer[0]. In fact, this is what the * operator compiles to. You can also use pointer[index] to access other memory locations (the index will be multiplied with the aligned size of the pointer base type and used as an offset, like in C). Pointer objects that represent arrays will report a JavaScript error if you try to write to an index that falls outside of the array. |
Index |