Changeset 2153
- Timestamp:
- Mar 26, 2011, 7:41:58 PM (14 years ago)
- Location:
- trunk/builder/scripts
- Files:
-
- 7 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/builder/scripts/Makefile.in
r2082 r2153 24 24 $(srcdir)/objpath.tcl \ 25 25 $(srcdir)/slideframes.tcl \ 26 $(srcdir)/templates.tcl \ 26 27 $(srcdir)/tool.rp \ 27 28 $(srcdir)/tweener.tcl 29 30 TEMPLATEFILES = \ 31 $(srcdir)/templates/clang.tl \ 32 $(srcdir)/templates/fortran77.tl \ 33 $(srcdir)/templates/java.tl \ 34 $(srcdir)/templates/matlab.tl \ 35 $(srcdir)/templates/octave.tl \ 36 $(srcdir)/templates/perl.tl \ 37 $(srcdir)/templates/python.tl \ 38 $(srcdir)/templates/ruby.tl \ 39 $(srcdir)/templates/tcl.tl 28 40 29 41 version = $(PACKAGE_VERSION) … … 38 50 --outfile tclIndex 39 51 40 install: install_scripts install_ images52 install: install_scripts install_templates install_images 41 53 42 54 install_scripts: … … 48 60 $(INSTALL) -m 444 tclIndex $(destdir) 49 61 62 install_templates: $(TEMPLATEFILES) 63 $(MKDIR_P) -m 0755 $(destdir)/templates 64 @for i in $(TEMPLATEFILES); do \ 65 echo "Installing $$i" ; \ 66 $(INSTALL) -m 555 $$i $(destdir)/templates ; \ 67 done 68 50 69 install_images: 51 70 $(MKDIR_P) -m 0755 $(destdir)/images 52 @for i in $(srcdir)/images/*. gif $(srcdir)/images/*.png $(srcdir)/images/*.xbm; do \71 @for i in $(srcdir)/images/*.png $(srcdir)/images/*.xbm; do \ 53 72 echo "Installing $$i" ; \ 54 73 $(INSTALL) -m 444 $$i $(destdir)/images ; \ -
trunk/builder/scripts/main.tcl
r2147 r2153 74 74 option add *saveas*progv*Button.padX 2 75 75 option add *saveas*progv*Button.padY 2 76 option add *saveas*progl*Label.font {Helvetica -12}77 option add *saveas*progl*Combobox.textBackground #d9d9d978 option add *saveas*progl*Combobox.borderWidth 179 76 80 77 switch $tcl_platform(platform) { … … 88 85 89 86 wm protocol . WM_DELETE_WINDOW main_exit 90 wm title . " Instant Rappture"87 wm title . "Rappture Builder" 91 88 92 89 # install a better bug handler … … 118 115 exit 1 119 116 } 117 118 # load all languages recognized by the builder 119 RapptureBuilder::templates::init 120 120 121 121 # ---------------------------------------------------------------------- … … 169 169 return 170 170 } 171 set win [.func.build.options.panes pane 0] 172 $win.scrl.skel select none 173 171 174 main_generate_xml 172 175 173 if {[string length $LastToolXmlLoaded] > 0 && ![string equal [$ToolXml xml] $LastToolXmlLoaded]} { 174 set choice [tk_messageBox -icon warning -type yesno -title "iRappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"] 176 if {[string length $LastToolXmlLoaded] > 0 && [$ToolXml xml] ne $LastToolXmlLoaded} { 177 puts ">>>>" 178 puts $LastToolXmlLoaded 179 puts "----" 180 puts [$ToolXml xml] 181 puts "<<<<" 182 set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"] 175 183 if {$choice == "yes" && ![main_saveas]} { 176 184 return … … 179 187 180 188 if {$what == "-new"} { 181 set xmlobj [Rappture::LibraryObj ::#auto "<?xml version=\"1.0\"?><run><tool/></run>"] 189 set xmlobj [Rappture::LibraryObj ::#auto "<?xml version=\"1.0\"?><run/>"] 190 $xmlobj put tool.command "" 182 191 } else { 183 192 if {$what == "-file"} { 184 set fname [tk_getOpenFile -title " iRappture: Open Tool" -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }]193 set fname [tk_getOpenFile -title "Rappture: Open Tool" -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }] 185 194 } else { 186 195 set fname $what … … 197 206 198 207 if {[catch {Rappture::library $fname} xmlobj]} { 199 tk_messageBox -icon error -title " iRappture: Error" -message "Error loading tool description: $xmlobj"208 tk_messageBox -icon error -title "Rappture: Error" -message "Error loading tool description: $xmlobj" 200 209 return 201 210 } … … 402 411 } 403 412 404 set choice [tk_messageBox -icon error -type yesno -title " iRappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition. Examine and resolve $problem?"]413 set choice [tk_messageBox -icon error -type yesno -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition. Examine and resolve $problem?"] 405 414 if {$choice == "yes"} { 406 415 return 1 … … 582 591 return 583 592 } 593 set win [.func.build.options.panes pane 0] 594 $win.scrl.skel select none 595 584 596 # generate now to catch any errors 585 597 main_generate_xml 598 599 # get the language choice and update the skeleton program option 600 set lang "" 601 set cmd [$ToolXml get tool.command] 602 if {[string index $cmd 0] == "!"} { 603 set lang [string range $cmd 1 end] 604 } else { 605 # It's hard to reload a real command from a tool.xml file. 606 # Scan through all languages and treat @@FILENAME@@ as a 607 # wildcard. See if any of the languages match. 608 foreach name [RapptureBuilder::templates::languages] { 609 set pat [RapptureBuilder::templates::generate command \ 610 -language $name -macros {@@FILENAME@@ * @@FILEROOT@@ *}] 611 612 if {[string match $pat $cmd]} { 613 set lang $name 614 break 615 } 616 } 617 } 618 if {$lang ne ""} { 619 .saveas.opts.prog configure -text "Skeleton program ($lang)" -state normal 620 .saveas.opts.progv.getfile configure -state normal 621 set ext [RapptureBuilder::templates::generate extension -language $lang] 622 .saveas.opts.progv.file configure -text "main$ext" 623 set SaveAs(lang) $lang 624 set SaveAs(ext) $ext 625 626 # see if there's a makefile for this program 627 if {[catch {RapptureBuilder::templates::generate makefile -language $lang}]} { 628 set SaveAs(make) 0 629 .saveas.opts.make configure -state disabled 630 } else { 631 .saveas.opts.make configure -state normal 632 } 633 } else { 634 .saveas.opts.prog configure -text "Skeleton program (select language under Tool section)" -state disabled 635 .saveas.opts.progv.file configure -text "select a file" 636 .saveas.opts.progv.getfile configure -state disabled 637 .saveas.opts.make configure -state disabled 638 set SaveAs(lang) ? 639 set SaveAs(ext) ? 640 set SaveAs(prog) 0 641 set SaveAs(make) 0 642 } 643 main_saveas update 586 644 587 645 # make the saveas dialog big enough and center it on the main win … … 621 679 set pfile [.saveas.opts.progv.file cget -text] 622 680 623 if {$SaveAs(tool) && ![string equal "select a file" $tfile]} { 681 if {$SaveAs(tool) && $tfile ne "select a file"} { 682 set tfile [file normalize $tfile] 683 684 if {$SaveAs(prog) && $pfile ne "select a file"} { 685 # if we have a tool.xml file, put the program in same dir 686 set tail [file tail $pfile] 687 set pfile [file join [file dirname $tfile] $tail] 688 } 689 } 690 691 if {$SaveAs(tool) && $tfile ne "select a file"} { 624 692 # generate again now that we know the file name to get 625 693 # relative file paths for things like <note>'s 626 694 set LastToolXmlFile $tfile 627 695 main_generate_xml 696 697 set cmd [$ToolXml get tool.command] 698 if {[string index $cmd 0] eq "!"} { 699 if {$pfile eq "select a file"} { 700 set pfile "main$SaveAs(ext)" 701 } 702 set tail [file tail $pfile] 703 set cmd [RapptureBuilder::templates::generate command \ 704 -language $SaveAs(lang) \ 705 -macros [list @@FILENAME@@ $tail \ 706 @@FILEROOT@@ [file rootname $tail]]] 707 $ToolXml put tool.command $cmd 708 } 628 709 629 710 set cmds { … … 634 715 } 635 716 if {[catch $cmds result]} { 636 tk_messageBox -icon error -title " iRappture: Error" -message "Error saving tool description: $result"717 tk_messageBox -icon error -title "Rappture: Error" -message "Error saving tool description: $result" 637 718 set status "error" 638 719 } else { … … 641 722 } 642 723 643 if {$SaveAs(prog) && ![string equal "select a file" $pfile]} { 644 tk_messageBox -icon error -title "iRappture: Error" -message "Generating script file is not yet implemented" 724 if {$SaveAs(prog) && $pfile ne "select a file"} { 725 if {[file exists $pfile]} { 726 set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Confirm" -message "File \"$pfile\" already exists.\n\nOverwrite?"] 727 if {$choice == "no"} { 728 # pop the dialog back up 729 wm deiconify .saveas 730 raise .saveas 731 grab set .saveas 732 return 733 } 734 } 735 set code [RapptureBuilder::templates::generate main \ 736 -language $SaveAs(lang) -xmlobj $ToolXml] 737 738 set cmds { 739 set fid [open $pfile w] 740 puts -nonewline $fid $code 741 close $fid 742 } 743 if {[catch $cmds result]} { 744 tk_messageBox -icon error -title "Rappture: Error" -message "Error saving skeleton program file: $result" 745 set status "error" 746 } 747 } 748 749 if {$SaveAs(make)} { 750 if {$pfile eq "select a file"} { 751 set pfile "main$SaveAs(ext)" 752 } 753 set mfile [file join [file dirname $pfile] Makefile] 754 if {[file exists $mfile]} { 755 set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Confirm" -message "File \"$mfile\" already exists.\n\nOverwrite?"] 756 if {$choice == "no"} { 757 # pop the dialog back up 758 wm deiconify .saveas 759 raise .saveas 760 grab set .saveas 761 return 762 } 763 } 764 765 set fname [file tail $pfile] 766 set dir [file dirname [file dirname $::Rappture::installdir]] 767 set macros [list @@RAPPTUREDIR@@ $dir] 768 lappend macros @@FILENAME@@ $fname 769 lappend macros @@FILEROOT@@ [file rootname $fname] 770 if {[catch {RapptureBuilder::templates::generate makefile -language $SaveAs(lang) -macros $macros} code] == 0} { 771 set cmds { 772 set fid [open $mfile w] 773 puts -nonewline $fid $code 774 close $fid 775 } 776 if {[catch $cmds result]} { 777 tk_messageBox -icon error -title "Rappture: Error" -message "Error saving Makefile: $result" 778 set status "error" 779 } 780 } 645 781 } 646 782 … … 650 786 update { 651 787 set havefile 0 788 set missingfile 0 652 789 set tfile [.saveas.opts.toolv.file cget -text] 653 if {$SaveAs(tool) && ![string equal $tfile "select a file"]} { 654 .saveas.opts.toolv.file configure -fg black 655 set havefile 1 790 if {$SaveAs(tool)} { 791 if {$tfile ne "select a file"} { 792 .saveas.opts.toolv.file configure -fg black 793 set havefile 1 794 } else { 795 set missingfile 1 796 } 656 797 } else { 657 798 .saveas.opts.toolv.file configure -fg gray60 … … 659 800 660 801 set pfile [.saveas.opts.progv.file cget -text] 661 if {$SaveAs(prog) && ![string equal $pfile "select a file"]} { 662 .saveas.opts.progv.file configure -fg black 663 set havefile 1 802 if {$SaveAs(prog)} { 803 if {$pfile ne "select a file"} { 804 .saveas.opts.progv.file configure -fg black 805 set havefile 1 806 } else { 807 set missingfile 1 808 } 664 809 } else { 665 810 .saveas.opts.progv.file configure -fg gray60 666 811 } 667 812 668 if {$havefile } {813 if {$havefile && !$missingfile} { 669 814 .saveas.cntls.save configure -state normal 670 815 } else { … … 674 819 675 820 gettoolfile { 676 set fname [tk_getSaveFile -title " iRappture: Save Tool" -parent .saveas -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }]821 set fname [tk_getSaveFile -title "Rappture: Save Tool" -parent .saveas -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }] 677 822 678 823 if {"" != $fname} { … … 684 829 685 830 getprogfile { 686 set ext .tcl 687 set fname [tk_getSaveFile -title "iRappture: Save Program Skeleton" -parent .saveas -initialfile "wrapper$ext" -defaultextension $ext -filetypes { 688 {{C programs} .c} 689 {{C++ programs} .cpp} 690 {{F77 programs} .f} 691 {{MATLAB scripts} .m} 692 {{Perl scripts} .pl} 693 {{Python scripts} .py} 694 {{Tcl scripts} .tcl} 695 {{Ruby scripts} .ruby} 696 {{All files} *} 697 }] 831 set flist "" 832 lappend flist [list "$SaveAs(lang) files" $SaveAs(ext)] 833 lappend flist [list "All files" *] 834 835 set pfile [.saveas.opts.progv.file cget -text] 836 if {$pfile eq "select a file"} { 837 set init "" 838 set ext "" 839 } else { 840 set init $pfile 841 set ext [file extension $pfile] 842 } 843 844 set fname [tk_getSaveFile -title "Rappture: Save Program Skeleton" -parent .saveas -initialfile $init -defaultextension $ext -filetypes $flist] 698 845 699 846 if {"" != $fname} { … … 724 871 return 725 872 } 873 set win [.func.build.options.panes pane 0] 874 $win.scrl.skel select none 875 726 876 main_generate_xml 727 877 728 if { ![string equal [$ToolXml xml] $LastToolXmlLoaded]} {729 set choice [tk_messageBox -icon warning -type yesno -title " iRappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"]878 if {[$ToolXml xml] ne $LastToolXmlLoaded} { 879 set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"] 730 880 if {$choice == "yes" && ![main_saveas]} { 731 881 return … … 846 996 # ---------------------------------------------------------------------- 847 997 wm geometry . 800x600 848 849 # ----------------------------------------------------------------------850 # MAIN WINDOW851 # ----------------------------------------------------------------------852 wm geometry . 600x500853 998 Rappture::Postern .postern 854 999 pack .postern -side bottom -fill x … … 1004 1149 grid $frame.cntls -row 0 -column 0 -columnspan 2 -sticky nsew 1005 1150 1006 if { ![string equal $type "Tool"]} {1151 if {$type ne "Tool"} { 1007 1152 # can't let people delete the tool info 1008 1153 button $frame.cntls.del -text "Delete" -command main_options_delete … … 1018 1163 pack $frame.cntls.path -side left -expand yes -fill both 1019 1164 1020 if { [string equal $type "Tool"]} {1165 if {$type eq "Tool"} { 1021 1166 # if this is a tool, then lose the rename button 1022 1167 pack forget [$frame.cntls.path component button] … … 1065 1210 1066 1211 # if an error was found at this attribute, set focus there 1067 if { [string equal $name $ErrFocusAttr]} {1212 if {$name eq $ErrFocusAttr} { 1068 1213 $obj edit 1069 1214 set ErrFocusAttr "" … … 1134 1279 catch {unset OptionsPanelObjs} 1135 1280 1136 set win [.func.build.options.panes pane 1]1137 set frame [$ win.vals contents frame]1138 foreach w in[winfo children $frame] {1139 destroy $w in1281 set bwin [.func.build.options.panes pane 1] 1282 set frame [$bwin.vals contents frame] 1283 foreach w [winfo children $frame] { 1284 destroy $w 1140 1285 } 1141 1286 } … … 1218 1363 toplevel .saveas 1219 1364 pack propagate .saveas off 1220 wm title .saveas " iRappture: Save As..."1365 wm title .saveas "Rappture: Save As..." 1221 1366 wm withdraw .saveas 1222 1367 wm protocol .saveas WM_DELETE_WINDOW {.saveas.cntls.cancel invoke} … … 1240 1385 frame .saveas.opts.toolv 1241 1386 pack .saveas.opts.toolv -anchor w 1242 label .saveas.opts.toolv.filel -text "File:" -width 12-anchor e1387 label .saveas.opts.toolv.filel -text "File:" -width 7 -anchor e 1243 1388 pack .saveas.opts.toolv.filel -side left 1244 1389 button .saveas.opts.toolv.getfile -text "Choose..." -command {main_saveas gettoolfile} … … 1252 1397 frame .saveas.opts.progv 1253 1398 pack .saveas.opts.progv -anchor w 1254 label .saveas.opts.progv.filel -text "File:" -width 12-anchor e1399 label .saveas.opts.progv.filel -text "File:" -width 7 -anchor e 1255 1400 pack .saveas.opts.progv.filel -side left 1256 1401 button .saveas.opts.progv.getfile -text "Choose..." -command {main_saveas getprogfile} … … 1258 1403 label .saveas.opts.progv.file -text "select a file" -anchor e -fg gray60 1259 1404 pack .saveas.opts.progv.file -side left -expand yes -fill x 1260 frame .saveas.opts.progl 1261 pack .saveas.opts.progl -anchor w 1262 label .saveas.opts.progl.l -text "Language:" -width 12 -anchor e 1263 pack .saveas.opts.progl.l -side left 1264 Rappture::Combobox .saveas.opts.progl.val -width 20 -editable no 1265 pack .saveas.opts.progl.val -side left -pady {4 0} 1266 .saveas.opts.progl.val choices insert end \ 1267 .c "C programs" \ 1268 .cpp "C++ programs" \ 1269 .f "F77 programs" \ 1270 .m "MATLAB scripts" \ 1271 .pl "Perl scripts" \ 1272 .py "Python scripts" \ 1273 .tcl "Tcl scripts" \ 1274 .ruby "Ruby scripts" 1275 .saveas.opts.progl.val value "Python scripts" 1405 1406 checkbutton .saveas.opts.make -text "Makefile for building this program" -variable SaveAs(make) -command {main_saveas update} 1407 pack .saveas.opts.make -side top -anchor w -pady {10 0} 1276 1408 1277 1409 # ---------------------------------------------------------------------- -
trunk/builder/scripts/templates.tcl
r2147 r2153 21 21 # ====================================================================== 22 22 package require Itcl 23 24 namespace eval RapptureBuilder { # forward declaration } 23 package require RapptureBuilder 24 25 25 namespace eval RapptureBuilder::templates { 26 26 # … … 44 44 $langParser hide $cmd 45 45 } 46 $langParser alias extension RapptureBuilder::templates::parse_template extension 47 $langParser alias command RapptureBuilder::templates::parse_template command 48 $langParser alias makefile RapptureBuilder::templates::parse_template makefile 49 46 50 $langParser alias main RapptureBuilder::templates::parse_template main 47 51 $langParser alias input RapptureBuilder::templates::parse_pattern input 48 52 $langParser alias output RapptureBuilder::templates::parse_pattern output 53 49 54 $langParser alias unknown RapptureBuilder::templates::parse_lang_unknown 50 55 proc ::RapptureBuilder::templates::parse_lang_unknown {args} { … … 110 115 # ---------------------------------------------------------------------- 111 116 # USAGE: RapptureBuilder::templates::generate <what> \ 112 # ?-language name? ?-xmlobj obj? 117 # ?-language name? ?-xmlobj obj? ?-macros <string-map>? 113 118 # 114 119 # Builds a string of generated information starting with <what> as 115 # the main template. This string may contain other @ NAME@ fields,120 # the main template. This string may contain other @@NAME@@ fields, 116 121 # which are substituted recursively until all substitutions have 117 122 # been made. The -language option specifies which language template 118 # should be used. The -xmlobj option gives data for the @ NAME@123 # should be used. The -xmlobj option gives data for the @@NAME@@ 119 124 # substitutions. 120 125 # … … 127 132 value -language "" 128 133 value -xmlobj "" 134 value -macros "" 129 135 } 130 136 if {[llength $args] > 0} { … … 151 157 if {$xmlobj ne ""} { 152 158 foreach path [Rappture::entities -as path $xmlobj input] { 153 append inputs [$langDefs($lang) generate $xmlobj $path ]159 append inputs [$langDefs($lang) generate $xmlobj $path -code] 154 160 } 155 161 } … … 159 165 if {$xmlobj ne ""} { 160 166 foreach path [Rappture::entities -as path $xmlobj output] { 161 append outputs [$langDefs($lang) generate $xmlobj $path] 162 } 163 } 164 165 set info [string map [list @@INPUTS@@ $inputs @@OUTPUTS@@ $outputs] $info] 167 append outputs [$langDefs($lang) generate $xmlobj $path -code] 168 } 169 } 170 171 # produce the @@DECLARATIONS@@ section... 172 set decls "" 173 if {$xmlobj ne ""} { 174 foreach path [Rappture::entities -as path $xmlobj input] { 175 append decls [$langDefs($lang) generate $xmlobj $path -decl] 176 } 177 foreach path [Rappture::entities -as path $xmlobj output] { 178 append decls [$langDefs($lang) generate $xmlobj $path -decl] 179 } 180 } 181 182 # handle the @@INPUTS@@ / @@OUTPUTS@@ / @@DECLARATIONS@@ specially 183 # preserve the indent at the beginning of each line 184 foreach {macro var} { 185 @@INPUTS@@ inputs 186 @@OUTPUTS@@ outputs 187 @@DECLARATIONS@@ decls 188 } { 189 set re [format {(?:^|\n)([ \t]*)%s} $macro] 190 while {[regexp -indices $re $info match indent]} { 191 set code [set $var] 192 foreach {m0 m1} $match break 193 foreach {i0 i1} $indent break 194 if {$i1-$i0 > 0} { 195 set indent [string range $info $i0 $i1] 196 set newcode "" 197 foreach line [split $code \n] { 198 append newcode $indent $line "\n" 199 } 200 set code [string trimright $newcode \n] 201 } 202 if {[string index $info $m0] eq "\n"} { set code "\n$code" } 203 set info [string replace $info $m0 $m1 $code] 204 } 205 } 206 207 # make substitutions for any remaining macros 208 set info [string map $params(-macros) $info] 166 209 167 210 # return the generated code … … 265 308 # used to register a script that processes an input/output element 266 309 public method handler {pattern body} { 267 set i [lsearch $_patterns $pattern]310 set i [lsearch -exact $_patterns $pattern] 268 311 if {$i < 0} { lappend _patterns $pattern } 269 312 set _pat2code($pattern) $body … … 271 314 272 315 # used to generate the output for a specific Rappture object in this lang 273 public method generate {xmlobj path } {316 public method generate {xmlobj path {what "-code"}} { 274 317 variable genParser 275 318 variable genOutput "" 319 variable genDecls "" 276 320 variable genXmlobj $xmlobj 277 321 variable genPath $path … … 297 341 $genParser eval $code 298 342 299 return $genOutput 343 switch -- $what { 344 -code { return $genOutput } 345 -decl { return $genDecls } 346 default { error "bad option \"$what\": should be -code, -decl" } 347 } 300 348 } 301 349 … … 309 357 # 310 358 private common genParser [interp create -safe] 311 $genParser alias puts RapptureBuilder::templates::LangDef::cmd_puts 359 $genParser alias code RapptureBuilder::templates::LangDef::cmd_code 360 $genParser alias decl RapptureBuilder::templates::LangDef::cmd_decl 312 361 $genParser alias attr RapptureBuilder::templates::LangDef::cmd_attr 313 362 314 private common genOutput "" ;# gathers the output from genParser 363 private common genOutput "" ;# gathers code output from genParser 364 private common genDecls "" ;# gathers declarations from genParser 315 365 private common genXmlobj "" ;# Rappture tool spec 316 366 private common genPath "" ;# current path in the genXmlobj data 317 367 318 368 # like the std "puts" command, but adds output to the generated code 319 proc cmd_ puts{args} {369 proc cmd_code {args} { 320 370 set nl "\n" 321 371 while {[llength $args] > 1} { … … 334 384 } 335 385 386 # like the std "puts" command, but adds output to code declarations 387 proc cmd_decl {args} { 388 set nl "\n" 389 while {[llength $args] > 1} { 390 set opt [lindex $args 0] 391 set args [lrange $args 1 end] 392 if {$opt eq "-nonewline"} { 393 set nl "" 394 } else { 395 error "bad option \"$opt\": should be -nonewline" 396 } 397 } 398 if {[llength $args] != 1} { 399 error "wrong # args: should be \"puts ?-nonewline? string\"" 400 } 401 append genDecls [lindex $args 0] $nl 402 } 403 336 404 # used to query attribute info for the current object 337 405 proc cmd_attr {option name} { -
trunk/builder/scripts/templates/python.tl
r2147 r2153 9 9 # ====================================================================== 10 10 language "Python" { 11 extension ".py" 12 command {python @tool/@@FILENAME@@ @driver} 13 11 14 main {# ---------------------------------------------------------------------- 12 15 # MAIN PROGRAM - generated by the Rappture Builder … … 24 27 @@INPUTS@@ 25 28 26 # : : : : : : : : : : : : : : : : : : : : : : : : : : : :29 ######################################################### 27 30 # Add your code here for the main body of your program 28 # : : : : : : : : : : : : : : : : : : : : : : : : : : : :31 ######################################################### 29 32 30 33 # spit out progress messages as you go along... … … 44 47 45 48 input boolean { 46 puts"\n# get input value for $path"47 puts"# returns value as string \"yes\" or \"no\""48 puts"$id = io.get('$path.current')"49 code "\n# get input value for $path" 50 code "# returns value as string \"yes\" or \"no\"" 51 code "$id = io.get('$path.current')" 49 52 } 50 53 input image { 51 puts"\n# get input value for $path"52 puts"# returns base64-encoded image data"53 puts"$id = io.get('$path.current')"54 code "\n# get input value for $path" 55 code "# returns base64-encoded image data" 56 code "$id = io.get('$path.current')" 54 57 } 55 58 input number { 56 59 set units [attr get units] 57 60 if {$units ne ""} { 58 puts"\n# get input value for $path and convert to $units"59 puts"str = io.get('$path.current')"60 puts"$id = Rappture.Units.convert(str, to=\"$units\", units=\"off\")"61 code "\n# get input value for $path and convert to $units" 62 code "str = io.get('$path.current')" 63 code "$id = Rappture.Units.convert(str, to=\"$units\", units=\"off\")" 61 64 } else { 62 puts"\n# get input value for $path"63 puts"$id = io.get('$path.current')"65 code "\n# get input value for $path" 66 code "$id = io.get('$path.current')" 64 67 } 65 68 } 66 69 input * { 67 puts"\n# get input value for $path"68 puts"$id = io.get('$path.current')"70 code "\n# get input value for $path" 71 code "$id = io.get('$path.current')" 69 72 } 70 73 71 74 output curve { 72 puts"\n# save output value for $path"73 puts"# this shows just one (x,y) point -- modify as needed"74 puts"line = "%g %g\n" % (x, y)"75 puts"io.put('$path.component.xy', line, append=1)"75 code "\n# save output value for $path" 76 code "# this shows just one (x,y) point -- modify as needed" 77 code "line = "%g %g\n" % (x, y)" 78 code "io.put('$path.component.xy', line, append=1)" 76 79 } 77 80 output histogram { 78 puts"\n# save output value for $path"79 puts"# this shows just one point -- modify as needed"80 puts"# (x,h,w) = x-coord, height of bar, and width of bar (optional)"81 puts"line = "%g %g %g\n" % (x, h, w)"82 puts"io.put('$path.component.xhw', line, append=1)"81 code "\n# save output value for $path" 82 code "# this shows just one point -- modify as needed" 83 code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)" 84 code "line = "%g %g %g\n" % (x, h, w)" 85 code "io.put('$path.component.xhw', line, append=1)" 83 86 } 84 87 output image { 85 puts"\n# save output value for $path"86 puts"# data should be base64-encoded image data"87 puts"io.put('$path.current', imdata)"88 code "\n# save output value for $path" 89 code "# data should be base64-encoded image data" 90 code "io.put('$path.current', imdata)" 88 91 } 89 92 output * { 90 puts"\n# save output value for $path"91 puts"io.put('$path.current',$id)"93 code "\n# save output value for $path" 94 code "io.put('$path.current',$id)" 92 95 } 93 96 } -
trunk/builder/scripts/templates/tcl.tl
r2147 r2153 9 9 # ====================================================================== 10 10 language "Tcl" { 11 extension ".tcl" 12 command {tclsh @tool/@@FILENAME@@ @driver} 13 11 14 main {# ---------------------------------------------------------------------- 12 15 # MAIN PROGRAM - generated by the Rappture Builder … … 22 25 @@INPUTS@@ 23 26 24 # : : : : : : : : : : : : : : : : : : : : : : : : : : : :27 ######################################################### 25 28 # Add your code here for the main body of your program 26 # : : : : : : : : : : : : : : : : : : : : : : : : : : : :29 ######################################################### 27 30 28 31 # spit out progress messages as you go along... … … 42 45 43 46 input boolean { 44 puts"\n# get input value for $path"45 puts"# returns value as string \"yes\" or \"no\""46 puts"set $id \[\$io get $path.current\]"47 code "\n# get input value for $path" 48 code "# returns value as string \"yes\" or \"no\"" 49 code "set $id \[\$io get $path.current\]" 47 50 } 48 51 input image { 49 puts"\n# get input value for $path"50 puts"# returns base64-encoded image data"51 puts"set imdata \[\$io get $path.current\]"52 puts"set $id \[image create photo -data \$imdata\]"52 code "\n# get input value for $path" 53 code "# returns base64-encoded image data" 54 code "set imdata \[\$io get $path.current\]" 55 code "set $id \[image create photo -data \$imdata\]" 53 56 } 54 57 input number { 55 58 set units [attr get units] 56 59 if {$units ne ""} { 57 puts"\n# get input value for $path and convert to $units"58 puts"set str \[\$io get $path.current\]"59 puts"set $id \[Rappture::Units::convert \$str -to $units -units off\]"60 code "\n# get input value for $path and convert to $units" 61 code "set str \[\$io get $path.current\]" 62 code "set $id \[Rappture::Units::convert \$str -to $units -units off\]" 60 63 } else { 61 puts"\n# get input value for $path"62 puts"set $id \[\$io get $path.current\]"64 code "\n# get input value for $path" 65 code "set $id \[\$io get $path.current\]" 63 66 } 64 67 } 65 68 input * { 66 puts"\n# get input value for $path"67 puts"set $id \[\$io get $path.current\]"69 code "\n# get input value for $path" 70 code "set $id \[\$io get $path.current\]" 68 71 } 69 72 70 73 output curve { 71 puts"\n# save output value for $path"72 puts"# this shows just one (x,y) point -- modify as needed"73 puts"\$io put -append yes $path.component.xy \"\$x \$y\\n\""74 code "\n# save output value for $path" 75 code "# this shows just one (x,y) point -- modify as needed" 76 code "\$io put -append yes $path.component.xy \"\$x \$y\\n\"" 74 77 } 75 78 output histogram { 76 puts"\n# save output value for $path"77 puts"# this shows just one point -- modify as needed"78 puts"# (x,h,w) = x-coord, height of bar, and width of bar (optional)"79 puts"\$io put -append yes $path.component.xy \"\$x \$h \$w\\n\""79 code "\n# save output value for $path" 80 code "# this shows just one point -- modify as needed" 81 code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)" 82 code "\$io put -append yes $path.component.xy \"\$x \$h \$w\\n\"" 80 83 } 81 84 output image { 82 puts"\n# save output value for $path"83 puts"# this assumes that \$imh is the handle for a Tk photo image"84 puts"\$io put $path.current \[\$imh data -format gif\]"85 code "\n# save output value for $path" 86 code "# this assumes that \$imh is the handle for a Tk photo image" 87 code "\$io put $path.current \[\$imh data -format gif\]" 85 88 } 86 89 output * { 87 puts"\n# save output value for $path"88 puts"\$io put $path.current \$id"90 code "\n# save output value for $path" 91 code "\$io put $path.current \$id" 89 92 } 90 93 } -
trunk/builder/scripts/tool.rp
r2082 r2153 4 4 attr title -type string -path title 5 5 attr description -type string:lines=6 -expand yes -path about 6 attr command -t ype string-path command6 attr command -title "Program" -type language -path command 7 7 8 8 check title {
Note: See TracChangeset
for help on using the changeset viewer.