OOP Macros And Procedures
Object
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.
ObjectEnd
The reserved word ObjectEnd is used to terminate the object definition started with Object.
VirtualMethod
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.
VirtualAbstract
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.
DynamicMethod
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.
DynamicAbstract
Same as VirtualAbstract, but applied to a dynamic method.
InterfaceMethod
The reserved word InterfaceMethod is used to define a special method to invoke COM compliant methods.
RedefineMethod
The reserved word RedefineMethod is used to redefine a method into an object declaration. The inherited code is replaced with the new declared procedure.
StaticMethod
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.
InlineMethod
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.
ObsoleteMethod
The reserved word ObsoleteMethod is used to strip a method from an object declaration.
DefineVariable
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.
Embed
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.
Event
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.
Override
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.
($)ICall
The reserved word ICall is used to call an interface method following the rule of COM method invocation.
($)OCall
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.
($)TCall
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.
($)ACall
The reserved word ACall is used to call an ancestor method using the execution address stored in the ancestors object template.
($)DCall
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.
($)MethodAddr
The reserved word MethodAddr is used to obtain the execution address of a method.
($)New
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.
Destroy
The reserved word Destroy is used to safely free an allocated object instance. Before the memory is released, the destructor Done is called.
Kill
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.
SetObject
The reserved word SetObject is used to assign an object type to a register.
ReleaseObject
The reserved word ReleaseObject is used to release a previous assignment done with SetObject.
GetObjectID
This is a procedure to retrieve the object's ID, specified with the Object macro.
SysInit
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.
SysDone
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.
SysSetup
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.
Method
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.
MethodEnd
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.
Last updated