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