5 # PCB, interactive printed circuit board design
6 # Copyright (C) 2004 DJ Delorie
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # Contact addresses for paper mail and Email:
23 # DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA
26 #-----------------------------------------------------------------------------
27 # Include a comment like this anywhere in your source to automatically
28 # register an action. The gather-actions script looks for these and
29 # generates the list, but the comment keeps it from actually doing
30 # anything in your source. Note: do not quote the name, and include no
33 # /* ACTION(name,func) */
35 # Similarly, but for menu flags. The parm is passed to the func, so
36 # you can have one function support multiple flags. */
38 # /* FLAG(name,func,parm) */
40 # Similarly, but for menu generators. In the menu resource, entries of
41 # the form "@func" will call the func named in this table to include a
42 # dynamically generated set of buttons. */
44 # /* MENU(name,func) */
45 #-----------------------------------------------------------------------------
49 open(OUT
, "> actionlist.c");
52 print "/* This file is generated by gather-actions. DO NOT EDIT. */\n";
54 print "#include \"global.h\"\n";
55 print "#include \"X11/Intrinsic.h\"\n";
58 foreach $file (@ARGV) {
59 next if $file =~ /\.h$/;
62 if (/\/\
* ACTION\
((.*)\
) *(POPUP
|CREATE
)?
/) {
63 print STDERR
"action: $1 $2\n" if $verbose;
64 ($name, $func) = split(',', $1, 2);
65 push(@actions, "$name\0$func\0$2");
66 push(@actionfuncs, "$func");
67 } elsif (/\/\
* FLAG\
((.*)\
)/) {
68 print STDERR
"flag: $1\n" if $verbose;
69 ($name, $func, $parm) = split(',', $1, 3);
70 $parm = 0 unless $parm =~ /\S/;
71 push(@flags, "$name\0$func\0$parm");
72 push(@flagfuncs, "$func");
73 } elsif (/\/\
* MENU\
((.*)\
)/) {
74 print STDERR
"menu: $1\n" if $verbose;
75 ($name, $func) = split(',', $1,2);
76 push(@menus, "$name\0$func");
77 push(@menufuncs, "$func");
83 #-----------------------------------------------------------------------------
85 for $func (sort @actionfuncs) {
86 print "extern void $func(Widget,XEvent *,String *, Cardinal *);\n";
90 print "XtActionsRec ActionList[] = {\n";
91 for $a (sort @actions) {
92 ($name, $func, $types) = split(/\0/, $a);
93 print " {\"$name\", $func},\n";
100 print "struct { char *name; int type; } ActionTypeList[] = {\n";
101 for $a (sort @actions) {
102 ($name, $func, $types) = split(/\0/, $a);
104 $type = "'p'" if $types =~ /popup/i;
105 $type = "'c'" if $types =~ /create/i;
106 print " {\"$name\", $type},\n";
113 print "int ActionListSize = $n;\n";
115 #-----------------------------------------------------------------------------
117 for $func (sort @flagfuncs) {
118 print "extern int $func(int);\n";
123 print " char *name;\n";
124 print " int (*func)(int);\n";
125 print " int parm;\n";
126 print "} FlagFuncList[] = {\n";
128 for $f (sort @flags) {
129 ($name, $func, $parm) = split(/\0/, $f);
130 print " {\"$name\", $func, $parm },\n";
138 print "int FlagFuncListSize = $n;\n";
140 #-----------------------------------------------------------------------------
142 print "struct Resource;\n";
143 for $func (sort @menufuncs) {
144 print "extern void $func(struct Resource *);\n";
149 print " char *name;\n";
150 print " void (*func)(struct Resource *);\n";
151 print "} MenuFuncList[] = {\n";
153 for $f (sort @menus) {
154 ($name, $func) = split(/\0/, $f);
155 print " {\"$name\", $func },\n";
163 print "int MenuFuncListSize = $n;\n";
165 #-----------------------------------------------------------------------------