Skip to content

2. Class declaration

Nicolas BOITEUX edited this page Dec 27, 2017 · 6 revisions

Declare your class

Declare your class using the Keyword:

CLASS("FOO")

where FOO have to be a string.

The declaration must be finish with the Keyword:

ENDCLASS;

Extend Class

You can also extend an already existing class by using the keyworkd

CLASS_EXTENDS("NEWFOO","FOO")

The declaration must be finish with the Keyworkd

ENDCLASS;

Instanciation of an object

To instanciate an object from your classe, you have to call the constructor method through the keyword new. The method require the argument type your declare with the constructor method.

example of instanciation with some parameters

_object = ["new", _PARAMETERS_] call FOO;

or

_object = (NEW, _PARAMETERS_);

example of instanciation without parameters

_object = "new" call FOO;

or

_object = NEW(FOO, nil);

Destruction of an object

To destroy an object, you have to call the deconstructor method through the keyword delete. The method require that you transmit the object you want to destroy as parameter to the class.

example of deconstructor with FOO.

["delete", _object] call FOO;

or

DELETE(_object);

Class minimal structure

Example:

CLASS("OO_FOO")

	PUBLIC FUNCTION("","constructor") {};

	PUBLIC FUNCTION("","deconstructor") {};

ENDCLASS;

Clone this wiki locally