Mercurial > hg > octave-lyh
annotate src/genprops.awk @ 12013:587d268cf64e release-3-2-x
implement d1mach, i1mach, and r1mach using slamch and dlamch from lapack
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 24 Jun 2009 08:13:16 +0200 |
parents | 1e5c11890f85 |
children | bdcfb756d721 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2007, 2008, 2009 John W. Eaton |
7019 | 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 | |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
260 printf ("public:\n\n"); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
261 if (base) |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
262 printf ("\n static bool has_property (const std::string& pname, const std::string& cname);\n\n"); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
263 else |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
264 printf ("\n static bool has_property (const std::string& pname);\n\n"); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
265 |
6874 | 266 if (idx > 0) |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
267 print (base ? "protected:\n" : "private:\n"); |
6874 | 268 |
269 for (i = 1; i <= idx; i++) | |
7363 | 270 printf (" %s%s %s;\n", mutable[i] ? "mutable " : "", type[i], name[i]); |
6874 | 271 |
272 if (idx > 0) | |
7363 | 273 print "\npublic:\n"; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
274 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
275 if (idx > 0) |
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 (" enum\n {"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
278 for (i = 1; i <= idx; i++) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
279 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
280 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
|
281 pcount++; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
282 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
283 printf ("\n };\n\n"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
284 pcount = (int(pcount/1000)+1)*1000; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
285 } |
6874 | 286 |
287 for (i = 1; i <= idx; i++) | |
288 { | |
7363 | 289 if (emit_get[i]) |
290 { | |
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
|
291 if (type[i] == "any_property") |
7363 | 292 emit_get_accessor(i, "octave_value", "get"); |
293 else if (type[i] == "handle_property") | |
294 emit_get_accessor(i, "graphics_handle", "handle_value"); | |
295 else if (type[i] == "string_property") | |
296 emit_get_accessor(i, "std::string", "string_value"); | |
297 else if (type[i] == "double_property") | |
298 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
|
299 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
|
300 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
|
301 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
|
302 || 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
|
303 emit_get_array(i); |
7363 | 304 else if (type[i] == "bool_property") |
305 emit_get_bool(i); | |
306 else if (type[i] == "radio_property") | |
307 emit_get_radio(i); | |
308 else if (type[i] == "color_property") | |
309 emit_get_color(i); | |
310 else if (type[i] == "callback_property") | |
311 emit_get_callback(i); | |
312 else | |
6874 | 313 { |
7363 | 314 printf (" %s get_%s (void) const", type[i], name[i]); |
6874 | 315 |
7363 | 316 if (emit_get[i] == "definition") |
317 printf (" { return %s; }\n", name[i]); | |
318 else | |
319 printf (";\n"); | |
6874 | 320 } |
7363 | 321 printf ("\n"); |
322 } | |
6874 | 323 } |
324 | |
325 if (idx > 0) | |
7363 | 326 printf ("\n"); |
6874 | 327 |
328 for (i = 1; i <= idx; i++) | |
329 { | |
7363 | 330 if (emit_set[i]) |
331 { | |
332 printf (" void set_%s (const octave_value& val)", name[i], type[i]); | |
6874 | 333 |
7363 | 334 if (emit_set[i] == "definition") |
335 { | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
336 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
|
337 has_builtin_listeners = 1; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
338 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
339 has_builtin_listeners = 0; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
340 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
341 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
|
342 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
|
343 if (mode[i]) |
6b3a965b6c7d
genprops.awk: emit set_mode calls before updaters
John W. Eaton <jwe@octave.org>
parents:
8063
diff
changeset
|
344 printf (" set_%smode (\"manual\");\n", name[i]); |
7427 | 345 if (updater[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
346 printf (" update_%s ();\n", name[i]); |
7363 | 347 if (limits[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
348 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
|
349 if (has_builtin_listeners) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
350 printf (" %s.run_listeners (POSTSET);\n", name[i]); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
351 printf (" mark_modified ();\n"); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
352 printf (" }\n"); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
353 if (mode[i]) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
354 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
|
355 printf (" }\n }\n\n"); |
6874 | 356 } |
7363 | 357 else |
358 printf (";\n\n"); | |
359 } | |
6874 | 360 |
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
|
361 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
|
362 { |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
363 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
|
364 } |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
365 |
7363 | 366 ## if (emit_ov_set[i]) |
367 ## { | |
368 ## printf (" void set_%s (const octave_value& val)", name[i]); | |
369 ## | |
370 ## if (emit_ov_set[i] == "definition") | |
371 ## printf (" { set_%s (%s (val)); }\n\n", name[i], type[i]); | |
372 ## else if (emit_ov_set[i] == "assignment") | |
373 ## { | |
374 ## printf ("\n {\n %s tmp (%s);\n tmp = val;\n set_%s (tmp);\n };\n\n", | |
375 ## type[i], name[i], name[i], name[i]); | |
376 ## } | |
377 ## else | |
378 ## printf (";\n"); | |
379 ## } | |
6874 | 380 } |
381 | |
7363 | 382 ## if (idx > 0) |
383 ## print "\nprivate:"; | |
384 } | |
385 | |
386 function emit_source () | |
387 { | |
388 if (class_name) | |
389 { | |
390 printf ("// ******** %s ********\n\n", class_name) >> filename; | |
391 | |
392 ## constructor | |
393 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
394 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
395 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
|
396 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
397 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
398 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
|
399 printf (" : base_properties (go_name, mh, p),\n") >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
400 } |
7363 | 401 |
402 for (i = 1; i <= idx; i++) | |
403 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
404 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
405 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
|
406 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
407 printf (" %s (%s)", name[i], defval[i]) >> filename; |
7363 | 408 if (i < idx) |
409 printf (",") >> filename; | |
410 printf ("\n") >> filename; | |
411 } | |
412 | |
7379 | 413 printf ("{\n") >> filename; |
7363 | 414 |
7379 | 415 for (i = 1; i <= idx; i++) |
416 { | |
417 ## 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
|
418 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
419 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
420 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
|
421 if (hidden[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
422 printf (" %s.set_hidden (true);\n", name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
423 } |
7379 | 424 } |
7363 | 425 |
7379 | 426 printf (" init ();\n}\n\n") >> filename; |
7363 | 427 |
428 ## set method | |
429 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
430 if (base) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
431 printf ("void\nbase_properties::set (const caseless_str& pname, const std::string& cname, const octave_value& val)\n{\n") >> filename; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
432 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
433 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
|
434 class_name) >> filename; |
7363 | 435 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
436 first = 1; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
437 |
7363 | 438 for (i = 1; i <= idx; i++) |
439 { | |
7403 | 440 if (! readonly[i]) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
441 { |
7406 | 442 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
|
443 (first == 0 ? "else " : ""), name[i], name[i]) >> filename; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
444 first = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
445 } |
7363 | 446 } |
447 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
448 if (base) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
449 printf (" else\n set_dynamic (pname, cname, val);\n}\n\n") >> filename; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
450 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
451 printf (" else\n base_properties::set (pname, \"%s\", val);\n}\n\n", class_name) >> filename; |
7363 | 452 |
453 ## get "all" method | |
454 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
455 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
456 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
457 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
|
458 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
|
459 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
460 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
461 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
462 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
|
463 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
|
464 } |
7363 | 465 |
466 for (i = 1; i <= idx; i++) | |
467 { | |
7379 | 468 if (hidden[i]) |
469 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
|
470 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7379 | 471 else |
472 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
|
473 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7363 | 474 } |
475 | |
476 printf ("\n return m;\n}\n\n") >> filename; | |
477 | |
478 ## get "one" method | |
479 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
480 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
481 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
|
482 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
483 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
|
484 class_name) >> filename; |
7363 | 485 printf (" octave_value retval;\n\n") >> filename; |
486 | |
487 for (i = 1; i<= idx; i++) | |
488 { | |
7406 | 489 printf (" %sif (pname.compare (\"%s\"))\n", |
7363 | 490 (i > 1 ? "else " : ""), name[i]) >> filename; |
491 printf (" retval = get_%s ()%s;\n", name[i], | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
492 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")) >> filename; |
7363 | 493 } |
494 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
495 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
496 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
|
497 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
498 printf (" else\n retval = base_properties::get (pname);\n\n") >> filename; |
7363 | 499 printf (" return retval;\n}\n\n") >> filename; |
500 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
501 ## get_property method |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
502 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
503 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
504 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
|
505 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
506 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
|
507 class_name) >> filename; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
508 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
509 for (i = 1; i<= idx; i++) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
510 { |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
511 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
512 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
513 printf (" %sif (pname.compare (\"%s\"))\n", |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
514 (i > 1 ? "else " : ""), name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
515 printf (" return property (&%s, true);\n", name[i]) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
516 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
517 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
518 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
519 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
520 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
|
521 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
522 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
|
523 printf ("}\n\n") >> filename; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
524 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
525 |
7363 | 526 ## factory defaults method |
527 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
528 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
529 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
530 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
|
531 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
|
532 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
533 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
534 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
535 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
|
536 class_name) >> filename; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
537 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
|
538 } |
7363 | 539 |
540 for (i = 1; i <= idx; i++) | |
541 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
542 if (factory[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
543 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
544 dval = defval[i]; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
545 if (type[i] == "radio_property" || type[i] == "color_property") |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
546 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
547 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
|
548 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
|
549 l = index (dval, "}"); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
550 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
|
551 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
|
552 else |
8cb2a144f321
genprops.awk (emit_source): don't use + to concatenate strings
John W. Eaton <jwe@octave.org>
parents:
8247
diff
changeset
|
553 dval = "octave_value ()"; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
554 } |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
555 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
556 printf (" m[\"%s\"] = %s%s;\n", name[i], dval, |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
557 (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
|
558 } |
7363 | 559 } |
560 | |
561 printf ("\n return m;\n}\n\n") >> filename; | |
562 | |
563 ## go_name static field | |
564 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
565 if (! base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
566 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
|
567 class_name, object_name) >> filename; |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
568 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
569 if (base) |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
570 printf ("bool base_properties::has_property (const std::string& pname, const std::string& cname") >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
571 else |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
572 printf ("bool %s::properties::has_property (const std::string& pname", class_name) >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
573 printf (")\n{\n static std::set<std::string> all_properties;\n\n static bool initialized = false;\n\n if (! initialized)\n {\n") >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
574 for (i = 1; i <= idx; i++) |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
575 printf (" all_properties.insert (\"%s\");\n", name[i]) >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
576 printf ("\n initialized = true;\n }\n\n") >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
577 if (base) |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
578 printf (" return all_properties.find (pname) != all_properties.end () || has_dynamic_property (pname, cname);\n}\n\n") >> filename; |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
579 else |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
580 printf (" return all_properties.find (pname) != all_properties.end () || base_properties::has_property (pname, \"%s\");\n}\n\n", class_name) >> filename; |
7363 | 581 } |
6874 | 582 } |
583 | |
584 BEGIN { | |
7363 | 585 filename = "graphics-props.cc"; |
586 printf ("// DO NOT EDIT! Generated automatically by genprops.awk.\n\n"); | |
587 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
|
588 pcount = 0; |
7363 | 589 } |
590 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
591 /BEGIN_PROPERTIES *\(.*\)/ { |
7363 | 592 gather = 1; |
593 idx = 0; | |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
594 str = $0; |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
595 beg = index (str, "(") + 1; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
596 len = index (str, ")") - beg; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
597 args = substr (str, beg, len); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
598 n = split (args, arg_list, ","); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
599 if (n > 0) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
600 class_name = arg_list[1]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
601 if (n > 1) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
602 object_name = arg_list[2]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
603 else |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
604 object_name = class_name; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
605 gsub (/ /, "", class_name); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
606 gsub (/ /, "", object_name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
607 base = 0; |
7363 | 608 next; |
6874 | 609 } |
610 | |
611 /BEGIN_PROPERTIES/ { | |
7363 | 612 gather = 1; |
613 idx = 0; | |
614 class_name = ""; | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
615 base = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
616 next; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
617 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
618 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
619 /BEGIN_BASE_PROPERTIES/ { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
620 gather = 1; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
621 idx = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
622 class_name = "base"; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
623 base = 1; |
7363 | 624 next; |
6874 | 625 } |
626 | |
627 /END_PROPERTIES/ { | |
7363 | 628 emit_declarations(); |
629 emit_source(); | |
630 gather = 0; | |
631 next; | |
6874 | 632 } |
633 | |
634 { | |
635 if (gather) | |
7363 | 636 { |
7403 | 637 if (NF < 2 || /^[ \t]*\/\//) |
7363 | 638 next; |
6874 | 639 |
7363 | 640 idx++; |
6874 | 641 |
7363 | 642 field = 1; |
6874 | 643 |
7363 | 644 if ($field == "mutable") |
645 { | |
646 mutable[idx] = 1; | |
647 field++; | |
648 } | |
649 else | |
650 mutable[idx] = 0; | |
6874 | 651 |
7363 | 652 type[idx] = $(field++); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
653 ptype[idx] = (type[idx] ~ /^.*_property$/); |
7363 | 654 name[idx] = $(field++); |
6874 | 655 |
7363 | 656 limits[idx] = 0; |
657 mode[idx] = 0; | |
7403 | 658 hidden[idx] = 0; |
659 readonly[idx] = 0; | |
7363 | 660 emit_get[idx] = "definition"; |
661 emit_set[idx] = "definition"; | |
7397 | 662 defval[idx] = ""; |
7427 | 663 updater[idx] = ""; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
664 factory[idx] = 1; |
7363 | 665 ## if (type[idx] == "octave_value") |
666 ## emit_ov_set[idx] = ""; | |
667 ## else | |
668 ## emit_ov_set[idx] = "definition"; | |
6874 | 669 |
7363 | 670 if (NF >= field) |
671 { | |
672 if ($field != ",") | |
673 { | |
674 quals = $(field++); | |
7214 | 675 |
7363 | 676 if (index (quals, "l")) |
677 limits[idx] = 1; | |
6874 | 678 |
7363 | 679 if (index (quals, "m")) |
680 mode[idx] = 1; | |
681 | |
682 ## There is a custom inline definition for the get function, | |
683 ## so we don't emit anything. | |
684 if (index (quals, "g")) | |
685 emit_get[idx] = ""; | |
6874 | 686 |
7363 | 687 ## There is a custom extern definition for the get function, |
688 ## but we still emit the declaration. | |
689 if (index (quals, "G")) | |
690 emit_get[idx] = "declaration"; | |
6874 | 691 |
7363 | 692 ## There is a custom inline definition for the set function, |
693 ## so we don't emit anything. | |
694 if (index (quals, "s")) | |
695 emit_set[idx] = ""; | |
6874 | 696 |
7363 | 697 ## There is a custom extern definition for the set function, |
698 ## but we still emit the declaration. | |
699 if (index (quals, "S")) | |
700 emit_set[idx] = "declaration"; | |
7379 | 701 |
7403 | 702 ## The property is hidden |
703 if (index (quals, "h")) | |
704 hidden[idx] = 1; | |
705 | |
706 ## The property is read-only | |
707 if (index (quals, "r")) | |
708 readonly[idx] = 1; | |
6904 | 709 |
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
|
710 ## There is an inline updater method that should be called |
7427 | 711 ## from the set method |
712 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
|
713 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
|
714 |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
715 ## 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
|
716 ## 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
|
717 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
|
718 updater[idx] = "extern"; |
7427 | 719 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
720 ## There is not factory default value |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
721 if (index (quals, "f")) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
722 factory[idx] = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
723 |
7363 | 724 ## ## emmit an asignment set function |
725 ## if (index (quals, "a")) | |
726 ## emit_ov_set[idx] = "assignment"; | |
727 ## | |
728 ## if (type[idx] != "octave_value") | |
729 ## { | |
730 ## ## The 'o' and 'O' qualifiers are only useful when the | |
731 ## ## the property type is something other than an | |
732 ## ## octave_value. | |
733 ## | |
734 ## ## There is a custom inline definition for the | |
735 ## ## octave_value version of the set function, so we | |
736 ## ## don't emit anything. | |
737 ## if (index (quals, "o")) | |
738 ## emit_ov_set[idx] = ""; | |
739 ## | |
740 ## ## There is a custom extern definition for the | |
741 ## ## octave_value version of the set function, but we | |
742 ## ## still emit the declaration. | |
743 ## if (index (quals, "O")) | |
744 ## emit_ov_set[idx] = "declaration"; | |
745 ## } | |
746 } | |
6874 | 747 |
7363 | 748 if (NF > field && $field == ",") |
749 { | |
750 field++; | |
6874 | 751 |
7363 | 752 for (i = field; i <= NF; i++) |
7397 | 753 defval[idx] = (defval[idx] (i > field ? " " : "") $i); |
7363 | 754 } |
6874 | 755 } |
7363 | 756 |
757 } | |
6874 | 758 else |
7363 | 759 print $0; |
6883 | 760 } |