summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-31 22:35:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-31 22:35:03 (GMT)
commitbe020c7aa5cc7dd88dba8e81b14e6201edf7d23d (patch)
tree4df07aa00ddcc5df3075572a5c7698135e33f024 /generic/tclBinary.c
parenta2a2ad30624a13d9d6b5e73b6a73a5bc735ba606 (diff)
parentd0613a05568e1c78a1c0f7e499a334089ec7809b (diff)
downloadtcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.zip
tcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.tar.gz
tcl-be020c7aa5cc7dd88dba8e81b14e6201edf7d23d.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c70
1 files changed, 16 insertions, 54 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 6760020..6b4a4f4 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -57,12 +57,9 @@
static void DupByteArrayInternalRep(Tcl_Obj *srcPtr,
Tcl_Obj *copyPtr);
-static void DupProperByteArrayInternalRep(Tcl_Obj *srcPtr,
- Tcl_Obj *copyPtr);
static int FormatNumber(Tcl_Interp *interp, int type,
Tcl_Obj *src, unsigned char **cursorPtr);
static void FreeByteArrayInternalRep(Tcl_Obj *objPtr);
-static void FreeProperByteArrayInternalRep(Tcl_Obj *objPtr);
static int GetFormatSpec(const char **formatPtr, char *cmdPtr,
int *countPtr, int *flagsPtr);
static Tcl_Obj * ScanNumber(unsigned char *buffer, int type,
@@ -248,10 +245,10 @@ static const EnsembleImplMap decodeMap[] = {
* over which bytearray values can be useful in the meanwhile.
*/
-static const Tcl_ObjType properByteArrayType = {
+const Tcl_ObjType tclPureByteArrayType = {
"bytearray",
- FreeProperByteArrayInternalRep,
- DupProperByteArrayInternalRep,
+ FreeByteArrayInternalRep,
+ DupByteArrayInternalRep,
UpdateStringOfByteArray,
NULL
};
@@ -287,13 +284,6 @@ typedef struct {
#define SET_BYTEARRAY(irPtr, baPtr) \
(irPtr)->twoPtrValue.ptr1 = (void *) (baPtr)
-int
-TclIsPureByteArray(
- Tcl_Obj * objPtr)
-{
- return objPtr->typePtr == &properByteArrayType;
-}
-
/*
*----------------------------------------------------------------------
*
@@ -420,7 +410,7 @@ Tcl_SetByteArrayObj(
}
SET_BYTEARRAY(&ir, byteArrayPtr);
- Tcl_StoreIntRep(objPtr, &properByteArrayType, &ir);
+ Tcl_StoreIntRep(objPtr, &tclPureByteArrayType, &ir);
}
/*
@@ -448,13 +438,13 @@ Tcl_GetByteArrayFromObj(
* array of bytes in the ByteArray object. */
{
ByteArray *baPtr;
- const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
@@ -502,12 +492,12 @@ Tcl_SetByteArrayLength(
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
}
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
@@ -553,7 +543,7 @@ SetByteArrayFromAny(
ByteArray *byteArrayPtr;
Tcl_ObjIntRep ir;
- if (objPtr->typePtr == &properByteArrayType) {
+ if (objPtr->typePtr == &tclPureByteArrayType) {
return TCL_OK;
}
if (objPtr->typePtr == &tclByteArrayType) {
@@ -577,7 +567,7 @@ SetByteArrayFromAny(
SET_BYTEARRAY(&ir, byteArrayPtr);
Tcl_StoreIntRep(objPtr,
- improper ? &tclByteArrayType : &properByteArrayType, &ir);
+ improper ? &tclByteArrayType : &tclPureByteArrayType, &ir);
return TCL_OK;
}
@@ -602,14 +592,7 @@ static void
FreeByteArrayInternalRep(
Tcl_Obj *objPtr) /* Object with internal rep to free. */
{
- Tcl_Free(GET_BYTEARRAY(TclFetchIntRep(objPtr, &tclByteArrayType)));
-}
-
-static void
-FreeProperByteArrayInternalRep(
- Tcl_Obj *objPtr) /* Object with internal rep to free. */
-{
- Tcl_Free(GET_BYTEARRAY(TclFetchIntRep(objPtr, &properByteArrayType)));
+ Tcl_Free(GET_BYTEARRAY(&(objPtr->internalRep)));
}
/*
@@ -638,28 +621,7 @@ DupByteArrayInternalRep(
ByteArray *srcArrayPtr, *copyArrayPtr;
Tcl_ObjIntRep ir;
- srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &tclByteArrayType));
- length = srcArrayPtr->used;
-
- copyArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
- copyArrayPtr->used = length;
- copyArrayPtr->allocated = length;
- memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
-
- SET_BYTEARRAY(&ir, copyArrayPtr);
- Tcl_StoreIntRep(copyPtr, &tclByteArrayType, &ir);
-}
-
-static void
-DupProperByteArrayInternalRep(
- Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
- Tcl_Obj *copyPtr) /* Object with internal rep to set. */
-{
- size_t length;
- ByteArray *srcArrayPtr, *copyArrayPtr;
- Tcl_ObjIntRep ir;
-
- srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &properByteArrayType));
+ srcArrayPtr = GET_BYTEARRAY(&(srcPtr->internalRep));
length = srcArrayPtr->used;
copyArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
@@ -668,7 +630,7 @@ DupProperByteArrayInternalRep(
memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
SET_BYTEARRAY(&ir, copyArrayPtr);
- Tcl_StoreIntRep(copyPtr, &properByteArrayType, &ir);
+ Tcl_StoreIntRep(copyPtr, srcPtr->typePtr, &ir);
}
/*
@@ -693,7 +655,7 @@ UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
- const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
ByteArray *byteArrayPtr = GET_BYTEARRAY(irPtr);
unsigned char *src = byteArrayPtr->bytes;
size_t i, length = byteArrayPtr->used;
@@ -763,12 +725,12 @@ TclAppendBytesToByteArray(
return;
}
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclPureByteArrayType);
if (irPtr == NULL) {
irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}