Skip to content

Commit

Permalink
Make TclInvokeObjectCommand/TclInvokeStringCommand static functions. …
Browse files Browse the repository at this point in the history
…They are not needed/useful for extensions
  • Loading branch information
jan.nijtmans committed Oct 6, 2023
2 parents a2630a8 + 07279b8 commit defed3c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
32 changes: 17 additions & 15 deletions generic/tclBasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static Tcl_NRPostProc DTraceCmdReturn;
#else
# define DTraceCmdReturn NULL
#endif /* USE_DTRACE */
static Tcl_ObjCmdProc InvokeStringCommand;
static Tcl_ObjCmdProc ExprAbsFunc;
static Tcl_ObjCmdProc ExprBinaryFunc;
static Tcl_ObjCmdProc ExprBoolFunc;
Expand Down Expand Up @@ -212,6 +213,7 @@ static void MathFuncWrongNumArgs(Tcl_Interp *interp, int expected,
static Tcl_NRPostProc NRCoroutineCallerCallback;
static Tcl_NRPostProc NRCoroutineExitCallback;
static Tcl_NRPostProc NRCommand;
static Tcl_CmdProc InvokeObjectCommand;

static void ProcessUnexpectedResult(Tcl_Interp *interp,
int returnCode);
Expand Down Expand Up @@ -1068,10 +1070,10 @@ Tcl_CreateInterp(void)
* Tcl_CreateCommand, because it's faster (there's no need to check for a
* preexisting command by the same name). If a command has a Tcl_CmdProc
* but no Tcl_ObjCmdProc, set the Tcl_ObjCmdProc to
* TclInvokeStringCommand. This is an object-based wrapper function that
* InvokeStringCommand. This is an object-based wrapper function that
* extracts strings, calls the string function, and creates an object for
* the result. Similarly, if a command has a Tcl_ObjCmdProc but no
* Tcl_CmdProc, set the Tcl_CmdProc to TclInvokeObjectCommand.
* Tcl_CmdProc, set the Tcl_CmdProc to InvokeObjectCommand.
*/

