diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-06-01 11:23:15 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-06-01 11:23:15 (GMT) |
commit | e9e2d96cf1a3a47f98f63bff0f1b2570a2e5b71d (patch) | |
tree | e08c1bcdbc61b667cda50e9af8fb3bf39b8f96d3 | |
parent | a88091c1bf14f254449273a9f864d8f09009fe67 (diff) | |
download | tcl-no_smartref.zip tcl-no_smartref.tar.gz tcl-no_smartref.tar.bz2 |
Attempt to get new clock code working without the need for smartref.no_smartref
-rw-r--r-- | generic/tclClock.c | 2 | ||||
-rw-r--r-- | generic/tclDictObj.c | 99 | ||||
-rw-r--r-- | generic/tclInt.h | 1 | ||||
-rw-r--r-- | library/clock.tcl | 11 |
4 files changed, 5 insertions, 108 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c index 95b3e36..4ebc7b6 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -637,7 +637,7 @@ ClockMCDict(ClockFmtScnCmdArgs *opts) /* be sure that object reference not increases (dict changeable) */ if (opts->mcDictObj->refCount > 0) { /* smart reference (shared dict as object with no ref-counter) */ - opts->mcDictObj = Tcl_DictObjSmartRef(opts->interp, opts->mcDictObj); + opts->mcDictObj = Tcl_DuplicateObj(opts->mcDictObj); } if ( opts->localeObj == dataPtr->CurrentLocale ) { Tcl_SetObjRef(dataPtr->CurrentLocaleDict, opts->mcDictObj); diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 593f5a3..87fb333 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -51,8 +51,6 @@ static int DictSetCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictSizeCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); -static int DictSmartRefCmd(ClientData dummy, Tcl_Interp *interp, - int objc, Tcl_Obj *const *objv); static int DictUnsetCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictUpdateCmd(ClientData dummy, Tcl_Interp *interp, @@ -100,7 +98,6 @@ static const EnsembleImplMap implementationMap[] = { {"replace", DictReplaceCmd, NULL, NULL, NULL, 0 }, {"set", DictSetCmd, TclCompileDictSetCmd, NULL, NULL, 0 }, {"size", DictSizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0 }, - {"smartref",DictSmartRefCmd,NULL, NULL, NULL, 0 }, {"unset", DictUnsetCmd, TclCompileDictUnsetCmd, NULL, NULL, 0 }, {"update", DictUpdateCmd, TclCompileDictUpdateCmd, NULL, NULL, 0 }, {"values", DictValuesCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0 }, @@ -1961,102 +1958,6 @@ DictSizeCmd( /* *---------------------------------------------------------------------- * - * Tcl_DictObjSmartRef -- - * - * This function returns new tcl-object with the smart reference to - * dictionary object. - * - * Object returned with this function is a smart reference (pointer), - * so new object of type tclDictType, that directly references given - * dictionary object (with internally increased refCount). - * - * The usage of such pointer objects allows to hold more as one - * reference to the same real dictionary object, allows to make a pointer - * to part of another dictionary, allows to change the dictionary without - * regarding of the "shared" state of the dictionary object. - * - * Prevents "called with shared object" exception if object is multiple - * referenced. - * - * Results: - * The newly create object (contains smart reference) is returned. - * The returned object has a ref count of 0. - * - * Side effects: - * Increases ref count of the referenced dictionary. - * - *---------------------------------------------------------------------- - */ - -Tcl_Obj * -Tcl_DictObjSmartRef( - Tcl_Interp *interp, - Tcl_Obj *dictPtr) -{ - Tcl_Obj *result; - Dict *dict; - - if (dictPtr->typePtr != &tclDictType - && SetDictFromAny(interp, dictPtr) != TCL_OK) { - return NULL; - } - - dict = DICT(dictPtr); - - result = Tcl_NewObj(); - DICT(result) = dict; - dict->refCount++; - result->internalRep.twoPtrValue.ptr2 = NULL; - result->typePtr = &tclDictType; - - return result; -} - -/* - *---------------------------------------------------------------------- - * - * DictSmartRefCmd -- - * - * This function implements the "dict smartref" Tcl command. - * - * See description of Tcl_DictObjSmartRef for details. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - -static int -DictSmartRefCmd( - ClientData dummy, - Tcl_Interp *interp, - int objc, - Tcl_Obj *const *objv) -{ - Tcl_Obj *result; - - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "dictionary"); - return TCL_ERROR; - } - - result = Tcl_DictObjSmartRef(interp, objv[1]); - if (result == NULL) { - return TCL_ERROR; - } - - Tcl_SetObjResult(interp, result); - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * * DictExistsCmd -- * * This function implements the "dict exists" Tcl command. See the user diff --git a/generic/tclInt.h b/generic/tclInt.h index 8edc518..759d8e7 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2884,7 +2884,6 @@ MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp, const char *dict, int dictLength, const char **elementPtr, const char **nextPtr, int *sizePtr, int *literalPtr); -MODULE_SCOPE Tcl_Obj * Tcl_DictObjSmartRef(Tcl_Interp *interp, Tcl_Obj *); /* TIP #280 - Modified token based evulation, with line information. */ MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script, int numBytes, int flags, int line, diff --git a/library/clock.tcl b/library/clock.tcl index 471deff..1222084 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -544,8 +544,7 @@ proc mcget {loc} { # try to retrieve now if already available: if {[dict exists $mcMergedCat $loc]} { - set mrgcat [dict get $mcMergedCat $loc] - return [dict smartref $mrgcat] + return [dict get $mcMergedCat $loc] } # get locales list for given locale (de_de -> {de_de de {}}) @@ -576,13 +575,12 @@ proc mcget {loc} { # locales List of locales to merge. # # Results: -# Returns the (weak pointer) to merged dictionary of message catalog. +# Returns the merged dictionary of message catalog. # proc mcMerge {locales} { variable mcMergedCat if {[dict exists $mcMergedCat [set loc [lindex $locales 0]]]} { - set mrgcat [dict get $mcMergedCat $loc] - return [dict smartref $mrgcat] + return [dict get $mcMergedCat $loc] } # package msgcat currently does not provide possibility to get whole catalog: upvar ::msgcat::Msgs Msgs @@ -601,8 +599,7 @@ proc mcMerge {locales} { } } dict set mcMergedCat $loc $mrgcat - # return smart reference (shared dict as object with exact one ref-counter) - return [dict smartref $mrgcat] + return $mrgcat } #---------------------------------------------------------------------- |