summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgriffin <briang42@easystreet.net>2022-12-21 06:59:38 (GMT)
committergriffin <briang42@easystreet.net>2022-12-21 06:59:38 (GMT)
commitbc3ff73062b718a3411ad95f90e0d55fed46ebd4 (patch)
tree4cc614c14e8355eee212f1192127026bb46b2d87
parenta3f8bc6993db508508f569ffc66150ce09a8a122 (diff)
downloadtcl-bc3ff73062b718a3411ad95f90e0d55fed46ebd4.zip
tcl-bc3ff73062b718a3411ad95f90e0d55fed46ebd4.tar.gz
tcl-bc3ff73062b718a3411ad95f90e0d55fed46ebd4.tar.bz2
Make as much abstract list implementation as possible internal.
Other code cleanup also.
-rw-r--r--generic/tcl.h46
-rwxr-xr-xgeneric/tclArithSeries.c178
-rw-r--r--generic/tclArithSeries.h45
-rw-r--r--generic/tclCmdIL.c1
-rw-r--r--generic/tclInt.h39
-rw-r--r--generic/tclListObj.c1
-rw-r--r--generic/tclTestABSList.c241
7 files changed, 305 insertions, 246 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 63be548..30ae8c7 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -738,52 +738,6 @@ typedef struct Tcl_Obj {
Tcl_ObjInternalRep internalRep; /* The internal representation: */
} Tcl_Obj;
-
-/*
- * Abstract List
- *
- * This structure provides the functions used in List operations to emulate a
- * List for AbstractList types.
- */
-
-
-#define Tcl_ObjTypeIndex(interp, objPtr, index, elemObjPtr) \
- (objPtr)->typePtr->indexProc((interp),(objPtr),(index),(elemObjPtr))
-#define Tcl_ObjTypeSlice(interp, objPtr, fromIdx, toIdx, newObjPtr) \
- (objPtr)->typePtr->sliceProc((interp),(objPtr),(fromIdx),(toIdx),(newObjPtr))
-#define Tcl_ObjTypeReverse(interp, objPtr, newObjPtr) \
- (objPtr)->typePtr->reverseProc((interp),(objPtr),(newObjPtr))
-#define Tcl_ObjTypeGetElements(interp, objPtr, objCPtr, objVPtr) \
- (objPtr)->typePtr->getElementsProc((interp),(objPtr),(objCPtr),(objVPtr))
-#define Tcl_ObjTypeSetElement(interp, objPtr, indexCount, indexArray, valueObj) \
- (objPtr)->typePtr->setElementProc((interp), (objPtr), (indexCount), (indexArray), (valueObj))
-#define Tcl_ObjTypeReplace(interp, objPtr, first, numToDelete, numToInsert, insertObjs) \
- (objPtr)->typePtr->replaceProc((interp), (objPtr), (first), (numToDelete), (numToInsert), (insertObjs))
-
-
-/*
- * Sets the storage used by the concrete abstract list type
- * Caller has to ensure type is AbstractList. Existing rep will be
- * overwritten so caller has to free previous rep if necessary.
- */
-static inline void Tcl_ObjSetConcreteRep(
- Tcl_Obj *objPtr, /* Object of type AbstractList */
- void *repPtr) /* New representation */
-{
- /* assert(objPtr->typePtr == &tclAbstractListType); */
- objPtr->internalRep.twoPtrValue.ptr1 = repPtr;
-}
-
-/*
- * Return the internal rep for the Obj.
- * Note: Caller is responsible for confirming and casting returned value.
- */
-static inline void* Tcl_ObjGetConcreteRep(
- Tcl_Obj *objPtr) /* Object of type AbstractList */
-{
- return objPtr->internalRep.twoPtrValue.ptr1;
-}
-
/*
*----------------------------------------------------------------------------
* The following definitions support Tcl's namespace facility. Note: the first
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c
index 4902158..3be6cad 100755
--- a/generic/tclArithSeries.c
+++ b/generic/tclArithSeries.c
@@ -13,15 +13,14 @@
#include <assert.h>
#include "tcl.h"
#include "tclInt.h"
-#include "tclArithSeries.h"
/*
- * The structure below defines the arithmetic series Tcl Obj Type by means of
- * procedures that can be invoked by generic object code.
+ * The structure below defines the arithmetic series Tcl object type
+ * by means of procedures that can be invoked by generic object code.
*
- * The arithmetic series object is a oTcl_AbstractList representing an interval
- * of an arithmetic series in constant space.
+ * The arithmetic series object is an AbstractList representing
+ * an interval of an arithmetic series in constant space.
*
* The arithmetic series is internally represented with three integers,
* *start*, *end*, and *step*, Where the length is calculated with
@@ -34,15 +33,37 @@
* else if RANGE < 0
* LEN is (((END-START)-1)/STEP) - 1
*
- * And where the list's I-th element is calculated
+ * And where an equivalent list's I-th element is calculated
* as:
*
- * LIST[i] = START+(STEP*i)
+ * LIST[i] = START + (STEP * i)
*
* Zero elements ranges, like in the case of START=10 END=10 STEP=1
* are valid and will be equivalent to the empty list.
*/
+/*
+ * The structure used for the ArithSeries internal representation.
+ * Note that the len can in theory be always computed by start,end,step
+ * but it's faster to cache it inside the internal representation.
+ */
+typedef struct {
+ Tcl_Size len;
+ Tcl_Obj **elements;
+ int isDouble;
+ Tcl_WideInt start;
+ Tcl_WideInt end;
+ Tcl_WideInt step;
+} ArithSeries;
+typedef struct {
+ Tcl_Size len;
+ Tcl_Obj **elements;
+ int isDouble;
+ double start;
+ double end;
+ double step;
+} ArithSeriesDbl;
+
static inline double ArithSeriesIndexDbl(ArithSeriesDbl *repPtr, Tcl_Size index)
{
return (repPtr->start + ((double)index * repPtr->step));
@@ -69,13 +90,14 @@ static Tcl_Obj *TclNewArithSeriesDbl(double start, double end,
static void DupArithSeriesRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr);
static void FreeArithSeriesRep(Tcl_Obj *arithSeriesObjPtr);
static void UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr);
+static int SetArithSeriesFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static Tcl_ObjType arithSeriesType = {
"arithseries", /* name */
FreeArithSeriesRep, /* freeIntRepProc */
DupArithSeriesRep, /* dupIntRepProc */
UpdateStringOfArithSeries, /* updateStringProc */
- NULL, /* setFromAnyProc */
+ SetArithSeriesFromAny, /* setFromAnyProc */
TCL_OBJTYPE_V1(
TclArithSeriesObjLength,
NULL,
@@ -103,7 +125,7 @@ static Tcl_ObjType arithSeriesType = {
*
* The length of the list generated by the given range,
* that may be zero.
- * The function returns -1 if the list is of length infiite.
+ * The function returns -1 if the list is of length infinite.
*
* Side effects:
*
@@ -149,8 +171,11 @@ DupArithSeriesRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)
/* Note: we do not have to be worry about existing internal rep because
copyPtr is supposed to be freshly initialized */
- Tcl_ObjSetConcreteRep(copyPtr, copyArithSeries);
- copyPtr->typePtr = srcPtr->typePtr;
+
+ Tcl_ObjInternalRep itr;
+ itr.twoPtrValue.ptr1 = copyArithSeries;
+ itr.twoPtrValue.ptr2 = NULL;
+ Tcl_StoreInternalRep(copyPtr, srcPtr->typePtr, &itr);
if (copyArithSeries->len > 0) {
Tcl_InvalidateStringRep(copyPtr);
} else {
@@ -217,8 +242,9 @@ TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_W
Tcl_ObjInternalRep itr;
ArithSeries *arithSeriesRepPtr;
+ TclNewObj(arithSeriesObj);
+
if (length <= 0) {
- TclNewObj(arithSeriesObj);
return arithSeriesObj;
}
@@ -230,9 +256,9 @@ TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_W
arithSeriesRepPtr->len = length;
arithSeriesRepPtr->elements = NULL;
- TclNewObj(arithSeriesObj);
+ itr.twoPtrValue.ptr1 = arithSeriesRepPtr;
+ itr.twoPtrValue.ptr2 = NULL;
Tcl_StoreInternalRep(arithSeriesObj, &arithSeriesType, &itr);
- Tcl_ObjSetConcreteRep(arithSeriesObj, arithSeriesRepPtr);
if (length > 0)
Tcl_InvalidateStringRep(arithSeriesObj);
@@ -266,8 +292,9 @@ TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len)
Tcl_ObjInternalRep itr;
ArithSeriesDbl *arithSeriesRepPtr;
+ TclNewObj(arithSeriesObj);
+
if (length <= 0) {
- TclNewObj(arithSeriesObj);
return arithSeriesObj;
}
@@ -279,9 +306,9 @@ TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len)
arithSeriesRepPtr->len = length;
arithSeriesRepPtr->elements = NULL;
- TclNewObj(arithSeriesObj);
+ itr.twoPtrValue.ptr1 = arithSeriesRepPtr;
+ itr.twoPtrValue.ptr2 = NULL;
Tcl_StoreInternalRep(arithSeriesObj, &arithSeriesType, &itr);
- Tcl_ObjSetConcreteRep(arithSeriesObj, arithSeriesRepPtr);
if (length > 0)
Tcl_InvalidateStringRep(arithSeriesObj);
@@ -294,7 +321,7 @@ TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len)
*
* assignNumber --
*
- * Create the approprite Tcl_Obj value for the given numeric values.
+ * Create the appropriate Tcl_Obj value for the given numeric values.
* Used locally only for decoding [lseq] numeric arguments.
* refcount = 0.
*
@@ -362,14 +389,14 @@ assignNumber(
int
TclNewArithSeriesObj(
- Tcl_Interp *interp, /* For error reporting */
- Tcl_Obj **arithSeriesObj, /* return value */
- int useDoubles, /* Promote values to double when true,
- * int otherwise */
- Tcl_Obj *startObj, /* First value in list */
- Tcl_Obj *endObj, /* Upper bound value of list */
- Tcl_Obj *stepObj, /* Increment amount */
- Tcl_Obj *lenObj) /* Number of elements */
+ Tcl_Interp *interp, /* For error reporting */
+ Tcl_Obj **arithSeriesObj, /* return value */
+ int useDoubles, /* Promote values to double when true,
+ ** int otherwise */
+ Tcl_Obj *startObj, /* First value in list */
+ Tcl_Obj *endObj, /* Upper bound value of list */
+ Tcl_Obj *stepObj, /* Increment amount */
+ Tcl_Obj *lenObj) /* Number of elements */
{
double dstart, dend, dstep;
Tcl_WideInt start, end, step;
@@ -390,7 +417,7 @@ TclNewArithSeriesObj(
}
if (dstep == 0) {
*arithSeriesObj = Tcl_NewObj();
- return TCL_OK;
+ return TCL_OK;
}
}
if (endObj) {
@@ -477,14 +504,14 @@ Tcl_Size TclArithSeriesObjLength(Tcl_Obj *arithSeriesObj)
* TclArithSeriesObjIndex --
*
* Returns the element with the specified index in the list
- * represented by the specified Arithmentic Sequence object.
+ * represented by the specified Arithmetic Sequence object.
* If the index is out of range, TCL_ERROR is returned,
* otherwise TCL_OK is returned and the integer value of the
* element is stored in *element.
*
* Results:
*
- * TCL_OK on succes, TCL_ERROR on index out of range.
+ * TCL_OK on success, TCL_ERROR on index out of range.
*
* Side Effects:
*
@@ -495,10 +522,10 @@ Tcl_Size TclArithSeriesObjLength(Tcl_Obj *arithSeriesObj)
int
TclArithSeriesObjIndex(
- Tcl_Interp *interp, /* Used for error reporting if not NULL. */
+ Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *arithSeriesPtr, /* List obj */
- Tcl_Size index, /* index to element of interest */
- Tcl_Obj **elemObj) /* Return value */
+ Tcl_Size index, /* index to element of interest */
+ Tcl_Obj **elemObj) /* Return value */
{
ArithSeries *arithSeriesRepPtr = (ArithSeries *)Tcl_ObjGetConcreteRep(arithSeriesPtr);
(void)interp; // quiet compiler
@@ -760,8 +787,33 @@ TclArithSeriesObjReverse(
}
/*
-** Handle ArithSeries GetElements call
-*/
+ *----------------------------------------------------------------------
+ *
+ * TclArithSeriesGetElements --
+ *
+ * This function returns an (objc,objv) array of the elements in a list
+ * object.
+ *
+ * Results:
+ * The return value is normally TCL_OK; in this case *objcPtr is set to
+ * the count of list elements and *objvPtr is set to a pointer to an
+ * array of (*objcPtr) pointers to each list element. If listPtr does not
+ * refer to an Abstract List object and the object can not be converted
+ * to one, TCL_ERROR is returned and an error message will be left in the
+ * interpreter's result if interp is not NULL.
+ *
+ * The objects referenced by the returned array should be treated as
+ * readonly and their ref counts are _not_ incremented; the caller must
+ * do that if it holds on to a reference. Furthermore, the pointer and
+ * length returned by this function may change as soon as any function is
+ * called on the list object; be careful about retaining the pointer in a
+ * local data structure.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
int
TclArithSeriesGetElements(
@@ -818,6 +870,34 @@ TclArithSeriesGetElements(
return TCL_OK;
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * UpdateStringOfArithSeries --
+ *
+ * Update the string representation for an arithseries object.
+ * Note: This procedure does not invalidate an existing old string rep
+ * so storage will be lost if this has not already been done.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The object's string is set to a valid string that results from
+ * the list-to-string conversion. This string will be empty if the
+ * list has no elements. The list internal representation
+ * should not be NULL and we assume it is not NULL.
+ *
+ * Notes:
+ * At the cost of overallocation it's possible to estimate
+ * the length of the string representation and make this procedure
+ * much faster. Because the programmer shouldn't expect the
+ * string conversion of a big arithmetic sequence to be fast
+ * this version takes more care of space than time.
+ *
+ *----------------------------------------------------------------------
+ */
+
static void
UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
{
@@ -862,6 +942,36 @@ UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
if (length > 0) arithSeriesObjPtr->bytes[length-1] = '\0';
arithSeriesObjPtr->length = length-1;
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * SetArithSeriesFromAny --
+ *
+ * The Arithmetic Series object is just an way to optimize
+ * Lists space complexity, so no one should try to convert
+ * a string to an Arithmetic Series object.
+ *
+ * This function is here just to populate the Type structure.
+ *
+ * Results:
+ *
+ * The result is always TCL_ERROR. But see Side Effects.
+ *
+ * Side effects:
+ *
+ * Tcl Panic if called.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+SetArithSeriesFromAny(
+ TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */
+ TCL_UNUSED(Tcl_Obj *)) /* The object to convert. */
+{
+ Tcl_Panic("SetArithSeriesFromAny: should never be called");
+ return TCL_ERROR;
+}
/*
* Local Variables:
diff --git a/generic/tclArithSeries.h b/generic/tclArithSeries.h
deleted file mode 100644
index a4428d6..0000000
--- a/generic/tclArithSeries.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * tclArithSeries.h --
- *
- * This file contains the ArithSeries concrete abstract list
- * implementation. It implements the inner workings of the lseq command.
- *
- * Copyright © 2022 Brian S. Griffin.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-/*
- * The structure used for the ArithSeries internal representation.
- * Note that the len can in theory be always computed by start,end,step
- * but it's faster to cache it inside the internal representation.
- */
-typedef struct {
- Tcl_Size len;
- Tcl_Obj **elements;
- int isDouble;
- Tcl_WideInt start;
- Tcl_WideInt end;
- Tcl_WideInt step;
-} ArithSeries;
-typedef struct {
- Tcl_Size len;
- Tcl_Obj **elements;
- int isDouble;
- double start;
- double end;
- double step;
-} ArithSeriesDbl;
-
-MODULE_SCOPE int TclNewArithSeriesObj(Tcl_Interp *interp, Tcl_Obj **arithSeriesPtr,
- int useDoubles, Tcl_Obj *startObj, Tcl_Obj *endObj,
- Tcl_Obj *stepObj, Tcl_Obj *lenObj);
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index d7f0d47..fd117e4 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -19,7 +19,6 @@
#include "tclInt.h"
#include "tclRegexp.h"
-#include "tclArithSeries.h"
#include "tclTomMath.h"
#include <math.h>
#include <assert.h>
diff --git a/generic/tclInt.h b/generic/tclInt.h
index a771443..93a9188 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -1098,6 +1098,42 @@ typedef struct ActiveInterpTrace {
MODULE_SCOPE size_t TclLengthOne(Tcl_Obj *);
+
+/*
+ * Abstract List
+ *
+ * This structure provides the functions used in List operations to emulate a
+ * List for AbstractList types.
+ */
+
+
+#define Tcl_ObjTypeLength(objPtr) (objPtr)->typePtr->lengthProc(objPtr)
+#define Tcl_ObjTypeIndex(interp, objPtr, index, elemObjPtr) \
+ (objPtr)->typePtr->indexProc((interp),(objPtr),(index),(elemObjPtr))
+#define Tcl_ObjTypeSlice(interp, objPtr, fromIdx, toIdx, newObjPtr) \
+ (objPtr)->typePtr->sliceProc((interp),(objPtr),(fromIdx),(toIdx),(newObjPtr))
+#define Tcl_ObjTypeReverse(interp, objPtr, newObjPtr) \
+ (objPtr)->typePtr->reverseProc((interp),(objPtr),(newObjPtr))
+#define Tcl_ObjTypeGetElements(interp, objPtr, objCPtr, objVPtr) \
+ (objPtr)->typePtr->getElementsProc((interp),(objPtr),(objCPtr),(objVPtr))
+#define Tcl_ObjTypeSetElement(interp, objPtr, indexCount, indexArray, valueObj) \
+ (objPtr)->typePtr->setElementProc((interp), (objPtr), (indexCount), (indexArray), (valueObj))
+#define Tcl_ObjTypeReplace(interp, objPtr, first, numToDelete, numToInsert, insertObjs) \
+ (objPtr)->typePtr->replaceProc((interp), (objPtr), (first), (numToDelete), (numToInsert), (insertObjs))
+#define Tcl_ObjTypeGetDouble(interp, objPtr, doublePtr) \
+ (objPtr)->typePtr->getDoubleProc((interp), (objPtr), (doublePtr))
+
+
+/*
+ * Return the internal rep for the Obj.
+ * Note: Caller is responsible for confirming and casting returned value.
+ */
+static inline void* Tcl_ObjGetConcreteRep(
+ Tcl_Obj *objPtr) /* Object of type AbstractList */
+{
+ return objPtr->internalRep.twoPtrValue.ptr1;
+}
+
/*
* The structure below defines an entry in the assocData hash table which is
* associated with an interpreter. The entry contains a pointer to a function
@@ -3264,6 +3300,9 @@ MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
MODULE_SCOPE Tcl_Obj * TclpTempFileName(void);
MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp,
Tcl_Obj* pathPtr);
+MODULE_SCOPE int TclNewArithSeriesObj(Tcl_Interp *interp, Tcl_Obj **arithSeriesPtr,
+ int useDoubles, Tcl_Obj *startObj, Tcl_Obj *endObj,
+ Tcl_Obj *stepObj, Tcl_Obj *lenObj);
MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep,
size_t len);
MODULE_SCOPE void TclpAlertNotifier(void *clientData);
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index dad5b99..c001230 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -12,7 +12,6 @@
#include <assert.h>
#include "tclInt.h"
#include "tclTomMath.h"
-#include "tclArithSeries.h"
/*
* TODO - memmove is fast. Measure at what size we should prefer memmove
diff --git a/generic/tclTestABSList.c b/generic/tclTestABSList.c
index 286ed0a..1593a85 100644
--- a/generic/tclTestABSList.c
+++ b/generic/tclTestABSList.c
@@ -58,193 +58,192 @@ typedef struct LString {
* AbstractList definition of an lstring type
*/
static const Tcl_ObjType lstringTypes[11] = {
- {
+ {/*0*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*1*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- NULL, /*default my_LStringObjLength,*/
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ NULL, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*2*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- NULL, /*default my_LStringObjIndex,*/
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
-
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ NULL, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*3*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- NULL, /*default my_LStringObjRange,*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ NULL, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*4*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- NULL, /*defaults my_LStringObjReverse,*/
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ NULL, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*5*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- NULL, /*default NULL / *my_LStringGetElements,*/
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ NULL, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*6*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ NULL, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*7*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ NULL, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*8*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- NULL, /*default my_LStringObjSetElem, / * use default update string */
- NULL, /*default my_LStringReplace*/
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*9*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- NULL, /*default my_LStringReplace*/
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
},
- {
+ {/*10*/
"lstring",
freeRep,
DupLStringRep,
UpdateStringOfLString,
NULL,
TCL_OBJTYPE_V1(
- my_LStringObjLength,
- NULL,
- my_LStringObjIndex,
- my_LStringObjRange,/*ObjRange*/
- my_LStringObjReverse,
- my_LStringGetElements,
- my_LStringObjSetElem, /* use default update string */
- my_LStringReplace,
- NULL)
+ my_LStringObjLength, /* Length */
+ NULL, /* RESERVED */
+ my_LStringObjIndex, /* Index */
+ my_LStringObjRange, /* Slice */
+ my_LStringObjReverse, /* Reverse */
+ my_LStringGetElements, /* GetElements */
+ my_LStringObjSetElem, /* SetElement */
+ my_LStringReplace, /* Replace */
+ NULL) /* getDouble */
}
};
@@ -344,8 +343,10 @@ DupLStringRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)
copyLString->string = (char*)Tcl_Alloc(srcLString->allocated);
strcpy(copyLString->string, srcLString->string);
copyLString->elements = NULL;
- Tcl_ObjSetConcreteRep(copyPtr,copyLString);
- copyPtr->typePtr = srcPtr->typePtr;
+ Tcl_ObjInternalRep itr;
+ itr.twoPtrValue.ptr1 = copyLString;
+ itr.twoPtrValue.ptr2 = NULL;
+ Tcl_StoreInternalRep(copyPtr, srcPtr->typePtr, &itr);
return;
}
@@ -459,8 +460,10 @@ static int my_LStringObjRange(
rangeRep->string[len] = 0;
rangeRep->elements = NULL;
rangeObj = Tcl_NewObj();
- rangeObj->typePtr = lstringObj->typePtr;
- Tcl_ObjSetConcreteRep(rangeObj, rangeRep);
+ Tcl_ObjInternalRep itr;
+ itr.twoPtrValue.ptr1 = rangeRep;
+ itr.twoPtrValue.ptr2 = NULL;
+ Tcl_StoreInternalRep(rangeObj, lstringObj->typePtr, &itr);
if (rangeRep->strlen > 0) {
Tcl_InvalidateStringRep(rangeObj);
} else {
@@ -511,8 +514,9 @@ my_LStringObjReverse(Tcl_Interp *interp, Tcl_Obj *srcObj, Tcl_Obj **newObjPtr)
*dstp-- = *srcp++;
}
revObj = Tcl_NewObj();
+ itr.twoPtrValue.ptr1 = revRep;
+ itr.twoPtrValue.ptr2 = NULL;
Tcl_StoreInternalRep(revObj, srcObj->typePtr, &itr);
- Tcl_ObjSetConcreteRep(revObj, revRep);
if (revRep->strlen > 0) {
Tcl_InvalidateStringRep(revObj);
} else {
@@ -710,10 +714,9 @@ my_NewLStringObj(
strcpy(lstringRepPtr->string, string);
lstringRepPtr->elements = NULL;
lstringPtr = Tcl_NewObj();
- itr.twoPtrValue.ptr1 = NULL;
+ itr.twoPtrValue.ptr1 = lstringRepPtr;
itr.twoPtrValue.ptr2 = NULL;
Tcl_StoreInternalRep(lstringPtr, lstringTypePtr, &itr);
- Tcl_ObjSetConcreteRep(lstringPtr, lstringRepPtr);
if (lstringRepPtr->strlen > 0) {
Tcl_InvalidateStringRep(lstringPtr);
} else {
@@ -755,7 +758,7 @@ freeRep(Tcl_Obj* lstringObj)
lstringRepPtr->elements = NULL;
}
Tcl_Free((char*)lstringRepPtr);
- Tcl_ObjSetConcreteRep(lstringObj, NULL);
+ lstringObj->internalRep.twoPtrValue.ptr1 = NULL;
}
/*