| ︙ | | | ︙ | |
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
|
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#undef Tcl_GetVar
const char *
Tcl_GetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY or TCL_LEAVE_ERR_MSG
* bits. */
{
Tcl_Obj *varNamePtr = Tcl_NewStringObj(varName, -1);
Tcl_Obj *resultPtr = Tcl_ObjGetVar2(interp, varNamePtr, NULL, flags);
TclDecrRefCount(varNamePtr);
if (resultPtr == NULL) {
return NULL;
}
return TclGetString(resultPtr);
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetVar2 --
*
* Return the value of a Tcl variable as a string, given a two-part name
|
>
>
|
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
|
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#ifndef TCL_NO_DEPRECATED
#undef Tcl_GetVar
const char *
Tcl_GetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. */
int flags) /* OR-ed combination of TCL_GLOBAL_ONLY,
* TCL_NAMESPACE_ONLY or TCL_LEAVE_ERR_MSG
* bits. */
{
Tcl_Obj *varNamePtr = Tcl_NewStringObj(varName, -1);
Tcl_Obj *resultPtr = Tcl_ObjGetVar2(interp, varNamePtr, NULL, flags);
TclDecrRefCount(varNamePtr);
if (resultPtr == NULL) {
return NULL;
}
return TclGetString(resultPtr);
}
#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
*
* Tcl_GetVar2 --
*
* Return the value of a Tcl variable as a string, given a two-part name
|
| ︙ | | | ︙ | |
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
|
* If varName is defined as a local or global variable in interp, its
* value is changed to newValue. If varName isn't currently defined, then
* a new global variable by that name is created.
*
*----------------------------------------------------------------------
*/
#undef Tcl_SetVar
const char *
Tcl_SetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. */
const char *newValue, /* New value for varName. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT,
* TCL_LEAVE_ERR_MSG. */
{
Tcl_Obj *varValuePtr, *varNamePtr = Tcl_NewStringObj(varName, -1);
Tcl_IncrRefCount(varNamePtr);
varValuePtr = Tcl_ObjSetVar2(interp, varNamePtr, NULL,
Tcl_NewStringObj(newValue, -1), flags);
Tcl_DecrRefCount(varNamePtr);
if (varValuePtr == NULL) {
return NULL;
}
return TclGetString(varValuePtr);
}
/*
*----------------------------------------------------------------------
*
* Tcl_SetVar2 --
*
* Given a two-part variable name, which may refer either to a scalar
|
>
<
|
<
<
<
>
|
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
|
* If varName is defined as a local or global variable in interp, its
* value is changed to newValue. If varName isn't currently defined, then
* a new global variable by that name is created.
*
*----------------------------------------------------------------------
*/
#ifndef TCL_NO_DEPRECATED
#undef Tcl_SetVar
const char *
Tcl_SetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. */
const char *newValue, /* New value for varName. */
int flags) /* Various flags that tell how to set value:
* any of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY,
* TCL_APPEND_VALUE, TCL_LIST_ELEMENT,
* TCL_LEAVE_ERR_MSG. */
{
Tcl_Obj *varValuePtr = Tcl_SetVar2Ex(interp, varName, NULL,
Tcl_NewStringObj(newValue, -1), flags);
if (varValuePtr == NULL) {
return NULL;
}
return TclGetString(varValuePtr);
}
#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
*
* Tcl_SetVar2 --
*
* Given a two-part variable name, which may refer either to a scalar
|
| ︙ | | | ︙ | |
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
|
* Side effects:
* If varName is defined as a local or global variable in interp, it is
* deleted.
*
*----------------------------------------------------------------------
*/
#undef Tcl_UnsetVar
int
Tcl_UnsetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. May be either
* a scalar name or an array name or an
|
>
|
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
|
* Side effects:
* If varName is defined as a local or global variable in interp, it is
* deleted.
*
*----------------------------------------------------------------------
*/
#ifndef TCL_NO_DEPRECATED
#undef Tcl_UnsetVar
int
Tcl_UnsetVar(
Tcl_Interp *interp, /* Command interpreter in which varName is to
* be looked up. */
const char *varName, /* Name of a variable in interp. May be either
* a scalar name or an array name or an
|
| ︙ | | | ︙ | |
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
|
flags &= (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG);
result = TclObjUnsetVar2(interp, varNamePtr, NULL, flags);
Tcl_DecrRefCount(varNamePtr);
return result;
}
/*
*----------------------------------------------------------------------
*
* Tcl_UnsetVar2 --
*
* Delete a variable, given a 2-part name.
|
>
|
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
|
flags &= (TCL_GLOBAL_ONLY|TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG);
result = TclObjUnsetVar2(interp, varNamePtr, NULL, flags);
Tcl_DecrRefCount(varNamePtr);
return result;
}
#endif /* TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
*
* Tcl_UnsetVar2 --
*
* Delete a variable, given a 2-part name.
|
| ︙ | | | ︙ | |
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
|
* ObjMakeUpvar --
*
* This function does all of the work of the "global" and "upvar"
* commands.
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
* message is left in iPtr->result.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
* given by otherP1 and otherP2, so that references to myName are
* redirected to the other variable like a symbolic link.
* Callers must Incr myNamePtr if they plan to Decr it.
* Callers must Incr otherP1Ptr if they plan to Decr it.
|
|
|
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
|
* ObjMakeUpvar --
*
* This function does all of the work of the "global" and "upvar"
* commands.
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
* message is left in interp.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
* given by otherP1 and otherP2, so that references to myName are
* redirected to the other variable like a symbolic link.
* Callers must Incr myNamePtr if they plan to Decr it.
* Callers must Incr otherP1Ptr if they plan to Decr it.
|
| ︙ | | | ︙ | |
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
|
* TclPtrMakeUpvar --
*
* This procedure does all of the work of the "global" and "upvar"
* commands.
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
* message is left in iPtr->result.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
* given by otherP1 and otherP2, so that references to myName are
* redirected to the other variable like a symbolic link.
*
*----------------------------------------------------------------------
|
|
|
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
|
* TclPtrMakeUpvar --
*
* This procedure does all of the work of the "global" and "upvar"
* commands.
*
* Results:
* A standard Tcl completion code. If an error occurs then an error
* message is left in interp.
*
* Side effects:
* The variable given by myName is linked to the variable in framePtr
* given by otherP1 and otherP2, so that references to myName are
* redirected to the other variable like a symbolic link.
*
*----------------------------------------------------------------------
|
| ︙ | | | ︙ | |