Skip to content

Commit b8c14ce

Browse files
author
jan.nijtmans
committed
Allow 3th argument of Itcl_FindC() to be NULL. doc update
1 parent 1561cf5 commit b8c14ce

File tree

7 files changed

+38
-30
lines changed

7 files changed

+38
-30
lines changed

doc/List.3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void
4646
List info structure.
4747
.AP Itcl_ListElem *elem in
4848
List element info structure.
49-
.AP ClientData clientData in
49+
.AP void *clientData in
5050
Arbitrary one-word value to save in the list.
5151
.BE
5252

doc/Object.3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void
2626
.SH ARGUMENTS
2727
.AP Tcl_FreeProc *fproc in
2828
Address of function to call when the block is to be freed.
29-
.AP ClientData clientData in
29+
.AP void *clientData in
3030
Arbitrary one-word value.
3131
.BE
3232

doc/RegisterC.3

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Name of command.
3737
.AP Tcl_CmdProc *argProc in
3838
Implementation of new command: \fIargProc\fR will be called whenever
3939
.AP Tcl_CmdProc **argProcPtr in/out
40-
The Tcl_CmdProc * to receive the pointer.
40+
The Tcl_CmdProc * to receive the pointer. Can be NULL.
4141
.AP Tcl_ObjCmdProc *objProc in
4242
Implementation of the new command: \fIobjProc\fR will be called whenever
4343
.AP Tcl_ObjCmdProc2 *objProc2 in
@@ -46,10 +46,10 @@ Implementation of the new command: \fIobjProc2\fR will be called whenever
4646
The Tcl_ObjCmdProc * to receive the pointer.
4747
.AP Tcl_ObjCmdProc2 **objProc2Ptr in/out
4848
The Tcl_ObjCmdProc2 * to receive the pointer.
49-
.AP ClientData clientData in
49+
.AP void *clientData in
5050
Arbitrary one-word value to pass to \fIproc\fR and \fIdeleteProc\fR.
51-
.AP ClientData *cDataPtr in/out
52-
The ClientData to receive the pointer.
51+
.AP void **cDataPtr in/out
52+
The void * to receive the pointer.
5353
.AP Tcl_CmdDeleteProc *deleteProc in
5454
Procedure to call before \fIcmdName\fR is deleted from the interpreter;
5555
allows for command-specific cleanup. If NULL, then no procedure is

doc/Stack.3

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ int
2323
int
2424
\fBItcl_PushStack\fR(\fIcdata, stack\fR)
2525

26-
ClientData
26+
void *
2727
\fBItcl_PopStack\fR(\fIstack\fR)
2828

29-
ClientData
29+
void *
3030
\fBItcl_PeekStack\fR(\fIstack\fR)
3131

32-
ClientData
32+
void *
3333
\fBItcl_GetStackValue\fR(\fIstack, pos\fR)
3434

3535
int
@@ -40,7 +40,7 @@ int
4040
Stack info structure.
4141
.AP int pos in
4242
position in stack order from the top.
43-
.AP ClientData clientData in
43+
.AP void *clientData in
4444
Arbitrary one-word value to save in the stack.
4545
.BE
4646

generic/itclDecls.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ extern const ItclStubs *itclStubsPtr;
221221
# endif
222222
# undef Itcl_RegisterObjC2
223223
# define Itcl_RegisterObjC2 Itcl_RegisterObjC
224+
# undef Itcl_FindC2
225+
# define Itcl_FindC2(interp, name, objProcPtr, cDataPtr) \
226+
Itcl_FindC(interp, name, NULL, objProcPtr, cDataPtr)
224227
#endif
225228

226229
#endif /* _ITCLDECLS */

