138
if {[llength $args] != 3} {
136
if {[llength $args] == 2} {
137
lassign $args index decl
138
set platformList generic
139
} elseif {[llength $args] == 3} {
140
lassign $args index platformList decl
139
142
puts stderr "wrong # args: declare $args"
141
lassign $args index platformList decl
143
146
# Check for duplicate declarations, then add the declaration and
144
147
# bump the lastNum counter if necessary.
497
500
set lfname [string tolower [string index $fname 0]]
498
501
append lfname [string range $fname 1 end]
500
set text "#ifndef $fname\n#define $fname"
503
set text "#ifndef $fname\n#define $fname \\\n\t("
501
504
if {$args == ""} {
502
append text " \\\n\t(*${name}StubsPtr->$lfname)"
503
append text " /* $index */\n#endif\n"
506
append text " \\\n\t(${name}StubsPtr->$lfname)"
507
append text "${name}StubsPtr->$lfname)"
507
508
append text " /* $index */\n#endif\n"
511
# genStubs::makeStub --
513
# Emits a stub function definition.
516
# name The interface name.
517
# decl The function declaration.
518
# index The slot index for this function.
521
# Returns the formatted stub function definition.
523
proc genStubs::makeStub {name decl index} {
524
lassign $decl rtype fname args
526
set lfname [string tolower [string index $fname 0]]
527
append lfname [string range $fname 1 end]
529
append text "/* Slot $index */\n" $rtype "\n" $fname
531
set arg1 [lindex $args 0]
533
if {![string compare $arg1 "TCL_VARARGS"]} {
534
lassign [lindex $args 1] type argName
535
append text " ($type$argName, ...)\n\{\n"
536
append text " " $type " var;\n va_list argList;\n"
537
if {[string compare $rtype "void"]} {
538
append text " " $rtype " resultValue;\n"
540
append text "\n var = (" $type ") (va_start(argList, " \
541
$argName "), " $argName ");\n\n "
542
if {[string compare $rtype "void"]} {
543
append text "resultValue = "
545
append text "(" $name "StubsPtr->" $lfname "VA)(var, argList);\n"
546
append text " va_end(argList);\n"
547
if {[string compare $rtype "void"]} {
548
append text "return resultValue;\n"
554
if {![string compare $arg1 "void"]} {
561
append argList $sep [lindex $arg 1]
562
append argDecls " " [lindex $arg 0] " " \
563
[lindex $arg 1] [lindex $arg 2] ";\n"
568
append text $argList "\n" $argDecls "{\n "
569
if {[string compare $rtype "void"]} {
570
append text "return "
572
append text "(" $name "StubsPtr->" $lfname ")" $argList ";\n}\n\n"
576
512
# genStubs::makeSlot --
578
514
# Generate the stub table entry for a function.
1023
# genStubs::emitStubs --
1025
# This function emits the body of the <name>Stubs.c file for
1026
# the specified interface.
1029
# name The name of the interface being emitted.
1034
proc genStubs::emitStubs {name} {
1037
append text "\n/*\n * Exported stub functions:\n */\n\n"
1038
forAllStubs $name makeStub 0 text
1040
rewriteFile [file join $outDir ${name}Stubs.c] $text
1044
961
# genStubs::emitInit --
1046
963
# Generate the table initializers for an interface.