Index: generic/gentclAPI.tcl =================================================================== diff -u -r9d1dfb6417294dbdc13ce4d249931055f7bd5ef8 -r40299a6ff3b3631f275f5f0ba4f90cbdb675d70b --- generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 9d1dfb6417294dbdc13ce4d249931055f7bd5ef8) +++ generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 40299a6ff3b3631f275f5f0ba4f90cbdb675d70b) @@ -42,25 +42,43 @@ return $name } -proc createconverter {type typename} { +proc createconverter {type typename isGlobal} { set name [convertername $type $typename] if {[info exists ::createdConverter($name)]} { return "" } set domain [split $type |] - set opts "static const char *opts\[\] = {\"[join $domain {", "}]\", NULL};" + + set localOpts [set globalOpts ""] + + if {!$isGlobal} { + set storageClass "static " + set optsName "opts" + set scope "localOpts" + } else { + set storageClass "" + set optsName "Nsf_${name}" + set scope "globalOpts" + } + set $scope "${storageClass}const char *$optsName\[\] = {\"[join $domain {", "}]\", NULL};" set ::createdConverter($name) "ConvertTo${name}, \"$type\"" + set enums [list ${name}NULL] foreach d $domain {lappend enums $name[string totitle [string map [list - _] $d]]Idx} - subst { -typedef enum {[join $enums {, }]} ${name}Idx_t; + set enums [join $enums {, }] -static int ConvertTo${name}(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, + set bindings [list @enums@ $enums @name@ $name @globalOpts@ $globalOpts \ + @localOpts@ $localOpts @optsName@ $optsName @typeName@ $typename] + + string map $bindings { +typedef enum {@enums@} @name@Idx_t; +@globalOpts@ +static int ConvertTo@name@(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { int index, result; - $opts + @localOpts@ (void)pPtr; - result = Tcl_GetIndexFromObj(interp, objPtr, opts, "$typename", 0, &index); + result = Tcl_GetIndexFromObj(interp, objPtr, @optsName@, "@typeName@", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); *outObjPtr = objPtr; return result; @@ -79,6 +97,7 @@ foreach parameterDefinition $parameterDefinitions { array unset "" array set "" {-flags 0} + array set "" {-global 0} array set "" $parameterDefinition switch $(-type) { "" {set type NULL} @@ -104,7 +123,7 @@ *|* { if {![info exists (-typeName)]} {set (-typeName) $(-argName)} set converter [convertername $type $(-typeName)] - append ::converter [createconverter $type $(-typeName)] + append ::converter [createconverter $type $(-typeName) $(-global)] addFlags flags "NSF_ARG_IS_ENUMERATION" } default { Index: generic/nsfAPI.decls =================================================================== diff -u -red88632709d9a9aa87619b5bc4d68e57d8b47d8d -r40299a6ff3b3631f275f5f0ba4f90cbdb675d70b --- generic/nsfAPI.decls (.../nsfAPI.decls) (revision ed88632709d9a9aa87619b5bc4d68e57d8b47d8d) +++ generic/nsfAPI.decls (.../nsfAPI.decls) (revision 40299a6ff3b3631f275f5f0ba4f90cbdb675d70b) @@ -89,7 +89,7 @@ } cmd configure NsfConfigureCmd { - {-argName "option" -required 1 -typeName "configureoption" -type "debug|dtrace|filter|softrecreate|objectsystems|keepcmds|checkresults|checkarguments"} + {-argName "option" -required 1 -typeName "configureoption" -type "debug|dtrace|filter|softrecreate|objectsystems|keepcmds|checkresults|checkarguments" -global 1} {-argName "value" -required 0 -type tclobj} } {-nxdoc 1} cmd colon NsfColonCmd { Index: generic/nsfAPI.h =================================================================== diff -u -r9d1dfb6417294dbdc13ce4d249931055f7bd5ef8 -r40299a6ff3b3631f275f5f0ba4f90cbdb675d70b --- generic/nsfAPI.h (.../nsfAPI.h) (revision 9d1dfb6417294dbdc13ce4d249931055f7bd5ef8) +++ generic/nsfAPI.h (.../nsfAPI.h) (revision 40299a6ff3b3631f275f5f0ba4f90cbdb675d70b) @@ -130,13 +130,13 @@ } typedef enum {ConfigureoptionNULL, ConfigureoptionDebugIdx, ConfigureoptionDtraceIdx, ConfigureoptionFilterIdx, ConfigureoptionSoftrecreateIdx, ConfigureoptionObjectsystemsIdx, ConfigureoptionKeepcmdsIdx, ConfigureoptionCheckresultsIdx, ConfigureoptionCheckargumentsIdx} ConfigureoptionIdx_t; - +const char *Nsf_Configureoption[] = {"debug", "dtrace", "filter", "softrecreate", "objectsystems", "keepcmds", "checkresults", "checkarguments", NULL}; static int ConvertToConfigureoption(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param const *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { int index, result; - static const char *opts[] = {"debug", "dtrace", "filter", "softrecreate", "objectsystems", "keepcmds", "checkresults", "checkarguments", NULL}; + (void)pPtr; - result = Tcl_GetIndexFromObj(interp, objPtr, opts, "configureoption", 0, &index); + result = Tcl_GetIndexFromObj(interp, objPtr, Nsf_Configureoption, "configureoption", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); *outObjPtr = objPtr; return result;