1/* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17#ifndef __G_OBJECT_H__
18#define __G_OBJECT_H__
19
20#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
21#error "Only <glib-object.h> can be included directly."
22#endif
23
24#include <gobject/gtype.h>
25#include <gobject/gvalue.h>
26#include <gobject/gparam.h>
27#include <gobject/gclosure.h>
28#include <gobject/gsignal.h>
29#include <gobject/gboxed.h>
30
31G_BEGIN_DECLS
32
33/* --- type macros --- */
34/**
35 * G_TYPE_IS_OBJECT:
36 * @type: Type id to check
37 *
38 * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it.
39 *
40 * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
41 */
42#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
43/**
44 * G_OBJECT:
45 * @object: Object which is subject to casting.
46 *
47 * Casts a #GObject or derived pointer into a (GObject*) pointer.
48 * Depending on the current debugging level, this function may invoke
49 * certain runtime checks to identify invalid casts.
50 */
51#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
52/**
53 * G_OBJECT_CLASS:
54 * @class: a valid #GObjectClass
55 *
56 * Casts a derived #GObjectClass structure into a #GObjectClass structure.
57 */
58#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
59/**
60 * G_IS_OBJECT:
61 * @object: Instance to check for being a %G_TYPE_OBJECT.
62 *
63 * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
64 */
65#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
66/**
67 * G_IS_OBJECT_CLASS:
68 * @class: a #GObjectClass
69 *
70 * Checks whether @class "is a" valid #GObjectClass structure of type
71 * %G_TYPE_OBJECT or derived.
72 */
73#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
74/**
75 * G_OBJECT_GET_CLASS:
76 * @object: a #GObject instance.
77 *
78 * Get the class structure associated to a #GObject instance.
79 *
80 * Returns: pointer to object class structure.
81 */
82#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
83/**
84 * G_OBJECT_TYPE:
85 * @object: Object to return the type id for.
86 *
87 * Get the type id of an object.
88 *
89 * Returns: Type id of @object.
90 */
91#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
92/**
93 * G_OBJECT_TYPE_NAME:
94 * @object: Object to return the type name for.
95 *
96 * Get the name of an object's type.
97 *
98 * Returns: Type name of @object. The string is owned by the type system and
99 * should not be freed.
100 */
101#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
102/**
103 * G_OBJECT_CLASS_TYPE:
104 * @class: a valid #GObjectClass
105 *
106 * Get the type id of a class structure.
107 *
108 * Returns: Type id of @class.
109 */
110#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
111/**
112 * G_OBJECT_CLASS_NAME:
113 * @class: a valid #GObjectClass
114 *
115 * Return the name of a class structure's type.
116 *
117 * Returns: Type name of @class. The string is owned by the type system and
118 * should not be freed.
119 */
120#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
121/**
122 * G_VALUE_HOLDS_OBJECT:
123 * @value: a valid #GValue structure
124 *
125 * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT.
126 *
127 * Returns: %TRUE on success.
128 */
129#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
130
131/* --- type macros --- */
132/**
133 * G_TYPE_INITIALLY_UNOWNED:
134 *
135 * The type for #GInitiallyUnowned.
136 */
137#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type())
138/**
139 * G_INITIALLY_UNOWNED:
140 * @object: Object which is subject to casting.
141 *
142 * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*)
143 * pointer. Depending on the current debugging level, this function may invoke
144 * certain runtime checks to identify invalid casts.
145 */
146#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
147/**
148 * G_INITIALLY_UNOWNED_CLASS:
149 * @class: a valid #GInitiallyUnownedClass
150 *
151 * Casts a derived #GInitiallyUnownedClass structure into a
152 * #GInitiallyUnownedClass structure.
153 */
154#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
155/**
156 * G_IS_INITIALLY_UNOWNED:
157 * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED.
158 *
159 * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED.
160 */
161#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))
162/**
163 * G_IS_INITIALLY_UNOWNED_CLASS:
164 * @class: a #GInitiallyUnownedClass
165 *
166 * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type
167 * %G_TYPE_INITIALLY_UNOWNED or derived.
168 */
169#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))
170/**
171 * G_INITIALLY_UNOWNED_GET_CLASS:
172 * @object: a #GInitiallyUnowned instance.
173 *
174 * Get the class structure associated to a #GInitiallyUnowned instance.
175 *
176 * Returns: pointer to object class structure.
177 */
178#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
179/* GInitiallyUnowned ia a GObject with initially floating reference count */
180
181
182/* --- typedefs & structures --- */
183typedef struct _GObject GObject;
184typedef struct _GObjectClass GObjectClass;
185typedef struct _GObject GInitiallyUnowned;
186typedef struct _GObjectClass GInitiallyUnownedClass;
187typedef struct _GObjectConstructParam GObjectConstructParam;
188/**
189 * GObjectGetPropertyFunc:
190 * @object: a #GObject
191 * @property_id: the numeric id under which the property was registered with
192 * g_object_class_install_property().
193 * @value: a #GValue to return the property value in
194 * @pspec: the #GParamSpec describing the property
195 *
196 * The type of the @get_property function of #GObjectClass.
197 */
198typedef void (*GObjectGetPropertyFunc) (GObject *object,
199 guint property_id,
200 GValue *value,
201 GParamSpec *pspec);
202/**
203 * GObjectSetPropertyFunc:
204 * @object: a #GObject
205 * @property_id: the numeric id under which the property was registered with
206 * g_object_class_install_property().
207 * @value: the new value for the property
208 * @pspec: the #GParamSpec describing the property
209 *
210 * The type of the @set_property function of #GObjectClass.
211 */
212typedef void (*GObjectSetPropertyFunc) (GObject *object,
213 guint property_id,
214 const GValue *value,
215 GParamSpec *pspec);
216/**
217 * GObjectFinalizeFunc:
218 * @object: the #GObject being finalized
219 *
220 * The type of the @finalize function of #GObjectClass.
221 */
222typedef void (*GObjectFinalizeFunc) (GObject *object);
223/**
224 * GWeakNotify:
225 * @data: data that was provided when the weak reference was established
226 * @where_the_object_was: the object being finalized
227 *
228 * A #GWeakNotify function can be added to an object as a callback that gets
229 * triggered when the object is finalized. Since the object is already being
230 * finalized when the #GWeakNotify is called, there's not much you could do
231 * with the object, apart from e.g. using its address as hash-index or the like.
232 */
233typedef void (*GWeakNotify) (gpointer data,
234 GObject *where_the_object_was);
235/**
236 * GObject:
237 *
238 * All the fields in the GObject structure are private
239 * to the #GObject implementation and should never be accessed directly.
240 */
241struct _GObject
242{
243 GTypeInstance g_type_instance;
244
245 /*< private >*/
246 volatile guint ref_count;
247 GData *qdata;
248};
249/**
250 * GObjectClass:
251 * @g_type_class: the parent class
252 * @constructor: the @constructor function is called by g_object_new () to
253 * complete the object initialization after all the construction properties are
254 * set. The first thing a @constructor implementation must do is chain up to the
255 * @constructor of the parent class. Overriding @constructor should be rarely
256 * needed, e.g. to handle construct properties, or to implement singletons.
257 * @set_property: the generic setter for all properties of this type. Should be
258 * overridden for every type with properties. If implementations of
259 * @set_property don't emit property change notification explicitly, this will
260 * be done implicitly by the type system. However, if the notify signal is
261 * emitted explicitly, the type system will not emit it a second time.
262 * @get_property: the generic getter for all properties of this type. Should be
263 * overridden for every type with properties.
264 * @dispose: the @dispose function is supposed to drop all references to other
265 * objects, but keep the instance otherwise intact, so that client method
266 * invocations still work. It may be run multiple times (due to reference
267 * loops). Before returning, @dispose should chain up to the @dispose method
268 * of the parent class.
269 * @finalize: instance finalization function, should finish the finalization of
270 * the instance begun in @dispose and chain up to the @finalize method of the
271 * parent class.
272 * @dispatch_properties_changed: emits property change notification for a bunch
273 * of properties. Overriding @dispatch_properties_changed should be rarely
274 * needed.
275 * @notify: the class closure for the notify signal
276 * @constructed: the @constructed function is called by g_object_new() as the
277 * final step of the object creation process. At the point of the call, all
278 * construction properties have been set on the object. The purpose of this
279 * call is to allow for object initialisation steps that can only be performed
280 * after construction properties have been set. @constructed implementors
281 * should chain up to the @constructed call of their parent class to allow it
282 * to complete its initialisation.
283 *
284 * The class structure for the GObject type.
285 *
286 * <example>
287 * <title>Implementing singletons using a constructor</title>
288 * <programlisting>
289 * static MySingleton *the_singleton = NULL;
290 *
291 * static GObject*
292 * my_singleton_constructor (GType type,
293 * guint n_construct_params,
294 * GObjectConstructParam *construct_params)
295 * {
296 * GObject *object;
297 *
298 * if (!the_singleton)
299 * {
300 * object = G_OBJECT_CLASS (parent_class)->constructor (type,
301 * n_construct_params,
302 * construct_params);
303 * the_singleton = MY_SINGLETON (object);
304 * }
305 * else
306 * object = g_object_ref (G_OBJECT (the_singleton));
307 *
308 * return object;
309 * }
310 * </programlisting></example>
311 */
312struct _GObjectClass
313{
314 GTypeClass g_type_class;
315
316 /*< private >*/
317 GSList *construct_properties;
318
319 /*< public >*/
320 /* seldom overidden */
321 GObject* (*constructor) (GType type,
322 guint n_construct_properties,
323 GObjectConstructParam *construct_properties);
324 /* overridable methods */
325 void (*set_property) (GObject *object,
326 guint property_id,
327 const GValue *value,
328 GParamSpec *pspec);
329 void (*get_property) (GObject *object,
330 guint property_id,
331 GValue *value,
332 GParamSpec *pspec);
333 void (*dispose) (GObject *object);
334 void (*finalize) (GObject *object);
335 /* seldom overidden */
336 void (*dispatch_properties_changed) (GObject *object,
337 guint n_pspecs,
338 GParamSpec **pspecs);
339 /* signals */
340 void (*notify) (GObject *object,
341 GParamSpec *pspec);
342
343 /* called when done constructing */
344 void (*constructed) (GObject *object);
345
346 /*< private >*/
347 gsize flags;
348
349 /* padding */
350 gpointer pdummy[6];
351};
352/**
353 * GObjectConstructParam:
354 * @pspec: the #GParamSpec of the construct parameter
355 * @value: the value to set the parameter to
356 *
357 * The GObjectConstructParam struct is an auxiliary
358 * structure used to hand #GParamSpec/#GValue pairs to the @constructor of
359 * a #GObjectClass.
360 */
361struct _GObjectConstructParam
362{
363 GParamSpec *pspec;
364 GValue *value;
365};
366
367/**
368 * GInitiallyUnowned:
369 *
370 * All the fields in the GInitiallyUnowned structure
371 * are private to the #GInitiallyUnowned implementation and should never be
372 * accessed directly.
373 */
374/**
375 * GInitiallyUnownedClass:
376 *
377 * The class structure for the GInitiallyUnowned type.
378 */
379
380
381/* --- prototypes --- */
382GLIB_AVAILABLE_IN_ALL
383GType g_initially_unowned_get_type (void);
384GLIB_AVAILABLE_IN_ALL
385void g_object_class_install_property (GObjectClass *oclass,
386 guint property_id,
387 GParamSpec *pspec);
388GLIB_AVAILABLE_IN_ALL
389GParamSpec* g_object_class_find_property (GObjectClass *oclass,
390 const gchar *property_name);
391GLIB_AVAILABLE_IN_ALL
392GParamSpec**g_object_class_list_properties (GObjectClass *oclass,
393 guint *n_properties);
394GLIB_AVAILABLE_IN_ALL
395void g_object_class_override_property (GObjectClass *oclass,
396 guint property_id,
397 const gchar *name);
398GLIB_AVAILABLE_IN_ALL
399void g_object_class_install_properties (GObjectClass *oclass,
400 guint n_pspecs,
401 GParamSpec **pspecs);
402
403GLIB_AVAILABLE_IN_ALL
404void g_object_interface_install_property (gpointer g_iface,
405 GParamSpec *pspec);
406GLIB_AVAILABLE_IN_ALL
407GParamSpec* g_object_interface_find_property (gpointer g_iface,
408 const gchar *property_name);
409GLIB_AVAILABLE_IN_ALL
410GParamSpec**g_object_interface_list_properties (gpointer g_iface,
411 guint *n_properties_p);
412
413GLIB_AVAILABLE_IN_ALL
414GType g_object_get_type (void) G_GNUC_CONST;
415GLIB_AVAILABLE_IN_ALL
416gpointer g_object_new (GType object_type,
417 const gchar *first_property_name,
418 ...);
419GLIB_AVAILABLE_IN_ALL
420gpointer g_object_newv (GType object_type,
421 guint n_parameters,
422 GParameter *parameters);
423GLIB_AVAILABLE_IN_ALL
424GObject* g_object_new_valist (GType object_type,
425 const gchar *first_property_name,
426 va_list var_args);
427GLIB_AVAILABLE_IN_ALL
428void g_object_set (gpointer object,
429 const gchar *first_property_name,
430 ...) G_GNUC_NULL_TERMINATED;
431GLIB_AVAILABLE_IN_ALL
432void g_object_get (gpointer object,
433 const gchar *first_property_name,
434 ...) G_GNUC_NULL_TERMINATED;
435GLIB_AVAILABLE_IN_ALL
436gpointer g_object_connect (gpointer object,
437 const gchar *signal_spec,
438 ...) G_GNUC_NULL_TERMINATED;
439GLIB_AVAILABLE_IN_ALL
440void g_object_disconnect (gpointer object,
441 const gchar *signal_spec,
442 ...) G_GNUC_NULL_TERMINATED;
443GLIB_AVAILABLE_IN_ALL
444void g_object_set_valist (GObject *object,
445 const gchar *first_property_name,
446 va_list var_args);
447GLIB_AVAILABLE_IN_ALL
448void g_object_get_valist (GObject *object,
449 const gchar *first_property_name,
450 va_list var_args);
451GLIB_AVAILABLE_IN_ALL
452void g_object_set_property (GObject *object,
453 const gchar *property_name,
454 const GValue *value);
455GLIB_AVAILABLE_IN_ALL
456void g_object_get_property (GObject *object,
457 const gchar *property_name,
458 GValue *value);
459GLIB_AVAILABLE_IN_ALL
460void g_object_freeze_notify (GObject *object);
461GLIB_AVAILABLE_IN_ALL
462void g_object_notify (GObject *object,
463 const gchar *property_name);
464GLIB_AVAILABLE_IN_ALL
465void g_object_notify_by_pspec (GObject *object,
466 GParamSpec *pspec);
467GLIB_AVAILABLE_IN_ALL
468void g_object_thaw_notify (GObject *object);
469GLIB_AVAILABLE_IN_ALL
470gboolean g_object_is_floating (gpointer object);
471GLIB_AVAILABLE_IN_ALL
472gpointer g_object_ref_sink (gpointer object);
473GLIB_AVAILABLE_IN_ALL
474gpointer g_object_ref (gpointer object);
475GLIB_AVAILABLE_IN_ALL
476void g_object_unref (gpointer object);
477GLIB_AVAILABLE_IN_ALL
478void g_object_weak_ref (GObject *object,
479 GWeakNotify notify,
480 gpointer data);
481GLIB_AVAILABLE_IN_ALL
482void g_object_weak_unref (GObject *object,
483 GWeakNotify notify,
484 gpointer data);
485GLIB_AVAILABLE_IN_ALL
486void g_object_add_weak_pointer (GObject *object,
487 gpointer *weak_pointer_location);
488GLIB_AVAILABLE_IN_ALL
489void g_object_remove_weak_pointer (GObject *object,
490 gpointer *weak_pointer_location);
491
492/**
493 * GToggleNotify:
494 * @data: Callback data passed to g_object_add_toggle_ref()
495 * @object: The object on which g_object_add_toggle_ref() was called.
496 * @is_last_ref: %TRUE if the toggle reference is now the
497 * last reference to the object. %FALSE if the toggle
498 * reference was the last reference and there are now other
499 * references.
500 *
501 * A callback function used for notification when the state
502 * of a toggle reference changes. See g_object_add_toggle_ref().
503 */
504typedef void (*GToggleNotify) (gpointer data,
505 GObject *object,
506 gboolean is_last_ref);
507
508GLIB_AVAILABLE_IN_ALL
509void g_object_add_toggle_ref (GObject *object,
510 GToggleNotify notify,
511 gpointer data);
512GLIB_AVAILABLE_IN_ALL
513void g_object_remove_toggle_ref (GObject *object,
514 GToggleNotify notify,
515 gpointer data);
516
517GLIB_AVAILABLE_IN_ALL
518gpointer g_object_get_qdata (GObject *object,
519 GQuark quark);
520GLIB_AVAILABLE_IN_ALL
521void g_object_set_qdata (GObject *object,
522 GQuark quark,
523 gpointer data);
524GLIB_AVAILABLE_IN_ALL
525void g_object_set_qdata_full (GObject *object,
526 GQuark quark,
527 gpointer data,
528 GDestroyNotify destroy);
529GLIB_AVAILABLE_IN_ALL
530gpointer g_object_steal_qdata (GObject *object,
531 GQuark quark);
532
533GLIB_AVAILABLE_IN_2_34
534gpointer g_object_dup_qdata (GObject *object,
535 GQuark quark,
536 GDuplicateFunc dup_func,
537 gpointer user_data);
538GLIB_AVAILABLE_IN_2_34
539gboolean g_object_replace_qdata (GObject *object,
540 GQuark quark,
541 gpointer oldval,
542 gpointer newval,
543 GDestroyNotify destroy,
544 GDestroyNotify *old_destroy);
545
546GLIB_AVAILABLE_IN_ALL
547gpointer g_object_get_data (GObject *object,
548 const gchar *key);
549GLIB_AVAILABLE_IN_ALL
550void g_object_set_data (GObject *object,
551 const gchar *key,
552 gpointer data);
553GLIB_AVAILABLE_IN_ALL
554void g_object_set_data_full (GObject *object,
555 const gchar *key,
556 gpointer data,
557 GDestroyNotify destroy);
558GLIB_AVAILABLE_IN_ALL
559gpointer g_object_steal_data (GObject *object,
560 const gchar *key);
561
562GLIB_AVAILABLE_IN_2_34
563gpointer g_object_dup_data (GObject *object,
564 const gchar *key,
565 GDuplicateFunc dup_func,
566 gpointer user_data);
567GLIB_AVAILABLE_IN_2_34
568gboolean g_object_replace_data (GObject *object,
569 const gchar *key,
570 gpointer oldval,
571 gpointer newval,
572 GDestroyNotify destroy,
573 GDestroyNotify *old_destroy);
574
575
576GLIB_AVAILABLE_IN_ALL
577void g_object_watch_closure (GObject *object,
578 GClosure *closure);
579GLIB_AVAILABLE_IN_ALL
580GClosure* g_cclosure_new_object (GCallback callback_func,
581 GObject *object);
582GLIB_AVAILABLE_IN_ALL
583GClosure* g_cclosure_new_object_swap (GCallback callback_func,
584 GObject *object);
585GLIB_AVAILABLE_IN_ALL
586GClosure* g_closure_new_object (guint sizeof_closure,
587 GObject *object);
588GLIB_AVAILABLE_IN_ALL
589void g_value_set_object (GValue *value,
590 gpointer v_object);
591GLIB_AVAILABLE_IN_ALL
592gpointer g_value_get_object (const GValue *value);
593GLIB_AVAILABLE_IN_ALL
594gpointer g_value_dup_object (const GValue *value);
595GLIB_AVAILABLE_IN_ALL
596gulong g_signal_connect_object (gpointer instance,
597 const gchar *detailed_signal,
598 GCallback c_handler,
599 gpointer gobject,
600 GConnectFlags connect_flags);
601
602/*< protected >*/
603GLIB_AVAILABLE_IN_ALL
604void g_object_force_floating (GObject *object);
605GLIB_AVAILABLE_IN_ALL
606void g_object_run_dispose (GObject *object);
607
608
609GLIB_AVAILABLE_IN_ALL
610void g_value_take_object (GValue *value,
611 gpointer v_object);
612GLIB_DEPRECATED_FOR(g_value_take_object)
613void g_value_set_object_take_ownership (GValue *value,
614 gpointer v_object);
615
616GLIB_DEPRECATED
617gsize g_object_compat_control (gsize what,
618 gpointer data);
619
620/* --- implementation macros --- */
621#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
622G_STMT_START { \
623 GObject *_glib__object = (GObject*) (object); \
624 GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \
625 guint _glib__property_id = (property_id); \
626 g_warning ("%s: invalid %s id %u for \"%s\" of type '%s' in '%s'", \
627 G_STRLOC, \
628 (pname), \
629 _glib__property_id, \
630 _glib__pspec->name, \
631 g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \
632 G_OBJECT_TYPE_NAME (_glib__object)); \
633} G_STMT_END
634/**
635 * G_OBJECT_WARN_INVALID_PROPERTY_ID:
636 * @object: the #GObject on which set_property() or get_property() was called
637 * @property_id: the numeric id of the property
638 * @pspec: the #GParamSpec of the property
639 *
640 * This macro should be used to emit a standard warning about unexpected
641 * properties in set_property() and get_property() implementations.
642 */
643#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
644 G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))
645
646GLIB_AVAILABLE_IN_ALL
647void g_clear_object (volatile GObject **object_ptr);
648#define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref)
649
650typedef struct {
651 /*<private>*/
652 union { gpointer p; } priv;
653} GWeakRef;
654
655GLIB_AVAILABLE_IN_ALL
656void g_weak_ref_init (GWeakRef *weak_ref,
657 gpointer object);
658GLIB_AVAILABLE_IN_ALL
659void g_weak_ref_clear (GWeakRef *weak_ref);
660GLIB_AVAILABLE_IN_ALL
661gpointer g_weak_ref_get (GWeakRef *weak_ref);
662GLIB_AVAILABLE_IN_ALL
663void g_weak_ref_set (GWeakRef *weak_ref,
664 gpointer object);
665
666G_END_DECLS
667
668#endif /* __G_OBJECT_H__ */
669