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.
C Symbol | Name |
---|---|
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] } }
DKF: Don't forget to list the types defined by Tk as well. And you might want to check for platform-specific types too.