Mercurial > hg > octave-lyh
annotate libinterp/genprops.awk @ 16629:cbaf19edc4ee
in Windows terminal, don't clear selection when copying to clipboard
* QWinTerminalImpl.cpp (QWinTerminalImpl::copyClipboard):
Don't clear selection.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 07 May 2013 15:53:53 -0400 |
parents | 2fc554ffbc28 |
children | f68b0f51c896 |
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 ## | |
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 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
244 ## 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
|
245 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
246 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
|
247 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
248 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
|
249 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
250 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
|
251 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
|
252 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
253 printf (";\n"); |
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 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
|
256 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
257 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
|
258 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
|
259 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
260 printf (";\n"); |
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 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
|
263 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12959
diff
changeset
|
264 |
7363 | 265 ## common section |
266 | |
267 function emit_common_declarations () | |
268 { | |
269 printf ("public:\n"); | |
270 printf (" properties (const graphics_handle& mh, const graphics_handle& p);\n\n"); | |
271 printf (" ~properties (void) { }\n\n"); | |
7406 | 272 printf (" void set (const caseless_str& pname, const octave_value& val);\n\n"); |
7379 | 273 printf (" octave_value get (bool all = false) const;\n\n"); |
7406 | 274 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
|
275 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
|
276 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
|
277 printf (" property get_property (const caseless_str& pname);\n\n"); |
7363 | 278 printf (" std::string graphics_object_name (void) const { return go_name; }\n\n"); |
279 printf (" static property_list::pval_map_type factory_defaults (void);\n\n"); | |
280 printf ("private:\n static std::string go_name;\n\n"); | |
281 } | |
282 | |
7225 | 283 function emit_declarations () |
6874 | 284 { |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
285 if (class_name && ! base) |
7363 | 286 emit_common_declarations(); |
287 | |
9972 | 288 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
|
289 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
290 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
|
291 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
|
292 |
6874 | 293 if (idx > 0) |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
294 print (base ? "protected:\n" : "private:\n"); |
6874 | 295 |
296 for (i = 1; i <= idx; i++) | |
7363 | 297 printf (" %s%s %s;\n", mutable[i] ? "mutable " : "", type[i], name[i]); |
6874 | 298 |
299 if (idx > 0) | |
7363 | 300 print "\npublic:\n"; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
301 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
302 if (idx > 0) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
303 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
304 printf (" enum\n {"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
305 for (i = 1; i <= idx; i++) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
306 { |
11239
5fa7667f90e5
Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents:
11074
diff
changeset
|
307 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
|
308 pcount++; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
309 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
310 printf ("\n };\n\n"); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
311 pcount = (int(pcount/1000)+1)*1000; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7895
diff
changeset
|
312 } |
6874 | 313 |
314 for (i = 1; i <= idx; i++) | |
315 { | |
7363 | 316 if (emit_get[i]) |
317 { | |
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
|
318 if (type[i] == "any_property") |
7363 | 319 emit_get_accessor(i, "octave_value", "get"); |
320 else if (type[i] == "handle_property") | |
321 emit_get_accessor(i, "graphics_handle", "handle_value"); | |
322 else if (type[i] == "string_property") | |
323 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
|
324 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
|
325 emit_get_accessor(i, "octave_value", "get"); |
7363 | 326 else if (type[i] == "double_property") |
327 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
|
328 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
|
329 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
|
330 else if (type[i] == "array_property" \ |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
331 || 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
|
332 emit_get_array(i); |
7363 | 333 else if (type[i] == "bool_property") |
334 emit_get_bool(i); | |
335 else if (type[i] == "radio_property") | |
336 emit_get_radio(i); | |
337 else if (type[i] == "color_property") | |
338 emit_get_color(i); | |
339 else if (type[i] == "callback_property") | |
340 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
|
341 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
|
342 emit_get_string_array(i); |
7363 | 343 else |
6874 | 344 { |
7363 | 345 printf (" %s get_%s (void) const", type[i], name[i]); |
6874 | 346 |
7363 | 347 if (emit_get[i] == "definition") |
348 printf (" { return %s; }\n", name[i]); | |
349 else | |
350 printf (";\n"); | |
6874 | 351 } |
7363 | 352 printf ("\n"); |
353 } | |
6874 | 354 } |
355 | |
356 if (idx > 0) | |
7363 | 357 printf ("\n"); |
6874 | 358 |
359 for (i = 1; i <= idx; i++) | |
360 { | |
7363 | 361 if (emit_set[i]) |
362 { | |
363 printf (" void set_%s (const octave_value& val)", name[i], type[i]); | |
6874 | 364 |
7363 | 365 if (emit_set[i] == "definition") |
366 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
367 if (updaters[i] || limits[i] || mode[i]) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
368 has_builtin_listeners = 1; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
369 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
370 has_builtin_listeners = 0; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
371 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
372 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
|
373 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
|
374 if (mode[i]) |
6b3a965b6c7d
genprops.awk: emit set_mode calls before updaters
John W. Eaton <jwe@octave.org>
parents:
8063
diff
changeset
|
375 printf (" set_%smode (\"manual\");\n", name[i]); |
7427 | 376 if (updater[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
377 printf (" update_%s ();\n", name[i]); |
7363 | 378 if (limits[i]) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
379 printf (" update_axis_limits (\"%s\");\n", name[i]); |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
380 if (has_builtin_listeners) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
381 printf (" %s.run_listeners (POSTSET);\n", name[i]); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8061
diff
changeset
|
382 printf (" mark_modified ();\n"); |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
383 printf (" }\n"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
384 if (mode[i]) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
385 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
|
386 printf (" }\n }\n\n"); |
6874 | 387 } |
7363 | 388 else |
389 printf (";\n\n"); | |
390 } | |
6874 | 391 |
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
|
392 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
|
393 { |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
394 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
|
395 } |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7523
diff
changeset
|
396 |
7363 | 397 ## if (emit_ov_set[i]) |
398 ## { | |
399 ## printf (" void set_%s (const octave_value& val)", name[i]); | |
400 ## | |
401 ## if (emit_ov_set[i] == "definition") | |
402 ## printf (" { set_%s (%s (val)); }\n\n", name[i], type[i]); | |
403 ## else if (emit_ov_set[i] == "assignment") | |
404 ## { | |
405 ## printf ("\n {\n %s tmp (%s);\n tmp = val;\n set_%s (tmp);\n };\n\n", | |
406 ## type[i], name[i], name[i], name[i]); | |
407 ## } | |
408 ## else | |
409 ## printf (";\n"); | |
410 ## } | |
6874 | 411 } |
412 | |
7363 | 413 ## if (idx > 0) |
414 ## print "\nprivate:"; | |
415 } | |
416 | |
417 function emit_source () | |
418 { | |
419 if (class_name) | |
420 { | |
9906 | 421 printf ("// ******** %s ********\n\n", class_name); |
7363 | 422 |
423 ## constructor | |
424 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
425 if (base) |
9906 | 426 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
|
427 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
428 { |
9906 | 429 printf ("%s::properties::properties (const graphics_handle& mh, const graphics_handle& p)\n", class_name); |
430 printf (" : base_properties (go_name, mh, p),\n"); | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
431 } |
7363 | 432 |
433 for (i = 1; i <= idx; i++) | |
434 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
435 if (ptype[i]) |
9906 | 436 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
|
437 else |
9906 | 438 printf (" %s (%s)", name[i], defval[i]); |
7363 | 439 if (i < idx) |
9906 | 440 printf (","); |
441 printf ("\n"); | |
7363 | 442 } |
443 | |
9906 | 444 printf ("{\n"); |
7363 | 445 |
7379 | 446 for (i = 1; i <= idx; i++) |
447 { | |
9906 | 448 ## 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
|
449 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
450 { |
11239
5fa7667f90e5
Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents:
11074
diff
changeset
|
451 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
|
452 if (hidden[i]) |
9906 | 453 printf (" %s.set_hidden (true);\n", name[i]); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
454 } |
7379 | 455 } |
7363 | 456 |
9906 | 457 printf (" init ();\n}\n\n"); |
7363 | 458 |
459 ## set method | |
460 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
461 if (base) |
9972 | 462 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
|
463 else |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
464 printf ("void\n%s::properties::set (const caseless_str& pname_arg, const octave_value& val)\n{\n", |
9906 | 465 class_name); |
7363 | 466 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9185
diff
changeset
|
467 if (! base) |
9906 | 468 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
|
469 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
470 first = 1; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
471 |
7363 | 472 for (i = 1; i <= idx; i++) |
473 { | |
7403 | 474 if (! readonly[i]) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
475 { |
7406 | 476 printf (" %sif (pname.compare (\"%s\"))\n set_%s (val);\n", |
9906 | 477 (first == 0 ? "else " : ""), name[i], name[i]); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
478 first = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
479 } |
7363 | 480 } |
481 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
482 if (base) |
9972 | 483 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
|
484 else |
9972 | 485 printf (" else\n base_properties::set (pname, val);\n}\n\n"); |
7363 | 486 |
487 ## get "all" method | |
488 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
489 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
490 { |
9906 | 491 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
|
492 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
|
493 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
494 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
495 { |
9906 | 496 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
|
497 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
|
498 } |
7363 | 499 |
500 for (i = 1; i <= idx; i++) | |
501 { | |
7379 | 502 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
|
503 printf (" if (all)\n m.assign (\"%s\", octave_value (get_%s ()%s));\n", name[i], name[i], |
9906 | 504 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")); |
7379 | 505 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
|
506 printf (" m.assign (\"%s\", octave_value (get_%s ()%s));\n", name[i], name[i], |
9906 | 507 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")); |
7363 | 508 } |
509 | |
9906 | 510 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
|
511 |
7363 | 512 ## get "one" method |
513 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
514 if (base) |
9906 | 515 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
|
516 else |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
517 printf ("octave_value\n%s::properties::get (const caseless_str& pname_arg) const\n{\n", |
9906 | 518 class_name); |
519 printf (" octave_value retval;\n\n"); | |
7363 | 520 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9185
diff
changeset
|
521 if (! base) |
9906 | 522 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
|
523 |
7363 | 524 for (i = 1; i<= idx; i++) |
525 { | |
7406 | 526 printf (" %sif (pname.compare (\"%s\"))\n", |
9906 | 527 (i > 1 ? "else " : ""), name[i]); |
7363 | 528 printf (" retval = get_%s ()%s;\n", name[i], |
9906 | 529 (type[i] == "handle_property" || type[i] == "graphics_handle" ? ".as_octave_value ()" : "")); |
7363 | 530 } |
531 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
532 if (base) |
9906 | 533 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
|
534 else |
9906 | 535 printf (" else\n retval = base_properties::get (pname);\n\n"); |
536 printf (" return retval;\n}\n\n"); | |
7363 | 537 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
538 ## get_property method |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
539 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
540 if (base) |
9906 | 541 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
|
542 else |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
543 printf ("property\n%s::properties::get_property (const caseless_str& pname_arg)\n{\n", |
9906 | 544 class_name); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
545 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9185
diff
changeset
|
546 if (! base) |
9906 | 547 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
|
548 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
549 for (i = 1; i<= idx; i++) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
550 { |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
551 if (ptype[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
552 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
553 printf (" %sif (pname.compare (\"%s\"))\n", |
9906 | 554 (i > 1 ? "else " : ""), name[i]); |
555 printf (" return property (&%s, true);\n", name[i]); | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
556 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
557 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
558 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
559 if (base) |
9906 | 560 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
|
561 else |
9906 | 562 printf (" else\n return base_properties::get_property (pname);\n"); |
563 printf ("}\n\n"); | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
564 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
565 |
7363 | 566 ## factory defaults method |
567 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
568 if (base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
569 { |
9906 | 570 printf ("property_list::pval_map_type\nbase_properties::factory_defaults (void)\n{\n"); |
571 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
|
572 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
573 else |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
574 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
575 printf ("property_list::pval_map_type\n%s::properties::factory_defaults (void)\n{\n", |
9906 | 576 class_name); |
577 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
|
578 } |
7363 | 579 |
580 for (i = 1; i <= idx; i++) | |
581 { | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
582 if (factory[i]) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
583 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
584 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
|
585 if (type[i] == "radio_property") |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
586 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
587 k = index (dval, "{"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
588 dval = substr (dval, k+1); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
589 l = index (dval, "}"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
590 if (k > 0 && l > 0) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
591 dval = "\"" substr (dval, 1, l-1) "\""; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
592 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
593 dval = "octave_value ()"; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
594 } |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
595 |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
596 printf (" m[\"%s\"] = %s%s;\n", name[i], dval, |
9906 | 597 (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
|
598 } |
7363 | 599 } |
600 | |
9906 | 601 printf ("\n return m;\n}\n\n"); |
7363 | 602 |
603 ## go_name static field | |
604 | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
605 if (! base) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
606 printf ("std::string %s::properties::go_name (\"%s\");\n\n", |
9906 | 607 class_name, object_name); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
608 |
9906 | 609 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
|
610 if (base) |
9906 | 611 printf ("base_properties"); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
612 else |
9906 | 613 printf ("%s::properties", class_name); |
614 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
|
615 for (i = 1; i <= idx; i++) |
9906 | 616 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
|
617 if (! base) |
9906 | 618 printf ("\n std::set<std::string> base_pnames = base_properties::core_property_names ();\n all_pnames.insert (base_pnames.begin (), base_pnames.end ());\n"); |
619 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
|
620 |
9906 | 621 printf ("bool\n"); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
622 if (base) |
9906 | 623 printf ("base_properties"); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
624 else |
9906 | 625 printf ("%s::properties", class_name); |
626 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
|
627 |
9906 | 628 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
|
629 if (base) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
630 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
|
631 else |
9906 | 632 printf ("%s::properties", class_name); |
9972 | 633 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
|
634 if (base) |
9972 | 635 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
|
636 else |
9972 | 637 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
|
638 |
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) |
9906 | 640 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 | 641 } |
6874 | 642 } |
643 | |
644 BEGIN { | |
9906 | 645 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
|
646 pcount = 0; |
7363 | 647 } |
648 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
649 /BEGIN_PROPERTIES *\(.*\)/ { |
7363 | 650 gather = 1; |
651 idx = 0; | |
7895
f1a1f6dd7fac
avoid using gensub in genprops.awk
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
652 str = $0; |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
653 beg = index (str, "(") + 1; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
654 len = index (str, ")") - beg; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
655 args = substr (str, beg, len); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
656 n = split (args, arg_list, ","); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
657 if (n > 0) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
658 class_name = arg_list[1]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
659 if (n > 1) |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
660 object_name = arg_list[2]; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
661 else |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
662 object_name = class_name; |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
663 gsub (/ /, "", class_name); |
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8139
diff
changeset
|
664 gsub (/ /, "", object_name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
665 base = 0; |
7363 | 666 next; |
6874 | 667 } |
668 | |
669 /BEGIN_PROPERTIES/ { | |
7363 | 670 gather = 1; |
671 idx = 0; | |
672 class_name = ""; | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
673 base = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
674 next; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
675 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
676 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
677 /BEGIN_BASE_PROPERTIES/ { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
678 gather = 1; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
679 idx = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
680 class_name = "base"; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
681 base = 1; |
7363 | 682 next; |
6874 | 683 } |
684 | |
685 /END_PROPERTIES/ { | |
9906 | 686 if (emit_graphics_props) |
687 emit_source(); | |
688 else | |
689 emit_declarations(); | |
7363 | 690 gather = 0; |
691 next; | |
6874 | 692 } |
693 | |
694 { | |
695 if (gather) | |
7363 | 696 { |
7403 | 697 if (NF < 2 || /^[ \t]*\/\//) |
7363 | 698 next; |
6874 | 699 |
7363 | 700 idx++; |
6874 | 701 |
7363 | 702 field = 1; |
6874 | 703 |
7363 | 704 if ($field == "mutable") |
705 { | |
706 mutable[idx] = 1; | |
707 field++; | |
708 } | |
709 else | |
710 mutable[idx] = 0; | |
6874 | 711 |
7363 | 712 type[idx] = $(field++); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
713 ptype[idx] = (type[idx] ~ /^.*_property$/); |
7363 | 714 name[idx] = $(field++); |
6874 | 715 |
7363 | 716 limits[idx] = 0; |
717 mode[idx] = 0; | |
7403 | 718 hidden[idx] = 0; |
719 readonly[idx] = 0; | |
7363 | 720 emit_get[idx] = "definition"; |
721 emit_set[idx] = "definition"; | |
7397 | 722 defval[idx] = ""; |
7427 | 723 updater[idx] = ""; |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
724 factory[idx] = 1; |
7363 | 725 ## if (type[idx] == "octave_value") |
726 ## emit_ov_set[idx] = ""; | |
727 ## else | |
728 ## emit_ov_set[idx] = "definition"; | |
6874 | 729 |
7363 | 730 if (NF >= field) |
731 { | |
732 if ($field != ",") | |
733 { | |
734 quals = $(field++); | |
7214 | 735 |
7363 | 736 if (index (quals, "l")) |
737 limits[idx] = 1; | |
6874 | 738 |
7363 | 739 if (index (quals, "m")) |
740 mode[idx] = 1; | |
741 | |
742 ## There is a custom inline definition for the get function, | |
743 ## so we don't emit anything. | |
744 if (index (quals, "g")) | |
745 emit_get[idx] = ""; | |
6874 | 746 |
7363 | 747 ## There is a custom extern definition for the get function, |
748 ## but we still emit the declaration. | |
749 if (index (quals, "G")) | |
750 emit_get[idx] = "declaration"; | |
6874 | 751 |
7363 | 752 ## There is a custom inline definition for the set function, |
753 ## so we don't emit anything. | |
754 if (index (quals, "s")) | |
755 emit_set[idx] = ""; | |
6874 | 756 |
7363 | 757 ## There is a custom extern definition for the set function, |
758 ## but we still emit the declaration. | |
759 if (index (quals, "S")) | |
760 emit_set[idx] = "declaration"; | |
7379 | 761 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
762 ## The property is hidden |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
763 if (index (quals, "h")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
764 hidden[idx] = 1; |
7403 | 765 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
766 ## The property is read-only |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
767 if (index (quals, "r")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
768 readonly[idx] = 1; |
6904 | 769 |
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
|
770 ## There is an inline updater method that should be called |
7427 | 771 ## from the set method |
772 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
|
773 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
|
774 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
775 ## 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
|
776 ## 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
|
777 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
|
778 updater[idx] = "extern"; |
7427 | 779 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10135
diff
changeset
|
780 ## There is not factory default value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
781 if (index (quals, "f")) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
782 factory[idx] = 0; |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
783 |
7363 | 784 ## ## emmit an asignment set function |
785 ## if (index (quals, "a")) | |
786 ## emit_ov_set[idx] = "assignment"; | |
787 ## | |
788 ## if (type[idx] != "octave_value") | |
789 ## { | |
790 ## ## The 'o' and 'O' qualifiers are only useful when the | |
791 ## ## the property type is something other than an | |
792 ## ## octave_value. | |
793 ## | |
794 ## ## There is a custom inline definition for the | |
795 ## ## octave_value version of the set function, so we | |
796 ## ## don't emit anything. | |
797 ## if (index (quals, "o")) | |
798 ## emit_ov_set[idx] = ""; | |
799 ## | |
800 ## ## There is a custom extern definition for the | |
801 ## ## octave_value version of the set function, but we | |
802 ## ## still emit the declaration. | |
803 ## if (index (quals, "O")) | |
804 ## emit_ov_set[idx] = "declaration"; | |
805 ## } | |
806 } | |
6874 | 807 |
7363 | 808 if (NF > field && $field == ",") |
809 { | |
810 field++; | |
6874 | 811 |
7363 | 812 for (i = field; i <= NF; i++) |
7397 | 813 defval[idx] = (defval[idx] (i > field ? " " : "") $i); |
7363 | 814 } |
6874 | 815 } |
7363 | 816 |
817 } | |
9906 | 818 else if (! emit_graphics_props) |
7363 | 819 print $0; |
6883 | 820 } |