Version 5 of Tcl_Obj types list

Updated 2004-02-18 12:24:21

SS Feb162004 - In the process of writing the GC for the references package, I needed to know what Tcl_Obj types aren't able to represent a valid reference. Numerical types are an example, but I wanted the full list of types defined inside the core. To reach the goal I wrote the little script at the end of the page, that I hope is sane enough to provide the full list.

This is the list of types defined in the .c and .h files under the /generic directory. For every type there is the C symbol name, and the name to pass to the Tcl_GetObjType function to get the pointer to the type stucture.

 tclByteArrayType     "bytearray"
 tclByteCodeType      "bytecode"
 tclDictType          "dict"
 tclIndexType         "index"
 tclListType          "list"
 tclNsNameType        "nsName"
 tclEnsembleCmdType   "ensembleCommand"
 tclBooleanType       "boolean"
 tclDoubleType        "double"
 tclIntType           "int"
 tclWideIntType       "wideInt"
 tclCmdNameType       "cmdName"
 tclFsPathType        "path"
 tclProcBodyType      "procbody"
 tclRegexpType        "regexp"
 tclStringType        "string"
 tclLocalVarNameType  "localVarName"
 tclNsVarNameType     "namespaceVarName"
 tclParsedVarNameType "parsedVarName"

The following is the script used to get the list. Please report any bug of the script, or additional types defined in well known Tcl extensions!

 set files [glob {/home/antirez/SVC/tcltk/CVS/tcl/generic/*.[ch]}]
 append re {Tcl_ObjType\s+([A-z]+?)\s+=\s+}
 append re \{
 append re {\s+"([A-z]+?)"}
 foreach f $files {
     set fd [open $f]
     set text [read $fd]
     close $fd
     set types [regexp -all -inline $re $text]
     foreach {- cname name} $types {
        puts [format "%-20.20s \"%s\"" $cname $name]
     }
 }

DGP 2004 Feb 16 It would be more useful to list these Tcl_ObjTypes according to their name; that is, the string you would pass to Tcl_GetObjType() to retrieve the Tcl_ObjType stucture. SS 2004 Feb 18 yep, done.