[DGD] Re: Allow Function to be called within Create

Erwin Harte harte at is-here.com
Wed Mar 10 15:15:44 CET 2004


On Tue, Mar 09, 2004 at 10:27:22PM -0500, Michael McKiel wrote:
> I've come up with the following resolution to allowing a function to only be
> called within a given objects create() which works, just wondering if there
> is a better way or not :)
[...]
> Also I wasn't sure if where the _F_create within the stack trace was static,
> I would think it would differ if the object was compiled/created by a wizard
> or by the driver in startup.

Check out /include/trace.h (or wherever you place the auto generated
include files):

    # define TRACE_OBJNAME  0       /* name of the object */
    # define TRACE_PROGNAME 1       /* name of the object the function is in */
    # define TRACE_FUNCTION 2       /* function name */
    # define TRACE_LINE     3       /* line number */
    # define TRACE_EXTERNAL 4       /* external call flag */
    # define TRACE_FIRSTARG 5       /* first argument to function */

You want TRACE_FUNCTION, like this:

    if (trace[i][TRACE_FUNCTION] == "_F_create") {
	return;
    }

I think you missed a check to make sure you aren't being called from
some _other_ object's create() function, though.  That shouldn't be
hard to add, of course, and just making the function static would go a
long way in preventing it in the first place.

Hope that helps,

Erwin.
-- 
Erwin Harte <harte at is-here.com>
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list