summaryrefslogtreecommitdiffstats
path: root/generic/tclTestObj.c
diff options
context:
space:
mode:
authorhershey <hershey>1999-06-08 02:59:23 (GMT)
committerhershey <hershey>1999-06-08 02:59:23 (GMT)
commit0e53e351cd3c0bdf51b84e459262c47f913c9a97 (patch)
tree87cee8e23f1c9f621f583c5d97e3e62979935fa9 /generic/tclTestObj.c
parentb2759d9c544b22071eca46475d110812304e8faa (diff)
downloadtcl-0e53e351cd3c0bdf51b84e459262c47f913c9a97.zip
tcl-0e53e351cd3c0bdf51b84e459262c47f913c9a97.tar.gz
tcl-0e53e351cd3c0bdf51b84e459262c47f913c9a97.tar.bz2
* tests/string.test:
* generic/tclVar.c (Tcl_SetVar2Ex): * generic/tclStringObj.c (Tcl_AppendObjToObj): * generic/tclCmdMZ.c (Tcl_StringObjCmd): optimized the string index, string length, string range, and append command in cases where the object's internal rep is a bytearray. Objects with other internal reps are converted to have the new unicode internal rep. * unix/Makefile.in: * win/Makefile.in: * win/Makefile.vc: * tests/unicode.test: * generic/tclInt.h: * generic/tclObj.c: * generic/tclUnicodeObj.c: added a new object type to store the unicode representation of a string. * generic/tclTestObj.c: added the objtype option to the testobj command. This option returns the name of the type of internal rep an object has.
Diffstat (limited to 'generic/tclTestObj.c')
-rw-r--r--generic/tclTestObj.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index d604c5b..533b967 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -7,11 +7,12 @@
* applications; they're only used for testing.
*
* Copyright (c) 1995-1998 Sun Microsystems, Inc.
+ * Copyright (c) 1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTestObj.c,v 1.3 1999/04/16 00:46:54 stanton Exp $
+ * RCS: @(#) $Id: tclTestObj.c,v 1.4 1999/06/08 02:59:26 hershey Exp $
*/
#include "tclInt.h"
@@ -774,6 +775,23 @@ TestobjCmd(clientData, interp, objc, objv)
}
SetVarToObj(varIndex, Tcl_NewObj());
Tcl_SetObjResult(interp, varPtr[varIndex]);
+ } else if (strcmp(subCmd, "objtype") == 0) {
+ char *typeName;
+
+ /*
+ * return an object containing the name of the argument's type
+ * of internal rep. If none exists, return "none".
+ */
+
+ if (objc != 3) {
+ goto wrongNumArgs;
+ }
+ if (objv[2]->typePtr == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
+ } else {
+ typeName = objv[2]->typePtr->name;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(typeName, -1));
+ }
} else if (strcmp(subCmd, "refcount") == 0) {
char buf[TCL_INTEGER_SPACE];
@@ -810,7 +828,8 @@ TestobjCmd(clientData, interp, objc, objv)
if (objc != 2) {
goto wrongNumArgs;
}
- if (Tcl_AppendAllObjTypes(interp, Tcl_GetObjResult(interp)) != TCL_OK) {
+ if (Tcl_AppendAllObjTypes(interp,
+ Tcl_GetObjResult(interp)) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -818,7 +837,7 @@ TestobjCmd(clientData, interp, objc, objv)
"bad option \"",
Tcl_GetString(objv[1]),
"\": must be assign, convert, duplicate, freeallvars, ",
- "newobj, objcount, refcount, type, or types",
+ "newobj, objcount, objtype, refcount, type, or types",
(char *) NULL);
return TCL_ERROR;
}