diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-09-11 14:43:41 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-09-11 14:43:41 (GMT) |
commit | d01b2d3aceb996995428a82620c6dd47775499bc (patch) | |
tree | 4a730a5029bb34a2b4ddfce0960d7ef651583a4f /generic/tclBasic.c | |
parent | 07a1136da5471e4dda4c7ee01757d226692ddaeb (diff) | |
parent | a1319ec00ada091354b870600685140a95aa8184 (diff) | |
download | tcl-d01b2d3aceb996995428a82620c6dd47775499bc.zip tcl-d01b2d3aceb996995428a82620c6dd47775499bc.tar.gz tcl-d01b2d3aceb996995428a82620c6dd47775499bc.tar.bz2 |
TIP #666 implementation: Change ptrdiff_t → Tcl_Size in Tcl 8.7 (and 9.0)
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r-- | generic/tclBasic.c | 160 |
1 files changed, 4 insertions, 156 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 5368681..318374e 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -2687,66 +2687,6 @@ Tcl_CreateCommand( *---------------------------------------------------------------------- */ -typedef struct { - Tcl_ObjCmdProc2 *proc; - void *clientData; /* Arbitrary value to pass to proc function. */ - Tcl_CmdDeleteProc *deleteProc; - void *deleteData; /* Arbitrary value to pass to deleteProc function. */ - Tcl_ObjCmdProc2 *nreProc; -} CmdWrapperInfo; - - -static int cmdWrapperProc(void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj * const *objv) -{ - CmdWrapperInfo *info = (CmdWrapperInfo *)clientData; - if (objc < 0) { - objc = -1; - } - return info->proc(info->clientData, interp, objc, objv); -} - -static void cmdWrapperDeleteProc(void *clientData) { - CmdWrapperInfo *info = (CmdWrapperInfo *)clientData; - - clientData = info->deleteData; - Tcl_CmdDeleteProc *deleteProc = info->deleteProc; - ckfree(info); - if (deleteProc != NULL) { - deleteProc(clientData); - } -} - -Tcl_Command -Tcl_CreateObjCommand2( - Tcl_Interp *interp, /* Token for command interpreter (returned by - * previous call to Tcl_CreateInterp). */ - const char *cmdName, /* Name of command. If it contains namespace - * qualifiers, the new command is put in the - * specified namespace; otherwise it is put in - * the global namespace. */ - Tcl_ObjCmdProc2 *proc, /* Object-based function to associate with - * name. */ - void *clientData, /* Arbitrary value to pass to object - * function. */ - Tcl_CmdDeleteProc *deleteProc - /* If not NULL, gives a function to call when - * this command is deleted. */ -) -{ - CmdWrapperInfo *info = (CmdWrapperInfo *)ckalloc(sizeof(CmdWrapperInfo)); - info->proc = proc; - info->clientData = clientData; - info->deleteProc = deleteProc; - info->deleteData = clientData; - - return Tcl_CreateObjCommand(interp, cmdName, - (proc ? cmdWrapperProc : NULL), - info, cmdWrapperDeleteProc); -} - Tcl_Command Tcl_CreateObjCommand( Tcl_Interp *interp, /* Token for command interpreter (returned by @@ -3380,14 +3320,8 @@ Tcl_SetCommandInfoFromToken( } cmdPtr->objClientData = infoPtr->objClientData; } - if (cmdPtr->deleteProc == cmdWrapperDeleteProc) { - CmdWrapperInfo *info = (CmdWrapperInfo *)cmdPtr->deleteData; - info->deleteProc = infoPtr->deleteProc; - info->deleteData = infoPtr->deleteData; - } else { - cmdPtr->deleteProc = infoPtr->deleteProc; - cmdPtr->deleteData = infoPtr->deleteData; - } + cmdPtr->deleteProc = infoPtr->deleteProc; + cmdPtr->deleteData = infoPtr->deleteData; return 1; } @@ -3464,14 +3398,8 @@ Tcl_GetCommandInfoFromToken( infoPtr->objClientData = cmdPtr->objClientData; infoPtr->proc = cmdPtr->proc; infoPtr->clientData = cmdPtr->clientData; - if (cmdPtr->deleteProc == cmdWrapperDeleteProc) { - CmdWrapperInfo *info = (CmdWrapperInfo *)cmdPtr->deleteData; - infoPtr->deleteProc = info->deleteProc; - infoPtr->deleteData = info->deleteData; - } else { - infoPtr->deleteProc = cmdPtr->deleteProc; - infoPtr->deleteData = cmdPtr->deleteData; - } + infoPtr->deleteProc = cmdPtr->deleteProc; + infoPtr->deleteData = cmdPtr->deleteData; infoPtr->namespacePtr = (Tcl_Namespace *) cmdPtr->nsPtr; return 1; } @@ -9170,42 +9098,6 @@ Tcl_NRCallObjProc( return TclNRRunCallbacks(interp, TCL_OK, rootPtr); } -int wrapperNRObjProc( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) -{ - CmdWrapperInfo *info = (CmdWrapperInfo *)clientData; - clientData = info->clientData; - Tcl_ObjCmdProc2 *proc = info->proc; - ckfree(info); - return proc(clientData, interp, objc, objv); -} - -int -Tcl_NRCallObjProc2( - Tcl_Interp *interp, - Tcl_ObjCmdProc2 *objProc, - void *clientData, - ptrdiff_t objc, - Tcl_Obj *const objv[]) -{ - if ((size_t)objc > INT_MAX) { - Tcl_WrongNumArgs(interp, 1, objv, "?args?"); - return TCL_ERROR; - } - - NRE_callback *rootPtr = TOP_CB(interp); - CmdWrapperInfo *info = (CmdWrapperInfo *)ckalloc(sizeof(CmdWrapperInfo)); - info->clientData = clientData; - info->proc = objProc; - - TclNRAddCallback(interp, Dispatch, wrapperNRObjProc, info, - INT2PTR(objc), objv); - return TclNRRunCallbacks(interp, TCL_OK, rootPtr); -} - /* *---------------------------------------------------------------------- * @@ -9234,50 +9126,6 @@ Tcl_NRCallObjProc2( *---------------------------------------------------------------------- */ -static int cmdWrapperNreProc( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) -{ - CmdWrapperInfo *info = (CmdWrapperInfo *)clientData; - if (objc < 0) { - objc = -1; - } - return info->nreProc(info->clientData, interp, objc, objv); -} - -Tcl_Command -Tcl_NRCreateCommand2( - Tcl_Interp *interp, /* Token for command interpreter (returned by - * previous call to Tcl_CreateInterp). */ - const char *cmdName, /* Name of command. If it contains namespace - * qualifiers, the new command is put in the - * specified namespace; otherwise it is put in - * the global namespace. */ - Tcl_ObjCmdProc2 *proc, /* Object-based function to associate with - * name, provides direct access for direct - * calls. */ - Tcl_ObjCmdProc2 *nreProc, /* Object-based function to associate with - * name, provides NR implementation */ - void *clientData, /* Arbitrary value to pass to object - * function. */ - Tcl_CmdDeleteProc *deleteProc) - /* If not NULL, gives a function to call when - * this command is deleted. */ -{ - CmdWrapperInfo *info = (CmdWrapperInfo *)ckalloc(sizeof(CmdWrapperInfo)); - info->proc = proc; - info->clientData = clientData; - info->nreProc = nreProc; - info->deleteProc = deleteProc; - info->deleteData = clientData; - return Tcl_NRCreateCommand(interp, cmdName, - (proc ? cmdWrapperProc : NULL), - (nreProc ? cmdWrapperNreProc : NULL), - info, cmdWrapperDeleteProc); -} - Tcl_Command Tcl_NRCreateCommand( Tcl_Interp *interp, /* Token for command interpreter (returned by |