summaryrefslogtreecommitdiffstats
path: root/tools/genStubs.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/genStubs.tcl')
-rw-r--r--tools/genStubs.tcl37
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index 159565d..6ac76fc 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -8,7 +8,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.3 1999/04/16 00:47:39 stanton Exp $
+# RCS: @(#) $Id: genStubs.tcl,v 1.4 1999/04/24 01:46:53 stanton Exp $
namespace eval genStubs {
# libraryName --
@@ -766,7 +766,13 @@ proc genStubs::emitInit {name textVar} {
append capName [string range $name 1 end]
if {[info exists hooks($name)]} {
- append text "\nstatic ${capName}StubHooks ${name}StubHooks;\n"
+ append text "\nstatic ${capName}StubHooks ${name}StubHooks = \{\n"
+ set sep " "
+ foreach sub $hooks($name) {
+ append text $sep "&${sub}Stubs"
+ set sep ",\n "
+ }
+ append text "\n\};\n"
}
append text "\n${capName}Stubs ${name}Stubs = \{\n"
append text " TCL_STUB_MAGIC,\n"
@@ -799,22 +805,23 @@ proc genStubs::emitInits {} {
variable libraryName
variable interfaces
+ # Assuming that dependencies only go one level deep, we need to emit
+ # all of the leaves first to avoid needing forward declarations.
+
+ set leaves {}
+ set roots {}
foreach name [lsort [array names interfaces]] {
+ if {[info exists hooks($name)]} {
+ lappend roots $name
+ } else {
+ lappend leaves $name
+ }
+ }
+ foreach name $leaves {
emitInit $name text
}
-
-
- foreach name [array names hooks] {
- set capName [string toupper [string index $name 0]]
- append capName [string range $name 1 end]
-
- append text "\nstatic ${capName}StubHooks ${name}StubHooks = \{\n"
- set sep " "
- foreach sub $hooks($name) {
- append text $sep "&${sub}Stubs"
- set sep ",\n "
- }
- append text "\n\};\n\n"
+ foreach name $roots {
+ emitInit $name text
}
rewriteFile [file join $outDir ${libraryName}StubInit.c] $text