From 3ec5992bb09cb1dc272a32e6306987f4c2b55e11 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 30 Dec 2024 17:10:37 +0000 Subject: [PATCH 1/4] [2bc08cd2e6] Document ObjPrintf size modifiers --- doc/StringObj.3 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/StringObj.3 b/doc/StringObj.3 index 4682cae8ccd..2745218745d 100644 --- a/doc/StringObj.3 +++ b/doc/StringObj.3 @@ -352,6 +352,22 @@ Tcl_Obj *newPtr = \fBTcl_ObjPrintf\fR(format, ...); but with greater convenience and efficiency when the appending functionality is needed. .PP +When printing integer types defined by Tcl, such as \fBTcl_Size\fR +or \fBTcl_WideInt\fR, a format size specifier is needed as the +integer width of those types is dependent on the Tcl version, +platform and compiler. To accomodate these differences, Tcl defines +C preprocessor symbols \fBTCL_LL_MODIFER\fR and +\fBTCL_SIZE_MODIFER\fR for use when formatting values of type +\fBTcl_WideInt\fR and \fBTcl_Size\fR respectively. Their usage +is illustrated by +.PP +.CS +Tcl_WideInt wide; +Tcl_Size len; +Tcl_Obj *wideObj = Tcl_ObjPrintf("wide = %" \fBTCL_LL_MODIFIER\fR "d", wide); +Tcl_Obj *lenObj = Tcl_ObjPrintf("len = %" \fBTCL_SIZE_MODIFIER\fR "d", len); +.CE +.PP The \fBTcl_SetObjLength\fR procedure changes the length of the string value of its \fIobjPtr\fR argument. If the \fInewLength\fR argument is greater than the space allocated for the value's From 39c028b8c31d3068531d525b753bcd78819f7f80 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 31 Dec 2024 01:18:08 +0000 Subject: [PATCH 2/4] Document TCL_SIZE_MAX --- doc/IntObj.3 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/IntObj.3 b/doc/IntObj.3 index 7cc93c1e28f..7bf100d5478 100644 --- a/doc/IntObj.3 +++ b/doc/IntObj.3 @@ -8,7 +8,7 @@ .so man.macros .BS .SH NAME -Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_NewWideUIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_SetWideUIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers +Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_NewWideUIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_SetWideUIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetSizeIntFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers .SH SYNOPSIS .nf \fB#include \fR @@ -124,6 +124,11 @@ typedef defined to be whatever signed integral type covers at least the 64-bit integer range (-9223372036854775808 to 9223372036854775807). Depending on the platform and the C compiler, the actual type might be \fBlong long int\fR, or something else. +The \fBTcl_Size\fR typedef is a signed integer type +capable of holding the maximum permitted lengths of Tcl values like +strings and lists. Correspondingly, the preprocessor constant +\fBTCL_SIZE_MAX\fR defines the maximum value that can be stored +in a variable of this type. The \fBmp_int\fR type is a multiple-precision integer type defined by the LibTomMath multiple-precision integer library. .PP @@ -193,7 +198,8 @@ integer value in the \fBmp_int\fR value \fIbigValue\fR. arguments, but do require that the object be unshared. .PP \fBTcl_GetIntFromObj\fR, \fBTcl_GetIntForIndex\fR, \fBTcl_GetLongFromObj\fR, -\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and +\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetSizeIntFromObj\fR, +\fBTcl_GetBignumFromObj\fR, and \fBTcl_TakeBignumFromObj\fR do not modify the reference count of their \fIobjPtr\fR arguments; they only read. Note however that this function may set the interpreter result; if that is the only place that is holding a From a7ef4fbf40344e9c000a977fed906c19b0b783cc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Jan 2025 13:23:28 +0000 Subject: [PATCH 3/4] Make room for 2 more (internal) stub entries: TclOOMakeProcInstanceMethod2 and TclOOMakeProcMethod2. Fill in more stub entries, for better binary compatibility with 9.0 --- generic/tcl.decls | 67 +++++++++++++++++ generic/tclDecls.h | 162 +++++++++++++++++++++++++++++----------- generic/tclOO.decls | 25 ++++++- generic/tclOODecls.h | 36 ++++++--- generic/tclOOIntDecls.h | 24 ++++++ generic/tclOOStubInit.c | 10 +-- generic/tclStubInit.c | 41 ++++++---- 7 files changed, 288 insertions(+), 77 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index 84915b287e0..7a26ef64e7d 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2411,6 +2411,24 @@ declare 649 { unsigned char *Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr) } +declare 650 { + unsigned char *TclGetBytesFromObj_(Tcl_Interp *interp, Tcl_Obj *objPtr, + Tcl_Size *numBytesPtr) +} + +# TIP #481 +declare 651 { + char *TclGetStringFromObj_(Tcl_Obj *objPtr, Tcl_Size *lengthPtr) +} +declare 652 { + Tcl_UniChar *TclGetUnicodeFromObj_(Tcl_Obj *objPtr, Tcl_Size *lengthPtr) +} + +# TIP 660 +declare 653 { + int Tcl_GetSizeIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, + Tcl_Size *sizePtr) +} # TIP #575 declare 654 { @@ -2446,6 +2464,33 @@ declare 660 { int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber) } +# TIP #616 +declare 661 { + int TclListObjGetElements_(Tcl_Interp *interp, Tcl_Obj *listPtr, + Tcl_Size *objcPtr, Tcl_Obj ***objvPtr) +} +declare 662 { + int TclListObjLength_(Tcl_Interp *interp, Tcl_Obj *listPtr, + Tcl_Size *lengthPtr) +} +declare 663 { + int TclDictObjSize_(Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size *sizePtr) +} +declare 664 { + int TclSplitList_(Tcl_Interp *interp, const char *listStr, Tcl_Size *argcPtr, + const char ***argvPtr) +} +declare 665 { + void TclSplitPath_(const char *path, Tcl_Size *argcPtr, const char ***argvPtr) +} +declare 666 { + Tcl_Obj *TclFSSplitPath_(Tcl_Obj *pathPtr, Tcl_Size *lenPtr) +} +declare 667 { + int TclParseArgsObjv_(Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, + Tcl_Size *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv) +} + # TIP #617 declare 668 { Tcl_Size Tcl_UniCharLen(const int *uniStr) @@ -2474,6 +2519,28 @@ declare 675 { int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags, char *charPtr) } +declare 676 { + Tcl_Command Tcl_CreateObjCommand2(Tcl_Interp *interp, + const char *cmdName, + Tcl_ObjCmdProc2 *proc2, void *clientData, + Tcl_CmdDeleteProc *deleteProc) +} +declare 677 { + Tcl_Trace Tcl_CreateObjTrace2(Tcl_Interp *interp, Tcl_Size level, int flags, + Tcl_CmdObjTraceProc2 *objProc2, void *clientData, + Tcl_CmdObjTraceDeleteProc *delProc) +} +declare 678 { + Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp, + const char *cmdName, Tcl_ObjCmdProc2 *proc, + Tcl_ObjCmdProc2 *nreProc2, void *clientData, + Tcl_CmdDeleteProc *deleteProc) +} +declare 679 { + int Tcl_NRCallObjProc2(Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2, + void *clientData, Tcl_Size objc, Tcl_Obj *const objv[]) +} + # TIP #638. declare 680 { int Tcl_GetNumberFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 936cf947317..4439004e1fd 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1938,10 +1938,18 @@ EXTERN int * Tcl_UtfToUniCharDString(const char *src, /* 649 */ EXTERN unsigned char * Tcl_GetBytesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); -/* Slot 650 is reserved */ -/* Slot 651 is reserved */ -/* Slot 652 is reserved */ -/* Slot 653 is reserved */ +/* 650 */ +EXTERN unsigned char * TclGetBytesFromObj_(Tcl_Interp *interp, + Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); +/* 651 */ +EXTERN char * TclGetStringFromObj_(Tcl_Obj *objPtr, + Tcl_Size *lengthPtr); +/* 652 */ +EXTERN Tcl_UniChar * TclGetUnicodeFromObj_(Tcl_Obj *objPtr, + Tcl_Size *lengthPtr); +/* 653 */ +EXTERN int Tcl_GetSizeIntFromObj(Tcl_Interp *interp, + Tcl_Obj *objPtr, Tcl_Size *sizePtr); /* 654 */ EXTERN int Tcl_UtfCharComplete(const char *src, Tcl_Size length); /* 655 */ @@ -1966,13 +1974,30 @@ EXTERN int Tcl_UtfToExternalDStringEx(Tcl_Interp *interp, /* 660 */ EXTERN int Tcl_AsyncMarkFromSignal(Tcl_AsyncHandler async, int sigNumber); -/* Slot 661 is reserved */ -/* Slot 662 is reserved */ -/* Slot 663 is reserved */ -/* Slot 664 is reserved */ -/* Slot 665 is reserved */ -/* Slot 666 is reserved */ -/* Slot 667 is reserved */ +/* 661 */ +EXTERN int TclListObjGetElements_(Tcl_Interp *interp, + Tcl_Obj *listPtr, Tcl_Size *objcPtr, + Tcl_Obj ***objvPtr); +/* 662 */ +EXTERN int TclListObjLength_(Tcl_Interp *interp, + Tcl_Obj *listPtr, Tcl_Size *lengthPtr); +/* 663 */ +EXTERN int TclDictObjSize_(Tcl_Interp *interp, Tcl_Obj *dictPtr, + Tcl_Size *sizePtr); +/* 664 */ +EXTERN int TclSplitList_(Tcl_Interp *interp, + const char *listStr, Tcl_Size *argcPtr, + const char ***argvPtr); +/* 665 */ +EXTERN void TclSplitPath_(const char *path, Tcl_Size *argcPtr, + const char ***argvPtr); +/* 666 */ +EXTERN Tcl_Obj * TclFSSplitPath_(Tcl_Obj *pathPtr, Tcl_Size *lenPtr); +/* 667 */ +EXTERN int TclParseArgsObjv_(Tcl_Interp *interp, + const Tcl_ArgvInfo *argTable, + Tcl_Size *objcPtr, Tcl_Obj *const *objv, + Tcl_Obj ***remObjv); /* 668 */ EXTERN Tcl_Size Tcl_UniCharLen(const int *uniStr); /* 669 */ @@ -1992,10 +2017,26 @@ EXTERN int Tcl_GetBool(Tcl_Interp *interp, const char *src, /* 675 */ EXTERN int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags, char *charPtr); -/* Slot 676 is reserved */ -/* Slot 677 is reserved */ -/* Slot 678 is reserved */ -/* Slot 679 is reserved */ +/* 676 */ +EXTERN Tcl_Command Tcl_CreateObjCommand2(Tcl_Interp *interp, + const char *cmdName, Tcl_ObjCmdProc2 *proc2, + void *clientData, + Tcl_CmdDeleteProc *deleteProc); +/* 677 */ +EXTERN Tcl_Trace Tcl_CreateObjTrace2(Tcl_Interp *interp, + Tcl_Size level, int flags, + Tcl_CmdObjTraceProc2 *objProc2, + void *clientData, + Tcl_CmdObjTraceDeleteProc *delProc); +/* 678 */ +EXTERN Tcl_Command Tcl_NRCreateCommand2(Tcl_Interp *interp, + const char *cmdName, Tcl_ObjCmdProc2 *proc, + Tcl_ObjCmdProc2 *nreProc2, void *clientData, + Tcl_CmdDeleteProc *deleteProc); +/* 679 */ +EXTERN int Tcl_NRCallObjProc2(Tcl_Interp *interp, + Tcl_ObjCmdProc2 *objProc2, void *clientData, + Tcl_Size objc, Tcl_Obj *const objv[]); /* 680 */ EXTERN int Tcl_GetNumberFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, void **clientDataPtr, @@ -2711,10 +2752,10 @@ typedef struct TclStubs { char * (*tcl_UniCharToUtfDString) (const int *uniStr, Tcl_Size uniLength, Tcl_DString *dsPtr); /* 647 */ int * (*tcl_UtfToUniCharDString) (const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 648 */ unsigned char * (*tcl_GetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 649 */ - void (*reserved650)(void); - void (*reserved651)(void); - void (*reserved652)(void); - void (*reserved653)(void); + unsigned char * (*tclGetBytesFromObj_) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *numBytesPtr); /* 650 */ + char * (*tclGetStringFromObj_) (Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 651 */ + Tcl_UniChar * (*tclGetUnicodeFromObj_) (Tcl_Obj *objPtr, Tcl_Size *lengthPtr); /* 652 */ + int (*tcl_GetSizeIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr); /* 653 */ int (*tcl_UtfCharComplete) (const char *src, Tcl_Size length); /* 654 */ const char * (*tcl_UtfNext) (const char *src); /* 655 */ const char * (*tcl_UtfPrev) (const char *src, const char *start); /* 656 */ @@ -2722,13 +2763,13 @@ typedef struct TclStubs { int (*tcl_ExternalToUtfDStringEx) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 658 */ int (*tcl_UtfToExternalDStringEx) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr); /* 659 */ int (*tcl_AsyncMarkFromSignal) (Tcl_AsyncHandler async, int sigNumber); /* 660 */ - void (*reserved661)(void); - void (*reserved662)(void); - void (*reserved663)(void); - void (*reserved664)(void); - void (*reserved665)(void); - void (*reserved666)(void); - void (*reserved667)(void); + int (*tclListObjGetElements_) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr); /* 661 */ + int (*tclListObjLength_) (Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size *lengthPtr); /* 662 */ + int (*tclDictObjSize_) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Size *sizePtr); /* 663 */ + int (*tclSplitList_) (Tcl_Interp *interp, const char *listStr, Tcl_Size *argcPtr, const char ***argvPtr); /* 664 */ + void (*tclSplitPath_) (const char *path, Tcl_Size *argcPtr, const char ***argvPtr); /* 665 */ + Tcl_Obj * (*tclFSSplitPath_) (Tcl_Obj *pathPtr, Tcl_Size *lenPtr); /* 666 */ + int (*tclParseArgsObjv_) (Tcl_Interp *interp, const Tcl_ArgvInfo *argTable, Tcl_Size *objcPtr, Tcl_Obj *const *objv, Tcl_Obj ***remObjv); /* 667 */ Tcl_Size (*tcl_UniCharLen) (const int *uniStr); /* 668 */ Tcl_Size (*tclNumUtfChars) (const char *src, Tcl_Size length); /* 669 */ Tcl_Size (*tclGetCharLength) (Tcl_Obj *objPtr); /* 670 */ @@ -2737,10 +2778,10 @@ typedef struct TclStubs { int (*tclGetUniChar) (Tcl_Obj *objPtr, Tcl_Size index); /* 673 */ int (*tcl_GetBool) (Tcl_Interp *interp, const char *src, int flags, char *charPtr); /* 674 */ int (*tcl_GetBoolFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags, char *charPtr); /* 675 */ - void (*reserved676)(void); - void (*reserved677)(void); - void (*reserved678)(void); - void (*reserved679)(void); + Tcl_Command (*tcl_CreateObjCommand2) (Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc2 *proc2, void *clientData, Tcl_CmdDeleteProc *deleteProc); /* 676 */ + Tcl_Trace (*tcl_CreateObjTrace2) (Tcl_Interp *interp, Tcl_Size level, int flags, Tcl_CmdObjTraceProc2 *objProc2, void *clientData, Tcl_CmdObjTraceDeleteProc *delProc); /* 677 */ + Tcl_Command (*tcl_NRCreateCommand2) (Tcl_Interp *interp, const char *cmdName, Tcl_ObjCmdProc2 *proc, Tcl_ObjCmdProc2 *nreProc2, void *clientData, Tcl_CmdDeleteProc *deleteProc); /* 678 */ + int (*tcl_NRCallObjProc2) (Tcl_Interp *interp, Tcl_ObjCmdProc2 *objProc2, void *clientData, Tcl_Size objc, Tcl_Obj *const objv[]); /* 679 */ int (*tcl_GetNumberFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, void **clientDataPtr, int *typePtr); /* 680 */ int (*tcl_GetNumber) (Tcl_Interp *interp, const char *bytes, Tcl_Size numBytes, void **clientDataPtr, int *typePtr); /* 681 */ int (*tcl_RemoveChannelMode) (Tcl_Interp *interp, Tcl_Channel chan, int mode); /* 682 */ @@ -4082,10 +4123,14 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UtfToUniCharDString) /* 648 */ #define Tcl_GetBytesFromObj \ (tclStubsPtr->tcl_GetBytesFromObj) /* 649 */ -/* Slot 650 is reserved */ -/* Slot 651 is reserved */ -/* Slot 652 is reserved */ -/* Slot 653 is reserved */ +#define TclGetBytesFromObj_ \ + (tclStubsPtr->tclGetBytesFromObj_) /* 650 */ +#define TclGetStringFromObj_ \ + (tclStubsPtr->tclGetStringFromObj_) /* 651 */ +#define TclGetUnicodeFromObj_ \ + (tclStubsPtr->tclGetUnicodeFromObj_) /* 652 */ +#define Tcl_GetSizeIntFromObj \ + (tclStubsPtr->tcl_GetSizeIntFromObj) /* 653 */ #define Tcl_UtfCharComplete \ (tclStubsPtr->tcl_UtfCharComplete) /* 654 */ #define Tcl_UtfNext \ @@ -4100,13 +4145,20 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UtfToExternalDStringEx) /* 659 */ #define Tcl_AsyncMarkFromSignal \ (tclStubsPtr->tcl_AsyncMarkFromSignal) /* 660 */ -/* Slot 661 is reserved */ -/* Slot 662 is reserved */ -/* Slot 663 is reserved */ -/* Slot 664 is reserved */ -/* Slot 665 is reserved */ -/* Slot 666 is reserved */ -/* Slot 667 is reserved */ +#define TclListObjGetElements_ \ + (tclStubsPtr->tclListObjGetElements_) /* 661 */ +#define TclListObjLength_ \ + (tclStubsPtr->tclListObjLength_) /* 662 */ +#define TclDictObjSize_ \ + (tclStubsPtr->tclDictObjSize_) /* 663 */ +#define TclSplitList_ \ + (tclStubsPtr->tclSplitList_) /* 664 */ +#define TclSplitPath_ \ + (tclStubsPtr->tclSplitPath_) /* 665 */ +#define TclFSSplitPath_ \ + (tclStubsPtr->tclFSSplitPath_) /* 666 */ +#define TclParseArgsObjv_ \ + (tclStubsPtr->tclParseArgsObjv_) /* 667 */ #define Tcl_UniCharLen \ (tclStubsPtr->tcl_UniCharLen) /* 668 */ #define TclNumUtfChars \ @@ -4123,10 +4175,14 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_GetBool) /* 674 */ #define Tcl_GetBoolFromObj \ (tclStubsPtr->tcl_GetBoolFromObj) /* 675 */ -/* Slot 676 is reserved */ -/* Slot 677 is reserved */ -/* Slot 678 is reserved */ -/* Slot 679 is reserved */ +#define Tcl_CreateObjCommand2 \ + (tclStubsPtr->tcl_CreateObjCommand2) /* 676 */ +#define Tcl_CreateObjTrace2 \ + (tclStubsPtr->tcl_CreateObjTrace2) /* 677 */ +#define Tcl_NRCreateCommand2 \ + (tclStubsPtr->tcl_NRCreateCommand2) /* 678 */ +#define Tcl_NRCallObjProc2 \ + (tclStubsPtr->tcl_NRCallObjProc2) /* 679 */ #define Tcl_GetNumberFromObj \ (tclStubsPtr->tcl_GetNumberFromObj) /* 680 */ #define Tcl_GetNumber \ @@ -4490,12 +4546,28 @@ extern const TclStubs *tclStubsPtr; #define Tcl_GetSlave Tcl_GetChild #define Tcl_GetMaster Tcl_GetParent +#undef Tcl_NRCallObjProc2 #define Tcl_NRCallObjProc2 Tcl_NRCallObjProc +#undef Tcl_CreateObjCommand2 #define Tcl_CreateObjCommand2 Tcl_CreateObjCommand +#undef Tcl_CreateObjTrace2 #define Tcl_CreateObjTrace2 Tcl_CreateObjTrace +#undef Tcl_NRCreateCommand2 #define Tcl_NRCreateCommand2 Tcl_NRCreateCommand +#undef TclDictObjSize_ +#undef TclFSSplitPath_ +#undef TclListObjGetElements_ +#undef TclListObjLength_ +#undef TclParseArgsObjv_ +#undef TclSplitList_ +#undef TclSplitPath_ +#undef TclGetBytesFromObj_ +#undef TclGetStringFromObj_ +#undef TclGetUnicodeFromObj_ + /* TIP #660 */ +#undef Tcl_GetSizeIntFromObj #define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj #endif /* _TCLDECLS */ diff --git a/generic/tclOO.decls b/generic/tclOO.decls index 913d76c4758..a73ed002fac 100644 --- a/generic/tclOO.decls +++ b/generic/tclOO.decls @@ -135,8 +135,19 @@ declare 30 { declare 31 { Tcl_Obj *Tcl_GetObjectClassName(Tcl_Interp *interp, Tcl_Object object) } +declare 32 { + int Tcl_MethodIsType2(Tcl_Method method, const Tcl_MethodType2 *typePtr, + void **clientDataPtr) +} +declare 33 { + Tcl_Method Tcl_NewInstanceMethod2(Tcl_Interp *interp, Tcl_Object object, + Tcl_Obj *nameObj, int flags, const Tcl_MethodType2 *typePtr, + void *clientData) +} declare 34 { - void TclOOUnusedStubEntry(void) + Tcl_Method Tcl_NewMethod2(Tcl_Interp *interp, Tcl_Class cls, + Tcl_Obj *nameObj, int flags, const Tcl_MethodType2 *typePtr, + void *clientData) } ###################################################################### @@ -222,6 +233,18 @@ declare 15 { void TclOOClassSetMixins(Tcl_Interp *interp, Class *classPtr, Tcl_Size numMixins, Class *const *mixins) } +declare 16 { + Tcl_Method TclOOMakeProcInstanceMethod2(Tcl_Interp *interp, Object *oPtr, + int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, + const Tcl_MethodType2 *typePtr, void *clientData, + Proc **procPtrPtr) +} +declare 17 { + Tcl_Method TclOOMakeProcMethod2(Tcl_Interp *interp, Class *clsPtr, + int flags, Tcl_Obj *nameObj, const char *namePtr, + Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType2 *typePtr, + void *clientData, Proc **procPtrPtr) +} return diff --git a/generic/tclOODecls.h b/generic/tclOODecls.h index 6126fe2eb71..de17670a339 100644 --- a/generic/tclOODecls.h +++ b/generic/tclOODecls.h @@ -123,10 +123,20 @@ TCLAPI Tcl_Class Tcl_GetClassOfObject(Tcl_Object object); /* 31 */ TCLAPI Tcl_Obj * Tcl_GetObjectClassName(Tcl_Interp *interp, Tcl_Object object); -/* Slot 32 is reserved */ -/* Slot 33 is reserved */ +/* 32 */ +TCLAPI int Tcl_MethodIsType2(Tcl_Method method, + const Tcl_MethodType2 *typePtr, + void **clientDataPtr); +/* 33 */ +TCLAPI Tcl_Method Tcl_NewInstanceMethod2(Tcl_Interp *interp, + Tcl_Object object, Tcl_Obj *nameObj, + int flags, const Tcl_MethodType2 *typePtr, + void *clientData); /* 34 */ -TCLAPI void TclOOUnusedStubEntry(void); +TCLAPI Tcl_Method Tcl_NewMethod2(Tcl_Interp *interp, Tcl_Class cls, + Tcl_Obj *nameObj, int flags, + const Tcl_MethodType2 *typePtr, + void *clientData); typedef struct { const struct TclOOIntStubs *tclOOIntStubs; @@ -168,9 +178,9 @@ typedef struct TclOOStubs { int (*tcl_MethodIsPrivate) (Tcl_Method method); /* 29 */ Tcl_Class (*tcl_GetClassOfObject) (Tcl_Object object); /* 30 */ Tcl_Obj * (*tcl_GetObjectClassName) (Tcl_Interp *interp, Tcl_Object object); /* 31 */ - void (*reserved32)(void); - void (*reserved33)(void); - void (*tclOOUnusedStubEntry) (void); /* 34 */ + int (*tcl_MethodIsType2) (Tcl_Method method, const Tcl_MethodType2 *typePtr, void **clientDataPtr); /* 32 */ + Tcl_Method (*tcl_NewInstanceMethod2) (Tcl_Interp *interp, Tcl_Object object, Tcl_Obj *nameObj, int flags, const Tcl_MethodType2 *typePtr, void *clientData); /* 33 */ + Tcl_Method (*tcl_NewMethod2) (Tcl_Interp *interp, Tcl_Class cls, Tcl_Obj *nameObj, int flags, const Tcl_MethodType2 *typePtr, void *clientData); /* 34 */ } TclOOStubs; extern const TclOOStubs *tclOOStubsPtr; @@ -249,18 +259,22 @@ extern const TclOOStubs *tclOOStubsPtr; (tclOOStubsPtr->tcl_GetClassOfObject) /* 30 */ #define Tcl_GetObjectClassName \ (tclOOStubsPtr->tcl_GetObjectClassName) /* 31 */ -/* Slot 32 is reserved */ -/* Slot 33 is reserved */ -#define TclOOUnusedStubEntry \ - (tclOOStubsPtr->tclOOUnusedStubEntry) /* 34 */ +#define Tcl_MethodIsType2 \ + (tclOOStubsPtr->tcl_MethodIsType2) /* 32 */ +#define Tcl_NewInstanceMethod2 \ + (tclOOStubsPtr->tcl_NewInstanceMethod2) /* 33 */ +#define Tcl_NewMethod2 \ + (tclOOStubsPtr->tcl_NewMethod2) /* 34 */ #endif /* defined(USE_TCLOO_STUBS) */ /* !END!: Do not edit above this line. */ -#undef TclOOUnusedStubEntry +#undef Tcl_MethodIsType2 #define Tcl_MethodIsType2 Tcl_MethodIsType +#undef Tcl_NewInstanceMethod2 #define Tcl_NewInstanceMethod2 Tcl_NewInstanceMethod +#undef Tcl_NewMethod2 #define Tcl_NewMethod2 Tcl_NewMethod diff --git a/generic/tclOOIntDecls.h b/generic/tclOOIntDecls.h index 730a73aa5b7..090b204695d 100644 --- a/generic/tclOOIntDecls.h +++ b/generic/tclOOIntDecls.h @@ -91,6 +91,19 @@ TCLAPI void TclOOObjectSetMixins(Object *oPtr, TCLAPI void TclOOClassSetMixins(Tcl_Interp *interp, Class *classPtr, Tcl_Size numMixins, Class *const *mixins); +/* 16 */ +TCLAPI Tcl_Method TclOOMakeProcInstanceMethod2(Tcl_Interp *interp, + Object *oPtr, int flags, Tcl_Obj *nameObj, + Tcl_Obj *argsObj, Tcl_Obj *bodyObj, + const Tcl_MethodType2 *typePtr, + void *clientData, Proc **procPtrPtr); +/* 17 */ +TCLAPI Tcl_Method TclOOMakeProcMethod2(Tcl_Interp *interp, + Class *clsPtr, int flags, Tcl_Obj *nameObj, + const char *namePtr, Tcl_Obj *argsObj, + Tcl_Obj *bodyObj, + const Tcl_MethodType2 *typePtr, + void *clientData, Proc **procPtrPtr); typedef struct TclOOIntStubs { int magic; @@ -112,6 +125,8 @@ typedef struct TclOOIntStubs { void (*tclOOClassSetFilters) (Tcl_Interp *interp, Class *classPtr, Tcl_Size numFilters, Tcl_Obj *const *filters); /* 13 */ void (*tclOOObjectSetMixins) (Object *oPtr, Tcl_Size numMixins, Class *const *mixins); /* 14 */ void (*tclOOClassSetMixins) (Tcl_Interp *interp, Class *classPtr, Tcl_Size numMixins, Class *const *mixins); /* 15 */ + Tcl_Method (*tclOOMakeProcInstanceMethod2) (Tcl_Interp *interp, Object *oPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType2 *typePtr, void *clientData, Proc **procPtrPtr); /* 16 */ + Tcl_Method (*tclOOMakeProcMethod2) (Tcl_Interp *interp, Class *clsPtr, int flags, Tcl_Obj *nameObj, const char *namePtr, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType2 *typePtr, void *clientData, Proc **procPtrPtr); /* 17 */ } TclOOIntStubs; extern const TclOOIntStubs *tclOOIntStubsPtr; @@ -158,9 +173,18 @@ extern const TclOOIntStubs *tclOOIntStubsPtr; (tclOOIntStubsPtr->tclOOObjectSetMixins) /* 14 */ #define TclOOClassSetMixins \ (tclOOIntStubsPtr->tclOOClassSetMixins) /* 15 */ +#define TclOOMakeProcInstanceMethod2 \ + (tclOOIntStubsPtr->tclOOMakeProcInstanceMethod2) /* 16 */ +#define TclOOMakeProcMethod2 \ + (tclOOIntStubsPtr->tclOOMakeProcMethod2) /* 17 */ #endif /* defined(USE_TCLOO_STUBS) */ /* !END!: Do not edit above this line. */ +#undef TclOOMakeProcInstanceMethod2 +#define TclOOMakeProcInstanceMethod2 TclOOMakeProcInstanceMethod +#undef TclOOMakeProcMethod2 +#define TclOOMakeProcMethod2 TclOOMakeProcMethod + #endif /* _TCLOOINTDECLS */ diff --git a/generic/tclOOStubInit.c b/generic/tclOOStubInit.c index 192303706aa..5971715dab0 100644 --- a/generic/tclOOStubInit.c +++ b/generic/tclOOStubInit.c @@ -14,8 +14,6 @@ MODULE_SCOPE const TclOOStubs tclOOStubs; #pragma GCC dependency "tclOO.decls" #endif -#define TclOOUnusedStubEntry 0 - /* !BEGIN!: Do not edit below this line. */ static const TclOOIntStubs tclOOIntStubs = { @@ -37,6 +35,8 @@ static const TclOOIntStubs tclOOIntStubs = { TclOOClassSetFilters, /* 13 */ TclOOObjectSetMixins, /* 14 */ TclOOClassSetMixins, /* 15 */ + TclOOMakeProcInstanceMethod2, /* 16 */ + TclOOMakeProcMethod2, /* 17 */ }; static const TclOOStubHooks tclOOStubHooks = { @@ -78,9 +78,9 @@ const TclOOStubs tclOOStubs = { Tcl_MethodIsPrivate, /* 29 */ Tcl_GetClassOfObject, /* 30 */ Tcl_GetObjectClassName, /* 31 */ - 0, /* 32 */ - 0, /* 33 */ - TclOOUnusedStubEntry, /* 34 */ + Tcl_MethodIsType2, /* 32 */ + Tcl_NewInstanceMethod2, /* 33 */ + Tcl_NewMethod2, /* 34 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 032ed771fb4..a6462953c42 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -85,6 +85,17 @@ #define TclWinConvertError (void (*)(DWORD))(void *)Tcl_WinConvertError #endif +#define TclDictObjSize_ Tcl_DictObjSize +#define TclFSSplitPath_ Tcl_FSSplitPath +#define TclListObjGetElements_ Tcl_ListObjGetElements +#define TclListObjLength_ Tcl_ListObjLength +#define TclParseArgsObjv_ Tcl_ParseArgsObjv +#define TclSplitList_ Tcl_SplitList +#define TclSplitPath_ Tcl_SplitPath +#define TclGetBytesFromObj_ Tcl_GetBytesFromObj +#define TclGetStringFromObj_ Tcl_GetStringFromObj +#define TclGetUnicodeFromObj_ Tcl_GetUnicodeFromObj + #if defined(TCL_NO_DEPRECATED) static void uniCodePanic(void) { @@ -1946,10 +1957,10 @@ const TclStubs tclStubs = { Tcl_UniCharToUtfDString, /* 647 */ Tcl_UtfToUniCharDString, /* 648 */ Tcl_GetBytesFromObj, /* 649 */ - 0, /* 650 */ - 0, /* 651 */ - 0, /* 652 */ - 0, /* 653 */ + TclGetBytesFromObj_, /* 650 */ + TclGetStringFromObj_, /* 651 */ + TclGetUnicodeFromObj_, /* 652 */ + Tcl_GetSizeIntFromObj, /* 653 */ Tcl_UtfCharComplete, /* 654 */ Tcl_UtfNext, /* 655 */ Tcl_UtfPrev, /* 656 */ @@ -1957,13 +1968,13 @@ const TclStubs tclStubs = { Tcl_ExternalToUtfDStringEx, /* 658 */ Tcl_UtfToExternalDStringEx, /* 659 */ Tcl_AsyncMarkFromSignal, /* 660 */ - 0, /* 661 */ - 0, /* 662 */ - 0, /* 663 */ - 0, /* 664 */ - 0, /* 665 */ - 0, /* 666 */ - 0, /* 667 */ + TclListObjGetElements_, /* 661 */ + TclListObjLength_, /* 662 */ + TclDictObjSize_, /* 663 */ + TclSplitList_, /* 664 */ + TclSplitPath_, /* 665 */ + TclFSSplitPath_, /* 666 */ + TclParseArgsObjv_, /* 667 */ Tcl_UniCharLen, /* 668 */ TclNumUtfChars, /* 669 */ TclGetCharLength, /* 670 */ @@ -1972,10 +1983,10 @@ const TclStubs tclStubs = { TclGetUniChar, /* 673 */ Tcl_GetBool, /* 674 */ Tcl_GetBoolFromObj, /* 675 */ - 0, /* 676 */ - 0, /* 677 */ - 0, /* 678 */ - 0, /* 679 */ + Tcl_CreateObjCommand2, /* 676 */ + Tcl_CreateObjTrace2, /* 677 */ + Tcl_NRCreateCommand2, /* 678 */ + Tcl_NRCallObjProc2, /* 679 */ Tcl_GetNumberFromObj, /* 680 */ Tcl_GetNumber, /* 681 */ Tcl_RemoveChannelMode, /* 682 */ From 0c41a44c782e5c13f6aa1bca5f83dfb33ecd826b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Jan 2025 13:28:41 +0000 Subject: [PATCH 4/4] (Cherry-pick): [2bc08cd2e6] - document TCL_{LL,SIZE}_MODIFIER, Tcl_Size, TCL_SIZE_MAX --- doc/IntObj.3 | 10 ++++++++-- doc/StringObj.3 | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/IntObj.3 b/doc/IntObj.3 index 8386bc38974..6c493dd6505 100644 --- a/doc/IntObj.3 +++ b/doc/IntObj.3 @@ -8,7 +8,7 @@ .so man.macros .BS .SH NAME -Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_NewWideUIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_SetWideUIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers +Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_NewWideUIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_SetWideUIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetSizeIntFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers .SH SYNOPSIS .nf \fB#include \fR @@ -124,6 +124,11 @@ typedef defined to be whatever signed integral type covers at least the 64-bit integer range (-9223372036854775808 to 9223372036854775807). Depending on the platform and the C compiler, the actual type might be \fBlong long int\fR, or something else. +The \fBTcl_Size\fR typedef is a signed integer type +capable of holding the maximum permitted lengths of Tcl values like +strings and lists. Correspondingly, the preprocessor constant +\fBTCL_SIZE_MAX\fR defines the maximum value that can be stored +in a variable of this type. The \fBmp_int\fR type is a multiple-precision integer type defined by the LibTomMath multiple-precision integer library. .PP @@ -193,7 +198,8 @@ integer value in the \fBmp_int\fR value \fIbigValue\fR. arguments, but do require that the object be unshared. .PP \fBTcl_GetIntFromObj\fR, \fBTcl_GetIntForIndex\fR, \fBTcl_GetLongFromObj\fR, -\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and +\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetSizeIntFromObj\fR, +\fBTcl_GetBignumFromObj\fR, and \fBTcl_TakeBignumFromObj\fR do not modify the reference count of their \fIobjPtr\fR arguments; they only read. Note however that this function may set the interpreter result; if that is the only place that is holding a diff --git a/doc/StringObj.3 b/doc/StringObj.3 index a31ada65482..c0d9099d96c 100644 --- a/doc/StringObj.3 +++ b/doc/StringObj.3 @@ -19,8 +19,10 @@ Tcl_Obj * Tcl_Obj * \fBTcl_NewUnicodeObj\fR(\fIunicode, numChars\fR) .sp +void \fBTcl_SetStringObj\fR(\fIobjPtr, bytes, length\fR) .sp +void \fBTcl_SetUnicodeObj\fR(\fIobjPtr, unicode, numChars\fR) .sp char * @@ -44,16 +46,22 @@ int Tcl_Obj * \fBTcl_GetRange\fR(\fIobjPtr, first, last\fR) .sp +void \fBTcl_AppendToObj\fR(\fIobjPtr, bytes, length\fR) .sp +void \fBTcl_AppendUnicodeToObj\fR(\fIobjPtr, unicode, numChars\fR) .sp +void \fBTcl_AppendObjToObj\fR(\fIobjPtr, appendObjPtr\fR) .sp +void \fBTcl_AppendStringsToObj\fR(\fIobjPtr, string, string, ... \fB(char *)NULL\fR) .sp +void \fBTcl_AppendStringsToObjVA\fR(\fIobjPtr, argList\fR) .sp +void \fBTcl_AppendLimitedToObj\fR(\fIobjPtr, bytes, length, limit, ellipsis\fR) .sp Tcl_Obj * @@ -65,8 +73,10 @@ int Tcl_Obj * \fBTcl_ObjPrintf\fR(\fIformat, ...\fR) .sp +void \fBTcl_AppendPrintfToObj\fR(\fIobjPtr, format, ...\fR) .sp +void \fBTcl_SetObjLength\fR(\fIobjPtr, newLength\fR) .sp int @@ -349,6 +359,22 @@ Tcl_Obj *newPtr = \fBTcl_ObjPrintf\fR(format, ...); but with greater convenience and efficiency when the appending functionality is needed. .PP +When printing integer types defined by Tcl, such as \fBTcl_Size\fR +or \fBTcl_WideInt\fR, a format size specifier is needed as the +integer width of those types is dependent on the Tcl version, +platform and compiler. To accomodate these differences, Tcl defines +C preprocessor symbols \fBTCL_LL_MODIFER\fR and +\fBTCL_SIZE_MODIFER\fR for use when formatting values of type +\fBTcl_WideInt\fR and \fBTcl_Size\fR respectively. Their usage +is illustrated by +.PP +.CS +Tcl_WideInt wide; +Tcl_Size len; +Tcl_Obj *wideObj = Tcl_ObjPrintf("wide = %" \fBTCL_LL_MODIFIER\fR "d", wide); +Tcl_Obj *lenObj = Tcl_ObjPrintf("len = %" \fBTCL_SIZE_MODIFIER\fR "d", len); +.CE +.PP The \fBTcl_SetObjLength\fR procedure changes the length of the string value of its \fIobjPtr\fR argument. If the \fInewLength\fR argument is greater than the space allocated for the value's