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