Tcl Source Code

View Ticket
Login
Ticket UUID: 1791190
Title: TclOO: extra interfaces for apw
Type: Patch Version: None
Submitter: dkf Created on: 2007-09-09 19:19:44
Subsystem: 35. TclOO Package Assigned To: dkf
Priority: 6 Severity:
Status: Closed Last Modified: 2008-01-06 05:56:47
Resolution: Accepted Closed By: dkf
    Closed on: 2008-01-05 22:56:47
Description:
[20:15]apwdkf_, as the first implementation round of itcl is done, I would like to come back to the public C-API interfaces I would like to have. I have pasted them here for discussion with you: http://paste.tclers.tk/379
User Comments: dkf added on 2008-01-06 05:56:47:
Logged In: YES 
user_id=79902
Originator: YES

Accepted as three functions:
  TclOOInvokeObject in tclOO.c (approx Tcl_PublicObjectCmd and Tcl_PrivateObjectCmd rolled into one, with fewer type hazards)
  TclOONewProcClassMethodEx and TclOONewProcInstanceMethodEx in tclOOMethod.c (Tcl_NewProcClassMethod and Tcl_NewProcMethod respectively with minor type signature changes for sanity)

All functions are in the private interface for now since they expose concepts (especially a "start class") and types (some of those callbacks) that are not public.

dkf added on 2007-12-30 22:35:15:
Logged In: YES 
user_id=79902
Originator: YES

Tcl_Method
Tcl_NewProcMethod(
    Tcl_Interp *interp,         /* The interpreter containing the object. */
    Tcl_Object oPtr,            /* The object to modify. */
    TclOO_PreCallProc preCallPtr,
    TclOO_PostCallProc postCallPtr,
    Tcl_ProcErrorProc errProc,
    ClientData clientData,
    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. */
    int flags,                  /* Whether this is a public method. */
    ClientData *clientData2)
{
    ProcedureMethod *pmPtr;
    Tcl_Method method;

    method = (Tcl_Method)TclOONewProcMethod(interp, (Object *)oPtr, flags,
            nameObj, argsObj, bodyObj, &pmPtr);
    pmPtr->flags = flags & USE_DECLARER_NS;
    pmPtr->preCallProc = preCallPtr;
    pmPtr->postCallProc = postCallPtr;
    pmPtr->errProc = errProc;
    pmPtr->clientData = clientData;
    if (clientData2 != NULL) {
        *clientData2 = pmPtr;
    }
    return method;
}
Tcl_Method
Tcl_NewProcClassMethod(
    Tcl_Interp *interp,         /* The interpreter containing the class. */
    Tcl_Class clsPtr,           /* The class to modify. */
    TclOO_PreCallProc preCallPtr,
    TclOO_PostCallProc postCallPtr,
    Tcl_ProcErrorProc errProc,
    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. */
    int flags,                  /* Whether this is a public method. */
    ClientData *clientData2)
{
    ProcedureMethod *pmPtr;
    Method *method;

    method = TclOONewProcClassMethod(interp, (Class *)clsPtr, flags,
            nameObj, argsObj, bodyObj, &pmPtr);
    pmPtr->flags = flags & USE_DECLARER_NS;
    pmPtr->preCallProc = preCallPtr;
    pmPtr->postCallProc = postCallPtr;
    pmPtr->errProc = errProc;
    pmPtr->clientData = clientData;
    if (clientData2 != NULL) {
        *clientData2 = pmPtr;
    }
    return (Tcl_Method)method;
}
#define PUBLIC_METHOD     0x01  /* This is a public (exported) method. */
#define PRIVATE_METHOD    0x02  /* This is a private (class's direct instances
                                 * only) method. */
#define USE_DECLARER_NS   0x80
/*
 * ----------------------------------------------------------------------
 *
 * Tcl_PublicObjectCmd, Tcl_PrivateObjectCmd --
 *
 * ----------------------------------------------------------------------
 */
int
Tcl_PublicObjectCmd(
    ClientData clientData,
    Tcl_Interp *interp,
    Tcl_Class clsPtr,
    int objc,
    Tcl_Obj *const *objv)
{
    Object *oPtr = (Object *)clientData;
    int result;

    result = TclOOObjectCmdCore(oPtr, interp, objc, objv, PUBLIC_METHOD,
            &oPtr->publicContextCache, (Class *)clsPtr);
    return result;
}

int
Tcl_PrivateObjectCmd(
    ClientData clientData,
    Tcl_Interp *interp,
    Tcl_Class clsPtr,
    int objc,
    Tcl_Obj *const *objv)
{
    Object *oPtr = (Object *)clientData;
    int result;

    result = TclOOObjectCmdCore(oPtr, interp, objc, objv, PRIVATE_METHOD,
            &oPtr->publicContextCache, (Class *)clsPtr);
    return result;
}

dkf added on 2007-09-10 02:19:44:

File Added - 244854: extra.c

Attachments: