File: plitclgen.tcl

package info (click to toggle)
plplot 5.10.0%2Bdfsg2-0.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,792 kB
  • ctags: 13,517
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,208; makefile: 210; lisp: 75; sed: 25; fortran: 7
file content (80 lines) | stat: -rw-r--r-- 2,773 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/local/bin/perl
# $Id: plitclgen 2352 2001-01-02 03:17:35Z mlebrun $
#
# Arjen Markus
# - translation of the original Perl script
#
# This script is used to automatically generate the [incr Tcl] methods
# needed in the PLWin [incr Tcl] class.  These methods mirror most of
# the Tcl API commands which are generated by the companion script,
# pltclgen.
#
# However, PLWin is a widget wrapper, and as such, not all of the Tcl
# API has any business being in the widget.  So we remove various
# shadow methods for portions of the API which are not relevant to
# widgets, such as the stream manipulation functions, etc.
#
# Also, note that this script is not quite as automatic as pltclgen.
# The output must be inserted by hand into PLWin.tcl.  Hopefully this
# will not seem like an unreasonable limitation, since the Tcl API
# only changes occasionally by this point.
###############################################################################

#
# Exclude several functions from the class
#
set ignore {
    "plend"
    "plend1"
    "plfamadv"
    "plgfam"
    "plsfam"
    "plsfnam"
    "plsstrm"
}

#
# Use eval or {*} - depending on the Tcl version
#
set use_expand [package vsatisfies [package present Tcl] 8.5]

# main code --
#
set verbose [expr {[lsearch $argv "-v"] >= 0}]

# Find the source tree directory that must be specified on the command line.
set sourcedir [lindex $argv 0]                    ;# Get the current source directory - for "out of source tree builds"
set specfile  [file join $sourcedir "plapi.tpl"]  ;# PLplot API template specification file.
set genfile   "gen.itcl"                          ;# Generated functions go here.

set SPECFILE  [open $specfile]
set GENFILE   [open $genfile "w"]

# Scan the PLplot API template specification file looking for function
# "prototypes".  These are introduced with the token "pltclcmd".  When
# we find one, go process it.  Anything other than a comment or a
# valid function "prototype" is considered an error, and is printed to
# stdout.

while { [gets $SPECFILE line] >= 0 } {
    regsub {#.*$} $line {} line
    if { $line == "" } continue

    if { [regexp {^pltclcmd (\w+) (.*)} $line ==> cmd] } {
        if { [lsearch $ignore $cmd] < 0 } {
            puts "Generating itcl method for $cmd.\n";

            puts $GENFILE "    method $cmd {args} {";
            if { $use_expand } {
                puts $GENFILE "        \$plwin cmd $cmd {*}\$args";
            } else {
                puts $GENFILE "        eval \$plwin cmd $cmd \$args";
            }
            puts $GENFILE "    }\n";
        }
    } else {

        # Just print the unrecognized output to stdout.
        puts "? $line"
    }
}