From cb37c28cf9df9a8ebdca318c7f03f697e5b5ee7d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 23 Apr 2013 10:39:33 +0000 Subject: Implement Tcl_NewBooleanObj, Tcl_DbNewBooleanObj and Tcl_SetBooleanObj as macros using Tcl_NewIntObj, Tcl_DbNewLongObj and Tcl_SetIntObj. Starting with Tcl 8.5, this is exactly the same, it only eliminates code duplication. --- ChangeLog | 7 +++++++ generic/tclDecls.h | 11 ++++++++++- generic/tclObj.c | 10 ++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d74b73c..6b520e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-04-23 Jan Nijtmans + + * generic/tclDecls.h: Implement Tcl_NewBooleanObj, Tcl_DbNewBooleanObj + and Tcl_SetBooleanObj as macros using Tcl_NewIntObj, Tcl_DbNewLongObj + and Tcl_SetIntObj. Starting with Tcl 8.5, this is exactly the same, + it only eliminates code duplication. + 2013-04-19 Jan Nijtmans * generic/tclDecls.h: Implement many Tcl_*Var* functions and diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 30e305b..77402f8 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -6560,6 +6560,15 @@ extern TclStubs *tclStubsPtr; #define Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr) \ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, \ sizeof(char *), msg, flags, indexPtr) +#undef Tcl_NewBooleanObj +#define Tcl_NewBooleanObj(boolValue) \ + Tcl_NewIntObj((boolValue)!=0) +#undef Tcl_DbNewBooleanObj +#define Tcl_DbNewBooleanObj(boolValue, file, line) \ + Tcl_DbNewLongObj((boolValue)!=0, file, line) +#undef Tcl_SetBooleanObj +#define Tcl_SetBooleanObj(objPtr, boolValue) \ + Tcl_SetIntObj((objPtr), (boolValue)!=0) #undef Tcl_SetVar #define Tcl_SetVar(interp, varName, newValue, flags) \ Tcl_SetVar2(interp, varName, NULL, newValue, flags) @@ -6585,6 +6594,7 @@ extern TclStubs *tclStubsPtr; /* * Deprecated Tcl procedures: */ + #undef Tcl_EvalObj #define Tcl_EvalObj(interp,objPtr) \ Tcl_EvalObjEx((interp),(objPtr),0) @@ -6593,4 +6603,3 @@ extern TclStubs *tclStubsPtr; Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL) #endif /* _TCLDECLS */ - diff --git a/generic/tclObj.c b/generic/tclObj.c index 96a4082..fb09a9e 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -1700,14 +1700,14 @@ Tcl_InvalidateStringRep( *---------------------------------------------------------------------- */ -#ifdef TCL_MEM_DEBUG #undef Tcl_NewBooleanObj +#ifdef TCL_MEM_DEBUG Tcl_Obj * Tcl_NewBooleanObj( register int boolValue) /* Boolean used to initialize new object. */ { - return Tcl_DbNewBooleanObj(boolValue, "unknown", 0); + return Tcl_DbNewLongObj(boolValue!=0, "unknown", 0); } #else /* if not TCL_MEM_DEBUG */ @@ -1718,7 +1718,7 @@ Tcl_NewBooleanObj( { register Tcl_Obj *objPtr; - TclNewBooleanObj(objPtr, boolValue); + TclNewIntObj(objPtr, boolValue!=0); return objPtr; } #endif /* TCL_MEM_DEBUG */ @@ -1749,6 +1749,7 @@ Tcl_NewBooleanObj( *---------------------------------------------------------------------- */ +#undef Tcl_DbNewBooleanObj #ifdef TCL_MEM_DEBUG Tcl_Obj * @@ -1801,6 +1802,7 @@ Tcl_DbNewBooleanObj( *---------------------------------------------------------------------- */ +#undef Tcl_SetBooleanObj void Tcl_SetBooleanObj( register Tcl_Obj *objPtr, /* Object whose internal rep to init. */ @@ -1810,7 +1812,7 @@ Tcl_SetBooleanObj( Tcl_Panic("%s called with shared object", "Tcl_SetBooleanObj"); } - TclSetBooleanObj(objPtr, boolValue); + TclSetIntObj(objPtr, boolValue!=0); } /* -- cgit v0.12