The <tt>DEFAULTMETHODS</tt> Statement



next up previous contents
Next: The SENDCLASS Statement Up: C.3 The VOOPS Syntax Previous: The DEFPRIVATE Statement

The DEFAULTMETHODS Statement

 

The DEFAULTMETHODS statement appears in two forms with or without class name symbols in template source files or in the master template source file respectively, and generates C code for generic or class specific default methods respectively.

In the master template source file the argumentless DEFAULTMETHODS statement should preferably but not necessarily appear immediately after the SUBMODULE statement. A list of all currently known methods is generated first internally and sorted alphabetically. Then the class table definition (or class versus method matrix) is generated, which is the reason why the statement should appear below the SUBMODULE statement: since the class table is a static C structure with initializers, improved readability of the resulting C code will result if this table is near the top of the generated C source file. The Mutate() default method changes an object's identity by changing its object ID to the requested one and reallocating it to the size of the new object ID. The SearchClass() default method performs a binary search in the class table for the given class name and returns the corresponding class ID or ID_NIL if the class could not be found.

In a normal template source file the DEFAULTMETHODS statement must appear immediately before the ENDSUBMODULE statement. One after the other class argument of the DEFAULTMETHODS statement is taken, and the default methods for that specific class are generated, provided that they are not already overridden in the template source file. This is the reason why this statement should appear at the end of the file immediately before the ENDSUBMODULE statement, because only then it is guaranteed that a method intended to override a default method indeed overrides it. The default methods generated are:

Note that all these names are augmented with the module name prefix and the class name postfix by VOOPS.



next up previous contents
Next: The SENDCLASS Statement Up: C.3 The VOOPS Syntax Previous: The DEFPRIVATE Statement



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