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