Posted to tcl by apw at Tue Aug 07 15:36:28 GMT 2007view raw
- /*
- * tclItclOOMethod.c --
- *
- * This file contains code to create and manage methods.
- *
- * Copyright (c) 2007 by Arnulf P. Wiedemann
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tclItclOOMethod.c,v 1.0 2007/07/30 14:20:21 apw Exp $
- */
- #include "tclOOInt.h"
- ^L
- /*
- * ----------------------------------------------------------------------
- *
- * Itcl_NewProcMethod --
- *
- * Create a new procedure-like method for an object for Itcl.
- *
- * ----------------------------------------------------------------------
- */
- Tcl_Method
- Itcl_NewProcMethod(
- Tcl_Interp *interp, /* The interpreter containing the object. */
- Object *oPtr, /* The object to modify. */
- Tcl_Obj *nameObj, /* The name of the method, which must not be
- * NULL. */
- Tcl_Obj *argsObj, /* The formal argument list for the method,
- * which must not be NULL. */
- Tcl_Obj *bodyObj, /* The body of the method, which must not be
- * NULL. */
- ClientData *clientData)
- {
- ProcedureMethod *pmPtr;
- int flags; /* Whether this is a public method. */
- Tcl_Method method;
- flags = PUBLIC_METHOD | USE_DECLARER_NS;
- method = (Tcl_Method)TclOONewProcMethod(interp, (Object *)clientData, flags,
- nameObj, argsObj, bodyObj, &pmPtr);
- pmPtr->flags = flags & USE_DECLARER_NS;
- pmPtr->clientData = clientData;
- if (clientData != NULL) {
- *clientData = pmPtr;
- }
- return method;
- }
- ^L
- /*
- * ----------------------------------------------------------------------
- *
- * Itcl_NewProcClassMethod --
- *
- * Create a new procedure-like method for a class for Itcl.
- *
- * ----------------------------------------------------------------------
- */
- Tcl_Method
- Itcl_NewProcClassMethod(
- Tcl_Interp *interp, /* The interpreter containing the class. */
- Class *clsPtr, /* The class to modify. */
- TclOO_PreCallProc preCallPtr,
- TclOO_PostCallProc postCallPtr,
- ClientData clientData,
- Tcl_Obj *nameObj, /* The name of the method, which may be NULL;
- * if so, up to caller to manage storage
- * (e.g., because it is a constructor or
- * destructor). */
- Tcl_Obj *argsObj, /* The formal argument list for the method,
- * which may be NULL; if so, it is equivalent
- * to an empty list. */
- Tcl_Obj *bodyObj, /* The body of the method, which must not be
- * NULL. */
- ClientData *clientData2)
- {
- int flags; /* Whether this is a public method. */
- ProcedureMethod *pmPtr;
- Tcl_Method method;
- flags = PUBLIC_METHOD | USE_DECLARER_NS;
- method = (Tcl_Method)TclOONewProcClassMethod(interp, clsPtr, flags,
- nameObj, argsObj, bodyObj, &pmPtr);
- pmPtr->flags = flags & USE_DECLARER_NS;
- pmPtr->preCallProc = preCallPtr;
- pmPtr->postCallProc = postCallPtr;
- pmPtr->clientData = clientData;
- if (clientData2 != NULL) {
- *clientData2 = pmPtr;
- }
- return method;
- }