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