Pointers and references
Any pointer or reference to a native object is translated to a
ptr<T>
instance that wraps
the pointer. This is the case for local variables, function parameters and return values:
void ProgramClass::ProgramFunc(Window* window, Surface& surface)
{
// window is a ptr<Window>
// surface is a ptr<Surface> too, hence why we use the -> operator
window->SetSize(640, 480);
surface->Create();
Pointers also support standard pointer arithmetic:
void Function()
{
int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
log(array[0]); // 0
ptr<int> p = array;
p++;
log(p[0]); // 1
p += 2;
log(p[1]); // 4
ptr<int> p2 = p - 2;
log(p2[0]); // 1