2005/05/10, Andreas Jönsson
Primitives in AngelScript have direct matches in C++.
AngelScript | C++ |
int | long |
int16 | short |
int8 | char |
uint | unsigned long |
uint16 | unsigned short |
uint8 | unsigned char |
bits | unsigned long |
bits16 | unsigned short |
bits8 | unsigned char |
float | float |
double | double |
bool | bool |
There is currently no 64 bit integer available in AngelScript.
The AngelScript arrays are not directly matched by C++ arrays. The arrays are stored in an special object. Thus you can normally not directly exchange a script with a C++ function expecting a C++ array, or vice versa. Nor can the application register C++ arrays as properties and expect AngelScript to be able to understand them.
It is however possible to override AngelScript's built-in array objects with application specified objects, on a per array type basis.
The AngelScript object handles are reference counted pointers to objects. This means that for object handles to work, the object must have some way of counting references, for example an AddRef/Release method pair.
When AngelScript passes an object handle by value to a function it increases the reference count to count for the argument instance, thus the function is responsible for releasing the reference once it is finished with it. In the same manner AngelScript expects any handle returned from a function to already have the reference accounted for.
However, when registering functions/methods with AngelScript the application can tell the library that it should automatically take care of releasing the handle references once a function return, likewise for returned handles. This is done by adding a + sign to the @ type modifier. When doing this an object handle can be safely passed to a C++ function that expects a normal pointer, but don't release it afterwards.
Because AngelScript needs to guarantee validity of pointers at all times, it normally doesn't pass references to the true object to the function parameter. Instead it creates a copy of the object, whose reference is passed to the function, and if the reference is marked to return a value, the clone is copied back to the original object (if it still exists) once the function returns.
Because of this, AngelScript's parameter references are mostly compatible with C++ references, or pointers, except that the address cannot be stored for later use, since the object will be destroyed once the function returns.
If it is necessary to store the address of the object, then object handles must be used instead.