diff options
author | nijtmans <nijtmans> | 2010-07-01 21:28:15 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-07-01 21:28:15 (GMT) |
commit | abb430245e8a99364bb0ddbca7f85c8adb62d36f (patch) | |
tree | 6504f41b881faedff35589b0b480a44e4042fb92 /tools/genStubs.tcl | |
parent | e10b292750a32db464a69efbd938795b6f2c8d52 (diff) | |
download | tcl-abb430245e8a99364bb0ddbca7f85c8adb62d36f.zip tcl-abb430245e8a99364bb0ddbca7f85c8adb62d36f.tar.gz tcl-abb430245e8a99364bb0ddbca7f85c8adb62d36f.tar.bz2 |
[Bug #3020677] wish can't link reg1.2
formatting, spacing, cleanup unused variables
Diffstat (limited to 'tools/genStubs.tcl')
-rw-r--r-- | tools/genStubs.tcl | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index 7a77314..88b24ab 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: genStubs.tcl,v 1.39 2010/02/15 22:56:20 nijtmans Exp $ +# RCS: @(#) $Id: genStubs.tcl,v 1.40 2010/07/01 21:28:15 nijtmans Exp $ package require Tcl 8.4 @@ -18,7 +18,7 @@ namespace eval genStubs { # libraryName -- # # The name of the entire library. This value is used to compute - # the USE_*_STUB_PROCS macro and the name of the init file. + # the USE_*_STUBS macro and the name of the init file. variable libraryName "UNKNOWN" @@ -152,7 +152,7 @@ proc genStubs::declare {args} { set decl [parseDecl $decl] foreach platform $platformList { - if {$decl != ""} { + if {$decl ne ""} { set stubs($curName,$platform,$index) $decl if {![info exists stubs($curName,$platform,lastNum)] \ || ($index > $stubs($curName,$platform,lastNum))} { @@ -176,14 +176,9 @@ proc genStubs::declare {args} { # None. proc genStubs::export {args} { - variable stubs - variable curName - if {[llength $args] != 1} { puts stderr "wrong # args: export $args" } - lassign $args decl - return } @@ -303,7 +298,6 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { # None. proc genStubs::emitSlots {name textVar} { - variable stubs upvar $textVar text forAllStubs $name makeSlot 1 text {" void *reserved$i;\n"} @@ -334,7 +328,7 @@ proc genStubs::parseDecl {decl} { return } set rtype [string trim $rtype] - if {$args == ""} { + if {$args eq ""} { return [list $rtype $fname {}] } foreach arg [split $args ,] { @@ -382,14 +376,14 @@ proc genStubs::parseDecl {decl} { proc genStubs::parseArg {arg} { if {![regexp {^(.+[ ][*]*)([^][ *]+)(\[\])?$} $arg all type name array]} { - if {$arg == "void"} { + if {$arg eq "void"} { return $arg } else { return } } set result [list [string trim $type] $name] - if {$array != ""} { + if {$array ne ""} { lappend result $array } return $result @@ -419,7 +413,7 @@ proc genStubs::makeDecl {name decl index} { append line " " set pad 0 } - if {$args == ""} { + if {$args eq ""} { append line $fname append text $line append text ";\n" @@ -499,7 +493,7 @@ proc genStubs::makeMacro {name decl index} { append lfname [string range $fname 1 end] set text "#ifndef $fname\n#define $fname" - if {$args == ""} { + if {$args eq ""} { append text " \\\n\t(*${name}StubsPtr->$lfname)" append text " /* $index */\n#endif\n" return $text @@ -528,11 +522,11 @@ proc genStubs::makeSlot {name decl index} { append lfname [string range $fname 1 end] set text " " - if {$args == ""} { + if {$args eq ""} { append text $rtype " *" $lfname "; /* $index */\n" return $text } - if {[string range $rtype end-7 end] == "CALLBACK"} { + if {[string range $rtype end-7 end] eq "CALLBACK"} { append text [string trim [string range $rtype 0 end-8]] " (CALLBACK *" $lfname ") " } else { append text $rtype " (*" $lfname ") " @@ -585,7 +579,7 @@ proc genStubs::makeSlot {name decl index} { # Returns the formatted declaration string. proc genStubs::makeInit {name decl index} { - if {[lindex $decl 2] == ""} { + if {[lindex $decl 2] eq ""} { append text " &" [lindex $decl 1] ", /* " $index " */\n" } else { append text " " [lindex $decl 1] ", /* " $index " */\n" @@ -614,7 +608,7 @@ proc genStubs::makeInit {name decl index} { # Results: # None. -proc genStubs::forAllStubs {name slotProc onAll textVar \ +proc genStubs::forAllStubs {name slotProc onAll textVar {skipString {"/* Slot $i is reserved */\n"}}} { variable stubs upvar $textVar text @@ -873,7 +867,6 @@ proc genStubs::forAllStubs {name slotProc onAll textVar \ # None. proc genStubs::emitDeclarations {name textVar} { - variable stubs upvar $textVar text append text "\n/*\n * Exported function declarations:\n */\n\n" @@ -893,7 +886,6 @@ proc genStubs::emitDeclarations {name textVar} { # None. proc genStubs::emitMacros {name textVar} { - variable stubs variable libraryName upvar $textVar text @@ -945,12 +937,12 @@ proc genStubs::emitHeader {name} { emitSlots $name text - append text "} ${capName}Stubs;\n" + append text "} ${capName}Stubs;\n\n" set upName [string toupper $libraryName] - append text "\n#if defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS)\n" - append text "extern const ${capName}Stubs *${name}StubsPtr;" - append text "\n#endif /* defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS) */\n" + append text "#if defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS)\n" + append text "extern const ${capName}Stubs *${name}StubsPtr;\n" + append text "#endif /* defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS) */\n" emitMacros $name text @@ -970,7 +962,6 @@ proc genStubs::emitHeader {name} { # Returns the formatted output. proc genStubs::emitInit {name textVar} { - variable stubs variable hooks variable interfaces upvar $textVar text @@ -990,19 +981,18 @@ proc genStubs::emitInit {name textVar} { } foreach intf [array names interfaces] { if {[info exists hooks($intf)]} { - if {0<=[lsearch -exact $hooks($intf) $name]} { + if {[lsearch -exact $hooks($intf) $name] >= 0} { set root 0 - break; + break } } } - if {$root} { - append text "\nconst ${capName}Stubs ${name}Stubs = \{\n" - } else { - append text "\nstatic const ${capName}Stubs ${name}Stubs = \{\n" + append text "\n" + if {!$root} { + append text "static " } - append text " TCL_STUB_MAGIC,\n" + append text "const ${capName}Stubs ${name}Stubs = \{\n TCL_STUB_MAGIC,\n" if {[info exists hooks($name)]} { append text " &${name}StubHooks,\n" } else { |