for (cmdInfoPtr = builtInCmds; cmdInfoPtr->name != NULL; cmdInfoPtr++) {
Expand All @@ -1090,7 +1092,7 @@ Tcl_CreateInterp(void)
cmdPtr->refCount = 1;
cmdPtr->cmdEpoch = 0;
cmdPtr->compileProc = cmdInfoPtr->compileProc;
cmdPtr->proc = TclInvokeObjectCommand;
cmdPtr->proc = InvokeObjectCommand;
cmdPtr->clientData = cmdPtr;
cmdPtr->objProc = cmdInfoPtr->objProc;
cmdPtr->objClientData = NULL;
Expand Down Expand Up @@ -2479,7 +2481,7 @@ Tcl_ExposeCommand(
* In the future, when cmdName is seen as the name of a command by
* Tcl_Eval, proc will be called. To support the bytecode interpreter,
* the command is created with a wrapper Tcl_ObjCmdProc
* (TclInvokeStringCommand) that eventually calls proc. When the command
* (InvokeStringCommand) that eventually calls proc. When the command
* is deleted from the table, deleteProc will be called. See the manual
* entry for details on the calling sequence.
*
Expand Down Expand Up @@ -2621,7 +2623,7 @@ Tcl_CreateCommand(
cmdPtr->refCount = 1;
cmdPtr->cmdEpoch = 0;
cmdPtr->compileProc = NULL;
cmdPtr->objProc = TclInvokeStringCommand;
cmdPtr->objProc = InvokeStringCommand;
cmdPtr->objClientData = cmdPtr;
cmdPtr->proc = proc;
cmdPtr->clientData = clientData;
Expand Down Expand Up @@ -2910,7 +2912,7 @@ TclCreateObjCommandInNs(
cmdPtr->compileProc = NULL;
cmdPtr->objProc = proc;
cmdPtr->objClientData = clientData;
cmdPtr->proc = TclInvokeObjectCommand;
cmdPtr->proc = InvokeObjectCommand;
cmdPtr->clientData = cmdPtr;
cmdPtr->deleteProc = deleteProc;
cmdPtr->deleteData = clientData;
Expand Down Expand Up @@ -2951,7 +2953,7 @@ TclCreateObjCommandInNs(
/*
*----------------------------------------------------------------------
*
* TclInvokeStringCommand --
* InvokeStringCommand --
*
* "Wrapper" Tcl_ObjCmdProc used to call an existing string-based
* Tcl_CmdProc if no object-based function exists for a command. A
Expand All @@ -2964,13 +2966,13 @@ TclCreateObjCommandInNs(
*
* Side effects:
* Besides those side effects of the called Tcl_CmdProc,
* TclInvokeStringCommand allocates and frees storage.
* InvokeStringCommand allocates and frees storage.
*
*----------------------------------------------------------------------
*/

int
TclInvokeStringCommand(
InvokeStringCommand(
void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Expand Down Expand Up @@ -2999,7 +3001,7 @@ TclInvokeStringCommand(
/*
*----------------------------------------------------------------------
*
* TclInvokeObjectCommand --
* InvokeObjectCommand --
*
* "Wrapper" Tcl_CmdProc used to call an existing object-based
* Tcl_ObjCmdProc if no string-based function exists for a command. A
Expand All @@ -3012,13 +3014,13 @@ TclInvokeStringCommand(
*
* Side effects:
* Besides those side effects of the called Tcl_ObjCmdProc,
* TclInvokeObjectCommand allocates and frees storage.
* InvokeObjectCommand allocates and frees storage.
*
*----------------------------------------------------------------------
*/

int
TclInvokeObjectCommand(
InvokeObjectCommand(
void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
Expand Down Expand Up @@ -3375,7 +3377,7 @@ Tcl_SetCommandInfoFromToken(
cmdPtr->proc = infoPtr->proc;
cmdPtr->clientData = infoPtr->clientData;
if (infoPtr->objProc == NULL) {
cmdPtr->objProc = TclInvokeStringCommand;
cmdPtr->objProc = InvokeStringCommand;
cmdPtr->objClientData = cmdPtr;
cmdPtr->nreProc = NULL;
} else {
Expand Down Expand Up @@ -3487,7 +3489,7 @@ Tcl_GetCommandInfoFromToken(

cmdPtr = (Command *) cmd;
infoPtr->isNativeObjectProc =
(cmdPtr->objProc != TclInvokeStringCommand);
(cmdPtr->objProc != InvokeStringCommand);
infoPtr->objProc = cmdPtr->objProc;
infoPtr->objClientData = cmdPtr->objClientData;
infoPtr->proc = cmdPtr->proc;
Expand Down Expand Up @@ -8588,7 +8590,7 @@ Tcl_NRCallObjProc2(
* Side effects:
* If no command named "cmdName" already exists for interp, one is
* created. Otherwise, if a command does exist, then if the object-based
* Tcl_ObjCmdProc is TclInvokeStringCommand, we assume Tcl_CreateCommand
* Tcl_ObjCmdProc is InvokeStringCommand, we assume Tcl_CreateCommand
* was called previously for the same command and just set its
* Tcl_ObjCmdProc to the argument "proc"; otherwise, we delete the old
* command.
Expand Down
22 changes: 14 additions & 8 deletions generic/tclInt.decls
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ declare 46 {
declare 51 {
int TclInterpInit(Tcl_Interp *interp)
}
declare 53 {
int TclInvokeObjectCommand(void *clientData, Tcl_Interp *interp,
int argc, const char **argv)
}
declare 54 {
int TclInvokeStringCommand(void *clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[])
}
# Removed in 9.0
#declare 53 {
# int TclInvokeObjectCommand(void *clientData, Tcl_Interp *interp,
# Tcl_Size argc, const char **argv)
#}
#declare 54 {
# int TclInvokeStringCommand(void *clientData, Tcl_Interp *interp,
# Tcl_Size objc, Tcl_Obj *const objv[])
#}
declare 55 {
Proc *TclIsProc(Command *cmdPtr)
}
Expand All @@ -162,6 +163,11 @@ declare 61 {
declare 62 {
int TclObjCommandComplete(Tcl_Obj *cmdPtr)
}
# Removed in 9.0:
#declare 63 {
# int TclObjInterpProc(void *clientData, Tcl_Interp *interp,
# Tcl_Size objc, Tcl_Obj *const objv[])
#}
declare 64 {
int TclObjInvoke(Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[],
int flags)
Expand Down
20 changes: 6 additions & 14 deletions generic/tclIntDecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,8 @@ EXTERN int TclInExit(void);
/* 51 */
EXTERN int TclInterpInit(Tcl_Interp *interp);
/* Slot 52 is reserved */
/* 53 */
EXTERN int TclInvokeObjectCommand(void *clientData,
Tcl_Interp *interp, int argc,
const char **argv);
/* 54 */
EXTERN int TclInvokeStringCommand(void *clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
/* Slot 53 is reserved */
/* Slot 54 is reserved */
/* 55 */
EXTERN Proc * TclIsProc(Command *cmdPtr);
/* Slot 56 is reserved */
Expand Down Expand Up @@ -641,8 +635,8 @@ typedef struct TclIntStubs {
void (*reserved50)(void);
int (*tclInterpInit) (Tcl_Interp *interp); /* 51 */
void (*reserved52)(void);
int (*tclInvokeObjectCommand) (void *clientData, Tcl_Interp *interp, int argc, const char **argv); /* 53 */
int (*tclInvokeStringCommand) (void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 54 */
void (*reserved53)(void);
void (*reserved54)(void);
Proc * (*tclIsProc) (Command *cmdPtr); /* 55 */
void (*reserved56)(void);
void (*reserved57)(void);
Expand Down Expand Up @@ -943,10 +937,8 @@ extern const TclIntStubs *tclIntStubsPtr;
#define TclInterpInit \
(tclIntStubsPtr->tclInterpInit) /* 51 */
/* Slot 52 is reserved */
#define TclInvokeObjectCommand \
(tclIntStubsPtr->tclInvokeObjectCommand) /* 53 */
#define TclInvokeStringCommand \
(tclIntStubsPtr->tclInvokeStringCommand) /* 54 */
/* Slot 53 is reserved */
/* Slot 54 is reserved */
#define TclIsProc \
(tclIntStubsPtr->tclIsProc) /* 55 */
/* Slot 56 is reserved */
Expand Down
4 changes: 2 additions & 2 deletions generic/tclStubInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ static const TclIntStubs tclIntStubs = {
0, /* 50 */
TclInterpInit, /* 51 */
0, /* 52 */
TclInvokeObjectCommand, /* 53 */
TclInvokeStringCommand, /* 54 */
0, /* 53 */
0, /* 54 */
TclIsProc, /* 55 */
0, /* 56 */
0, /* 57 */
Expand Down
4 changes: 2 additions & 2 deletions tests/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ test basic-15.2 {Tcl_CreateObjCommand, Bug 0e4d88b650} -setup {
}


test basic-16.1 {TclInvokeStringCommand} {emptyTest} {
test basic-16.1 {InvokeStringCommand} {emptyTest} {
} {}

test basic-17.1 {TclInvokeObjCommand} {emptyTest} {
test basic-17.1 {InvokeObjCommand} {emptyTest} {
} {}

test basic-18.1 {TclRenameCommand, name of existing cmd can have namespace qualifiers} {
Expand Down

0 comments on commit defed3c

Please sign in to comment.