summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-10-27 01:04:33 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-10-27 01:04:33 (GMT)
commitb28e8c3bd12a7bf36eb2745b105c36901403b6c2 (patch)
tree72fe349a710c2bb642ef8a768a56c0ddb92768ed /generic
parent7ecdd17b4d021a420e4eb9996208dcdf54061703 (diff)
downloadtcl-b28e8c3bd12a7bf36eb2745b105c36901403b6c2.zip
tcl-b28e8c3bd12a7bf36eb2745b105c36901403b6c2.tar.gz
tcl-b28e8c3bd12a7bf36eb2745b105c36901403b6c2.tar.bz2
Draft implementation of TIP 506 - rebased to Tcl 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls14
-rw-r--r--generic/tcl.h30
-rw-r--r--generic/tclDecls.h20
-rw-r--r--generic/tclObj.c62
-rw-r--r--generic/tclStubInit.c3
5 files changed, 99 insertions, 30 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index dfcb822..8f6bd06 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -132,7 +132,7 @@ declare 28 {
declare 29 {
Tcl_Obj *Tcl_DuplicateObj(Tcl_Obj *objPtr)
}
-declare 30 {
+declare 30 {deprecated {Kept only for deployed refcounting macros}} {
void TclFreeObj(Tcl_Obj *objPtr)
}
declare 31 {
@@ -2346,6 +2346,18 @@ declare 635 {
unsigned char *data, size_t datalen, int copy)
}
+declare 636 {
+ void Tcl_IncrRefCount(Tcl_Obj *objPtr)
+}
+
+declare 637 {
+ void Tcl_DecrRefCount(Tcl_Obj *objPtr)
+}
+
+declare 638 {
+ int Tcl_IsShared(Tcl_Obj *objPtr)
+}
+
# ----- BASELINE -- FOR -- 8.7.0 ----- #
##############################################################################
diff --git a/generic/tcl.h b/generic/tcl.h
index 0971066..4e5c783 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -798,17 +798,6 @@ typedef struct Tcl_Obj {
} internalRep;
} Tcl_Obj;
-/*
- * Macros to increment and decrement a Tcl_Obj's reference count, and to test
- * whether an object is shared (i.e. has reference count > 1). Note: clients
- * should use Tcl_DecrRefCount() when they are finished using an object, and
- * should never call TclFreeObj() directly. TclFreeObj() is only defined and
- * made public in tcl.h to support Tcl_DecrRefCount's macro definition.
- */
-
-void Tcl_IncrRefCount(Tcl_Obj *objPtr);
-void Tcl_DecrRefCount(Tcl_Obj *objPtr);
-int Tcl_IsShared(Tcl_Obj *objPtr);
/*
*----------------------------------------------------------------------------
@@ -2482,28 +2471,15 @@ EXTERN int TclZipfs_AppHook(int *argc, char ***argv);
#endif /* !TCL_MEM_DEBUG */
#ifdef TCL_MEM_DEBUG
+# undef Tcl_IncrRefCount
# define Tcl_IncrRefCount(objPtr) \
Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
+# undef Tcl_DecrRefCount
# define Tcl_DecrRefCount(objPtr) \
Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
+# undef Tcl_IsShared
# define Tcl_IsShared(objPtr) \
Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
-#else
-# define Tcl_IncrRefCount(objPtr) \
- ++(objPtr)->refCount
- /*
- * Use do/while0 idiom for optimum correctness without compiler warnings.
- * http://c2.com/cgi/wiki?TrivialDoWhileLoop
- */
-# define Tcl_DecrRefCount(objPtr) \
- do { \
- Tcl_Obj *_objPtr = (objPtr); \
- if ((_objPtr)->refCount-- <= 1) { \
- TclFreeObj(_objPtr); \
- } \
- } while(0)
-# define Tcl_IsShared(objPtr) \
- ((objPtr)->refCount > 1)
#endif
/*
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index e20782e..b96eabf 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -143,7 +143,8 @@ EXTERN Tcl_Obj * Tcl_DbNewStringObj(const char *bytes, int length,
/* 29 */
EXTERN Tcl_Obj * Tcl_DuplicateObj(Tcl_Obj *objPtr);
/* 30 */
-EXTERN void TclFreeObj(Tcl_Obj *objPtr);
+TCL_DEPRECATED("Kept only for deployed refcounting macros")
+void TclFreeObj(Tcl_Obj *objPtr);
/* 31 */
EXTERN int Tcl_GetBoolean(Tcl_Interp *interp, const char *src,
int *boolPtr);
@@ -1875,6 +1876,12 @@ EXTERN Tcl_Obj * TclZipfs_TclLibrary(void);
EXTERN int TclZipfs_MountBuffer(Tcl_Interp *interp,
const char *mountPoint, unsigned char *data,
size_t datalen, int copy);
+/* 636 */
+EXTERN void Tcl_IncrRefCount(Tcl_Obj *objPtr);
+/* 637 */
+EXTERN void Tcl_DecrRefCount(Tcl_Obj *objPtr);
+/* 638 */
+EXTERN int Tcl_IsShared(Tcl_Obj *objPtr);
typedef struct {
const struct TclPlatStubs *tclPlatStubs;
@@ -1932,7 +1939,7 @@ typedef struct TclStubs {
Tcl_Obj * (*tcl_DbNewObj) (const char *file, int line); /* 27 */
Tcl_Obj * (*tcl_DbNewStringObj) (const char *bytes, int length, const char *file, int line); /* 28 */
Tcl_Obj * (*tcl_DuplicateObj) (Tcl_Obj *objPtr); /* 29 */
- void (*tclFreeObj) (Tcl_Obj *objPtr); /* 30 */
+ TCL_DEPRECATED_API("Kept only for deployed refcounting macros") void (*tclFreeObj) (Tcl_Obj *objPtr); /* 30 */
int (*tcl_GetBoolean) (Tcl_Interp *interp, const char *src, int *boolPtr); /* 31 */
int (*tcl_GetBooleanFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *boolPtr); /* 32 */
unsigned char * (*tcl_GetByteArrayFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 33 */
@@ -2546,6 +2553,9 @@ typedef struct TclStubs {
int (*tclZipfs_Unmount) (Tcl_Interp *interp, const char *mountPoint); /* 633 */
Tcl_Obj * (*tclZipfs_TclLibrary) (void); /* 634 */
int (*tclZipfs_MountBuffer) (Tcl_Interp *interp, const char *mountPoint, unsigned char *data, size_t datalen, int copy); /* 635 */
+ void (*tcl_IncrRefCount) (Tcl_Obj *objPtr); /* 636 */
+ void (*tcl_DecrRefCount) (Tcl_Obj *objPtr); /* 637 */
+ int (*tcl_IsShared) (Tcl_Obj *objPtr); /* 638 */
} TclStubs;
extern const TclStubs *tclStubsPtr;
@@ -3848,6 +3858,12 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tclZipfs_TclLibrary) /* 634 */
#define TclZipfs_MountBuffer \
(tclStubsPtr->tclZipfs_MountBuffer) /* 635 */
+#define Tcl_IncrRefCount \
+ (tclStubsPtr->tcl_IncrRefCount) /* 636 */
+#define Tcl_DecrRefCount \
+ (tclStubsPtr->tcl_DecrRefCount) /* 637 */
+#define Tcl_IsShared \
+ (tclStubsPtr->tcl_IsShared) /* 638 */
#endif /* defined(USE_TCL_STUBS) */
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 5a8ce3b..137bf8a 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -3658,6 +3658,68 @@ TclGetNumberFromObj(
/*
*----------------------------------------------------------------------
*
+ * Tcl_IncrRefCount --
+ *
+ * Increments the reference count of the object.
+ *
+ * Results:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Tcl_IncrRefCount(
+ Tcl_Obj *objPtr) /* The object we are registering a reference to. */
+{
+ ++(objPtr)->refCount;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_DecrRefCount --
+ *
+ * Decrements the reference count of the object.
+ *
+ * Results:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Tcl_DecrRefCount(
+ Tcl_Obj *objPtr) /* The object we are releasing a reference to. */
+{
+ if (objPtr->refCount-- <= 1) {
+ TclFreeObj(objPtr);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_IsShared --
+ *
+ * Tests if the object has a ref count greater than one.
+ *
+ * Results:
+ * Boolean value that is the result of the test.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+Tcl_IsShared(
+ Tcl_Obj *objPtr) /* The object to test for being shared. */
+{
+ return ((objPtr)->refCount > 1);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_DbIncrRefCount --
*
* This function is normally called when debugging: i.e., when
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 6a4eabc..ec087a4 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -1581,6 +1581,9 @@ const TclStubs tclStubs = {
TclZipfs_Unmount, /* 633 */
TclZipfs_TclLibrary, /* 634 */
TclZipfs_MountBuffer, /* 635 */
+ Tcl_IncrRefCount, /* 636 */
+ Tcl_DecrRefCount, /* 637 */
+ Tcl_IsShared, /* 638 */
};
/* !END!: Do not edit above this line. */