Mercurial > hg > octave-lyh
annotate src/genprops.awk @ 8766:8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 16 Feb 2009 14:43:34 -0500 |
parents | e41f420875db |
children | eb63fbe60fab |
rev | line source |
---|---|
7019 | 1 ## Copyright (C) 2007 John W. Eaton |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by the | |
7 ## Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 ## for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 ## | |
6874 | 19 ## This script is used to generate the graphics.h file from graphics.h.in. |
20 ## | |
21 ## Lines between the BEGIN_PROPERTIES and END_PROPERTIES markers have | |
22 ## one of the following formats: | |
23 ## | |
24 ## TYPE NAME | |
25 ## TYPE NAME QUALIFIERS | |
26 ## mutable TYPE NAME | |
27 ## mutable TYPE NAME QUALIFIERS | |
28 ## | |
29 ## For each property, we generate a declaration for the property. | |
30 ## | |
31 ## If QUALIFIERS is omitted, we generate the following functions directly | |
32 ## in the class declaration: | |
33 ## | |
6875 | 34 ## TYPE |
35 ## get_NAME (void) const | |
36 ## { | |
37 ## return NAME; | |
38 ## } | |
39 ## | |
40 ## void | |
41 ## set_NAME (const TYPE& val) | |
42 ## { | |
43 ## if (! error_state) | |
44 ## NAME = val; | |
45 ## } | |
46 ## | |
47 ## void | |
48 ## set_NAME (const octave_value& val) | |
49 ## { | |
50 ## set_NAME (TYPE (val)); | |
51 ## } | |
6874 | 52 ## |
53 ## If present, the QUALIFIERS string may include any of the characters | |
7379 | 54 ## g, G, m, s, S, o, O, h, which have the following meanings: |
6874 | 55 ## |
56 ## g: There is a custom inline definition for the get function, | |
57 ## so we don't emit one. | |
58 ## | |
59 ## G: There is a custom extern definition for the get function, | |
60 ## so we emit only the declaration. | |
61 ## | |
62 ## s: There is a custom inline definition for the type-specific set | |
63 ## function, so we don't emit one. | |
64 ## | |
65 ## S: There is a custom extern definition for the type-specific set | |
66 ## function, so we emit only the declaration. | |
67 ## | |
68 ## o: There is a custom inline definition for the octave_value version | |
69 ## of the set function, so we don't emit one. | |
70 ## | |
71 ## O: There is a custom extern definition for the octave_value version | |
72 ## of the set function, so we emit only the declaration. | |
73 ## | |
6904 | 74 ## a: The octave_value version of the set function will use assignment: |
75 ## | |
76 ## void | |
77 ## set_NAME (const octave_value& val) | |
78 ## { | |
79 ## TYPE tmp (NAME); | |
80 ## tmp = val; | |
81 ## set_NAME (tmp); | |
82 ## } | |
83 ## | |
84 ## This is useful for things like the radio_value classes which | |
85 ## use an overloaded assignment operator of the form | |
86 ## | |
87 ## radio_property& operator = (const octave_value& val); | |
88 ## | |
89 ## that preserves the list of possible values, which is different | |
90 ## from what would happen if we simply used the | |
91 ## | |
92 ## TYPE (const octave_value&) | |
93 ## | |
94 ## constructor, which creates a new radio_property and so cannot | |
95 ## preserve the old list of possible values. | |
96 ## | |
7214 | 97 ## l: Add the line |
98 ## | |
99 ## update_axis_limits ("NAME"); | |
100 ## | |
101 ## to the type-specific set function. | |
102 ## | |
6874 | 103 ## m: Add the line |
104 ## | |
105 ## set_NAMEmode ("manual"); | |
106 ## | |
107 ## to the type-specific set function. | |
108 ## | |
7379 | 109 ## h: Make the property hidden |
110 ## | |
7427 | 111 ## r: Make the property read-only. A read-only property is not |
112 ## settable from the global set (caseless_str, octave_value) | |
113 ## method, but still has set_X accessor. | |
114 ## | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
115 ## u: The property has an inline updater method. This effectively |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
116 ## add the line |
7427 | 117 ## |
118 ## update_NAME (); | |
119 ## | |
120 ## to the type-specific set function. This line is added before | |
121 ## any other update call (like those added by the 'l' or 'm' | |
122 ## modifiers. | |
123 ## | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
124 ## U: Like 'u' modifier except that the updater is not inline. |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
125 ## A declaration for the updater function will be emitted. |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
126 ## |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
127 ## f: The property does not have any factory default value. |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
128 ## |
6874 | 129 ## The 'o' and 'O' qualifiers are only useful when the the property type |
130 ## is something other than octave_value. | |
131 | |
7363 | 132 ## simple accessor |
133 | |
134 function emit_get_accessor (i, rtype, faccess) | |
135 { | |
136 printf (" %s get_%s (void) const", rtype, name[i]); | |
137 | |
138 if (emit_get[i] == "definition") | |
139 printf (" { return %s.%s (); }\n", name[i], faccess); | |
140 else | |
141 printf (";\n"); | |
142 } | |
143 | |
144 ## bool_property | |
145 | |
146 function emit_get_bool (i) | |
147 { | |
148 printf (" bool is_%s (void) const", name[i]); | |
149 | |
150 if (emit_get[i] == "definition") | |
151 printf (" { return %s.is_on (); }\n", name[i]); | |
152 else | |
153 printf (";\n"); | |
154 | |
155 emit_get_accessor(i, "std::string", "current_value"); | |
156 } | |
157 | |
158 ## radio_property | |
159 | |
160 function emit_get_radio (i) | |
161 { | |
162 printf (" bool %s_is (const std::string& v) const", name[i]); | |
163 | |
164 if (emit_get[i] == "definition") | |
165 printf (" { return %s.is (v); }\n", name[i]); | |
166 else | |
167 printf (";\n"); | |
168 | |
169 emit_get_accessor(i, "std::string", "current_value"); | |
170 } | |
171 | |
172 ## color_property | |
173 | |
174 function emit_get_color (i) | |
175 { | |
176 printf (" bool %s_is_rgb (void) const { return %s.is_rgb (); }\n", name[i], name[i]); | |
177 | |
178 printf (" bool %s_is (const std::string& v) const", name[i]); | |
179 | |
180 if (emit_get[i] == "definition") | |
181 printf (" { return %s.is (v); }\n", name[i]); | |
182 else | |
183 printf (";\n"); | |
184 | |
185 printf (" Matrix get_%s_rgb (void) const", name[i]); | |
186 | |
187 if (emit_get[i] == "definition") | |
188 printf (" { return (%s.is_rgb () ? %s.rgb () : Matrix ()); }\n", name[i], name[i]); | |
189 else | |
190 printf (";\n"); | |
191 | |
192 emit_get_accessor(i, "octave_value", "get"); | |
193 } | |
194 | |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
195 ## double_radio_property |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
196 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
197 function emit_get_double_radio (i) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
198 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
199 printf (" bool %s_is_double (void) const { return %s.is_double (); }\n", name[i], name[i]); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
200 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
201 printf (" bool %s_is (const std::string& v) const", name[i]); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
202 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
203 if (emit_get[i] == "definition") |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
204 printf (" { return %s.is (v); }\n", name[i]); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
205 else |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
206 printf (";\n"); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
207 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
208 printf (" double get_%s_double (void) const", name[i]); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
209 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
210 if (emit_get[i] == "definition") |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
211 printf (" { return (%s.is_double () ? %s.double_value () : 0); }\n", name[i], name[i]); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
212 else |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
213 printf (";\n"); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
214 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
215 emit_get_accessor(i, "octave_value", "get"); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
216 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
217 |
7363 | 218 ## callback_property |
219 | |
220 function emit_get_callback (i) | |
221 { | |
7367 | 222 printf (" void execute_%s (const octave_value& data = octave_value ()) const", name[i]); |
7363 | 223 |
224 if (emit_get[i] == "definition") | |
7367 | 225 printf (" { %s.execute (data); }\n", name[i]); |
7363 | 226 else |
227 printf (";\n"); | |
228 | |
229 emit_get_accessor(i, "octave_value", "get"); | |
230 } | |
231 | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
232 ## array_property |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
233 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
234 function emit_get_array (i) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
235 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
236 emit_get_accessor(i, "octave_value", "get"); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
237 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
238 |
7363 | 239 ## common section |
240 | |
241 function emit_common_declarations () | |
242 { | |
243 printf ("public:\n"); | |
244 printf (" properties (const graphics_handle& mh, const graphics_handle& p);\n\n"); | |
245 printf (" ~properties (void) { }\n\n"); | |
7406 | 246 printf (" void set (const caseless_str& pname, const octave_value& val);\n\n"); |
7379 | 247 printf (" octave_value get (bool all = false) const;\n\n"); |
7406 | 248 printf (" octave_value get (const caseless_str& pname) const;\n\n"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
249 printf (" property get_property (const caseless_str& pname);\n\n"); |
7363 | 250 printf (" std::string graphics_object_name (void) const { return go_name; }\n\n"); |
251 printf (" static property_list::pval_map_type factory_defaults (void);\n\n"); | |
252 printf ("private:\n static std::string go_name;\n\n"); | |
253 } | |
254 | |
7225 | 255 function emit_declarations () |
6874 | 256 { |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
257 if (class_name && ! base) |
7363 | 258 emit_common_declarations(); |
259 | |
6874 | 260 if (idx > 0) |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
261 print (base ? "protected:\n" : "private:\n"); |
6874 | 262 |
263 for (i = 1; i <= idx; i++) | |
7363 | 264 printf (" %s%s %s;\n", mutable[i] ? "mutable " : "", type[i], name[i]); |
6874 | 265 |
266 if (idx > 0) | |
7363 | 267 print "\npublic:\n"; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
268 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
269 if (idx > 0) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
270 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
271 printf (" enum\n {"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
272 for (i = 1; i <= idx; i++) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
273 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
274 printf ("%s\n %s = %d", (i == 1 ? "" : ","), toupper(name[i]), pcount); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
275 pcount++; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
276 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
277 printf ("\n };\n\n"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
278 pcount = (int(pcount/1000)+1)*1000; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
279 } |
6874 | 280 |
281 for (i = 1; i <= idx; i++) | |
282 { | |
7363 | 283 if (emit_get[i]) |
284 { | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
285 if (type[i] == "any_property") |
7363 | 286 emit_get_accessor(i, "octave_value", "get"); |
287 else if (type[i] == "handle_property") | |
288 emit_get_accessor(i, "graphics_handle", "handle_value"); | |
289 else if (type[i] == "string_property") | |
290 emit_get_accessor(i, "std::string", "string_value"); | |
291 else if (type[i] == "double_property") | |
292 emit_get_accessor(i, "double", "double_value"); | |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
293 else if (type[i] == "double_radio_property") |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7836
diff
changeset
|
294 emit_get_double_radio(i); |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
295 else if (type[i] == "array_property" \ |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
296 || type[i] == "row_vector_property") |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7826
diff
changeset
|
297 emit_get_array(i); |
7363 | 298 else if (type[i] == "bool_property") |
299 emit_get_bool(i); | |
300 else if (type[i] == "radio_property") | |
301 emit_get_radio(i); | |
302 else if (type[i] == "color_property") | |
303 emit_get_color(i); | |
304 else if (type[i] == "callback_property") | |
305 emit_get_callback(i); | |
306 else | |
6874 | 307 { |
7363 | 308 printf (" %s get_%s (void) const", type[i], name[i]); |
6874 | 309 |
7363 | 310 if (emit_get[i] == "definition") |
311 printf (" { return %s; }\n", name[i]); | |
312 else | |
313 printf (";\n"); | |
6874 | 314 } |
7363 | 315 printf ("\n"); |
316 } | |
6874 | 317 } |
318 | |
319 if (idx > 0) | |
7363 | 320 printf ("\n"); |
6874 | 321 |
322 for (i = 1; i <= idx; i++) | |
323 { | |
7363 | 324 if (emit_set[i]) |
325 { | |
326 printf (" void set_%s (const octave_value& val)", name[i], type[i]); | |
6874 | 327 |
7363 | 328 if (emit_set[i] == "definition") |
329 { | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
330 if (updaters[i] || limits[i] || mode[i]) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
331 has_builtin_listeners = 1; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
332 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
333 has_builtin_listeners = 0; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
334 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
335 printf ("\n {\n if (! error_state)\n {\n if (%s.set (val, %s))\n {\n", |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
336 name[i], (has_builtin_listeners ? "false" : "true")); |
8139
6b3a965b6c7d
genprops.awk: emit set_mode calls before updaters
John W. Eaton <jwe@octave.org>
parents:
8063
diff
changeset
|
337 if (mode[i]) |
6b3a965b6c7d
genprops.awk: emit set_mode calls before updaters
John W. Eaton <jwe@octave.org>
parents:
8063
diff
changeset
|
338 printf (" set_%smode (\"manual\");\n", name[i]); |
7427 | 339 if (updater[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
340 printf (" update_%s ();\n", name[i]); |
7363 | 341 if (limits[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
342 printf (" update_axis_limits (\"%s\");\n", name[i]); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
343 if (has_builtin_listeners) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
344 printf (" %s.run_listeners (POSTSET);\n", name[i]); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
345 printf (" mark_modified ();\n"); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
346 printf (" }\n"); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
347 if (mode[i]) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
348 printf (" else\n set_%smode (\"manual\");\n", name[i]); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
349 printf (" }\n }\n\n"); |
6874 | 350 } |
7363 | 351 else |
352 printf (";\n\n"); | |
353 } | |
6874 | 354 |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
355 if (updater[i] == "extern") |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
356 { |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
357 printf (" void update_%s (void);\n\n", name[i]); |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
358 } |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
359 |
7363 | 360 ## if (emit_ov_set[i]) |
361 ## { | |
362 ## printf (" void set_%s (const octave_value& val)", name[i]); | |
363 ## | |
364 ## if (emit_ov_set[i] == "definition") | |
365 ## printf (" { set_%s (%s (val)); }\n\n", name[i], type[i]); | |
366 ## else if (emit_ov_set[i] == "assignment") | |
367 ## { | |
368 ## printf ("\n {\n %s tmp (%s);\n tmp = val;\n set_%s (tmp);\n };\n\n", | |
369 ## type[i], name[i], name[i], name[i]); | |
370 ## } | |
371 ## else | |
372 ## printf (";\n"); | |
373 ## } | |
6874 | 374 } |
375 | |
7363 | 376 ## if (idx > 0) |
377 ## print "\nprivate:"; | |
378 } | |
379 | |
380 function emit_source () | |
381 { | |
382 if (class_name) | |
383 { | |
384 printf ("// ******** %s ********\n\n", class_name) >> filename; | |
385 | |
386 ## constructor | |
387 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
388 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
389 printf ("base_properties::base_properties (const std::string& ty, const graphics_handle& mh, const graphics_handle& p)\n : ") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
390 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
391 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
392 printf ("%s::properties::properties (const graphics_handle& mh, const graphics_handle& p)\n", class_name) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
393 printf (" : base_properties (go_name, mh, p),\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
394 } |
7363 | 395 |
396 for (i = 1; i <= idx; i++) | |
397 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
398 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
399 printf (" %s (\"%s\", mh, %s)", name[i], name[i], defval[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
400 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
401 printf (" %s (%s)", name[i], defval[i]) >> filename; |
7363 | 402 if (i < idx) |
403 printf (",") >> filename; | |
404 printf ("\n") >> filename; | |
405 } | |
406 | |
7379 | 407 printf ("{\n") >> filename; |
7363 | 408 |
7379 | 409 for (i = 1; i <= idx; i++) |
410 { | |
411 ## printf (" insert_static_property (\"%s\", %s);\n", name[i], name[i]) >> filename; | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
412 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
413 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
414 printf (" %s.set_id (%s);\n", name[i], toupper(name[i])) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
415 if (hidden[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
416 printf (" %s.set_hidden (true);\n", name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
417 } |
7379 | 418 } |
7363 | 419 |
7379 | 420 printf (" init ();\n}\n\n") >> filename; |
7363 | 421 |
422 ## set method | |
423 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
424 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
425 printf ("void\nbase_properties::set (const caseless_str& pname, const octave_value& val)\n{\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
426 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
427 printf ("void\n%s::properties::set (const caseless_str& pname, const octave_value& val)\n{\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
428 class_name) >> filename; |
7363 | 429 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
430 first = 1; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
431 |
7363 | 432 for (i = 1; i <= idx; i++) |
433 { | |
7403 | 434 if (! readonly[i]) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
435 { |
7406 | 436 printf (" %sif (pname.compare (\"%s\"))\n set_%s (val);\n", |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
437 (first == 0 ? "else " : ""), name[i], name[i]) >> filename; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
438 first = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
439 } |
7363 | 440 } |
441 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
442 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
443 printf (" else\n set_dynamic (pname, val);\n}\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
444 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
445 printf (" else\n base_properties::set (pname, val);\n}\n\n") >> filename; |
7363 | 446 |
447 ## get "all" method | |
448 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
449 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
450 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
451 printf ("octave_value\nbase_properties::get (bool all) const\n{\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
452 printf (" Octave_map m = get_dynamic (all).map_value ();\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
453 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
454 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
455 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
456 printf ("octave_value\n%s::properties::get (bool all) const\n{\n", class_name) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
457 printf (" Octave_map m = base_properties::get (all).map_value ();\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
458 } |
7363 | 459 |
460 for (i = 1; i <= idx; i++) | |
461 { | |
7379 | 462 if (hidden[i]) |
463 printf (" if (all)\n m.assign (\"%s\", get_%s ()%s);\n", name[i], name[i], | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
464 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7379 | 465 else |
466 printf (" m.assign (\"%s\", get_%s ()%s);\n", name[i], name[i], | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
467 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7363 | 468 } |
469 | |
470 printf ("\n return m;\n}\n\n") >> filename; | |
471 | |
472 ## get "one" method | |
473 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
474 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
475 printf ("octave_value\nbase_properties::get (const caseless_str& pname) const\n{\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
476 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
477 printf ("octave_value\n%s::properties::get (const caseless_str& pname) const\n{\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
478 class_name) >> filename; |
7363 | 479 printf (" octave_value retval;\n\n") >> filename; |
480 | |
481 for (i = 1; i<= idx; i++) | |
482 { | |
7406 | 483 printf (" %sif (pname.compare (\"%s\"))\n", |
7363 | 484 (i > 1 ? "else " : ""), name[i]) >> filename; |
485 printf (" retval = get_%s ()%s;\n", name[i], | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
486 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7363 | 487 } |
488 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
489 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
490 printf (" else\n retval = get_dynamic (pname);\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
491 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
492 printf (" else\n retval = base_properties::get (pname);\n\n") >> filename; |
7363 | 493 printf (" return retval;\n}\n\n") >> filename; |
494 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
495 ## get_property method |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
496 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
497 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
498 printf ("property\nbase_properties::get_property (const caseless_str& pname)\n{\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
499 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
500 printf ("property\n%s::properties::get_property (const caseless_str& pname)\n{\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
501 class_name) >> filename; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
502 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
503 for (i = 1; i<= idx; i++) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
504 { |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
505 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
506 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
507 printf (" %sif (pname.compare (\"%s\"))\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
508 (i > 1 ? "else " : ""), name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
509 printf (" return property (&%s, true);\n", name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
510 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
511 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
512 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
513 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
514 printf (" else\n return get_property_dynamic (pname);\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
515 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
516 printf (" else\n return base_properties::get_property (pname);\n") >> filename; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
517 printf ("}\n\n") >> filename; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
518 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
519 |
7363 | 520 ## factory defaults method |
521 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
522 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
523 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
524 printf ("property_list::pval_map_type\nbase_properties::factory_defaults (void)\n{\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
525 printf (" property_list::pval_map_type m;\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
526 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
527 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
528 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
529 printf ("property_list::pval_map_type\n%s::properties::factory_defaults (void)\n{\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
530 class_name) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
531 printf (" property_list::pval_map_type m = base_properties::factory_defaults ();\n\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
532 } |
7363 | 533 |
534 for (i = 1; i <= idx; i++) | |
535 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
536 if (factory[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
537 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
538 dval = defval[i]; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
539 if (type[i] == "radio_property" || type[i] == "color_property") |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
540 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
541 k = index (dval, "{"); |
8766
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
542 dval = substr (dval, k+1); |
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
543 l = index (dval, "}"); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
544 if (k > 0 && l > 0) |
8766
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
545 dval = "\"" substr (dval, 1, l-1) "\""; |
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
546 else |
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
547 dval = "octave_value ()"; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
548 } |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
549 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
550 printf (" m[\"%s\"] = %s%s;\n", name[i], dval, |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
551 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
552 } |
7363 | 553 } |
554 | |
555 printf ("\n return m;\n}\n\n") >> filename; | |
556 | |
557 ## go_name static field | |
558 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
559 if (! base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
560 printf ("std::string %s::properties::go_name (\"%s\");\n\n", |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
561 class_name, object_name) >> filename; |
7363 | 562 } |
6874 | 563 } |
564 | |
565 BEGIN { | |
7363 | 566 filename = "graphics-props.cc"; |
567 printf ("// DO NOT EDIT! Generated automatically by genprops.awk.\n\n"); | |
568 printf ("// DO NOT EDIT! Generated automatically by genprops.awk.\n\n") > filename; | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
569 pcount = 0; |
7363 | 570 } |
571 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
572 /BEGIN_PROPERTIES *\(.*\)/ { |
7363 | 573 gather = 1; |
574 idx = 0; | |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
575 str = $0; |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
576 beg = index (str, "(") + 1; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
577 len = index (str, ")") - beg; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
578 args = substr (str, beg, len); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
579 n = split (args, arg_list, ","); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
580 if (n > 0) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
581 class_name = arg_list[1]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
582 if (n > 1) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
583 object_name = arg_list[2]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
584 else |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
585 object_name = class_name; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
586 gsub (/ /, "", class_name); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
587 gsub (/ /, "", object_name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
588 base = 0; |
7363 | 589 next; |
6874 | 590 } |
591 | |
592 /BEGIN_PROPERTIES/ { | |
7363 | 593 gather = 1; |
594 idx = 0; | |
595 class_name = ""; | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
596 base = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
597 next; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
598 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
599 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
600 /BEGIN_BASE_PROPERTIES/ { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
601 gather = 1; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
602 idx = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
603 class_name = "base"; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
604 base = 1; |
7363 | 605 next; |
6874 | 606 } |
607 | |
608 /END_PROPERTIES/ { | |
7363 | 609 emit_declarations(); |
610 emit_source(); | |
611 gather = 0; | |
612 next; | |
6874 | 613 } |
614 | |
615 { | |
616 if (gather) | |
7363 | 617 { |
7403 | 618 if (NF < 2 || /^[ \t]*\/\//) |
7363 | 619 next; |
6874 | 620 |
7363 | 621 idx++; |
6874 | 622 |
7363 | 623 field = 1; |
6874 | 624 |
7363 | 625 if ($field == "mutable") |
626 { | |
627 mutable[idx] = 1; | |
628 field++; | |
629 } | |
630 else | |
631 mutable[idx] = 0; | |
6874 | 632 |
7363 | 633 type[idx] = $(field++); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
634 ptype[idx] = (type[idx] ~ /^.*_property$/); |
7363 | 635 name[idx] = $(field++); |
6874 | 636 |
7363 | 637 limits[idx] = 0; |
638 mode[idx] = 0; | |
7403 | 639 hidden[idx] = 0; |
640 readonly[idx] = 0; | |
7363 | 641 emit_get[idx] = "definition"; |
642 emit_set[idx] = "definition"; | |
7397 | 643 defval[idx] = ""; |
7427 | 644 updater[idx] = ""; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
645 factory[idx] = 1; |
7363 | 646 ## if (type[idx] == "octave_value") |
647 ## emit_ov_set[idx] = ""; | |
648 ## else | |
649 ## emit_ov_set[idx] = "definition"; | |
6874 | 650 |
7363 | 651 if (NF >= field) |
652 { | |
653 if ($field != ",") | |
654 { | |
655 quals = $(field++); | |
7214 | 656 |
7363 | 657 if (index (quals, "l")) |
658 limits[idx] = 1; | |
6874 | 659 |
7363 | 660 if (index (quals, "m")) |
661 mode[idx] = 1; | |
662 | |
663 ## There is a custom inline definition for the get function, | |
664 ## so we don't emit anything. | |
665 if (index (quals, "g")) | |
666 emit_get[idx] = ""; | |
6874 | 667 |
7363 | 668 ## There is a custom extern definition for the get function, |
669 ## but we still emit the declaration. | |
670 if (index (quals, "G")) | |
671 emit_get[idx] = "declaration"; | |
6874 | 672 |
7363 | 673 ## There is a custom inline definition for the set function, |
674 ## so we don't emit anything. | |
675 if (index (quals, "s")) | |
676 emit_set[idx] = ""; | |
6874 | 677 |
7363 | 678 ## There is a custom extern definition for the set function, |
679 ## but we still emit the declaration. | |
680 if (index (quals, "S")) | |
681 emit_set[idx] = "declaration"; | |
7379 | 682 |
7403 | 683 ## The property is hidden |
684 if (index (quals, "h")) | |
685 hidden[idx] = 1; | |
686 | |
687 ## The property is read-only | |
688 if (index (quals, "r")) | |
689 readonly[idx] = 1; | |
6904 | 690 |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
691 ## There is an inline updater method that should be called |
7427 | 692 ## from the set method |
693 if (index (quals, "u")) | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
694 updater[idx] = "inline"; |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
695 |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
696 ## There is an extern updater method that should be called |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
697 ## from the set method |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
698 if (index (quals, "U")) |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
699 updater[idx] = "extern"; |
7427 | 700 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
701 ## There is not factory default value |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
702 if (index (quals, "f")) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
703 factory[idx] = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
704 |
7363 | 705 ## ## emmit an asignment set function |
706 ## if (index (quals, "a")) | |
707 ## emit_ov_set[idx] = "assignment"; | |
708 ## | |
709 ## if (type[idx] != "octave_value") | |
710 ## { | |
711 ## ## The 'o' and 'O' qualifiers are only useful when the | |
712 ## ## the property type is something other than an | |
713 ## ## octave_value. | |
714 ## | |
715 ## ## There is a custom inline definition for the | |
716 ## ## octave_value version of the set function, so we | |
717 ## ## don't emit anything. | |
718 ## if (index (quals, "o")) | |
719 ## emit_ov_set[idx] = ""; | |
720 ## | |
721 ## ## There is a custom extern definition for the | |
722 ## ## octave_value version of the set function, but we | |
723 ## ## still emit the declaration. | |
724 ## if (index (quals, "O")) | |
725 ## emit_ov_set[idx] = "declaration"; | |
726 ## } | |
727 } | |
6874 | 728 |
7363 | 729 if (NF > field && $field == ",") |
730 { | |
731 field++; | |
6874 | 732 |
7363 | 733 for (i = field; i <= NF; i++) |
7397 | 734 defval[idx] = (defval[idx] (i > field ? " " : "") $i); |
7363 | 735 } |
6874 | 736 } |
7363 | 737 |
738 } | |
6874 | 739 else |
7363 | 740 print $0; |
6883 | 741 } |