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