File: plitclgen

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 (84 lines) | stat: -rwxr-xr-x 2,407 bytes parent folder | download | duplicates (5)
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
81
82
83
84
#!/usr/local/bin/perl
# $Id: plitclgen 2352 2001-01-02 03:17:35Z mlebrun $
#
# Geoffrey Furnish
# Institute for Fusion Studies
# University of Texas at Austin
# 6 July 1995
#
# 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.
###############################################################################

require "getopts.pl";

&Getopts('v');

$verbose = $opt_v;

$specfile = "plapi.tpl";	# PLplot API template specification file.
$genfile  = "gen.itcl";		# Generated methods go here.

open( SPECFILE, "<$specfile") || die "Can't open PLplot API spec file.";
open( GENFILE,  ">$genfile" ) || die "Can't open output file.";

# Set up the list of excludable functions.  Have to think a bit more
# carefully about what should really go in here.

@ignore = (
	   "plend",
	   "plend1",
	   "plfamadv",
	   "plgfam",
	   "plsfam",
	   "plsfnam",
	   "plsstrm",
	   );

# 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( <SPECFILE> ) {
    chop;			# skip the \n.

    if (/([^\#]*)\#.*/) {	# Discard # to end of line.
        $_ = $1;
    }
    next if /^\s*$/;            # Discard empty lines.

    if (/^pltclcmd (\w+) (.*)/) {
	$cmd = $1;
	$rtype = $2;

	$exclude = 0;
	foreach(@ignore) {
	    $exclude = 1 if /$cmd/;
	}

	if (!$exclude) {
	    print "Generating itcl method for $cmd.\n";

	    print GENFILE "    method $cmd {args} {\n";
	    print GENFILE "        eval \$plwin cmd $cmd \$args\n";
	    print GENFILE "    }\n";
	    print GENFILE "\n";
	}

	next;
    }
}