Up: Design Issues
Previous: Design Issues
One of the first issues to be addressed when considering the implementation
of DOM in an imperative language like C is the mapping of the
object-oriented architecture of DOM.
Gdome2 objects are implemented in a straightforward way: objects
have fields classified into instance fields and class fields.
Instance fields are allocated for each instance of a given class
(where the ``class'' is the realization of a DOM interface),
and they are grouped in a standard C structure. Class fields
are fields shared by all the instances of a given interface.
Each Gdome2 object has one instance field which is a pointer to
a statically allocated structure containing its class fields.
A typical example of a class field which is present in all
Gdome2 objects is the virtual table, containing pointers
to the methods implemented by the class of the object itself.
The use of virtual tables enables us to have a mechanism equivalent to
inheritance of methods, thus favoring the reuse of code and
making easier the maintenance of the source code.