]>
Commit | Line | Data |
---|---|---|
7a464420 AC |
1 | #!/bin/sh -e |
2 | ||
6e2c7fa1 DJ |
3 | # Make certain that the script is not running in an internationalized |
4 | # environment. | |
5 | LANG=c ; export LANG | |
6 | LC_ALL=c ; export LC_ALL | |
7 | ||
7a464420 AC |
8 | if test $# -ne 3 |
9 | then | |
10 | echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2 | |
11 | exit 0 | |
12 | fi | |
13 | ||
14 | lang=$1 ; shift | |
15 | texi=$1 ; shift | |
15c3c5c6 | 16 | o=$1 |
99efcb59 AS |
17 | case $lang in |
18 | h) tmp=htmp ;; | |
19 | inc) tmp=itmp ;; | |
20 | esac | |
21 | otmp="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift | |
15c3c5c6 EZ |
22 | echo "Creating ${otmp}" 1>&2 |
23 | rm -f ${otmp} | |
7a464420 AC |
24 | |
25 | # Can use any of the following: cat cmp cp diff echo egrep expr false | |
26 | # grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar | |
27 | # test touch true | |
28 | ||
15c3c5c6 | 29 | cat <<EOF >>${otmp} |
7a464420 AC |
30 | /* GDB Notifications to Observers. |
31 | ||
6aba47ca | 32 | Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. |
7a464420 AC |
33 | |
34 | This file is part of GDB. | |
35 | ||
36 | This program is free software; you can redistribute it and/or modify | |
37 | it under the terms of the GNU General Public License as published by | |
50efebf8 | 38 | the Free Software Foundation; either version 3 of the License, or |
7a464420 | 39 | (at your option) any later version. |
50efebf8 | 40 | |
7a464420 AC |
41 | This program is distributed in the hope that it will be useful, |
42 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
43 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
44 | GNU General Public License for more details. | |
50efebf8 | 45 | |
7a464420 | 46 | You should have received a copy of the GNU General Public License |
50efebf8 | 47 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
7a464420 AC |
48 | |
49 | -- | |
50 | ||
51 | This file was generated using observer.sh and observer.texi. */ | |
52 | ||
53 | EOF | |
54 | ||
55 | ||
56 | case $lang in | |
15c3c5c6 | 57 | h) cat <<EOF >>${otmp} |
7a464420 AC |
58 | #ifndef OBSERVER_H |
59 | #define OBSERVER_H | |
60 | ||
61 | struct observer; | |
62 | struct bpstats; | |
84acb35a | 63 | struct so_list; |
06d3b283 | 64 | struct objfile; |
7a464420 AC |
65 | EOF |
66 | ;; | |
67 | esac | |
68 | ||
5711a8b0 EZ |
69 | # We are about to set IFS=:, so DOS-style file names with a drive |
70 | # letter and a colon will be in trouble. | |
71 | ||
f3e25dcb | 72 | if test -n "$DJGPP" |
5711a8b0 EZ |
73 | then |
74 | texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'` | |
75 | fi | |
7a464420 AC |
76 | |
77 | # generate a list of events that can be observed | |
78 | ||
79 | IFS=: | |
80 | sed -n ' | |
81 | /@deftypefun void/{ | |
350c2e5b | 82 | # Save original line for later processing into the actual parameter |
7a464420 | 83 | h |
350c2e5b JB |
84 | # Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...) |
85 | # to event and formals: EVENT:TYPE PARAM, ...: | |
7a464420 AC |
86 | s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/ |
87 | s/@var{//g | |
88 | s/}//g | |
350c2e5b | 89 | # Switch to held |
7a464420 | 90 | x |
350c2e5b JB |
91 | # Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...) |
92 | # to actuals: PARAM, ... | |
7a464420 AC |
93 | s/^[^{]*[{]*// |
94 | s/[}]*[^}]*$// | |
95 | s/}[^{]*{/, /g | |
350c2e5b JB |
96 | # Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into |
97 | # FUNC:TYPE PARAM, ...:PARAM, ... | |
7a464420 AC |
98 | H |
99 | x | |
100 | s/\n/:/g | |
101 | p | |
102 | } | |
103 | ' $texi | while read event formal actual | |
104 | do | |
105 | case $lang in | |
15c3c5c6 | 106 | h) cat <<EOF >>${otmp} |
7a464420 AC |
107 | |
108 | /* ${event} notifications. */ | |
109 | ||
110 | typedef void (observer_${event}_ftype) (${formal}); | |
111 | ||
112 | extern struct observer *observer_attach_${event} (observer_${event}_ftype *f); | |
113 | extern void observer_detach_${event} (struct observer *observer); | |
114 | extern void observer_notify_${event} (${formal}); | |
115 | EOF | |
116 | ;; | |
117 | ||
118 | inc) | |
15c3c5c6 | 119 | cat <<EOF >>${otmp} |
7a464420 AC |
120 | |
121 | /* ${event} notifications. */ | |
122 | ||
123 | static struct observer_list *${event}_subject = NULL; | |
124 | ||
125 | struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; }; | |
126 | ||
127 | static void | |
128 | observer_${event}_notification_stub (const void *data, const void *args_data) | |
129 | { | |
130 | observer_${event}_ftype *notify = (observer_${event}_ftype *) data; | |
131 | const struct ${event}_args *args = args_data; | |
132 | notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`); | |
133 | } | |
134 | ||
135 | struct observer * | |
136 | observer_attach_${event} (observer_${event}_ftype *f) | |
137 | { | |
138 | return generic_observer_attach (&${event}_subject, | |
139 | &observer_${event}_notification_stub, | |
140 | (void *) f); | |
141 | } | |
142 | ||
143 | void | |
144 | observer_detach_${event} (struct observer *observer) | |
145 | { | |
146 | generic_observer_detach (&${event}_subject, observer); | |
147 | } | |
148 | ||
149 | void | |
150 | observer_notify_${event} (${formal}) | |
151 | { | |
152 | struct ${event}_args args; | |
153 | `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`; | |
2b4855ab AC |
154 | if (observer_debug) |
155 | fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n"); | |
7a464420 AC |
156 | generic_observer_notify (${event}_subject, &args); |
157 | } | |
158 | EOF | |
159 | ;; | |
160 | esac | |
161 | done | |
162 | ||
163 | ||
164 | case $lang in | |
15c3c5c6 | 165 | h) cat <<EOF >>${otmp} |
7a464420 AC |
166 | |
167 | #endif /* OBSERVER_H */ | |
168 | EOF | |
169 | esac | |
170 | ||
171 | ||
15c3c5c6 EZ |
172 | echo Moving ${otmp} to ${o} |
173 | mv ${otmp} ${o} |