|
2001-04-17
| ||
| 04:54 | • Ticket [218574ffff] Tcl_ObjGetVar2 and Tcl_ObjSetVar2 status still Closed wi... artifact: c6c25c78cc user: dgp | |
|
2000-10-26
| ||
| 08:24 | • Closed ticket [218574ffff]. artifact: 513524f4d0 user: welch | |
| 01:02 | • New ticket [218574ffff]. artifact: 04d2a7b96e user: nobody | |
Tcl_ObjGetVar2 and Tcl_ObjSetVar2
Closed / Fixed218574ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:02:37
OriginalBugID: 1263 RFE
Version: 8.1b1
SubmitDate: '1999-02-23'
LastModified: '1999-03-17'
Severity: LOW
Status: Released
Submitter: pat
ChangedBy: stanton
OS: Other
Machine: NA
FixedDate: '1999-03-17'
FixedInVersion: 8.1b2
ClosedDate: '2000-10-25'
Name:
Kevin B. Kenny
CVS:
* RCS: @(#) $Id: tclVar.c,v 1.1.2.3 1998/11/06 21:51:57 stanton Exp $
DesiredBehavior:
It seems a bit gratuitous to eliminate Tcl_ObjGetVar2 and Tcl_ObjSetVar2 from
Tcl 8.1. Since Tcl strings are once again null terminated (with UTF-8 used
to represent embedded multibyte characters that contain nulls), it would appear
safe to implement them as straightforward wrappers around the new
Tcl_GetObjVar2 and Tcl_SetObjVar2 functions. That change would avoid breaking
a fair amount of existing code.
Patch:
I've just been adding the following in a separate source file so as not
to hack up the Tcl core. It should probably go in tclVar.c, and of course
the functions should go back into tcl.h.
/*
* Tcl_ObjSetVar2 --
*
*Given a two-part variable name, which may refer to either a scalar
*variable or an element of an array, change the value of the variable
*to a new Tcl object value. If the named scalar or array element
*doesn't exist, then create it.
*
* Results:
*Returns a pointer to the Tcl_Obj structure that holds the new
*value of the variable. If the write operation was disallowed
*because an array was expected but a scalar was found (or vice
*versa), or because a write trace failed, then NULL is returned.
*If the TCL_LEAVE_ERR_MSG flag is set, then an explanatory message
*is left in the interpreter's result. Note that the returned object
*may not be the same one that was passed in newValuePtr, nor need
*it have the same value; write traces could have modified the
*value of the variable before Tcl_ObjSetVar2 returns.
*
* Side effects:
*The value of the variable is set. If either the array or the
*entry didn't exist, then a new variable is created.
*
* This function is simply a wrapper around Tcl_SetObjVar2, provided
* for compatibility with Tcl 8.0.
*
*----------------------------------------------------------------------
*/
Tcl_Obj*
Tcl_ObjSetVar2( interp, part1Ptr, part2Ptr, newValuePtr, flags )
Tcl_Interp* interp;/* Tcl interpreter */
Tcl_Obj* part1Ptr;/* Part 1 of the variable name */
Tcl_Obj* part2Ptr;/* Part 2 of the variable name */
Tcl_Obj* newValuePtr;/* New value of the variable */
int flags;/* OR-ed combination of bits providing
* additional information for the operation. */
{
return Tcl_SetObjVar2( interp,
Tcl_GetString( part1Ptr ),
Tcl_GetString( part2Ptr ),
newValuePtr,
flags );
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetObjVar2 --
*
*Return the value of a Tcl variable as a Tcl object, given a
*two-part name consisting of array name and element within array.
*
* Results:
*The return value points to the current object value of the variable
*given by part1Ptr and part2Ptr. If the specified variable doesn't
*exist, or if there is a clash in array usage, then NULL is returned
*and a message will be left in the interpreter's result if the
*TCL_LEAVE_ERR_MSG flag is set.
*
* Side effects:
*The ref count for the returned object is _not_ incremented to
*reflect the returned reference; if you want to keep a reference to
*the object you must increment its ref count yourself.
*
*----------------------------------------------------------------------
*/
Tcl_Obj*
Tcl_ObjGetVar2( interp, part1Ptr, part2Ptr, flags )
Tcl_Interp* interp;/* Tcl interpreter */
Tcl_Obj* part1;/* Name of the array or variable */
Tcl_Obj* part2;/* Subscript in the array, or NULL */
int flags;/* OR-ed combination of bits providing
* additional information for the operation. */
{
return Tcl_GetObjVar2( interp,
Tcl_GetString( part1Ptr ),
Tcl_GetString( part2Ptr ),
flags );
}
03/17/1999 17:50 - stanton - Obj*Var2 interfaces were added back to 8.1b2
welch Closed ticket [218574ffff].
[History diff]2000-10-26 08:24:15
dgp Ticket [218574ffff]: 3 changes
[History diff]2001-04-17 04:54:28
Log in (anonymous is fine) to add a comment.