OOP Macros And Procedures
The reserved word Object is used to define objects that conform the ObjAsm model. An object is a structure that contains a fixed number of members. Each member is either a variable, which contains data of a particular type, or a method, which performs an operation on these data.
An object can inherit members from another object. The inheriting object is a descendant and the object inherited from, is an ancestor.
The reserved word ObjectEnd is used to terminate the object definition started with Object.
The reserved word VirtualMethod is used to define a method whose entry point is resolved at run-time (late binding), using the address stored in the object Virtual Method Table (VMT). A static method cannot be redefined at run-time at an object's instance level.
The reserved word VirtualAbstract is used to define a static method whose implementation is not defined in the object declaration in which it appears; its definition is instead deferred to descendant objects. An abstract method defines only placeholder for an execution address in the VMT, but not the underlying method code.
Overriding an abstract method is identical to override a normal virtual or dynamic method, except that in the implementation of the method, an inherited method is not available to be called (see ACall).
Calling an abstract method through an object that has not overridden the method will generate an exception at run time, since the execution address is set to FFFFFFFFh. You can provide your own address to handle such situations, i.e. displaying an error message.
The reserved word DynamicMethod is used to define a method whose entry point is resolved at run-time using the address stored in the object's instance. This makes possible to redefine this address at run-time for each instance.
Same as VirtualAbstract, but applied to a dynamic method.
The reserved word InterfaceMethod is used to define a special method to invoke COM compliant methods.
The reserved word RedefineMethod is used to redefine a method into an object declaration. The inherited code is replaced with the new declared procedure.
The reserved word StaticMethod is used to define a method whose entry point is resolved at compile-time. The concept of bound methods is equivalent to "early binding" in other languages. The advantage of these methods is that the execution time is slightly shorter.
The reserved word InlineMethod is used to define a method that works like a macro. An inline method acts like a macro. It expands where the call is made. Like static methods, no polymorphism can be applied. The method definition must be done similar to a macro.
The reserved word ObsoleteMethod is used to strip a method from an object declaration.
The reserved word DefineVariable is used to reserve data storage for an object member of any type. This variable can be initialized at compile time to reduce the constructor code size and execution time.
The reserved word Embed is used to reserve data storage for an object inside another object like another variable defined with DefineVariable. The embedded object members are automatically initialized at compile time.
The reserved word Event is used with Windows applications to trigger some method, when a corresponding message is sent to the WndProc procedure.
A shorter way to define an Event and a corresponding method is using the VirtualEvent or DynamicEvent for a VirtualMethod or a DynamicMethod respectively.
The reserved word Override is used to redefine a static or dynamic method at run-time.
Redefining a static method will affect all instances of the object, while redefining a dynamic method only affects a specific object instance.
The reserved word ICall is used to call an interface method following the rule of COM method invocation.
The reserved word OCall is the normal way to call a method. If it is a static or private method, the execution address is taken from the object template, while if it is a dynamic method, the execution address is taken from the object instance data.
The reserved word TCall is used to call a method using always the execution address stored in the object template, regardless of the value stored in the object instance data.
The reserved word ACall is used to call an ancestor method using the execution address stored in the ancestors object template.
The reserved word DCall is used to call a method, linking it directly at compile-time. No object member is used to call the procedure.
The reserved word MethodAddr is used to obtain the execution address of a method.
The reserved word New is used to create an instance of an object. A constructor can be supplied to be executed immediately after the instantiation.
The reserved word Destroy is used to safely free an allocated object instance. Before the memory is released, the destructor Done is called.
The reserved word Kill is used to free an allocated object instance. No validation check is performed. Before the memory is released, the destructor Done is called.
The reserved word SetObject is used to assign an object type to a register.
The reserved word ReleaseObject is used to release a previous assignment done with SetObject.
This is a procedure to retrieve the object's ID, specified with the Object macro.
This is a macro that must be placed at the beginning of every application. It is the runtime initialization of the OOP model. First, it loads the hInstance and hProcessHeap variables and starts the object chain setting the pFirstObject pointer.
Finally, it invokes all defined Startup methods. When this special BoundMethod is called, it passes a pointer to the object template as instance pointer (pSelf). That allows performing some special initialization on the template or some registration work to the OS.
This macro is the counterpart of SysInit and must be placed at the end of every application. It invokes the declared Shutdown methods of all objects. The instance pointer (pSelf) points again to the object template. This allows the application to perform some work on resources or some unregistration work to the OS.
This macro is required to setup the OOP model. The first argument defines the desired OOP level, loading the corresponding base objects and macros. The second argument can be the DEBUG macro, which indicates that the debugging subsystem should be loaded. This macro has also some arguments to customize this system and what debugging subsystems to use.
The reserved word Method is used to indicate that the following lines of code are part of an object method. It also sets the scope, necessary for other macros. The syntax is similar to the proc syntax.
The reserved word MethodEnd is used to indicate the end of a method. It finalizes all assumptions on registers which were done with previous SetObject macros, sets the End Of Method (@@EOM) label and executes a ret instruction. An optional parameter can modify the ret instruction.