5 echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
12 echo "Creating ${o}-tmp" 1>&2
15 # Can use any of the following: cat cmp cp diff echo egrep expr false
16 # grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar
20 /* GDB Notifications to Observers.
22 Copyright 2004 Free Software Foundation, Inc.
24 This file is part of GDB.
26 This program is free software; you can redistribute it and/or modify
27 it under the terms of the GNU General Public License as published by
28 the Free Software Foundation; either version 2 of the License, or
29 (at your option) any later version.
31 This program is distributed in the hope that it will be useful,
32 but WITHOUT ANY WARRANTY; without even the implied warranty of
33 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 GNU General Public License for more details.
36 You should have received a copy of the GNU General Public License
37 along with this program; if not, write to the Free Software
38 Foundation, Inc., 59 Temple Place - Suite 330,
39 Boston, MA 02111-1307, USA.
43 This file was generated using observer.sh and observer.texi. */
49 h) cat <<EOF >>${o}-tmp
61 # generate a list of events that can be observed
66 # Save original line for later processing into the actual parameter
68 # Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
69 # to event and formals: EVENT:TYPE PARAM, ...:
70 s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
75 # Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
76 # to actuals: PARAM, ...
80 # Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
81 # FUNC:TYPE PARAM, ...:PARAM, ...
87 ' $texi | while read event formal actual
90 h) cat <<EOF >>${o}-tmp
92 /* ${event} notifications. */
94 typedef void (observer_${event}_ftype) (${formal});
96 extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
97 extern void observer_detach_${event} (struct observer *observer);
98 extern void observer_notify_${event} (${formal});
105 /* ${event} notifications. */
107 static struct observer_list *${event}_subject = NULL;
109 struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
112 observer_${event}_notification_stub (const void *data, const void *args_data)
114 observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
115 const struct ${event}_args *args = args_data;
116 notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
120 observer_attach_${event} (observer_${event}_ftype *f)
122 return generic_observer_attach (&${event}_subject,
123 &observer_${event}_notification_stub,
128 observer_detach_${event} (struct observer *observer)
130 generic_observer_detach (&${event}_subject, observer);
134 observer_notify_${event} (${formal})
136 struct ${event}_args args;
137 `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
139 fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
140 generic_observer_notify (${event}_subject, &args);
149 h) cat <<EOF >>${o}-tmp
151 #endif /* OBSERVER_H */
156 echo Moving ${o}-tmp to ${o}