C.2 Methods and the Messaging Concept



next up previous contents
Next: C.3 The VOOPS Syntax Up: PhD Thesis Franz Fasching Previous: C.1 The Class Table

C.2 Methods and the Messaging Concept

     

Method inheritance is directly implemented in the class table construction step, where the function pointers of inherited methods, if not overridden through genuine methods defined on a certain class, are stored in place of the genuine function pointer. If there is neither a genuine nor an inherited method in a certain class for a certain method name, a NULL pointer is stored. On invocation of a method, the corresponding method pointer of the class is checked if its non-NULL. In this case, the pointer is dereferenced, hence the function is called, otherwise an appropriate error is issued stating that there exists no corresponding method for this class. As we can see, there is only one NULL-pointer check and one pointer dereference which is the main reason for the efficiency of the static class model implemented in VOOPS, whereas an OOP system with a dynamic class model would have to search through its more or less complicated run-time class and method structures to find the appropriate applicable method. The above behavior is implemented in the VOOPS SEND and SENDID statements.

The above algorithm is only to be applied when the class of the object a specific message is to be sent to is not known in advance (i.e. prior to compilation), since then the class has to be determined from the object ID. In case the class is already known, meaning that the class of the object the message is to be sent to is known to be equal to or above in the inheritance branch of the specific class, the method can be applied directly using the VOOPS SENDCLASS statement which is just translated into a C function call. However, all methods in an inheritance branch have to be aliased appropriately with C macro definitions. This is done in the master header file following the respective class definition.



next up previous contents
Next: C.3 The VOOPS Syntax Up: PhD Thesis Franz Fasching Previous: C.1 The Class Table



Martin Stiftinger
Tue Nov 29 19:41:50 MET 1994