From 4391b633d94f7d36fc07107753bac88a29504488 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 11 Oct 2022 15:07:33 +0000 Subject: TIP 644 - Make Tcl_ObjType extensible --- generic/tcl.h | 5 +++++ generic/tclArithSeries.c | 3 ++- generic/tclAssembly.c | 3 ++- generic/tclBinary.c | 3 ++- generic/tclCompile.c | 4 +++- generic/tclDictObj.c | 3 ++- generic/tclDisassemble.c | 1 + generic/tclEncoding.c | 8 +++++++- generic/tclEnsemble.c | 3 ++- generic/tclExecute.c | 5 +++-- generic/tclIO.c | 3 ++- generic/tclIndexObj.c | 3 ++- generic/tclLink.c | 3 ++- generic/tclListObj.c | 3 ++- generic/tclNamesp.c | 3 ++- generic/tclOOCall.c | 3 ++- generic/tclObj.c | 15 ++++++++++----- generic/tclPathObj.c | 3 ++- generic/tclProc.c | 8 +++++--- generic/tclRegexp.c | 3 ++- generic/tclStringObj.c | 3 ++- generic/tclUtil.c | 3 ++- generic/tclVar.c | 4 ++-- 23 files changed, 66 insertions(+), 29 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 80494f3..f1d27ef 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -616,7 +616,12 @@ typedef struct Tcl_ObjType { /* Called to convert the object's internal rep * to this type. Frees the internal rep of the * old type. Returns TCL_ERROR on failure. */ + unsigned char version; } Tcl_ObjType; +#define TCL_OBJTYPE_V0 0 /* Pre-Tcl 9. Set to 0 so compiler will auto-init + * when existing code that does not init this field + * is compiled with Tcl9 headers */ +#define TCL_OBJTYPE_CURRENT TCL_OBJTYPE_V0 /* * The following structure stores an internal representation (internalrep) for diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index d88c8ed..65807c3 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -75,7 +75,8 @@ const Tcl_ObjType tclArithSeriesType = { FreeArithSeriesInternalRep, /* freeIntRepProc */ DupArithSeriesInternalRep, /* dupIntRepProc */ UpdateStringOfArithSeries, /* updateStringProc */ - SetArithSeriesFromAny /* setFromAnyProc */ + SetArithSeriesFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index b7bfd2d..9448162 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -325,7 +325,8 @@ static const Tcl_ObjType assembleCodeType = { FreeAssembleCodeInternalRep, /* freeIntRepProc */ DupAssembleCodeInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclBinary.c b/generic/tclBinary.c index a7d6617..7e2634c 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -162,7 +162,8 @@ static const Tcl_ObjType properByteArrayType = { FreeProperByteArrayInternalRep, DupProperByteArrayInternalRep, UpdateStringOfByteArray, - NULL + NULL, + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclCompile.c b/generic/tclCompile.c index a57743c..fc2b6b7 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -708,7 +708,8 @@ const Tcl_ObjType tclByteCodeType = { FreeByteCodeInternalRep, /* freeIntRepProc */ DupByteCodeInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - SetByteCodeFromAny /* setFromAnyProc */ + SetByteCodeFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* @@ -722,6 +723,7 @@ static const Tcl_ObjType substCodeType = { DupByteCodeInternalRep, /* dupIntRepProc - shared with bytecode */ NULL, /* updateStringProc */ NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define SubstFlags(objPtr) (objPtr)->internalRep.twoPtrValue.ptr2 diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index ca2501c..26f98e1 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -146,7 +146,8 @@ const Tcl_ObjType tclDictType = { FreeDictInternalRep, /* freeIntRepProc */ DupDictInternalRep, /* dupIntRepProc */ UpdateStringOfDict, /* updateStringProc */ - SetDictFromAny /* setFromAnyProc */ + SetDictFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define DictSetInternalRep(objPtr, dictRepPtr) \ diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 8fd90a3..9670b84 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -42,6 +42,7 @@ static const Tcl_ObjType instNameType = { NULL, /* dupIntRepProc */ UpdateStringOfInstName, /* updateStringProc */ NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0, }; #define InstNameSetInternalRep(objPtr, inst) \ diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index e366904..7e7c1a6 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -236,8 +236,14 @@ static Tcl_EncodingConvertProc Iso88591ToUtfProc; */ static const Tcl_ObjType encodingType = { - "encoding", FreeEncodingInternalRep, DupEncodingInternalRep, NULL, NULL + "encoding", + FreeEncodingInternalRep, + DupEncodingInternalRep, + NULL, + NULL, + TCL_OBJTYPE_V0, }; + #define EncodingSetInternalRep(objPtr, encoding) \ do { \ Tcl_ObjInternalRep ir; \ diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 8bb90da..44179cf 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -81,7 +81,8 @@ static const Tcl_ObjType ensembleCmdType = { FreeEnsembleCmdRep, /* freeIntRepProc */ DupEnsembleCmdRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define ECRSetInternalRep(objPtr, ecRepPtr) \ diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 4b9ed0d..2ec0337 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -663,7 +663,8 @@ static const Tcl_ObjType exprCodeType = { FreeExprCodeInternalRep, /* freeIntRepProc */ DupExprCodeInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* @@ -674,7 +675,7 @@ static const Tcl_ObjType exprCodeType = { static const Tcl_ObjType dictIteratorType = { "dictIterator", ReleaseDictIterator, - NULL, NULL, NULL + NULL, NULL, NULL, TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclIO.c b/generic/tclIO.c index 5f831c9..8d54045 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -332,7 +332,8 @@ static const Tcl_ObjType chanObjType = { FreeChannelInternalRep, /* freeIntRepProc */ DupChannelInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define ChanSetInternalRep(objPtr, resPtr) \ diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index aab7820..58bcc04 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -41,7 +41,8 @@ static const Tcl_ObjType indexType = { FreeIndex, /* freeIntRepProc */ DupIndex, /* dupIntRepProc */ UpdateStringOfIndex, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclLink.c b/generic/tclLink.c index 2649d12..d184700 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -114,7 +114,8 @@ static Tcl_ObjType invalidRealType = { NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 14f6132..06a316f 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -155,7 +155,8 @@ const Tcl_ObjType tclListType = { FreeListInternalRep, /* freeIntRepProc */ DupListInternalRep, /* dupIntRepProc */ UpdateStringOfList, /* updateStringProc */ - SetListFromAny /* setFromAnyProc */ + SetListFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* Macros to manipulate the List internal rep */ diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 979426c..1882e0a 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -130,7 +130,8 @@ static const Tcl_ObjType nsNameType = { FreeNsNameInternalRep, /* freeIntRepProc */ DupNsNameInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - SetNsNameFromAny /* setFromAnyProc */ + SetNsNameFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define NsNameSetInternalRep(objPtr, nnPtr) \ diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c index 912c368..450fc9f 100644 --- a/generic/tclOOCall.c +++ b/generic/tclOOCall.c @@ -150,7 +150,8 @@ static const Tcl_ObjType methodNameType = { FreeMethodNameRep, DupMethodNameRep, NULL, - NULL + NULL, + TCL_OBJTYPE_V0 }; diff --git a/generic/tclObj.c b/generic/tclObj.c index 5e55784..eeaa727 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -230,28 +230,32 @@ const Tcl_ObjType tclBooleanType = { NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ NULL, /* updateStringProc */ - TclSetBooleanFromAny /* setFromAnyProc */ + TclSetBooleanFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; const Tcl_ObjType tclDoubleType = { "double", /* name */ NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ UpdateStringOfDouble, /* updateStringProc */ - SetDoubleFromAny /* setFromAnyProc */ + SetDoubleFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; const Tcl_ObjType tclIntType = { "int", /* name */ NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ UpdateStringOfInt, /* updateStringProc */ - SetIntFromAny /* setFromAnyProc */ + SetIntFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; const Tcl_ObjType tclBignumType = { "bignum", /* name */ FreeBignum, /* freeIntRepProc */ DupBignum, /* dupIntRepProc */ UpdateStringOfBignum, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* @@ -295,7 +299,8 @@ Tcl_ObjType tclCmdNameType = { FreeCmdNameInternalRep, /* freeIntRepProc */ DupCmdNameInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - SetCmdNameFromAny /* setFromAnyProc */ + SetCmdNameFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 40955b1..17bbc46 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -41,7 +41,8 @@ static const Tcl_ObjType fsPathType = { FreeFsPathInternalRep, /* freeIntRepProc */ DupFsPathInternalRep, /* dupIntRepProc */ UpdateStringOfFsPath, /* updateStringProc */ - SetFsPathFromAny /* setFromAnyProc */ + SetFsPathFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclProc.c b/generic/tclProc.c index acb520c..a9baba2 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -63,8 +63,9 @@ const Tcl_ObjType tclProcBodyType = { NULL, /* UpdateString function; Tcl_GetString and * Tcl_GetStringFromObj should panic * instead. */ - NULL /* SetFromAny function; Tcl_ConvertToType + NULL, /* SetFromAny function; Tcl_ConvertToType * should panic instead. */ + TCL_OBJTYPE_V0 }; #define ProcSetIntRep(objPtr, procPtr) \ @@ -93,7 +94,7 @@ const Tcl_ObjType tclProcBodyType = { static const Tcl_ObjType levelReferenceType = { "levelReference", - NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, TCL_OBJTYPE_V0 }; /* @@ -110,7 +111,8 @@ static const Tcl_ObjType lambdaType = { FreeLambdaInternalRep, /* freeIntRepProc */ DupLambdaInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - SetLambdaFromAny /* setFromAnyProc */ + SetLambdaFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define LambdaSetIntRep(objPtr, procPtr, nsObjPtr) \ diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 5fe5412..259e3f7 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -106,7 +106,8 @@ const Tcl_ObjType tclRegexpType = { FreeRegexpInternalRep, /* freeIntRepProc */ DupRegexpInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ - SetRegexpFromAny /* setFromAnyProc */ + SetRegexpFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; #define RegexpSetInternalRep(objPtr, rePtr) \ diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index cf23aab..fb7e45a 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -90,7 +90,8 @@ const Tcl_ObjType tclStringType = { FreeStringInternalRep, /* freeIntRepPro */ DupStringInternalRep, /* dupIntRepProc */ UpdateStringOfString, /* updateStringProc */ - SetStringFromAny /* setFromAnyProc */ + SetStringFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 5870781..cdaa242 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -127,7 +127,8 @@ static const Tcl_ObjType endOffsetType = { NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ NULL, /* updateStringProc */ - NULL /* setFromAnyProc */ + NULL, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; /* diff --git a/generic/tclVar.c b/generic/tclVar.c index 337f923..6226e1e 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -245,7 +245,7 @@ static Tcl_DupInternalRepProc DupParsedVarName; static const Tcl_ObjType localVarNameType = { "localVarName", - FreeLocalVarName, DupLocalVarName, NULL, NULL + FreeLocalVarName, DupLocalVarName, NULL, NULL, TCL_OBJTYPE_V0 }; #define LocalSetInternalRep(objPtr, index, namePtr) \ @@ -268,7 +268,7 @@ static const Tcl_ObjType localVarNameType = { static const Tcl_ObjType parsedVarNameType = { "parsedVarName", - FreeParsedVarName, DupParsedVarName, NULL, NULL + FreeParsedVarName, DupParsedVarName, NULL, NULL, TCL_OBJTYPE_V0 }; #define ParsedSetInternalRep(objPtr, arrayPtr, elem) \ -- cgit v0.12 From c8a85bbc05960b91123999e18cdf1c872896dec7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 21 Oct 2022 09:01:36 +0000 Subject: Change version field to Tcl_ObjTypeVersion --- generic/tcl.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 4def1b3..3f54c6d 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -360,6 +360,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; typedef struct Tcl_Channel_ *Tcl_Channel; typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion; +typedef struct Tcl_ObjTypeVersion_ *Tcl_ObjTypeVersion; typedef struct Tcl_Command_ *Tcl_Command; typedef struct Tcl_Condition_ *Tcl_Condition; typedef struct Tcl_Dict_ *Tcl_Dict; @@ -616,11 +617,11 @@ typedef struct Tcl_ObjType { /* Called to convert the object's internal rep * to this type. Frees the internal rep of the * old type. Returns TCL_ERROR on failure. */ - unsigned char version; + Tcl_ObjTypeVersion version; } Tcl_ObjType; -#define TCL_OBJTYPE_V0 0 /* Pre-Tcl 9. Set to 0 so compiler will auto-init - * when existing code that does not init this field - * is compiled with Tcl9 headers */ +#define TCL_OBJTYPE_V0 ((Tcl_ObjTypeVersion)0) /* Pre-Tcl 9. Set to 0 so + * compiler will auto-init when existing code that does + * not init this field is compiled with Tcl9 headers */ #define TCL_OBJTYPE_CURRENT TCL_OBJTYPE_V0 /* -- cgit v0.12 From 50f633ff289fe9ff3f3c37defa42209ecd4e24ea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 9 Nov 2022 17:15:52 +0000 Subject: No trailing ',' --- generic/tclDisassemble.c | 2 +- generic/tclEncoding.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 66acade..57adcf0 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -42,7 +42,7 @@ static const Tcl_ObjType instNameType = { NULL, /* dupIntRepProc */ UpdateStringOfInstName, /* updateStringProc */ NULL, /* setFromAnyProc */ - TCL_OBJTYPE_V0, + TCL_OBJTYPE_V0 }; #define InstNameSetInternalRep(objPtr, inst) \ diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 455d7a6..76a936c 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -241,7 +241,7 @@ static const Tcl_ObjType encodingType = { DupEncodingInternalRep, NULL, NULL, - TCL_OBJTYPE_V0, + TCL_OBJTYPE_V0 }; #define EncodingSetInternalRep(objPtr, encoding) \ -- cgit v0.12 From 6065eb2868a1672cbc4285c8117db7cb451f239e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Nov 2022 11:20:02 +0000 Subject: Forgot one TCL_OBJTYPE_V0 --- macosx/tclMacOSXFCmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c index 020288f..71b98b5 100644 --- a/macosx/tclMacOSXFCmd.c +++ b/macosx/tclMacOSXFCmd.c @@ -88,7 +88,8 @@ static const Tcl_ObjType tclOSTypeType = { NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ UpdateStringOfOSType, /* updateStringProc */ - SetOSTypeFromAny /* setFromAnyProc */ + SetOSTypeFromAny, /* setFromAnyProc */ + TCL_OBJTYPE_V0 }; enum { -- cgit v0.12 From 7dc710b2f42b81cfac6a8e5b8a80f4acf35aee78 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Sun, 13 Nov 2022 06:37:55 +0000 Subject: Update Tcl_ObjType documentation --- doc/ObjectType.3 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ObjectType.3 b/doc/ObjectType.3 index 9f8d04f..3e6d0c2 100644 --- a/doc/ObjectType.3 +++ b/doc/ObjectType.3 @@ -109,6 +109,7 @@ typedef struct Tcl_ObjType { Tcl_DupInternalRepProc *\fIdupIntRepProc\fR; Tcl_UpdateStringProc *\fIupdateStringProc\fR; Tcl_SetFromAnyProc *\fIsetFromAnyProc\fR; + size_t \fIversion\fR; } \fBTcl_ObjType\fR; .CE .SS "THE NAME FIELD" @@ -253,6 +254,10 @@ Note that if a subsidiary value has its reference count reduced to zero during the running of a \fIfreeIntRepProc\fR, that value may be not freed immediately, in order to limit stack usage. However, the value will be freed before the outermost current \fBTcl_DecrRefCount\fR returns. +.SS "THE VERSION FIELD" +.PP +The \fIversion\fR member provides for future extensibility of the structure +and should be set to \fITCL_OBJTYPE_V0\fR. .SH "REFERENCE COUNT MANAGEMENT" .PP The \fIobjPtr\fR argument to \fBTcl_AppendAllObjTypes\fR should be an unshared -- cgit v0.12