|
When a new method is defined, an argument list class is derived from
METHOD_ARGS to contain the arguments to be passed to the method in addition to the entity pointer. This provides for compile-time type checking. To ensure that the correct argument list class is passed to the method, each argument list class provides an id method which returns a string identifying the class.
|
|
|
A master list is maintained that associates an index value with each combination of method name and argument list identifier requested by an application. This list is maintained as a linked list sorted by method name. Multiple methods with the same name are further sorted by argument list identifier. A
METHOD_ID class is used to look up entries in the master list. If the requested combination of method name and argument list identifier is not found, a new entry is added to the list and given the next available index value.
|
|
|
Each class derived from
ENTITY has a dynamically allocated array of function pointers associated with it. When a method is registered for the class, this array is expanded if necessary and a pointer to the specified function is stored in the element indicated by the index value in the specified
METHOD_ID.
|
|
|
When a method is called, the identifier for the supplied argument list item is first checked against the identifier in the specified
METHOD_ID. If they do not match,
FALSE is returned. Otherwise, the function at the element specified by the
METHOD_ID in the function table for the class is called with the entity pointer and the specified argument list item. If the function table for the class does not contain the specified element of that element is the
NULL pointer, the method is called for the parent of the class. If no ancestor of the class provides the method,
FALSE is returned.
|