generic/itclLinkage.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ int
273273
Itcl_FindC(
274274
Tcl_Interp *interp, /* interpreter handling this registration */
275275
const char *name, /* symbolic name for procedure */
276-
Tcl_CmdProc **argProcPtr, /* returns (argc,argv) command handler */
276+
Tcl_CmdProc **argProcPtr, /* returns (argc,argv) command handler, can be NULL */
277277
Tcl_ObjCmdProc **objProcPtr, /* returns (objc,objv) command handler */
278278
void **cDataPtr) /* returns client data */
279279
{
280280
Tcl_HashEntry *entry;
281281
Tcl_HashTable *procTable;
282282
ItclCfunc *cfunc;
283+
Tcl_CmdProc *argProc = NULL; /* assume info won't be found */
283284

284-
*argProcPtr = NULL; /* assume info won't be found */
285285
*objProcPtr = NULL;
286286
*cDataPtr = NULL;
287287

@@ -293,13 +293,16 @@ Itcl_FindC(
293293
entry = Tcl_FindHashEntry(procTable, name);
294294
if (entry) {
295295
cfunc = (ItclCfunc*)Tcl_GetHashValue(entry);
296-
*argProcPtr = cfunc->argCmdProc;
296+
argProc = cfunc->argCmdProc;
297297
*objProcPtr = cfunc->objCmdProc;
298298
*cDataPtr = cfunc->clientData;
299299
}
300300
}
301301
}
302-
return (*argProcPtr != NULL || *objProcPtr != NULL);
302+
if (argProcPtr) {
303+
*argProcPtr = argProc;
304+
}
305+
return (((argProcPtr != NULL) && (argProc != NULL)) || (*objProcPtr != NULL));
303306
}
304307

305308
#if TCL_MAJOR_VERSION > 8
@@ -310,14 +313,13 @@ Itcl_FindC2(
310313
Tcl_ObjCmdProc2 **objProcPtr, /* returns (objc,objv) command handler */
311314
void **cDataPtr) /* returns client data */
312315
{
313-
Tcl_CmdProc *procPtr;
314-
Tcl_ObjCmdProc *regProcPtr;
315-
void *dataPtr;
316+
Tcl_ObjCmdProc *regProcPtr;
317+
void *dataPtr;
316318

317319
*objProcPtr = NULL; /* assume info won't be found */
318320
*cDataPtr = NULL;
319321

320-
if (Itcl_FindC(interp, name, &procPtr, &regProcPtr, &dataPtr) == TCL_OK) {
322+
if (Itcl_FindC(interp, name, NULL, &regProcPtr, &dataPtr)) {
321323
if (regProcPtr == regCmdProc) {
322324
regInfo *info = (regInfo *)dataPtr;
323325
*objProcPtr = info->objProc;
@@ -326,18 +328,6 @@ Itcl_FindC2(
326328
}
327329
return (*objProcPtr != NULL);
328330
}
329-
#else
330-
int
331-
Itcl_FindC2(
332-
Tcl_Interp *interp, /* interpreter handling this registration */
333-
const char *name, /* symbolic name for procedure */
334-
Tcl_ObjCmdProc **objProcPtr, /* returns (objc,objv) command handler */
335-
void **cDataPtr) /* returns client data */
336-
{
337-
Tcl_CmdProc *argProcPtr;
338-
return Itcl_FindC(interp, name, &argProcPtr, objProcPtr, cDataPtr);
339-
}
340-
341331
#endif /* TCL_MAJOR_VERSION */
342332

343333

generic/itclStubInit.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
#include "itclInt.h"
77

88
MODULE_SCOPE const ItclStubs itclStubs;
9+
10+
#if TCL_MAJOR_VERSION < 9
11+
#undef Itcl_FindC2
12+
#define Itcl_FindC2 findC2
13+
static int Itcl_FindC2(
14+
Tcl_Interp *interp, /* interpreter handling this registration */
15+
const char *name, /* symbolic name for procedure */
16+
Tcl_ObjCmdProc **objProcPtr, /* returns (objc,objv) command handler */
17+
void **cDataPtr) /* returns client data */
18+
{
19+
return Itcl_FindC(interp, name, NULL, objProcPtr, cDataPtr);
20+
}
21+
#endif
22+
23+
924
/* !BEGIN!: Do not edit below this line. */
1025

1126
static const ItclIntStubs itclIntStubs = {

0 commit comments

Comments
 (0)