[DGD]Automatically inherited objects

Felix A. Croes felix at dworkin.nl
Tue Dec 1 13:21:48 CET 1998


Robert Jones <robertbjones at yahoo.com> wrote:

>     I've seen reference made to the possibility of having certain
> objects implicitly inherit an object other than the auto object (once
> in a message by Erwin Harte, and elsewhere that I can't recall at the
> moment.)  My question is:  How?
>
>     My (none-too-original) design consists of a bare-bones kernel lib,
> and Everything Else.  I'd like to be able to have Everything Else
> inherit from a second "auto" object automatically, so that I can place
> additional restrictions on the behavior of objects outside of the
> kernel.  However, I don't see how I can achieve this.  Changing the
> behavior of inherit_program() in the driver object would seem to be
> the obvious solution except that inherit_program() isn't called in the
> case of the auto object.

You can do this without any modification to the kernel lib (assuming
that you are using DGD's standard kernel library):

Use driver_obj->set_object_manager() to register an object manager
(see the docs on how this is supposed to work).  With the object
manager, you can keep track of new objects being compiled,
destructed, inherited, and so on.  You can also specify the path
of an include file, depending on which object is including it.

Add the line `#include "AUTO"' to /include/std.h.  Create an empty
file /include/AUTO which will normally be included.  Now, for
new objects in the Everything Else class, let the object manager
redirect the include of "AUTO" to "/include/second_auto.h" (or
some such name) using the path_special() function, and let this file
contain a line like `inherit "/foo/bar/second/auto";'.

Regards,
Dworkin



More information about the DGD mailing list