/src/tinysparql/subprojects/glib-2.80.3/gobject/gparamspecs.c
Line | Count | Source |
1 | | /* GObject - GLib Type, Object, Parameter and Signal Library |
2 | | * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. |
3 | | * Copyright (C) 2010 Christian Persch |
4 | | * |
5 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
6 | | * |
7 | | * This library is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * This library is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General |
18 | | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
19 | | */ |
20 | | |
21 | | /* |
22 | | * MT safe |
23 | | */ |
24 | | |
25 | | #include "config.h" |
26 | | |
27 | | #include <string.h> |
28 | | |
29 | | #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS |
30 | | #define GLIB_DISABLE_DEPRECATION_WARNINGS |
31 | | #endif |
32 | | |
33 | | #include "gparamspecs.h" |
34 | | #include "gtype-private.h" |
35 | | #include "gvaluecollector.h" |
36 | | |
37 | | #include "gvaluearray.h" |
38 | | |
39 | | |
40 | 0 | #define G_FLOAT_EPSILON (1e-30) |
41 | 0 | #define G_DOUBLE_EPSILON (1e-90) |
42 | | |
43 | | |
44 | | /* --- param spec functions --- */ |
45 | | static void |
46 | | param_char_init (GParamSpec *pspec) |
47 | 0 | { |
48 | 0 | GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec); |
49 | | |
50 | 0 | cspec->minimum = 0x7f; |
51 | 0 | cspec->maximum = 0x80; |
52 | 0 | cspec->default_value = 0; |
53 | 0 | } |
54 | | |
55 | | static void |
56 | | param_char_set_default (GParamSpec *pspec, |
57 | | GValue *value) |
58 | 0 | { |
59 | 0 | value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value; |
60 | 0 | } |
61 | | |
62 | | static gboolean |
63 | | param_char_is_valid (GParamSpec *pspec, |
64 | | const GValue *value) |
65 | 0 | { |
66 | 0 | GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec); |
67 | 0 | gint oval = value->data[0].v_int; |
68 | | |
69 | 0 | return cspec->minimum <= oval && oval <= cspec->maximum; |
70 | 0 | } |
71 | | |
72 | | static gboolean |
73 | | param_char_validate (GParamSpec *pspec, |
74 | | GValue *value) |
75 | 0 | { |
76 | 0 | GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec); |
77 | 0 | gint oval = value->data[0].v_int; |
78 | | |
79 | 0 | value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum); |
80 | | |
81 | 0 | return value->data[0].v_int != oval; |
82 | 0 | } |
83 | | |
84 | | static void |
85 | | param_uchar_init (GParamSpec *pspec) |
86 | 0 | { |
87 | 0 | GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec); |
88 | | |
89 | 0 | uspec->minimum = 0; |
90 | 0 | uspec->maximum = 0xff; |
91 | 0 | uspec->default_value = 0; |
92 | 0 | } |
93 | | |
94 | | static void |
95 | | param_uchar_set_default (GParamSpec *pspec, |
96 | | GValue *value) |
97 | 0 | { |
98 | 0 | value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value; |
99 | 0 | } |
100 | | |
101 | | static gboolean |
102 | | param_uchar_is_valid (GParamSpec *pspec, |
103 | | const GValue *value) |
104 | 0 | { |
105 | 0 | GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec); |
106 | 0 | guint oval = value->data[0].v_uint; |
107 | | |
108 | 0 | return uspec->minimum <= oval && oval <= uspec->maximum; |
109 | 0 | } |
110 | | |
111 | | static gboolean |
112 | | param_uchar_validate (GParamSpec *pspec, |
113 | | GValue *value) |
114 | 0 | { |
115 | 0 | GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec); |
116 | 0 | guint oval = value->data[0].v_uint; |
117 | | |
118 | 0 | value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum); |
119 | | |
120 | 0 | return value->data[0].v_uint != oval; |
121 | 0 | } |
122 | | |
123 | | static void |
124 | | param_boolean_set_default (GParamSpec *pspec, |
125 | | GValue *value) |
126 | 1 | { |
127 | 1 | value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value; |
128 | 1 | } |
129 | | |
130 | | static gboolean |
131 | | param_boolean_is_valid (GParamSpec *pspec, |
132 | | const GValue *value) |
133 | 28 | { |
134 | 28 | int oval = value->data[0].v_int; |
135 | | |
136 | 28 | return oval == FALSE || oval == TRUE; |
137 | 28 | } |
138 | | |
139 | | static gboolean |
140 | | param_boolean_validate (GParamSpec *pspec, |
141 | | GValue *value) |
142 | 0 | { |
143 | 0 | gint oval = value->data[0].v_int; |
144 | | |
145 | 0 | value->data[0].v_int = value->data[0].v_int != FALSE; |
146 | | |
147 | 0 | return value->data[0].v_int != oval; |
148 | 0 | } |
149 | | |
150 | | static void |
151 | | param_int_init (GParamSpec *pspec) |
152 | 1 | { |
153 | 1 | GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec); |
154 | | |
155 | 1 | ispec->minimum = 0x7fffffff; |
156 | 1 | ispec->maximum = 0x80000000; |
157 | 1 | ispec->default_value = 0; |
158 | 1 | } |
159 | | |
160 | | static void |
161 | | param_int_set_default (GParamSpec *pspec, |
162 | | GValue *value) |
163 | 0 | { |
164 | 0 | value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value; |
165 | 0 | } |
166 | | |
167 | | static gboolean |
168 | | param_int_is_valid (GParamSpec *pspec, |
169 | | const GValue *value) |
170 | 0 | { |
171 | 0 | GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec); |
172 | 0 | int oval = value->data[0].v_int; |
173 | |
|
174 | 0 | return ispec->minimum <= oval && oval <= ispec->maximum; |
175 | 0 | } |
176 | | |
177 | | static gboolean |
178 | | param_int_validate (GParamSpec *pspec, |
179 | | GValue *value) |
180 | 0 | { |
181 | 0 | GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec); |
182 | 0 | gint oval = value->data[0].v_int; |
183 | | |
184 | 0 | value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum); |
185 | | |
186 | 0 | return value->data[0].v_int != oval; |
187 | 0 | } |
188 | | |
189 | | static gint |
190 | | param_int_values_cmp (GParamSpec *pspec, |
191 | | const GValue *value1, |
192 | | const GValue *value2) |
193 | 0 | { |
194 | 0 | if (value1->data[0].v_int < value2->data[0].v_int) |
195 | 0 | return -1; |
196 | 0 | else |
197 | 0 | return value1->data[0].v_int > value2->data[0].v_int; |
198 | 0 | } |
199 | | |
200 | | static void |
201 | | param_uint_init (GParamSpec *pspec) |
202 | 1 | { |
203 | 1 | GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec); |
204 | | |
205 | 1 | uspec->minimum = 0; |
206 | 1 | uspec->maximum = 0xffffffff; |
207 | 1 | uspec->default_value = 0; |
208 | 1 | } |
209 | | |
210 | | static void |
211 | | param_uint_set_default (GParamSpec *pspec, |
212 | | GValue *value) |
213 | 1 | { |
214 | 1 | value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value; |
215 | 1 | } |
216 | | |
217 | | static gboolean |
218 | | param_uint_is_valid (GParamSpec *pspec, |
219 | | const GValue *value) |
220 | 8 | { |
221 | 8 | GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec); |
222 | 8 | guint oval = value->data[0].v_uint; |
223 | | |
224 | 8 | return uspec->minimum <= oval && oval <= uspec->maximum; |
225 | 8 | } |
226 | | |
227 | | static gboolean |
228 | | param_uint_validate (GParamSpec *pspec, |
229 | | GValue *value) |
230 | 0 | { |
231 | 0 | GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec); |
232 | 0 | guint oval = value->data[0].v_uint; |
233 | | |
234 | 0 | value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum); |
235 | | |
236 | 0 | return value->data[0].v_uint != oval; |
237 | 0 | } |
238 | | |
239 | | static gint |
240 | | param_uint_values_cmp (GParamSpec *pspec, |
241 | | const GValue *value1, |
242 | | const GValue *value2) |
243 | 0 | { |
244 | 0 | if (value1->data[0].v_uint < value2->data[0].v_uint) |
245 | 0 | return -1; |
246 | 0 | else |
247 | 0 | return value1->data[0].v_uint > value2->data[0].v_uint; |
248 | 0 | } |
249 | | |
250 | | static void |
251 | | param_long_init (GParamSpec *pspec) |
252 | 0 | { |
253 | 0 | GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec); |
254 | | |
255 | | #if SIZEOF_LONG == 4 |
256 | | lspec->minimum = 0x7fffffff; |
257 | | lspec->maximum = 0x80000000; |
258 | | #else /* SIZEOF_LONG != 4 (8) */ |
259 | 0 | lspec->minimum = 0x7fffffffffffffff; |
260 | 0 | lspec->maximum = 0x8000000000000000; |
261 | 0 | #endif |
262 | 0 | lspec->default_value = 0; |
263 | 0 | } |
264 | | |
265 | | static void |
266 | | param_long_set_default (GParamSpec *pspec, |
267 | | GValue *value) |
268 | 0 | { |
269 | 0 | value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value; |
270 | 0 | } |
271 | | |
272 | | static gboolean |
273 | | param_long_is_valid (GParamSpec *pspec, |
274 | | const GValue *value) |
275 | 0 | { |
276 | 0 | GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec); |
277 | 0 | glong oval = value->data[0].v_long; |
278 | | |
279 | 0 | return lspec->minimum <= oval && oval <= lspec->maximum; |
280 | 0 | } |
281 | | |
282 | | static gboolean |
283 | | param_long_validate (GParamSpec *pspec, |
284 | | GValue *value) |
285 | 0 | { |
286 | 0 | GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec); |
287 | 0 | glong oval = value->data[0].v_long; |
288 | | |
289 | 0 | value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum); |
290 | | |
291 | 0 | return value->data[0].v_long != oval; |
292 | 0 | } |
293 | | |
294 | | static gint |
295 | | param_long_values_cmp (GParamSpec *pspec, |
296 | | const GValue *value1, |
297 | | const GValue *value2) |
298 | 0 | { |
299 | 0 | if (value1->data[0].v_long < value2->data[0].v_long) |
300 | 0 | return -1; |
301 | 0 | else |
302 | 0 | return value1->data[0].v_long > value2->data[0].v_long; |
303 | 0 | } |
304 | | |
305 | | static void |
306 | | param_ulong_init (GParamSpec *pspec) |
307 | 0 | { |
308 | 0 | GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec); |
309 | | |
310 | 0 | uspec->minimum = 0; |
311 | | #if SIZEOF_LONG == 4 |
312 | | uspec->maximum = 0xffffffff; |
313 | | #else /* SIZEOF_LONG != 4 (8) */ |
314 | 0 | uspec->maximum = 0xffffffffffffffff; |
315 | 0 | #endif |
316 | 0 | uspec->default_value = 0; |
317 | 0 | } |
318 | | |
319 | | static void |
320 | | param_ulong_set_default (GParamSpec *pspec, |
321 | | GValue *value) |
322 | 0 | { |
323 | 0 | value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value; |
324 | 0 | } |
325 | | |
326 | | static gboolean |
327 | | param_ulong_is_valid (GParamSpec *pspec, |
328 | | const GValue *value) |
329 | 0 | { |
330 | 0 | GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec); |
331 | 0 | gulong oval = value->data[0].v_ulong; |
332 | | |
333 | 0 | return uspec->minimum <= oval && oval <= uspec->maximum; |
334 | 0 | } |
335 | | |
336 | | static gboolean |
337 | | param_ulong_validate (GParamSpec *pspec, |
338 | | GValue *value) |
339 | 0 | { |
340 | 0 | GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec); |
341 | 0 | gulong oval = value->data[0].v_ulong; |
342 | | |
343 | 0 | value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum); |
344 | | |
345 | 0 | return value->data[0].v_ulong != oval; |
346 | 0 | } |
347 | | |
348 | | static gint |
349 | | param_ulong_values_cmp (GParamSpec *pspec, |
350 | | const GValue *value1, |
351 | | const GValue *value2) |
352 | 0 | { |
353 | 0 | if (value1->data[0].v_ulong < value2->data[0].v_ulong) |
354 | 0 | return -1; |
355 | 0 | else |
356 | 0 | return value1->data[0].v_ulong > value2->data[0].v_ulong; |
357 | 0 | } |
358 | | |
359 | | static void |
360 | | param_int64_init (GParamSpec *pspec) |
361 | 0 | { |
362 | 0 | GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec); |
363 | | |
364 | 0 | lspec->minimum = G_MININT64; |
365 | 0 | lspec->maximum = G_MAXINT64; |
366 | 0 | lspec->default_value = 0; |
367 | 0 | } |
368 | | |
369 | | static void |
370 | | param_int64_set_default (GParamSpec *pspec, |
371 | | GValue *value) |
372 | 0 | { |
373 | 0 | value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value; |
374 | 0 | } |
375 | | |
376 | | static gboolean |
377 | | param_int64_is_valid (GParamSpec *pspec, |
378 | | const GValue *value) |
379 | 0 | { |
380 | 0 | GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec); |
381 | 0 | gint64 oval = value->data[0].v_int64; |
382 | | |
383 | 0 | return lspec->minimum <= oval && oval <= lspec->maximum; |
384 | 0 | } |
385 | | |
386 | | static gboolean |
387 | | param_int64_validate (GParamSpec *pspec, |
388 | | GValue *value) |
389 | 0 | { |
390 | 0 | GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec); |
391 | 0 | gint64 oval = value->data[0].v_int64; |
392 | | |
393 | 0 | value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum); |
394 | | |
395 | 0 | return value->data[0].v_int64 != oval; |
396 | 0 | } |
397 | | |
398 | | static gint |
399 | | param_int64_values_cmp (GParamSpec *pspec, |
400 | | const GValue *value1, |
401 | | const GValue *value2) |
402 | 0 | { |
403 | 0 | if (value1->data[0].v_int64 < value2->data[0].v_int64) |
404 | 0 | return -1; |
405 | 0 | else |
406 | 0 | return value1->data[0].v_int64 > value2->data[0].v_int64; |
407 | 0 | } |
408 | | |
409 | | static void |
410 | | param_uint64_init (GParamSpec *pspec) |
411 | 0 | { |
412 | 0 | GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec); |
413 | | |
414 | 0 | uspec->minimum = 0; |
415 | 0 | uspec->maximum = G_MAXUINT64; |
416 | 0 | uspec->default_value = 0; |
417 | 0 | } |
418 | | |
419 | | static void |
420 | | param_uint64_set_default (GParamSpec *pspec, |
421 | | GValue *value) |
422 | 0 | { |
423 | 0 | value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value; |
424 | 0 | } |
425 | | |
426 | | static gboolean |
427 | | param_uint64_is_valid (GParamSpec *pspec, |
428 | | const GValue *value) |
429 | 0 | { |
430 | 0 | GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec); |
431 | 0 | guint64 oval = value->data[0].v_uint64; |
432 | | |
433 | 0 | return uspec->minimum <= oval && oval <= uspec->maximum; |
434 | 0 | } |
435 | | |
436 | | static gboolean |
437 | | param_uint64_validate (GParamSpec *pspec, |
438 | | GValue *value) |
439 | 0 | { |
440 | 0 | GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec); |
441 | 0 | guint64 oval = value->data[0].v_uint64; |
442 | | |
443 | 0 | value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum); |
444 | | |
445 | 0 | return value->data[0].v_uint64 != oval; |
446 | 0 | } |
447 | | |
448 | | static gint |
449 | | param_uint64_values_cmp (GParamSpec *pspec, |
450 | | const GValue *value1, |
451 | | const GValue *value2) |
452 | 0 | { |
453 | 0 | if (value1->data[0].v_uint64 < value2->data[0].v_uint64) |
454 | 0 | return -1; |
455 | 0 | else |
456 | 0 | return value1->data[0].v_uint64 > value2->data[0].v_uint64; |
457 | 0 | } |
458 | | |
459 | | static void |
460 | | param_unichar_init (GParamSpec *pspec) |
461 | 0 | { |
462 | 0 | GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec); |
463 | | |
464 | 0 | uspec->default_value = 0; |
465 | 0 | } |
466 | | |
467 | | static void |
468 | | param_unichar_set_default (GParamSpec *pspec, |
469 | | GValue *value) |
470 | 0 | { |
471 | 0 | value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value; |
472 | 0 | } |
473 | | |
474 | | static gboolean |
475 | | param_unichar_is_valid (GParamSpec *pspec, |
476 | | const GValue *value) |
477 | 0 | { |
478 | 0 | return g_unichar_validate (value->data[0].v_uint); |
479 | 0 | } |
480 | | |
481 | | static gboolean |
482 | | param_unichar_validate (GParamSpec *pspec, |
483 | | GValue *value) |
484 | 0 | { |
485 | 0 | gunichar oval = value->data[0].v_uint; |
486 | 0 | gboolean changed = FALSE; |
487 | |
|
488 | 0 | if (!g_unichar_validate (oval)) |
489 | 0 | { |
490 | 0 | value->data[0].v_uint = 0; |
491 | 0 | changed = TRUE; |
492 | 0 | } |
493 | |
|
494 | 0 | return changed; |
495 | 0 | } |
496 | | |
497 | | static gint |
498 | | param_unichar_values_cmp (GParamSpec *pspec, |
499 | | const GValue *value1, |
500 | | const GValue *value2) |
501 | 0 | { |
502 | 0 | if (value1->data[0].v_uint < value2->data[0].v_uint) |
503 | 0 | return -1; |
504 | 0 | else |
505 | 0 | return value1->data[0].v_uint > value2->data[0].v_uint; |
506 | 0 | } |
507 | | |
508 | | static void |
509 | | param_enum_init (GParamSpec *pspec) |
510 | 1 | { |
511 | 1 | GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec); |
512 | | |
513 | 1 | espec->enum_class = NULL; |
514 | 1 | espec->default_value = 0; |
515 | 1 | } |
516 | | |
517 | | static void |
518 | | param_enum_finalize (GParamSpec *pspec) |
519 | 0 | { |
520 | 0 | GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec); |
521 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM)); |
522 | | |
523 | 0 | if (espec->enum_class) |
524 | 0 | { |
525 | 0 | g_type_class_unref (espec->enum_class); |
526 | 0 | espec->enum_class = NULL; |
527 | 0 | } |
528 | | |
529 | 0 | parent_class->finalize (pspec); |
530 | 0 | } |
531 | | |
532 | | static void |
533 | | param_enum_set_default (GParamSpec *pspec, |
534 | | GValue *value) |
535 | 0 | { |
536 | 0 | value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value; |
537 | 0 | } |
538 | | |
539 | | static gboolean |
540 | | param_enum_is_valid (GParamSpec *pspec, |
541 | | const GValue *value) |
542 | 12 | { |
543 | 12 | GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec); |
544 | 12 | glong oval = value->data[0].v_long; |
545 | | |
546 | 12 | return g_enum_get_value (espec->enum_class, oval) != NULL; |
547 | 12 | } |
548 | | |
549 | | static gboolean |
550 | | param_enum_validate (GParamSpec *pspec, |
551 | | GValue *value) |
552 | 0 | { |
553 | 0 | GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec); |
554 | 0 | glong oval = value->data[0].v_long; |
555 | | |
556 | 0 | if (!espec->enum_class || |
557 | 0 | !g_enum_get_value (espec->enum_class, value->data[0].v_long)) |
558 | 0 | value->data[0].v_long = espec->default_value; |
559 | | |
560 | 0 | return value->data[0].v_long != oval; |
561 | 0 | } |
562 | | |
563 | | static void |
564 | | param_flags_init (GParamSpec *pspec) |
565 | 2 | { |
566 | 2 | GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec); |
567 | | |
568 | 2 | fspec->flags_class = NULL; |
569 | 2 | fspec->default_value = 0; |
570 | 2 | } |
571 | | |
572 | | static void |
573 | | param_flags_finalize (GParamSpec *pspec) |
574 | 0 | { |
575 | 0 | GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec); |
576 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS)); |
577 | | |
578 | 0 | if (fspec->flags_class) |
579 | 0 | { |
580 | 0 | g_type_class_unref (fspec->flags_class); |
581 | 0 | fspec->flags_class = NULL; |
582 | 0 | } |
583 | | |
584 | 0 | parent_class->finalize (pspec); |
585 | 0 | } |
586 | | |
587 | | static void |
588 | | param_flags_set_default (GParamSpec *pspec, |
589 | | GValue *value) |
590 | 0 | { |
591 | 0 | value->data[0].v_ulong = G_PARAM_SPEC_FLAGS (pspec)->default_value; |
592 | 0 | } |
593 | | |
594 | | static gboolean |
595 | | param_flags_is_valid (GParamSpec *pspec, |
596 | | const GValue *value) |
597 | 4 | { |
598 | 4 | GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec); |
599 | 4 | gulong oval = value->data[0].v_ulong; |
600 | | |
601 | 4 | return (oval & ~fspec->flags_class->mask) == 0; |
602 | 4 | } |
603 | | static gboolean |
604 | | param_flags_validate (GParamSpec *pspec, |
605 | | GValue *value) |
606 | 0 | { |
607 | 0 | GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec); |
608 | 0 | gulong oval = value->data[0].v_ulong; |
609 | | |
610 | 0 | if (fspec->flags_class) |
611 | 0 | value->data[0].v_ulong &= fspec->flags_class->mask; |
612 | 0 | else |
613 | 0 | value->data[0].v_ulong = fspec->default_value; |
614 | | |
615 | 0 | return value->data[0].v_ulong != oval; |
616 | 0 | } |
617 | | |
618 | | static void |
619 | | param_float_init (GParamSpec *pspec) |
620 | 0 | { |
621 | 0 | GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec); |
622 | | |
623 | 0 | fspec->minimum = -G_MAXFLOAT; |
624 | 0 | fspec->maximum = G_MAXFLOAT; |
625 | 0 | fspec->default_value = 0; |
626 | 0 | fspec->epsilon = G_FLOAT_EPSILON; |
627 | 0 | } |
628 | | |
629 | | static void |
630 | | param_float_set_default (GParamSpec *pspec, |
631 | | GValue *value) |
632 | 0 | { |
633 | 0 | value->data[0].v_float = G_PARAM_SPEC_FLOAT (pspec)->default_value; |
634 | 0 | } |
635 | | |
636 | | static gboolean |
637 | | param_float_is_valid (GParamSpec *pspec, |
638 | | const GValue *value) |
639 | 0 | { |
640 | 0 | GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec); |
641 | 0 | gfloat oval = value->data[0].v_float; |
642 | | |
643 | 0 | return fspec->minimum <= oval && oval <= fspec->maximum; |
644 | 0 | } |
645 | | |
646 | | static gboolean |
647 | | param_float_validate (GParamSpec *pspec, |
648 | | GValue *value) |
649 | 0 | { |
650 | 0 | GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec); |
651 | 0 | gfloat oval = value->data[0].v_float; |
652 | | |
653 | 0 | value->data[0].v_float = CLAMP (value->data[0].v_float, fspec->minimum, fspec->maximum); |
654 | | |
655 | 0 | return value->data[0].v_float != oval; |
656 | 0 | } |
657 | | |
658 | | static gint |
659 | | param_float_values_cmp (GParamSpec *pspec, |
660 | | const GValue *value1, |
661 | | const GValue *value2) |
662 | 0 | { |
663 | 0 | gfloat epsilon = G_PARAM_SPEC_FLOAT (pspec)->epsilon; |
664 | | |
665 | 0 | if (value1->data[0].v_float < value2->data[0].v_float) |
666 | 0 | return - (value2->data[0].v_float - value1->data[0].v_float > epsilon); |
667 | 0 | else |
668 | 0 | return value1->data[0].v_float - value2->data[0].v_float > epsilon; |
669 | 0 | } |
670 | | |
671 | | static void |
672 | | param_double_init (GParamSpec *pspec) |
673 | 0 | { |
674 | 0 | GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec); |
675 | | |
676 | 0 | dspec->minimum = -G_MAXDOUBLE; |
677 | 0 | dspec->maximum = G_MAXDOUBLE; |
678 | 0 | dspec->default_value = 0; |
679 | 0 | dspec->epsilon = G_DOUBLE_EPSILON; |
680 | 0 | } |
681 | | |
682 | | static void |
683 | | param_double_set_default (GParamSpec *pspec, |
684 | | GValue *value) |
685 | 0 | { |
686 | 0 | value->data[0].v_double = G_PARAM_SPEC_DOUBLE (pspec)->default_value; |
687 | 0 | } |
688 | | |
689 | | static gboolean |
690 | | param_double_is_valid (GParamSpec *pspec, |
691 | | const GValue *value) |
692 | 0 | { |
693 | 0 | GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec); |
694 | 0 | gfloat oval = value->data[0].v_double; |
695 | | |
696 | 0 | return dspec->minimum <= oval && oval <= dspec->maximum; |
697 | 0 | } |
698 | | |
699 | | static gboolean |
700 | | param_double_validate (GParamSpec *pspec, |
701 | | GValue *value) |
702 | 0 | { |
703 | 0 | GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec); |
704 | 0 | gdouble oval = value->data[0].v_double; |
705 | | |
706 | 0 | value->data[0].v_double = CLAMP (value->data[0].v_double, dspec->minimum, dspec->maximum); |
707 | | |
708 | 0 | return value->data[0].v_double != oval; |
709 | 0 | } |
710 | | |
711 | | static gint |
712 | | param_double_values_cmp (GParamSpec *pspec, |
713 | | const GValue *value1, |
714 | | const GValue *value2) |
715 | 0 | { |
716 | 0 | gdouble epsilon = G_PARAM_SPEC_DOUBLE (pspec)->epsilon; |
717 | | |
718 | 0 | if (value1->data[0].v_double < value2->data[0].v_double) |
719 | 0 | return - (value2->data[0].v_double - value1->data[0].v_double > epsilon); |
720 | 0 | else |
721 | 0 | return value1->data[0].v_double - value2->data[0].v_double > epsilon; |
722 | 0 | } |
723 | | |
724 | | static void |
725 | | param_string_init (GParamSpec *pspec) |
726 | 2 | { |
727 | 2 | GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec); |
728 | | |
729 | 2 | sspec->default_value = NULL; |
730 | 2 | sspec->cset_first = NULL; |
731 | 2 | sspec->cset_nth = NULL; |
732 | 2 | sspec->substitutor = '_'; |
733 | 2 | sspec->null_fold_if_empty = FALSE; |
734 | 2 | sspec->ensure_non_null = FALSE; |
735 | 2 | } |
736 | | |
737 | | static void |
738 | | param_string_finalize (GParamSpec *pspec) |
739 | 0 | { |
740 | 0 | GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec); |
741 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING)); |
742 | | |
743 | 0 | g_free (sspec->default_value); |
744 | 0 | g_free (sspec->cset_first); |
745 | 0 | g_free (sspec->cset_nth); |
746 | 0 | sspec->default_value = NULL; |
747 | 0 | sspec->cset_first = NULL; |
748 | 0 | sspec->cset_nth = NULL; |
749 | | |
750 | 0 | parent_class->finalize (pspec); |
751 | 0 | } |
752 | | |
753 | | static void |
754 | | param_string_set_default (GParamSpec *pspec, |
755 | | GValue *value) |
756 | 0 | { |
757 | 0 | value->data[0].v_pointer = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value); |
758 | 0 | } |
759 | | |
760 | | static gboolean |
761 | | param_string_validate (GParamSpec *pspec, |
762 | | GValue *value) |
763 | 0 | { |
764 | 0 | GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec); |
765 | 0 | gchar *string = value->data[0].v_pointer; |
766 | 0 | guint changed = 0; |
767 | | |
768 | 0 | if (string && string[0]) |
769 | 0 | { |
770 | 0 | gchar *s; |
771 | | |
772 | 0 | if (sspec->cset_first && !strchr (sspec->cset_first, string[0])) |
773 | 0 | { |
774 | 0 | if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) |
775 | 0 | { |
776 | 0 | value->data[0].v_pointer = g_strdup (string); |
777 | 0 | string = value->data[0].v_pointer; |
778 | 0 | value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; |
779 | 0 | } |
780 | 0 | string[0] = sspec->substitutor; |
781 | 0 | changed++; |
782 | 0 | } |
783 | 0 | if (sspec->cset_nth) |
784 | 0 | for (s = string + 1; *s; s++) |
785 | 0 | if (!strchr (sspec->cset_nth, *s)) |
786 | 0 | { |
787 | 0 | if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) |
788 | 0 | { |
789 | 0 | value->data[0].v_pointer = g_strdup (string); |
790 | 0 | s = (gchar*) value->data[0].v_pointer + (s - string); |
791 | 0 | string = value->data[0].v_pointer; |
792 | 0 | value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; |
793 | 0 | } |
794 | 0 | *s = sspec->substitutor; |
795 | 0 | changed++; |
796 | 0 | } |
797 | 0 | } |
798 | 0 | if (sspec->null_fold_if_empty && string && string[0] == 0) |
799 | 0 | { |
800 | 0 | if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)) |
801 | 0 | g_free (value->data[0].v_pointer); |
802 | 0 | else |
803 | 0 | value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; |
804 | 0 | value->data[0].v_pointer = NULL; |
805 | 0 | changed++; |
806 | 0 | string = value->data[0].v_pointer; |
807 | 0 | } |
808 | 0 | if (sspec->ensure_non_null && !string) |
809 | 0 | { |
810 | 0 | value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; |
811 | 0 | value->data[0].v_pointer = g_strdup (""); |
812 | 0 | changed++; |
813 | 0 | string = value->data[0].v_pointer; |
814 | 0 | } |
815 | |
|
816 | 0 | return changed; |
817 | 0 | } |
818 | | |
819 | | static gboolean |
820 | | param_string_is_valid (GParamSpec *pspec, |
821 | | const GValue *value) |
822 | 247 | { |
823 | 247 | GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec); |
824 | 247 | gboolean ret = TRUE; |
825 | | |
826 | 247 | if (sspec->cset_first != NULL || sspec->cset_nth != NULL || |
827 | 247 | sspec->ensure_non_null || sspec->null_fold_if_empty) |
828 | 0 | { |
829 | 0 | GValue tmp_value = G_VALUE_INIT; |
830 | |
|
831 | 0 | g_value_init (&tmp_value, G_VALUE_TYPE (value)); |
832 | 0 | g_value_copy (value, &tmp_value); |
833 | |
|
834 | 0 | ret = !param_string_validate (pspec, &tmp_value); |
835 | |
|
836 | 0 | g_value_unset (&tmp_value); |
837 | 0 | } |
838 | | |
839 | 247 | return ret; |
840 | 247 | } |
841 | | |
842 | | static gint |
843 | | param_string_values_cmp (GParamSpec *pspec, |
844 | | const GValue *value1, |
845 | | const GValue *value2) |
846 | 0 | { |
847 | 0 | if (!value1->data[0].v_pointer) |
848 | 0 | return value2->data[0].v_pointer != NULL ? -1 : 0; |
849 | 0 | else if (!value2->data[0].v_pointer) |
850 | 0 | return value1->data[0].v_pointer != NULL; |
851 | 0 | else |
852 | 0 | return strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer); |
853 | 0 | } |
854 | | |
855 | | static void |
856 | | param_param_init (GParamSpec *pspec) |
857 | 0 | { |
858 | | /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */ |
859 | 0 | } |
860 | | |
861 | | static void |
862 | | param_param_set_default (GParamSpec *pspec, |
863 | | GValue *value) |
864 | 0 | { |
865 | 0 | value->data[0].v_pointer = NULL; |
866 | 0 | } |
867 | | |
868 | | static gboolean |
869 | | param_param_is_valid (GParamSpec *pspec, |
870 | | const GValue *value) |
871 | 0 | { |
872 | 0 | GParamSpec *param = value->data[0].v_pointer; |
873 | |
|
874 | 0 | if (param == NULL) |
875 | 0 | return FALSE; |
876 | | |
877 | 0 | return g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)); |
878 | 0 | } |
879 | | |
880 | | static gboolean |
881 | | param_param_validate (GParamSpec *pspec, |
882 | | GValue *value) |
883 | 0 | { |
884 | | /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */ |
885 | 0 | GParamSpec *param = value->data[0].v_pointer; |
886 | 0 | guint changed = 0; |
887 | | |
888 | 0 | if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec))) |
889 | 0 | { |
890 | 0 | g_param_spec_unref (param); |
891 | 0 | value->data[0].v_pointer = NULL; |
892 | 0 | changed++; |
893 | 0 | } |
894 | | |
895 | 0 | return changed; |
896 | 0 | } |
897 | | |
898 | | static void |
899 | | param_boxed_init (GParamSpec *pspec) |
900 | 0 | { |
901 | | /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */ |
902 | 0 | } |
903 | | |
904 | | static void |
905 | | param_boxed_set_default (GParamSpec *pspec, |
906 | | GValue *value) |
907 | 0 | { |
908 | 0 | value->data[0].v_pointer = NULL; |
909 | 0 | } |
910 | | |
911 | | static gint |
912 | | param_boxed_values_cmp (GParamSpec *pspec, |
913 | | const GValue *value1, |
914 | | const GValue *value2) |
915 | 0 | { |
916 | 0 | guint8 *p1 = value1->data[0].v_pointer; |
917 | 0 | guint8 *p2 = value2->data[0].v_pointer; |
918 | | |
919 | | /* not much to compare here, try to at least provide stable lesser/greater result */ |
920 | |
|
921 | 0 | return p1 < p2 ? -1 : p1 > p2; |
922 | 0 | } |
923 | | |
924 | | static void |
925 | | param_pointer_init (GParamSpec *pspec) |
926 | 0 | { |
927 | | /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */ |
928 | 0 | } |
929 | | |
930 | | static void |
931 | | param_pointer_set_default (GParamSpec *pspec, |
932 | | GValue *value) |
933 | 0 | { |
934 | 0 | value->data[0].v_pointer = NULL; |
935 | 0 | } |
936 | | |
937 | | static gint |
938 | | param_pointer_values_cmp (GParamSpec *pspec, |
939 | | const GValue *value1, |
940 | | const GValue *value2) |
941 | 0 | { |
942 | 0 | guint8 *p1 = value1->data[0].v_pointer; |
943 | 0 | guint8 *p2 = value2->data[0].v_pointer; |
944 | | |
945 | | /* not much to compare here, try to at least provide stable lesser/greater result */ |
946 | |
|
947 | 0 | return p1 < p2 ? -1 : p1 > p2; |
948 | 0 | } |
949 | | |
950 | | static void |
951 | | param_value_array_init (GParamSpec *pspec) |
952 | 0 | { |
953 | 0 | GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); |
954 | |
|
955 | 0 | aspec->element_spec = NULL; |
956 | 0 | aspec->fixed_n_elements = 0; /* disable */ |
957 | 0 | } |
958 | | |
959 | | static inline guint |
960 | | value_array_ensure_size (GValueArray *value_array, |
961 | | guint fixed_n_elements) |
962 | 0 | { |
963 | 0 | guint changed = 0; |
964 | |
|
965 | 0 | if (fixed_n_elements) |
966 | 0 | { |
967 | 0 | while (value_array->n_values < fixed_n_elements) |
968 | 0 | { |
969 | 0 | g_value_array_append (value_array, NULL); |
970 | 0 | changed++; |
971 | 0 | } |
972 | 0 | while (value_array->n_values > fixed_n_elements) |
973 | 0 | { |
974 | 0 | g_value_array_remove (value_array, value_array->n_values - 1); |
975 | 0 | changed++; |
976 | 0 | } |
977 | 0 | } |
978 | 0 | return changed; |
979 | 0 | } |
980 | | |
981 | | static void |
982 | | param_value_array_finalize (GParamSpec *pspec) |
983 | 0 | { |
984 | 0 | GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); |
985 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY)); |
986 | |
|
987 | 0 | if (aspec->element_spec) |
988 | 0 | { |
989 | 0 | g_param_spec_unref (aspec->element_spec); |
990 | 0 | aspec->element_spec = NULL; |
991 | 0 | } |
992 | |
|
993 | 0 | parent_class->finalize (pspec); |
994 | 0 | } |
995 | | |
996 | | static void |
997 | | param_value_array_set_default (GParamSpec *pspec, |
998 | | GValue *value) |
999 | 0 | { |
1000 | 0 | GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); |
1001 | |
|
1002 | 0 | if (!value->data[0].v_pointer && aspec->fixed_n_elements) |
1003 | 0 | value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements); |
1004 | |
|
1005 | 0 | if (value->data[0].v_pointer) |
1006 | 0 | { |
1007 | | /* g_value_reset (value); already done */ |
1008 | 0 | value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements); |
1009 | 0 | } |
1010 | 0 | } |
1011 | | |
1012 | | static gboolean |
1013 | | param_value_array_validate (GParamSpec *pspec, |
1014 | | GValue *value) |
1015 | 0 | { |
1016 | 0 | GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); |
1017 | 0 | GValueArray *value_array = value->data[0].v_pointer; |
1018 | 0 | guint changed = 0; |
1019 | |
|
1020 | 0 | if (!value->data[0].v_pointer && aspec->fixed_n_elements) |
1021 | 0 | value_array = value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements); |
1022 | |
|
1023 | 0 | if (value->data[0].v_pointer) |
1024 | 0 | { |
1025 | | /* ensure array size validity */ |
1026 | 0 | changed += value_array_ensure_size (value_array, aspec->fixed_n_elements); |
1027 | | |
1028 | | /* ensure array values validity against a present element spec */ |
1029 | 0 | if (aspec->element_spec) |
1030 | 0 | { |
1031 | 0 | GParamSpec *element_spec = aspec->element_spec; |
1032 | 0 | guint i; |
1033 | | |
1034 | 0 | for (i = 0; i < value_array->n_values; i++) |
1035 | 0 | { |
1036 | 0 | GValue *element = value_array->values + i; |
1037 | | |
1038 | | /* need to fixup value type, or ensure that the array value is initialized at all */ |
1039 | 0 | if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec))) |
1040 | 0 | { |
1041 | 0 | if (G_VALUE_TYPE (element) != 0) |
1042 | 0 | g_value_unset (element); |
1043 | 0 | g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec)); |
1044 | 0 | g_param_value_set_default (element_spec, element); |
1045 | 0 | changed++; |
1046 | 0 | } |
1047 | 0 | else |
1048 | 0 | { |
1049 | | /* validate array value against element_spec */ |
1050 | 0 | changed += g_param_value_validate (element_spec, element); |
1051 | 0 | } |
1052 | 0 | } |
1053 | 0 | } |
1054 | 0 | } |
1055 | |
|
1056 | 0 | return changed; |
1057 | 0 | } |
1058 | | |
1059 | | static gint |
1060 | | param_value_array_values_cmp (GParamSpec *pspec, |
1061 | | const GValue *value1, |
1062 | | const GValue *value2) |
1063 | 0 | { |
1064 | 0 | GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); |
1065 | 0 | GValueArray *value_array1 = value1->data[0].v_pointer; |
1066 | 0 | GValueArray *value_array2 = value2->data[0].v_pointer; |
1067 | |
|
1068 | 0 | if (!value_array1 || !value_array2) |
1069 | 0 | return value_array2 ? -1 : value_array1 != value_array2; |
1070 | | |
1071 | 0 | if (value_array1->n_values != value_array2->n_values) |
1072 | 0 | return value_array1->n_values < value_array2->n_values ? -1 : 1; |
1073 | 0 | else if (!aspec->element_spec) |
1074 | 0 | { |
1075 | | /* we need an element specification for comparisons, so there's not much |
1076 | | * to compare here, try to at least provide stable lesser/greater result |
1077 | | */ |
1078 | 0 | return value_array1->n_values < value_array2->n_values ? -1 : value_array1->n_values > value_array2->n_values; |
1079 | 0 | } |
1080 | 0 | else /* value_array1->n_values == value_array2->n_values */ |
1081 | 0 | { |
1082 | 0 | guint i; |
1083 | |
|
1084 | 0 | for (i = 0; i < value_array1->n_values; i++) |
1085 | 0 | { |
1086 | 0 | GValue *element1 = value_array1->values + i; |
1087 | 0 | GValue *element2 = value_array2->values + i; |
1088 | 0 | gint cmp; |
1089 | | |
1090 | | /* need corresponding element types, provide stable result otherwise */ |
1091 | 0 | if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2)) |
1092 | 0 | return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1; |
1093 | 0 | cmp = g_param_values_cmp (aspec->element_spec, element1, element2); |
1094 | 0 | if (cmp) |
1095 | 0 | return cmp; |
1096 | 0 | } |
1097 | 0 | return 0; |
1098 | 0 | } |
1099 | 0 | } |
1100 | | |
1101 | | static void |
1102 | | param_object_init (GParamSpec *pspec) |
1103 | 11 | { |
1104 | | /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */ |
1105 | 11 | } |
1106 | | |
1107 | | static void |
1108 | | param_object_set_default (GParamSpec *pspec, |
1109 | | GValue *value) |
1110 | 1 | { |
1111 | 1 | value->data[0].v_pointer = NULL; |
1112 | 1 | } |
1113 | | |
1114 | | static gboolean |
1115 | | param_object_is_valid (GParamSpec *pspec, |
1116 | | const GValue *value) |
1117 | 307 | { |
1118 | 307 | GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); |
1119 | 307 | GObject *object = value->data[0].v_pointer; |
1120 | | |
1121 | 307 | return object && |
1122 | 290 | g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)); |
1123 | 307 | } |
1124 | | |
1125 | | static gboolean |
1126 | | param_object_validate (GParamSpec *pspec, |
1127 | | GValue *value) |
1128 | 17 | { |
1129 | 17 | GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); |
1130 | 17 | GObject *object = value->data[0].v_pointer; |
1131 | 17 | guint changed = 0; |
1132 | | |
1133 | 17 | if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec))) |
1134 | 0 | { |
1135 | 0 | g_object_unref (object); |
1136 | 0 | value->data[0].v_pointer = NULL; |
1137 | 0 | changed++; |
1138 | 0 | } |
1139 | | |
1140 | 17 | return changed; |
1141 | 17 | } |
1142 | | |
1143 | | static gint |
1144 | | param_object_values_cmp (GParamSpec *pspec, |
1145 | | const GValue *value1, |
1146 | | const GValue *value2) |
1147 | 0 | { |
1148 | 0 | guint8 *p1 = value1->data[0].v_pointer; |
1149 | 0 | guint8 *p2 = value2->data[0].v_pointer; |
1150 | | |
1151 | | /* not much to compare here, try to at least provide stable lesser/greater result */ |
1152 | |
|
1153 | 0 | return p1 < p2 ? -1 : p1 > p2; |
1154 | 0 | } |
1155 | | |
1156 | | static void |
1157 | | param_override_init (GParamSpec *pspec) |
1158 | 0 | { |
1159 | | /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */ |
1160 | 0 | } |
1161 | | |
1162 | | static void |
1163 | | param_override_finalize (GParamSpec *pspec) |
1164 | 0 | { |
1165 | 0 | GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); |
1166 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE)); |
1167 | | |
1168 | 0 | if (ospec->overridden) |
1169 | 0 | { |
1170 | 0 | g_param_spec_unref (ospec->overridden); |
1171 | 0 | ospec->overridden = NULL; |
1172 | 0 | } |
1173 | | |
1174 | 0 | parent_class->finalize (pspec); |
1175 | 0 | } |
1176 | | |
1177 | | static void |
1178 | | param_override_set_default (GParamSpec *pspec, |
1179 | | GValue *value) |
1180 | 0 | { |
1181 | 0 | GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); |
1182 | |
|
1183 | 0 | g_param_value_set_default (ospec->overridden, value); |
1184 | 0 | } |
1185 | | |
1186 | | static gboolean |
1187 | | param_override_is_valid (GParamSpec *pspec, |
1188 | | const GValue *value) |
1189 | 0 | { |
1190 | 0 | GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); |
1191 | |
|
1192 | 0 | return g_param_value_is_valid (ospec->overridden, value); |
1193 | 0 | } |
1194 | | |
1195 | | static gboolean |
1196 | | param_override_validate (GParamSpec *pspec, |
1197 | | GValue *value) |
1198 | 0 | { |
1199 | 0 | GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); |
1200 | | |
1201 | 0 | return g_param_value_validate (ospec->overridden, value); |
1202 | 0 | } |
1203 | | |
1204 | | static gint |
1205 | | param_override_values_cmp (GParamSpec *pspec, |
1206 | | const GValue *value1, |
1207 | | const GValue *value2) |
1208 | 0 | { |
1209 | 0 | GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); |
1210 | |
|
1211 | 0 | return g_param_values_cmp (ospec->overridden, value1, value2); |
1212 | 0 | } |
1213 | | |
1214 | | static void |
1215 | | param_gtype_init (GParamSpec *pspec) |
1216 | 0 | { |
1217 | 0 | } |
1218 | | |
1219 | | static void |
1220 | | param_gtype_set_default (GParamSpec *pspec, |
1221 | | GValue *value) |
1222 | 0 | { |
1223 | 0 | GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec); |
1224 | |
|
1225 | 0 | value->data[0].v_pointer = GTYPE_TO_POINTER (tspec->is_a_type); |
1226 | 0 | } |
1227 | | |
1228 | | static gboolean |
1229 | | param_gtype_is_valid (GParamSpec *pspec, |
1230 | | const GValue *value) |
1231 | 0 | { |
1232 | 0 | GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec); |
1233 | 0 | GType gtype = GPOINTER_TO_TYPE (value->data[0].v_pointer); |
1234 | | |
1235 | 0 | return tspec->is_a_type == G_TYPE_NONE || |
1236 | 0 | g_type_is_a (gtype, tspec->is_a_type); |
1237 | 0 | } |
1238 | | |
1239 | | static gboolean |
1240 | | param_gtype_validate (GParamSpec *pspec, |
1241 | | GValue *value) |
1242 | 0 | { |
1243 | 0 | GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec); |
1244 | 0 | GType gtype = GPOINTER_TO_TYPE (value->data[0].v_pointer); |
1245 | 0 | guint changed = 0; |
1246 | | |
1247 | 0 | if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type)) |
1248 | 0 | { |
1249 | 0 | value->data[0].v_pointer = GTYPE_TO_POINTER (tspec->is_a_type); |
1250 | 0 | changed++; |
1251 | 0 | } |
1252 | | |
1253 | 0 | return changed; |
1254 | 0 | } |
1255 | | |
1256 | | static gint |
1257 | | param_gtype_values_cmp (GParamSpec *pspec, |
1258 | | const GValue *value1, |
1259 | | const GValue *value2) |
1260 | 0 | { |
1261 | 0 | GType p1 = GPOINTER_TO_TYPE (value1->data[0].v_pointer); |
1262 | 0 | GType p2 = GPOINTER_TO_TYPE (value2->data[0].v_pointer); |
1263 | | |
1264 | | /* not much to compare here, try to at least provide stable lesser/greater result */ |
1265 | |
|
1266 | 0 | return p1 < p2 ? -1 : p1 > p2; |
1267 | 0 | } |
1268 | | |
1269 | | static void |
1270 | | param_variant_init (GParamSpec *pspec) |
1271 | 0 | { |
1272 | 0 | GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec); |
1273 | |
|
1274 | 0 | vspec->type = NULL; |
1275 | 0 | vspec->default_value = NULL; |
1276 | 0 | } |
1277 | | |
1278 | | static void |
1279 | | param_variant_finalize (GParamSpec *pspec) |
1280 | 0 | { |
1281 | 0 | GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec); |
1282 | 0 | GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VARIANT)); |
1283 | |
|
1284 | 0 | if (vspec->default_value) |
1285 | 0 | g_variant_unref (vspec->default_value); |
1286 | 0 | g_variant_type_free (vspec->type); |
1287 | |
|
1288 | 0 | parent_class->finalize (pspec); |
1289 | 0 | } |
1290 | | |
1291 | | static void |
1292 | | param_variant_set_default (GParamSpec *pspec, |
1293 | | GValue *value) |
1294 | 0 | { |
1295 | 0 | value->data[0].v_pointer = G_PARAM_SPEC_VARIANT (pspec)->default_value; |
1296 | 0 | value->data[1].v_uint |= G_VALUE_NOCOPY_CONTENTS; |
1297 | 0 | } |
1298 | | |
1299 | | static gboolean |
1300 | | param_variant_is_valid (GParamSpec *pspec, |
1301 | | const GValue *value) |
1302 | 0 | { |
1303 | 0 | GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec); |
1304 | 0 | GVariant *variant = value->data[0].v_pointer; |
1305 | |
|
1306 | 0 | if (variant == NULL) |
1307 | 0 | return vspec->default_value == NULL; |
1308 | 0 | else |
1309 | 0 | return g_variant_is_of_type (variant, vspec->type); |
1310 | 0 | } |
1311 | | |
1312 | | static gboolean |
1313 | | param_variant_validate (GParamSpec *pspec, |
1314 | | GValue *value) |
1315 | 0 | { |
1316 | 0 | GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec); |
1317 | 0 | GVariant *variant = value->data[0].v_pointer; |
1318 | |
|
1319 | 0 | if ((variant == NULL && vspec->default_value != NULL) || |
1320 | 0 | (variant != NULL && !g_variant_is_of_type (variant, vspec->type))) |
1321 | 0 | { |
1322 | 0 | g_param_value_set_default (pspec, value); |
1323 | 0 | return TRUE; |
1324 | 0 | } |
1325 | | |
1326 | 0 | return FALSE; |
1327 | 0 | } |
1328 | | |
1329 | | /* g_variant_compare() can only be used with scalar types. */ |
1330 | | static gboolean |
1331 | | variant_is_incomparable (GVariant *v) |
1332 | 0 | { |
1333 | 0 | GVariantClass v_class = g_variant_classify (v); |
1334 | |
|
1335 | 0 | return (v_class == G_VARIANT_CLASS_HANDLE || |
1336 | 0 | v_class == G_VARIANT_CLASS_VARIANT || |
1337 | 0 | v_class == G_VARIANT_CLASS_MAYBE|| |
1338 | 0 | v_class == G_VARIANT_CLASS_ARRAY || |
1339 | 0 | v_class == G_VARIANT_CLASS_TUPLE || |
1340 | 0 | v_class == G_VARIANT_CLASS_DICT_ENTRY); |
1341 | 0 | } |
1342 | | |
1343 | | static gint |
1344 | | param_variant_values_cmp (GParamSpec *pspec, |
1345 | | const GValue *value1, |
1346 | | const GValue *value2) |
1347 | 0 | { |
1348 | 0 | GVariant *v1 = value1->data[0].v_pointer; |
1349 | 0 | GVariant *v2 = value2->data[0].v_pointer; |
1350 | |
|
1351 | 0 | if (v1 == NULL && v2 == NULL) |
1352 | 0 | return 0; |
1353 | 0 | else if (v1 == NULL && v2 != NULL) |
1354 | 0 | return -1; |
1355 | 0 | else if (v1 != NULL && v2 == NULL) |
1356 | 0 | return 1; |
1357 | | |
1358 | 0 | if (!g_variant_type_equal (g_variant_get_type (v1), g_variant_get_type (v2)) || |
1359 | 0 | variant_is_incomparable (v1) || |
1360 | 0 | variant_is_incomparable (v2)) |
1361 | 0 | return g_variant_equal (v1, v2) ? 0 : (v1 < v2 ? -1 : 1); |
1362 | | |
1363 | 0 | return g_variant_compare (v1, v2); |
1364 | 0 | } |
1365 | | |
1366 | | /* --- type initialization --- */ |
1367 | | |
1368 | 40 | #define set_is_valid_vfunc(type,func) { \ |
1369 | 40 | GParamSpecClass *class = g_type_class_ref (type); \ |
1370 | 40 | class->value_is_valid = func; \ |
1371 | 40 | g_type_class_unref (class); \ |
1372 | 40 | } |
1373 | | |
1374 | | GType *g_param_spec_types = NULL; |
1375 | | |
1376 | | void |
1377 | | _g_param_spec_types_init (void) |
1378 | 2 | { |
1379 | 2 | const guint n_types = 23; |
1380 | 2 | GType type, *spec_types; |
1381 | 2 | #ifndef G_DISABLE_ASSERT |
1382 | 2 | GType *spec_types_bound; |
1383 | 2 | #endif |
1384 | | |
1385 | 2 | g_param_spec_types = g_new0 (GType, n_types); |
1386 | 2 | spec_types = g_param_spec_types; |
1387 | 2 | #ifndef G_DISABLE_ASSERT |
1388 | 2 | spec_types_bound = g_param_spec_types + n_types; |
1389 | 2 | #endif |
1390 | | |
1391 | | /* G_TYPE_PARAM_CHAR |
1392 | | */ |
1393 | 2 | { |
1394 | 2 | const GParamSpecTypeInfo pspec_info = { |
1395 | 2 | sizeof (GParamSpecChar), /* instance_size */ |
1396 | 2 | 16, /* n_preallocs */ |
1397 | 2 | param_char_init, /* instance_init */ |
1398 | 2 | G_TYPE_CHAR, /* value_type */ |
1399 | 2 | NULL, /* finalize */ |
1400 | 2 | param_char_set_default, /* value_set_default */ |
1401 | 2 | param_char_validate, /* value_validate */ |
1402 | 2 | param_int_values_cmp, /* values_cmp */ |
1403 | 2 | }; |
1404 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info); |
1405 | 2 | set_is_valid_vfunc (type, param_char_is_valid); |
1406 | 2 | *spec_types++ = type; |
1407 | 2 | g_assert (type == G_TYPE_PARAM_CHAR); |
1408 | 2 | } |
1409 | | |
1410 | | /* G_TYPE_PARAM_UCHAR |
1411 | | */ |
1412 | 2 | { |
1413 | 2 | const GParamSpecTypeInfo pspec_info = { |
1414 | 2 | sizeof (GParamSpecUChar), /* instance_size */ |
1415 | 2 | 16, /* n_preallocs */ |
1416 | 2 | param_uchar_init, /* instance_init */ |
1417 | 2 | G_TYPE_UCHAR, /* value_type */ |
1418 | 2 | NULL, /* finalize */ |
1419 | 2 | param_uchar_set_default, /* value_set_default */ |
1420 | 2 | param_uchar_validate, /* value_validate */ |
1421 | 2 | param_uint_values_cmp, /* values_cmp */ |
1422 | 2 | }; |
1423 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info); |
1424 | 2 | set_is_valid_vfunc (type, param_uchar_is_valid); |
1425 | 2 | *spec_types++ = type; |
1426 | 2 | g_assert (type == G_TYPE_PARAM_UCHAR); |
1427 | 2 | } |
1428 | | |
1429 | | /* G_TYPE_PARAM_BOOLEAN |
1430 | | */ |
1431 | 2 | { |
1432 | 2 | const GParamSpecTypeInfo pspec_info = { |
1433 | 2 | sizeof (GParamSpecBoolean), /* instance_size */ |
1434 | 2 | 16, /* n_preallocs */ |
1435 | 2 | NULL, /* instance_init */ |
1436 | 2 | G_TYPE_BOOLEAN, /* value_type */ |
1437 | 2 | NULL, /* finalize */ |
1438 | 2 | param_boolean_set_default, /* value_set_default */ |
1439 | 2 | param_boolean_validate, /* value_validate */ |
1440 | 2 | param_int_values_cmp, /* values_cmp */ |
1441 | 2 | }; |
1442 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info); |
1443 | 2 | set_is_valid_vfunc (type, param_boolean_is_valid); |
1444 | 2 | *spec_types++ = type; |
1445 | 2 | g_assert (type == G_TYPE_PARAM_BOOLEAN); |
1446 | 2 | } |
1447 | | |
1448 | | /* G_TYPE_PARAM_INT |
1449 | | */ |
1450 | 2 | { |
1451 | 2 | const GParamSpecTypeInfo pspec_info = { |
1452 | 2 | sizeof (GParamSpecInt), /* instance_size */ |
1453 | 2 | 16, /* n_preallocs */ |
1454 | 2 | param_int_init, /* instance_init */ |
1455 | 2 | G_TYPE_INT, /* value_type */ |
1456 | 2 | NULL, /* finalize */ |
1457 | 2 | param_int_set_default, /* value_set_default */ |
1458 | 2 | param_int_validate, /* value_validate */ |
1459 | 2 | param_int_values_cmp, /* values_cmp */ |
1460 | 2 | }; |
1461 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info); |
1462 | 2 | set_is_valid_vfunc (type, param_int_is_valid); |
1463 | 2 | *spec_types++ = type; |
1464 | 2 | g_assert (type == G_TYPE_PARAM_INT); |
1465 | 2 | } |
1466 | | |
1467 | | /* G_TYPE_PARAM_UINT |
1468 | | */ |
1469 | 2 | { |
1470 | 2 | const GParamSpecTypeInfo pspec_info = { |
1471 | 2 | sizeof (GParamSpecUInt), /* instance_size */ |
1472 | 2 | 16, /* n_preallocs */ |
1473 | 2 | param_uint_init, /* instance_init */ |
1474 | 2 | G_TYPE_UINT, /* value_type */ |
1475 | 2 | NULL, /* finalize */ |
1476 | 2 | param_uint_set_default, /* value_set_default */ |
1477 | 2 | param_uint_validate, /* value_validate */ |
1478 | 2 | param_uint_values_cmp, /* values_cmp */ |
1479 | 2 | }; |
1480 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info); |
1481 | 2 | set_is_valid_vfunc (type, param_uint_is_valid); |
1482 | 2 | *spec_types++ = type; |
1483 | 2 | g_assert (type == G_TYPE_PARAM_UINT); |
1484 | 2 | } |
1485 | | |
1486 | | /* G_TYPE_PARAM_LONG |
1487 | | */ |
1488 | 2 | { |
1489 | 2 | const GParamSpecTypeInfo pspec_info = { |
1490 | 2 | sizeof (GParamSpecLong), /* instance_size */ |
1491 | 2 | 16, /* n_preallocs */ |
1492 | 2 | param_long_init, /* instance_init */ |
1493 | 2 | G_TYPE_LONG, /* value_type */ |
1494 | 2 | NULL, /* finalize */ |
1495 | 2 | param_long_set_default, /* value_set_default */ |
1496 | 2 | param_long_validate, /* value_validate */ |
1497 | 2 | param_long_values_cmp, /* values_cmp */ |
1498 | 2 | }; |
1499 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info); |
1500 | 2 | set_is_valid_vfunc (type, param_long_is_valid); |
1501 | 2 | *spec_types++ = type; |
1502 | 2 | g_assert (type == G_TYPE_PARAM_LONG); |
1503 | 2 | } |
1504 | | |
1505 | | /* G_TYPE_PARAM_ULONG |
1506 | | */ |
1507 | 2 | { |
1508 | 2 | const GParamSpecTypeInfo pspec_info = { |
1509 | 2 | sizeof (GParamSpecULong), /* instance_size */ |
1510 | 2 | 16, /* n_preallocs */ |
1511 | 2 | param_ulong_init, /* instance_init */ |
1512 | 2 | G_TYPE_ULONG, /* value_type */ |
1513 | 2 | NULL, /* finalize */ |
1514 | 2 | param_ulong_set_default, /* value_set_default */ |
1515 | 2 | param_ulong_validate, /* value_validate */ |
1516 | 2 | param_ulong_values_cmp, /* values_cmp */ |
1517 | 2 | }; |
1518 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info); |
1519 | 2 | set_is_valid_vfunc (type, param_ulong_is_valid); |
1520 | 2 | *spec_types++ = type; |
1521 | 2 | g_assert (type == G_TYPE_PARAM_ULONG); |
1522 | 2 | } |
1523 | | |
1524 | | /* G_TYPE_PARAM_INT64 |
1525 | | */ |
1526 | 2 | { |
1527 | 2 | const GParamSpecTypeInfo pspec_info = { |
1528 | 2 | sizeof (GParamSpecInt64), /* instance_size */ |
1529 | 2 | 16, /* n_preallocs */ |
1530 | 2 | param_int64_init, /* instance_init */ |
1531 | 2 | G_TYPE_INT64, /* value_type */ |
1532 | 2 | NULL, /* finalize */ |
1533 | 2 | param_int64_set_default, /* value_set_default */ |
1534 | 2 | param_int64_validate, /* value_validate */ |
1535 | 2 | param_int64_values_cmp, /* values_cmp */ |
1536 | 2 | }; |
1537 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info); |
1538 | 2 | set_is_valid_vfunc (type, param_int64_is_valid); |
1539 | 2 | *spec_types++ = type; |
1540 | 2 | g_assert (type == G_TYPE_PARAM_INT64); |
1541 | 2 | } |
1542 | | |
1543 | | /* G_TYPE_PARAM_UINT64 |
1544 | | */ |
1545 | 2 | { |
1546 | 2 | const GParamSpecTypeInfo pspec_info = { |
1547 | 2 | sizeof (GParamSpecUInt64), /* instance_size */ |
1548 | 2 | 16, /* n_preallocs */ |
1549 | 2 | param_uint64_init, /* instance_init */ |
1550 | 2 | G_TYPE_UINT64, /* value_type */ |
1551 | 2 | NULL, /* finalize */ |
1552 | 2 | param_uint64_set_default, /* value_set_default */ |
1553 | 2 | param_uint64_validate, /* value_validate */ |
1554 | 2 | param_uint64_values_cmp, /* values_cmp */ |
1555 | 2 | }; |
1556 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info); |
1557 | 2 | set_is_valid_vfunc (type, param_uint64_is_valid); |
1558 | 2 | *spec_types++ = type; |
1559 | 2 | g_assert (type == G_TYPE_PARAM_UINT64); |
1560 | 2 | } |
1561 | | |
1562 | | /* G_TYPE_PARAM_UNICHAR |
1563 | | */ |
1564 | 2 | { |
1565 | 2 | const GParamSpecTypeInfo pspec_info = { |
1566 | 2 | sizeof (GParamSpecUnichar), /* instance_size */ |
1567 | 2 | 16, /* n_preallocs */ |
1568 | 2 | param_unichar_init, /* instance_init */ |
1569 | 2 | G_TYPE_UINT, /* value_type */ |
1570 | 2 | NULL, /* finalize */ |
1571 | 2 | param_unichar_set_default, /* value_set_default */ |
1572 | 2 | param_unichar_validate, /* value_validate */ |
1573 | 2 | param_unichar_values_cmp, /* values_cmp */ |
1574 | 2 | }; |
1575 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info); |
1576 | 2 | set_is_valid_vfunc (type, param_unichar_is_valid); |
1577 | 2 | *spec_types++ = type; |
1578 | 2 | g_assert (type == G_TYPE_PARAM_UNICHAR); |
1579 | 2 | } |
1580 | | |
1581 | | /* G_TYPE_PARAM_ENUM |
1582 | | */ |
1583 | 2 | { |
1584 | 2 | const GParamSpecTypeInfo pspec_info = { |
1585 | 2 | sizeof (GParamSpecEnum), /* instance_size */ |
1586 | 2 | 16, /* n_preallocs */ |
1587 | 2 | param_enum_init, /* instance_init */ |
1588 | 2 | G_TYPE_ENUM, /* value_type */ |
1589 | 2 | param_enum_finalize, /* finalize */ |
1590 | 2 | param_enum_set_default, /* value_set_default */ |
1591 | 2 | param_enum_validate, /* value_validate */ |
1592 | 2 | param_long_values_cmp, /* values_cmp */ |
1593 | 2 | }; |
1594 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info); |
1595 | 2 | set_is_valid_vfunc (type, param_enum_is_valid); |
1596 | 2 | *spec_types++ = type; |
1597 | 2 | g_assert (type == G_TYPE_PARAM_ENUM); |
1598 | 2 | } |
1599 | | |
1600 | | /* G_TYPE_PARAM_FLAGS |
1601 | | */ |
1602 | 2 | { |
1603 | 2 | const GParamSpecTypeInfo pspec_info = { |
1604 | 2 | sizeof (GParamSpecFlags), /* instance_size */ |
1605 | 2 | 16, /* n_preallocs */ |
1606 | 2 | param_flags_init, /* instance_init */ |
1607 | 2 | G_TYPE_FLAGS, /* value_type */ |
1608 | 2 | param_flags_finalize, /* finalize */ |
1609 | 2 | param_flags_set_default, /* value_set_default */ |
1610 | 2 | param_flags_validate, /* value_validate */ |
1611 | 2 | param_ulong_values_cmp, /* values_cmp */ |
1612 | 2 | }; |
1613 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info); |
1614 | 2 | set_is_valid_vfunc (type, param_flags_is_valid); |
1615 | 2 | *spec_types++ = type; |
1616 | 2 | g_assert (type == G_TYPE_PARAM_FLAGS); |
1617 | 2 | } |
1618 | | |
1619 | | /* G_TYPE_PARAM_FLOAT |
1620 | | */ |
1621 | 2 | { |
1622 | 2 | const GParamSpecTypeInfo pspec_info = { |
1623 | 2 | sizeof (GParamSpecFloat), /* instance_size */ |
1624 | 2 | 16, /* n_preallocs */ |
1625 | 2 | param_float_init, /* instance_init */ |
1626 | 2 | G_TYPE_FLOAT, /* value_type */ |
1627 | 2 | NULL, /* finalize */ |
1628 | 2 | param_float_set_default, /* value_set_default */ |
1629 | 2 | param_float_validate, /* value_validate */ |
1630 | 2 | param_float_values_cmp, /* values_cmp */ |
1631 | 2 | }; |
1632 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info); |
1633 | 2 | set_is_valid_vfunc (type, param_float_is_valid); |
1634 | 2 | *spec_types++ = type; |
1635 | 2 | g_assert (type == G_TYPE_PARAM_FLOAT); |
1636 | 2 | } |
1637 | | |
1638 | | /* G_TYPE_PARAM_DOUBLE |
1639 | | */ |
1640 | 2 | { |
1641 | 2 | const GParamSpecTypeInfo pspec_info = { |
1642 | 2 | sizeof (GParamSpecDouble), /* instance_size */ |
1643 | 2 | 16, /* n_preallocs */ |
1644 | 2 | param_double_init, /* instance_init */ |
1645 | 2 | G_TYPE_DOUBLE, /* value_type */ |
1646 | 2 | NULL, /* finalize */ |
1647 | 2 | param_double_set_default, /* value_set_default */ |
1648 | 2 | param_double_validate, /* value_validate */ |
1649 | 2 | param_double_values_cmp, /* values_cmp */ |
1650 | 2 | }; |
1651 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info); |
1652 | 2 | set_is_valid_vfunc (type, param_double_is_valid); |
1653 | 2 | *spec_types++ = type; |
1654 | 2 | g_assert (type == G_TYPE_PARAM_DOUBLE); |
1655 | 2 | } |
1656 | | |
1657 | | /* G_TYPE_PARAM_STRING |
1658 | | */ |
1659 | 2 | { |
1660 | 2 | const GParamSpecTypeInfo pspec_info = { |
1661 | 2 | sizeof (GParamSpecString), /* instance_size */ |
1662 | 2 | 16, /* n_preallocs */ |
1663 | 2 | param_string_init, /* instance_init */ |
1664 | 2 | G_TYPE_STRING, /* value_type */ |
1665 | 2 | param_string_finalize, /* finalize */ |
1666 | 2 | param_string_set_default, /* value_set_default */ |
1667 | 2 | param_string_validate, /* value_validate */ |
1668 | 2 | param_string_values_cmp, /* values_cmp */ |
1669 | 2 | }; |
1670 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info); |
1671 | 2 | set_is_valid_vfunc (type, param_string_is_valid); |
1672 | 2 | *spec_types++ = type; |
1673 | 2 | g_assert (type == G_TYPE_PARAM_STRING); |
1674 | 2 | } |
1675 | | |
1676 | | /* G_TYPE_PARAM_PARAM |
1677 | | */ |
1678 | 2 | { |
1679 | 2 | const GParamSpecTypeInfo pspec_info = { |
1680 | 2 | sizeof (GParamSpecParam), /* instance_size */ |
1681 | 2 | 16, /* n_preallocs */ |
1682 | 2 | param_param_init, /* instance_init */ |
1683 | 2 | G_TYPE_PARAM, /* value_type */ |
1684 | 2 | NULL, /* finalize */ |
1685 | 2 | param_param_set_default, /* value_set_default */ |
1686 | 2 | param_param_validate, /* value_validate */ |
1687 | 2 | param_pointer_values_cmp, /* values_cmp */ |
1688 | 2 | }; |
1689 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info); |
1690 | 2 | set_is_valid_vfunc (type, param_param_is_valid); |
1691 | 2 | *spec_types++ = type; |
1692 | 2 | g_assert (type == G_TYPE_PARAM_PARAM); |
1693 | 2 | } |
1694 | | |
1695 | | /* G_TYPE_PARAM_BOXED |
1696 | | */ |
1697 | 2 | { |
1698 | 2 | const GParamSpecTypeInfo pspec_info = { |
1699 | 2 | sizeof (GParamSpecBoxed), /* instance_size */ |
1700 | 2 | 4, /* n_preallocs */ |
1701 | 2 | param_boxed_init, /* instance_init */ |
1702 | 2 | G_TYPE_BOXED, /* value_type */ |
1703 | 2 | NULL, /* finalize */ |
1704 | 2 | param_boxed_set_default, /* value_set_default */ |
1705 | 2 | NULL, /* value_validate */ |
1706 | 2 | param_boxed_values_cmp, /* values_cmp */ |
1707 | 2 | }; |
1708 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info); |
1709 | 2 | *spec_types++ = type; |
1710 | 2 | g_assert (type == G_TYPE_PARAM_BOXED); |
1711 | 2 | } |
1712 | | |
1713 | | /* G_TYPE_PARAM_POINTER |
1714 | | */ |
1715 | 2 | { |
1716 | 2 | const GParamSpecTypeInfo pspec_info = { |
1717 | 2 | sizeof (GParamSpecPointer), /* instance_size */ |
1718 | 2 | 0, /* n_preallocs */ |
1719 | 2 | param_pointer_init, /* instance_init */ |
1720 | 2 | G_TYPE_POINTER, /* value_type */ |
1721 | 2 | NULL, /* finalize */ |
1722 | 2 | param_pointer_set_default, /* value_set_default */ |
1723 | 2 | NULL, |
1724 | 2 | param_pointer_values_cmp, /* values_cmp */ |
1725 | 2 | }; |
1726 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info); |
1727 | 2 | *spec_types++ = type; |
1728 | 2 | g_assert (type == G_TYPE_PARAM_POINTER); |
1729 | 2 | } |
1730 | | |
1731 | | /* G_TYPE_PARAM_VALUE_ARRAY |
1732 | | */ |
1733 | 2 | { |
1734 | 2 | /* const */ GParamSpecTypeInfo pspec_info = { |
1735 | 2 | sizeof (GParamSpecValueArray), /* instance_size */ |
1736 | 2 | 0, /* n_preallocs */ |
1737 | 2 | param_value_array_init, /* instance_init */ |
1738 | 2 | 0xdeadbeef, /* value_type, assigned further down */ |
1739 | 2 | param_value_array_finalize, /* finalize */ |
1740 | 2 | param_value_array_set_default, /* value_set_default */ |
1741 | 2 | param_value_array_validate, /* value_validate */ |
1742 | 2 | param_value_array_values_cmp, /* values_cmp */ |
1743 | 2 | }; |
1744 | 2 | pspec_info.value_type = G_TYPE_VALUE_ARRAY; |
1745 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info); |
1746 | 2 | *spec_types++ = type; |
1747 | 2 | g_assert (type == G_TYPE_PARAM_VALUE_ARRAY); |
1748 | 2 | } |
1749 | | |
1750 | | /* G_TYPE_PARAM_OBJECT |
1751 | | */ |
1752 | 2 | { |
1753 | 2 | const GParamSpecTypeInfo pspec_info = { |
1754 | 2 | sizeof (GParamSpecObject), /* instance_size */ |
1755 | 2 | 16, /* n_preallocs */ |
1756 | 2 | param_object_init, /* instance_init */ |
1757 | 2 | G_TYPE_OBJECT, /* value_type */ |
1758 | 2 | NULL, /* finalize */ |
1759 | 2 | param_object_set_default, /* value_set_default */ |
1760 | 2 | param_object_validate, /* value_validate */ |
1761 | 2 | param_object_values_cmp, /* values_cmp */ |
1762 | 2 | }; |
1763 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info); |
1764 | 2 | set_is_valid_vfunc (type, param_object_is_valid); |
1765 | 2 | *spec_types++ = type; |
1766 | 2 | g_assert (type == G_TYPE_PARAM_OBJECT); |
1767 | 2 | } |
1768 | | |
1769 | | /* G_TYPE_PARAM_OVERRIDE |
1770 | | */ |
1771 | 2 | { |
1772 | 2 | const GParamSpecTypeInfo pspec_info = { |
1773 | 2 | sizeof (GParamSpecOverride), /* instance_size */ |
1774 | 2 | 16, /* n_preallocs */ |
1775 | 2 | param_override_init, /* instance_init */ |
1776 | 2 | G_TYPE_NONE, /* value_type */ |
1777 | 2 | param_override_finalize, /* finalize */ |
1778 | 2 | param_override_set_default, /* value_set_default */ |
1779 | 2 | param_override_validate, /* value_validate */ |
1780 | 2 | param_override_values_cmp, /* values_cmp */ |
1781 | 2 | }; |
1782 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info); |
1783 | 2 | set_is_valid_vfunc (type, param_override_is_valid); |
1784 | 2 | *spec_types++ = type; |
1785 | 2 | g_assert (type == G_TYPE_PARAM_OVERRIDE); |
1786 | 2 | } |
1787 | | |
1788 | | /* G_TYPE_PARAM_GTYPE |
1789 | | */ |
1790 | 2 | { |
1791 | 2 | GParamSpecTypeInfo pspec_info = { |
1792 | 2 | sizeof (GParamSpecGType), /* instance_size */ |
1793 | 2 | 0, /* n_preallocs */ |
1794 | 2 | param_gtype_init, /* instance_init */ |
1795 | 2 | 0xdeadbeef, /* value_type, assigned further down */ |
1796 | 2 | NULL, /* finalize */ |
1797 | 2 | param_gtype_set_default, /* value_set_default */ |
1798 | 2 | param_gtype_validate, /* value_validate */ |
1799 | 2 | param_gtype_values_cmp, /* values_cmp */ |
1800 | 2 | }; |
1801 | 2 | pspec_info.value_type = G_TYPE_GTYPE; |
1802 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info); |
1803 | 2 | set_is_valid_vfunc (type, param_gtype_is_valid); |
1804 | 2 | *spec_types++ = type; |
1805 | 2 | g_assert (type == G_TYPE_PARAM_GTYPE); |
1806 | 2 | } |
1807 | | |
1808 | | /* G_TYPE_PARAM_VARIANT |
1809 | | */ |
1810 | 2 | { |
1811 | 2 | const GParamSpecTypeInfo pspec_info = { |
1812 | 2 | sizeof (GParamSpecVariant), /* instance_size */ |
1813 | 2 | 0, /* n_preallocs */ |
1814 | 2 | param_variant_init, /* instance_init */ |
1815 | 2 | G_TYPE_VARIANT, /* value_type */ |
1816 | 2 | param_variant_finalize, /* finalize */ |
1817 | 2 | param_variant_set_default, /* value_set_default */ |
1818 | 2 | param_variant_validate, /* value_validate */ |
1819 | 2 | param_variant_values_cmp, /* values_cmp */ |
1820 | 2 | }; |
1821 | 2 | type = g_param_type_register_static (g_intern_static_string ("GParamVariant"), &pspec_info); |
1822 | 2 | set_is_valid_vfunc (type, param_variant_is_valid); |
1823 | 2 | *spec_types++ = type; |
1824 | 2 | g_assert (type == G_TYPE_PARAM_VARIANT); |
1825 | 2 | } |
1826 | | |
1827 | 2 | g_assert (spec_types == spec_types_bound); |
1828 | 2 | } |
1829 | | |
1830 | | /* --- GParamSpec initialization --- */ |
1831 | | |
1832 | | /** |
1833 | | * g_param_spec_char: |
1834 | | * @name: canonical name of the property specified |
1835 | | * @nick: (nullable): nick name for the property specified |
1836 | | * @blurb: (nullable): description of the property specified |
1837 | | * @minimum: minimum value for the property specified |
1838 | | * @maximum: maximum value for the property specified |
1839 | | * @default_value: default value for the property specified |
1840 | | * @flags: flags for the property specified |
1841 | | * |
1842 | | * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property. |
1843 | | * |
1844 | | * Returns: (transfer full): a newly created parameter specification |
1845 | | */ |
1846 | | GParamSpec* |
1847 | | g_param_spec_char (const gchar *name, |
1848 | | const gchar *nick, |
1849 | | const gchar *blurb, |
1850 | | gint8 minimum, |
1851 | | gint8 maximum, |
1852 | | gint8 default_value, |
1853 | | GParamFlags flags) |
1854 | 0 | { |
1855 | 0 | GParamSpecChar *cspec; |
1856 | |
|
1857 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
1858 | | |
1859 | 0 | cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR, |
1860 | 0 | name, |
1861 | 0 | nick, |
1862 | 0 | blurb, |
1863 | 0 | flags); |
1864 | | |
1865 | 0 | cspec->minimum = minimum; |
1866 | 0 | cspec->maximum = maximum; |
1867 | 0 | cspec->default_value = default_value; |
1868 | | |
1869 | 0 | return G_PARAM_SPEC (cspec); |
1870 | 0 | } |
1871 | | |
1872 | | /** |
1873 | | * g_param_spec_uchar: |
1874 | | * @name: canonical name of the property specified |
1875 | | * @nick: (nullable): nick name for the property specified |
1876 | | * @blurb: (nullable): description of the property specified |
1877 | | * @minimum: minimum value for the property specified |
1878 | | * @maximum: maximum value for the property specified |
1879 | | * @default_value: default value for the property specified |
1880 | | * @flags: flags for the property specified |
1881 | | * |
1882 | | * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property. |
1883 | | * |
1884 | | * Returns: (transfer full): a newly created parameter specification |
1885 | | */ |
1886 | | GParamSpec* |
1887 | | g_param_spec_uchar (const gchar *name, |
1888 | | const gchar *nick, |
1889 | | const gchar *blurb, |
1890 | | guint8 minimum, |
1891 | | guint8 maximum, |
1892 | | guint8 default_value, |
1893 | | GParamFlags flags) |
1894 | 0 | { |
1895 | 0 | GParamSpecUChar *uspec; |
1896 | |
|
1897 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
1898 | | |
1899 | 0 | uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR, |
1900 | 0 | name, |
1901 | 0 | nick, |
1902 | 0 | blurb, |
1903 | 0 | flags); |
1904 | | |
1905 | 0 | uspec->minimum = minimum; |
1906 | 0 | uspec->maximum = maximum; |
1907 | 0 | uspec->default_value = default_value; |
1908 | | |
1909 | 0 | return G_PARAM_SPEC (uspec); |
1910 | 0 | } |
1911 | | |
1912 | | /** |
1913 | | * g_param_spec_boolean: |
1914 | | * @name: canonical name of the property specified |
1915 | | * @nick: (nullable): nick name for the property specified |
1916 | | * @blurb: (nullable): description of the property specified |
1917 | | * @default_value: default value for the property specified |
1918 | | * @flags: flags for the property specified |
1919 | | * |
1920 | | * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN |
1921 | | * property. In many cases, it may be more appropriate to use an enum with |
1922 | | * g_param_spec_enum(), both to improve code clarity by using explicitly named |
1923 | | * values, and to allow for more values to be added in future without breaking |
1924 | | * API. |
1925 | | * |
1926 | | * See g_param_spec_internal() for details on property names. |
1927 | | * |
1928 | | * Returns: (transfer full): a newly created parameter specification |
1929 | | */ |
1930 | | GParamSpec* |
1931 | | g_param_spec_boolean (const gchar *name, |
1932 | | const gchar *nick, |
1933 | | const gchar *blurb, |
1934 | | gboolean default_value, |
1935 | | GParamFlags flags) |
1936 | 2 | { |
1937 | 2 | GParamSpecBoolean *bspec; |
1938 | | |
1939 | 2 | g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL); |
1940 | | |
1941 | 2 | bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN, |
1942 | 2 | name, |
1943 | 2 | nick, |
1944 | 2 | blurb, |
1945 | 2 | flags); |
1946 | | |
1947 | 2 | bspec->default_value = default_value; |
1948 | | |
1949 | 2 | return G_PARAM_SPEC (bspec); |
1950 | 2 | } |
1951 | | |
1952 | | /** |
1953 | | * g_param_spec_int: |
1954 | | * @name: canonical name of the property specified |
1955 | | * @nick: (nullable): nick name for the property specified |
1956 | | * @blurb: (nullable): description of the property specified |
1957 | | * @minimum: minimum value for the property specified |
1958 | | * @maximum: maximum value for the property specified |
1959 | | * @default_value: default value for the property specified |
1960 | | * @flags: flags for the property specified |
1961 | | * |
1962 | | * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property. |
1963 | | * |
1964 | | * See g_param_spec_internal() for details on property names. |
1965 | | * |
1966 | | * Returns: (transfer full): a newly created parameter specification |
1967 | | */ |
1968 | | GParamSpec* |
1969 | | g_param_spec_int (const gchar *name, |
1970 | | const gchar *nick, |
1971 | | const gchar *blurb, |
1972 | | gint minimum, |
1973 | | gint maximum, |
1974 | | gint default_value, |
1975 | | GParamFlags flags) |
1976 | 1 | { |
1977 | 1 | GParamSpecInt *ispec; |
1978 | | |
1979 | 1 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
1980 | | |
1981 | 1 | ispec = g_param_spec_internal (G_TYPE_PARAM_INT, |
1982 | 1 | name, |
1983 | 1 | nick, |
1984 | 1 | blurb, |
1985 | 1 | flags); |
1986 | | |
1987 | 1 | ispec->minimum = minimum; |
1988 | 1 | ispec->maximum = maximum; |
1989 | 1 | ispec->default_value = default_value; |
1990 | | |
1991 | 1 | return G_PARAM_SPEC (ispec); |
1992 | 1 | } |
1993 | | |
1994 | | /** |
1995 | | * g_param_spec_uint: |
1996 | | * @name: canonical name of the property specified |
1997 | | * @nick: (nullable): nick name for the property specified |
1998 | | * @blurb: (nullable): description of the property specified |
1999 | | * @minimum: minimum value for the property specified |
2000 | | * @maximum: maximum value for the property specified |
2001 | | * @default_value: default value for the property specified |
2002 | | * @flags: flags for the property specified |
2003 | | * |
2004 | | * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property. |
2005 | | * |
2006 | | * See g_param_spec_internal() for details on property names. |
2007 | | * |
2008 | | * Returns: (transfer full): a newly created parameter specification |
2009 | | */ |
2010 | | GParamSpec* |
2011 | | g_param_spec_uint (const gchar *name, |
2012 | | const gchar *nick, |
2013 | | const gchar *blurb, |
2014 | | guint minimum, |
2015 | | guint maximum, |
2016 | | guint default_value, |
2017 | | GParamFlags flags) |
2018 | 1 | { |
2019 | 1 | GParamSpecUInt *uspec; |
2020 | | |
2021 | 1 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2022 | | |
2023 | 1 | uspec = g_param_spec_internal (G_TYPE_PARAM_UINT, |
2024 | 1 | name, |
2025 | 1 | nick, |
2026 | 1 | blurb, |
2027 | 1 | flags); |
2028 | | |
2029 | 1 | uspec->minimum = minimum; |
2030 | 1 | uspec->maximum = maximum; |
2031 | 1 | uspec->default_value = default_value; |
2032 | | |
2033 | 1 | return G_PARAM_SPEC (uspec); |
2034 | 1 | } |
2035 | | |
2036 | | /** |
2037 | | * g_param_spec_long: |
2038 | | * @name: canonical name of the property specified |
2039 | | * @nick: (nullable): nick name for the property specified |
2040 | | * @blurb: (nullable): description of the property specified |
2041 | | * @minimum: minimum value for the property specified |
2042 | | * @maximum: maximum value for the property specified |
2043 | | * @default_value: default value for the property specified |
2044 | | * @flags: flags for the property specified |
2045 | | * |
2046 | | * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property. |
2047 | | * |
2048 | | * See g_param_spec_internal() for details on property names. |
2049 | | * |
2050 | | * Returns: (transfer full): a newly created parameter specification |
2051 | | */ |
2052 | | GParamSpec* |
2053 | | g_param_spec_long (const gchar *name, |
2054 | | const gchar *nick, |
2055 | | const gchar *blurb, |
2056 | | glong minimum, |
2057 | | glong maximum, |
2058 | | glong default_value, |
2059 | | GParamFlags flags) |
2060 | 0 | { |
2061 | 0 | GParamSpecLong *lspec; |
2062 | |
|
2063 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2064 | | |
2065 | 0 | lspec = g_param_spec_internal (G_TYPE_PARAM_LONG, |
2066 | 0 | name, |
2067 | 0 | nick, |
2068 | 0 | blurb, |
2069 | 0 | flags); |
2070 | | |
2071 | 0 | lspec->minimum = minimum; |
2072 | 0 | lspec->maximum = maximum; |
2073 | 0 | lspec->default_value = default_value; |
2074 | | |
2075 | 0 | return G_PARAM_SPEC (lspec); |
2076 | 0 | } |
2077 | | |
2078 | | /** |
2079 | | * g_param_spec_ulong: |
2080 | | * @name: canonical name of the property specified |
2081 | | * @nick: (nullable): nick name for the property specified |
2082 | | * @blurb: (nullable): description of the property specified |
2083 | | * @minimum: minimum value for the property specified |
2084 | | * @maximum: maximum value for the property specified |
2085 | | * @default_value: default value for the property specified |
2086 | | * @flags: flags for the property specified |
2087 | | * |
2088 | | * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG |
2089 | | * property. |
2090 | | * |
2091 | | * See g_param_spec_internal() for details on property names. |
2092 | | * |
2093 | | * Returns: (transfer full): a newly created parameter specification |
2094 | | */ |
2095 | | GParamSpec* |
2096 | | g_param_spec_ulong (const gchar *name, |
2097 | | const gchar *nick, |
2098 | | const gchar *blurb, |
2099 | | gulong minimum, |
2100 | | gulong maximum, |
2101 | | gulong default_value, |
2102 | | GParamFlags flags) |
2103 | 0 | { |
2104 | 0 | GParamSpecULong *uspec; |
2105 | |
|
2106 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2107 | | |
2108 | 0 | uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG, |
2109 | 0 | name, |
2110 | 0 | nick, |
2111 | 0 | blurb, |
2112 | 0 | flags); |
2113 | | |
2114 | 0 | uspec->minimum = minimum; |
2115 | 0 | uspec->maximum = maximum; |
2116 | 0 | uspec->default_value = default_value; |
2117 | | |
2118 | 0 | return G_PARAM_SPEC (uspec); |
2119 | 0 | } |
2120 | | |
2121 | | /** |
2122 | | * g_param_spec_int64: |
2123 | | * @name: canonical name of the property specified |
2124 | | * @nick: (nullable): nick name for the property specified |
2125 | | * @blurb: (nullable): description of the property specified |
2126 | | * @minimum: minimum value for the property specified |
2127 | | * @maximum: maximum value for the property specified |
2128 | | * @default_value: default value for the property specified |
2129 | | * @flags: flags for the property specified |
2130 | | * |
2131 | | * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property. |
2132 | | * |
2133 | | * See g_param_spec_internal() for details on property names. |
2134 | | * |
2135 | | * Returns: (transfer full): a newly created parameter specification |
2136 | | */ |
2137 | | GParamSpec* |
2138 | | g_param_spec_int64 (const gchar *name, |
2139 | | const gchar *nick, |
2140 | | const gchar *blurb, |
2141 | | gint64 minimum, |
2142 | | gint64 maximum, |
2143 | | gint64 default_value, |
2144 | | GParamFlags flags) |
2145 | 0 | { |
2146 | 0 | GParamSpecInt64 *lspec; |
2147 | | |
2148 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2149 | | |
2150 | 0 | lspec = g_param_spec_internal (G_TYPE_PARAM_INT64, |
2151 | 0 | name, |
2152 | 0 | nick, |
2153 | 0 | blurb, |
2154 | 0 | flags); |
2155 | | |
2156 | 0 | lspec->minimum = minimum; |
2157 | 0 | lspec->maximum = maximum; |
2158 | 0 | lspec->default_value = default_value; |
2159 | | |
2160 | 0 | return G_PARAM_SPEC (lspec); |
2161 | 0 | } |
2162 | | |
2163 | | /** |
2164 | | * g_param_spec_uint64: |
2165 | | * @name: canonical name of the property specified |
2166 | | * @nick: (nullable): nick name for the property specified |
2167 | | * @blurb: (nullable): description of the property specified |
2168 | | * @minimum: minimum value for the property specified |
2169 | | * @maximum: maximum value for the property specified |
2170 | | * @default_value: default value for the property specified |
2171 | | * @flags: flags for the property specified |
2172 | | * |
2173 | | * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64 |
2174 | | * property. |
2175 | | * |
2176 | | * See g_param_spec_internal() for details on property names. |
2177 | | * |
2178 | | * Returns: (transfer full): a newly created parameter specification |
2179 | | */ |
2180 | | GParamSpec* |
2181 | | g_param_spec_uint64 (const gchar *name, |
2182 | | const gchar *nick, |
2183 | | const gchar *blurb, |
2184 | | guint64 minimum, |
2185 | | guint64 maximum, |
2186 | | guint64 default_value, |
2187 | | GParamFlags flags) |
2188 | 0 | { |
2189 | 0 | GParamSpecUInt64 *uspec; |
2190 | | |
2191 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2192 | | |
2193 | 0 | uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64, |
2194 | 0 | name, |
2195 | 0 | nick, |
2196 | 0 | blurb, |
2197 | 0 | flags); |
2198 | | |
2199 | 0 | uspec->minimum = minimum; |
2200 | 0 | uspec->maximum = maximum; |
2201 | 0 | uspec->default_value = default_value; |
2202 | | |
2203 | 0 | return G_PARAM_SPEC (uspec); |
2204 | 0 | } |
2205 | | |
2206 | | /** |
2207 | | * g_param_spec_unichar: |
2208 | | * @name: canonical name of the property specified |
2209 | | * @nick: (nullable): nick name for the property specified |
2210 | | * @blurb: (nullable): description of the property specified |
2211 | | * @default_value: default value for the property specified |
2212 | | * @flags: flags for the property specified |
2213 | | * |
2214 | | * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT |
2215 | | * property. #GValue structures for this property can be accessed with |
2216 | | * g_value_set_uint() and g_value_get_uint(). |
2217 | | * |
2218 | | * See g_param_spec_internal() for details on property names. |
2219 | | * |
2220 | | * Returns: (transfer full): a newly created parameter specification |
2221 | | */ |
2222 | | GParamSpec* |
2223 | | g_param_spec_unichar (const gchar *name, |
2224 | | const gchar *nick, |
2225 | | const gchar *blurb, |
2226 | | gunichar default_value, |
2227 | | GParamFlags flags) |
2228 | 0 | { |
2229 | 0 | GParamSpecUnichar *uspec; |
2230 | |
|
2231 | 0 | uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR, |
2232 | 0 | name, |
2233 | 0 | nick, |
2234 | 0 | blurb, |
2235 | 0 | flags); |
2236 | | |
2237 | 0 | uspec->default_value = default_value; |
2238 | | |
2239 | 0 | return G_PARAM_SPEC (uspec); |
2240 | 0 | } |
2241 | | |
2242 | | /** |
2243 | | * g_param_spec_enum: |
2244 | | * @name: canonical name of the property specified |
2245 | | * @nick: (nullable): nick name for the property specified |
2246 | | * @blurb: (nullable): description of the property specified |
2247 | | * @enum_type: a #GType derived from %G_TYPE_ENUM |
2248 | | * @default_value: default value for the property specified |
2249 | | * @flags: flags for the property specified |
2250 | | * |
2251 | | * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM |
2252 | | * property. |
2253 | | * |
2254 | | * See g_param_spec_internal() for details on property names. |
2255 | | * |
2256 | | * Returns: (transfer full): a newly created parameter specification |
2257 | | */ |
2258 | | GParamSpec* |
2259 | | g_param_spec_enum (const gchar *name, |
2260 | | const gchar *nick, |
2261 | | const gchar *blurb, |
2262 | | GType enum_type, |
2263 | | gint default_value, |
2264 | | GParamFlags flags) |
2265 | 1 | { |
2266 | 1 | GParamSpecEnum *espec; |
2267 | 1 | GEnumClass *enum_class; |
2268 | | |
2269 | 1 | g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); |
2270 | | |
2271 | 1 | enum_class = g_type_class_ref (enum_type); |
2272 | | |
2273 | 1 | g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL); |
2274 | | |
2275 | 1 | espec = g_param_spec_internal (G_TYPE_PARAM_ENUM, |
2276 | 1 | name, |
2277 | 1 | nick, |
2278 | 1 | blurb, |
2279 | 1 | flags); |
2280 | | |
2281 | 1 | espec->enum_class = enum_class; |
2282 | 1 | espec->default_value = default_value; |
2283 | 1 | G_PARAM_SPEC (espec)->value_type = enum_type; |
2284 | | |
2285 | 1 | return G_PARAM_SPEC (espec); |
2286 | 1 | } |
2287 | | |
2288 | | /** |
2289 | | * g_param_spec_flags: |
2290 | | * @name: canonical name of the property specified |
2291 | | * @nick: (nullable): nick name for the property specified |
2292 | | * @blurb: (nullable): description of the property specified |
2293 | | * @flags_type: a #GType derived from %G_TYPE_FLAGS |
2294 | | * @default_value: default value for the property specified |
2295 | | * @flags: flags for the property specified |
2296 | | * |
2297 | | * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS |
2298 | | * property. |
2299 | | * |
2300 | | * See g_param_spec_internal() for details on property names. |
2301 | | * |
2302 | | * Returns: (transfer full): a newly created parameter specification |
2303 | | */ |
2304 | | GParamSpec* |
2305 | | g_param_spec_flags (const gchar *name, |
2306 | | const gchar *nick, |
2307 | | const gchar *blurb, |
2308 | | GType flags_type, |
2309 | | guint default_value, |
2310 | | GParamFlags flags) |
2311 | 2 | { |
2312 | 2 | GParamSpecFlags *fspec; |
2313 | 2 | GFlagsClass *flags_class; |
2314 | | |
2315 | 2 | g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL); |
2316 | | |
2317 | 2 | flags_class = g_type_class_ref (flags_type); |
2318 | | |
2319 | 2 | g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL); |
2320 | | |
2321 | 2 | fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS, |
2322 | 2 | name, |
2323 | 2 | nick, |
2324 | 2 | blurb, |
2325 | 2 | flags); |
2326 | | |
2327 | 2 | fspec->flags_class = flags_class; |
2328 | 2 | fspec->default_value = default_value; |
2329 | 2 | G_PARAM_SPEC (fspec)->value_type = flags_type; |
2330 | | |
2331 | 2 | return G_PARAM_SPEC (fspec); |
2332 | 2 | } |
2333 | | |
2334 | | /** |
2335 | | * g_param_spec_float: |
2336 | | * @name: canonical name of the property specified |
2337 | | * @nick: (nullable): nick name for the property specified |
2338 | | * @blurb: (nullable): description of the property specified |
2339 | | * @minimum: minimum value for the property specified |
2340 | | * @maximum: maximum value for the property specified |
2341 | | * @default_value: default value for the property specified |
2342 | | * @flags: flags for the property specified |
2343 | | * |
2344 | | * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property. |
2345 | | * |
2346 | | * See g_param_spec_internal() for details on property names. |
2347 | | * |
2348 | | * Returns: (transfer full): a newly created parameter specification |
2349 | | */ |
2350 | | GParamSpec* |
2351 | | g_param_spec_float (const gchar *name, |
2352 | | const gchar *nick, |
2353 | | const gchar *blurb, |
2354 | | gfloat minimum, |
2355 | | gfloat maximum, |
2356 | | gfloat default_value, |
2357 | | GParamFlags flags) |
2358 | 0 | { |
2359 | 0 | GParamSpecFloat *fspec; |
2360 | |
|
2361 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2362 | | |
2363 | 0 | fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT, |
2364 | 0 | name, |
2365 | 0 | nick, |
2366 | 0 | blurb, |
2367 | 0 | flags); |
2368 | | |
2369 | 0 | fspec->minimum = minimum; |
2370 | 0 | fspec->maximum = maximum; |
2371 | 0 | fspec->default_value = default_value; |
2372 | | |
2373 | 0 | return G_PARAM_SPEC (fspec); |
2374 | 0 | } |
2375 | | |
2376 | | /** |
2377 | | * g_param_spec_double: |
2378 | | * @name: canonical name of the property specified |
2379 | | * @nick: (nullable): nick name for the property specified |
2380 | | * @blurb: (nullable): description of the property specified |
2381 | | * @minimum: minimum value for the property specified |
2382 | | * @maximum: maximum value for the property specified |
2383 | | * @default_value: default value for the property specified |
2384 | | * @flags: flags for the property specified |
2385 | | * |
2386 | | * Creates a new #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE |
2387 | | * property. |
2388 | | * |
2389 | | * See g_param_spec_internal() for details on property names. |
2390 | | * |
2391 | | * Returns: (transfer full): a newly created parameter specification |
2392 | | */ |
2393 | | GParamSpec* |
2394 | | g_param_spec_double (const gchar *name, |
2395 | | const gchar *nick, |
2396 | | const gchar *blurb, |
2397 | | gdouble minimum, |
2398 | | gdouble maximum, |
2399 | | gdouble default_value, |
2400 | | GParamFlags flags) |
2401 | 0 | { |
2402 | 0 | GParamSpecDouble *dspec; |
2403 | |
|
2404 | 0 | g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL); |
2405 | | |
2406 | 0 | dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE, |
2407 | 0 | name, |
2408 | 0 | nick, |
2409 | 0 | blurb, |
2410 | 0 | flags); |
2411 | | |
2412 | 0 | dspec->minimum = minimum; |
2413 | 0 | dspec->maximum = maximum; |
2414 | 0 | dspec->default_value = default_value; |
2415 | | |
2416 | 0 | return G_PARAM_SPEC (dspec); |
2417 | 0 | } |
2418 | | |
2419 | | /** |
2420 | | * g_param_spec_string: |
2421 | | * @name: canonical name of the property specified |
2422 | | * @nick: (nullable): nick name for the property specified |
2423 | | * @blurb: (nullable): description of the property specified |
2424 | | * @default_value: (nullable): default value for the property specified |
2425 | | * @flags: flags for the property specified |
2426 | | * |
2427 | | * Creates a new #GParamSpecString instance. |
2428 | | * |
2429 | | * See g_param_spec_internal() for details on property names. |
2430 | | * |
2431 | | * Returns: (transfer full): a newly created parameter specification |
2432 | | */ |
2433 | | GParamSpec* |
2434 | | g_param_spec_string (const gchar *name, |
2435 | | const gchar *nick, |
2436 | | const gchar *blurb, |
2437 | | const gchar *default_value, |
2438 | | GParamFlags flags) |
2439 | 2 | { |
2440 | 2 | GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING, |
2441 | 2 | name, |
2442 | 2 | nick, |
2443 | 2 | blurb, |
2444 | 2 | flags); |
2445 | | |
2446 | 2 | g_free (sspec->default_value); |
2447 | 2 | sspec->default_value = g_strdup (default_value); |
2448 | | |
2449 | 2 | return G_PARAM_SPEC (sspec); |
2450 | 2 | } |
2451 | | |
2452 | | /** |
2453 | | * g_param_spec_param: |
2454 | | * @name: canonical name of the property specified |
2455 | | * @nick: (nullable): nick name for the property specified |
2456 | | * @blurb: (nullable): description of the property specified |
2457 | | * @param_type: a #GType derived from %G_TYPE_PARAM |
2458 | | * @flags: flags for the property specified |
2459 | | * |
2460 | | * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM |
2461 | | * property. |
2462 | | * |
2463 | | * See g_param_spec_internal() for details on property names. |
2464 | | * |
2465 | | * Returns: (transfer full): a newly created parameter specification |
2466 | | */ |
2467 | | GParamSpec* |
2468 | | g_param_spec_param (const gchar *name, |
2469 | | const gchar *nick, |
2470 | | const gchar *blurb, |
2471 | | GType param_type, |
2472 | | GParamFlags flags) |
2473 | 0 | { |
2474 | 0 | GParamSpecParam *pspec; |
2475 | | |
2476 | 0 | g_return_val_if_fail (G_TYPE_IS_PARAM (param_type), NULL); |
2477 | | |
2478 | 0 | pspec = g_param_spec_internal (G_TYPE_PARAM_PARAM, |
2479 | 0 | name, |
2480 | 0 | nick, |
2481 | 0 | blurb, |
2482 | 0 | flags); |
2483 | |
|
2484 | 0 | G_PARAM_SPEC (pspec)->value_type = param_type; |
2485 | | |
2486 | 0 | return G_PARAM_SPEC (pspec); |
2487 | 0 | } |
2488 | | |
2489 | | /** |
2490 | | * g_param_spec_boxed: |
2491 | | * @name: canonical name of the property specified |
2492 | | * @nick: (nullable): nick name for the property specified |
2493 | | * @blurb: (nullable): description of the property specified |
2494 | | * @boxed_type: %G_TYPE_BOXED derived type of this property |
2495 | | * @flags: flags for the property specified |
2496 | | * |
2497 | | * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED |
2498 | | * derived property. |
2499 | | * |
2500 | | * See g_param_spec_internal() for details on property names. |
2501 | | * |
2502 | | * Returns: (transfer full): a newly created parameter specification |
2503 | | */ |
2504 | | GParamSpec* |
2505 | | g_param_spec_boxed (const gchar *name, |
2506 | | const gchar *nick, |
2507 | | const gchar *blurb, |
2508 | | GType boxed_type, |
2509 | | GParamFlags flags) |
2510 | 0 | { |
2511 | 0 | GParamSpecBoxed *bspec; |
2512 | | |
2513 | 0 | g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL); |
2514 | 0 | g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL); |
2515 | | |
2516 | 0 | bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED, |
2517 | 0 | name, |
2518 | 0 | nick, |
2519 | 0 | blurb, |
2520 | 0 | flags); |
2521 | |
|
2522 | 0 | G_PARAM_SPEC (bspec)->value_type = boxed_type; |
2523 | | |
2524 | 0 | return G_PARAM_SPEC (bspec); |
2525 | 0 | } |
2526 | | |
2527 | | /** |
2528 | | * g_param_spec_pointer: |
2529 | | * @name: canonical name of the property specified |
2530 | | * @nick: (nullable): nick name for the property specified |
2531 | | * @blurb: (nullable): description of the property specified |
2532 | | * @flags: flags for the property specified |
2533 | | * |
2534 | | * Creates a new #GParamSpecPointer instance specifying a pointer property. |
2535 | | * Where possible, it is better to use g_param_spec_object() or |
2536 | | * g_param_spec_boxed() to expose memory management information. |
2537 | | * |
2538 | | * See g_param_spec_internal() for details on property names. |
2539 | | * |
2540 | | * Returns: (transfer full): a newly created parameter specification |
2541 | | */ |
2542 | | GParamSpec* |
2543 | | g_param_spec_pointer (const gchar *name, |
2544 | | const gchar *nick, |
2545 | | const gchar *blurb, |
2546 | | GParamFlags flags) |
2547 | 0 | { |
2548 | 0 | GParamSpecPointer *pspec; |
2549 | | |
2550 | 0 | pspec = g_param_spec_internal (G_TYPE_PARAM_POINTER, |
2551 | 0 | name, |
2552 | 0 | nick, |
2553 | 0 | blurb, |
2554 | 0 | flags); |
2555 | |
|
2556 | 0 | return G_PARAM_SPEC (pspec); |
2557 | 0 | } |
2558 | | |
2559 | | /** |
2560 | | * g_param_spec_gtype: |
2561 | | * @name: canonical name of the property specified |
2562 | | * @nick: (nullable): nick name for the property specified |
2563 | | * @blurb: (nullable): description of the property specified |
2564 | | * @is_a_type: a #GType whose subtypes are allowed as values |
2565 | | * of the property (use %G_TYPE_NONE for any type) |
2566 | | * @flags: flags for the property specified |
2567 | | * |
2568 | | * Creates a new #GParamSpecGType instance specifying a |
2569 | | * %G_TYPE_GTYPE property. |
2570 | | * |
2571 | | * See g_param_spec_internal() for details on property names. |
2572 | | * |
2573 | | * Since: 2.10 |
2574 | | * |
2575 | | * Returns: (transfer full): a newly created parameter specification |
2576 | | */ |
2577 | | GParamSpec* |
2578 | | g_param_spec_gtype (const gchar *name, |
2579 | | const gchar *nick, |
2580 | | const gchar *blurb, |
2581 | | GType is_a_type, |
2582 | | GParamFlags flags) |
2583 | 0 | { |
2584 | 0 | GParamSpecGType *tspec; |
2585 | | |
2586 | 0 | tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE, |
2587 | 0 | name, |
2588 | 0 | nick, |
2589 | 0 | blurb, |
2590 | 0 | flags); |
2591 | |
|
2592 | 0 | tspec->is_a_type = is_a_type; |
2593 | |
|
2594 | 0 | return G_PARAM_SPEC (tspec); |
2595 | 0 | } |
2596 | | |
2597 | | /** |
2598 | | * g_param_spec_value_array: (skip) |
2599 | | * @name: canonical name of the property specified |
2600 | | * @nick: (nullable): nick name for the property specified |
2601 | | * @blurb: (nullable): description of the property specified |
2602 | | * @element_spec: a #GParamSpec describing the elements contained in |
2603 | | * arrays of this property, may be %NULL |
2604 | | * @flags: flags for the property specified |
2605 | | * |
2606 | | * Creates a new #GParamSpecValueArray instance specifying a |
2607 | | * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a |
2608 | | * %G_TYPE_BOXED type, as such, #GValue structures for this property |
2609 | | * can be accessed with g_value_set_boxed() and g_value_get_boxed(). |
2610 | | * |
2611 | | * See g_param_spec_internal() for details on property names. |
2612 | | * |
2613 | | * Returns: a newly created parameter specification |
2614 | | */ |
2615 | | GParamSpec* |
2616 | | g_param_spec_value_array (const gchar *name, |
2617 | | const gchar *nick, |
2618 | | const gchar *blurb, |
2619 | | GParamSpec *element_spec, |
2620 | | GParamFlags flags) |
2621 | 0 | { |
2622 | 0 | GParamSpecValueArray *aspec; |
2623 | | |
2624 | 0 | g_return_val_if_fail (element_spec == NULL || G_IS_PARAM_SPEC (element_spec), NULL); |
2625 | | |
2626 | 0 | aspec = g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY, |
2627 | 0 | name, |
2628 | 0 | nick, |
2629 | 0 | blurb, |
2630 | 0 | flags); |
2631 | |
|
2632 | 0 | if (element_spec) |
2633 | 0 | { |
2634 | 0 | aspec->element_spec = g_param_spec_ref (element_spec); |
2635 | 0 | g_param_spec_sink (element_spec); |
2636 | 0 | } |
2637 | |
|
2638 | 0 | return G_PARAM_SPEC (aspec); |
2639 | 0 | } |
2640 | | |
2641 | | /** |
2642 | | * g_param_spec_object: |
2643 | | * @name: canonical name of the property specified |
2644 | | * @nick: (nullable): nick name for the property specified |
2645 | | * @blurb: (nullable): description of the property specified |
2646 | | * @object_type: %G_TYPE_OBJECT derived type of this property |
2647 | | * @flags: flags for the property specified |
2648 | | * |
2649 | | * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT |
2650 | | * derived property. |
2651 | | * |
2652 | | * See g_param_spec_internal() for details on property names. |
2653 | | * |
2654 | | * Returns: (transfer full): a newly created parameter specification |
2655 | | */ |
2656 | | GParamSpec* |
2657 | | g_param_spec_object (const gchar *name, |
2658 | | const gchar *nick, |
2659 | | const gchar *blurb, |
2660 | | GType object_type, |
2661 | | GParamFlags flags) |
2662 | 11 | { |
2663 | 11 | GParamSpecObject *ospec; |
2664 | | |
2665 | 11 | g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL); |
2666 | | |
2667 | 11 | ospec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, |
2668 | 11 | name, |
2669 | 11 | nick, |
2670 | 11 | blurb, |
2671 | 11 | flags); |
2672 | | |
2673 | 11 | G_PARAM_SPEC (ospec)->value_type = object_type; |
2674 | | |
2675 | 11 | return G_PARAM_SPEC (ospec); |
2676 | 11 | } |
2677 | | |
2678 | | /** |
2679 | | * g_param_spec_override: (skip) |
2680 | | * @name: the name of the property. |
2681 | | * @overridden: The property that is being overridden |
2682 | | * |
2683 | | * Creates a new property of type #GParamSpecOverride. This is used |
2684 | | * to direct operations to another paramspec, and will not be directly |
2685 | | * useful unless you are implementing a new base type similar to GObject. |
2686 | | * |
2687 | | * Since: 2.4 |
2688 | | * |
2689 | | * Returns: the newly created #GParamSpec |
2690 | | */ |
2691 | | GParamSpec* |
2692 | | g_param_spec_override (const gchar *name, |
2693 | | GParamSpec *overridden) |
2694 | 0 | { |
2695 | 0 | GParamSpec *pspec; |
2696 | | |
2697 | 0 | g_return_val_if_fail (name != NULL, NULL); |
2698 | 0 | g_return_val_if_fail (G_IS_PARAM_SPEC (overridden), NULL); |
2699 | | |
2700 | | /* Dereference further redirections for property that was passed in |
2701 | | */ |
2702 | 0 | while (TRUE) |
2703 | 0 | { |
2704 | 0 | GParamSpec *indirect = g_param_spec_get_redirect_target (overridden); |
2705 | 0 | if (indirect) |
2706 | 0 | overridden = indirect; |
2707 | 0 | else |
2708 | 0 | break; |
2709 | 0 | } |
2710 | |
|
2711 | 0 | pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE, |
2712 | 0 | name, NULL, NULL, |
2713 | 0 | overridden->flags); |
2714 | | |
2715 | 0 | pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden); |
2716 | 0 | G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden); |
2717 | |
|
2718 | 0 | return pspec; |
2719 | 0 | } |
2720 | | |
2721 | | /** |
2722 | | * g_param_spec_variant: |
2723 | | * @name: canonical name of the property specified |
2724 | | * @nick: (nullable): nick name for the property specified |
2725 | | * @blurb: (nullable): description of the property specified |
2726 | | * @type: a #GVariantType |
2727 | | * @default_value: (nullable) (transfer full): a #GVariant of type @type to |
2728 | | * use as the default value, or %NULL |
2729 | | * @flags: flags for the property specified |
2730 | | * |
2731 | | * Creates a new #GParamSpecVariant instance specifying a #GVariant |
2732 | | * property. |
2733 | | * |
2734 | | * If @default_value is floating, it is consumed. |
2735 | | * |
2736 | | * See g_param_spec_internal() for details on property names. |
2737 | | * |
2738 | | * Returns: (transfer full): the newly created #GParamSpec |
2739 | | * |
2740 | | * Since: 2.26 |
2741 | | */ |
2742 | | GParamSpec* |
2743 | | g_param_spec_variant (const gchar *name, |
2744 | | const gchar *nick, |
2745 | | const gchar *blurb, |
2746 | | const GVariantType *type, |
2747 | | GVariant *default_value, |
2748 | | GParamFlags flags) |
2749 | 0 | { |
2750 | 0 | GParamSpecVariant *vspec; |
2751 | |
|
2752 | 0 | g_return_val_if_fail (type != NULL, NULL); |
2753 | 0 | g_return_val_if_fail (default_value == NULL || |
2754 | 0 | g_variant_is_of_type (default_value, type), NULL); |
2755 | | |
2756 | 0 | vspec = g_param_spec_internal (G_TYPE_PARAM_VARIANT, |
2757 | 0 | name, |
2758 | 0 | nick, |
2759 | 0 | blurb, |
2760 | 0 | flags); |
2761 | |
|
2762 | 0 | vspec->type = g_variant_type_copy (type); |
2763 | 0 | if (default_value) |
2764 | 0 | vspec->default_value = g_variant_ref_sink (default_value); |
2765 | |
|
2766 | 0 | return G_PARAM_SPEC (vspec); |
2767 | 0 | } |