Re: gobject introspection in runtime possible?



Le jeudi 07 avril 2011 à 12:22 +0200, Andrea a écrit :
> Hello list,
>  Just a flash question about introspection (I'm a newbye).
> 
> 
> Is it possible to get introspection data from a GObject in runtime?
> I was wondering if it would be convenient to create a special
> introspectable parent object to declare d-bus interfaces of derived,
> simply listing properties and class initialized methods.
> 
> 
> As I see gobject-introspection do it offline reading .c file

Indeed gobject-introspection generates metadata at build-time. Though
GType/GObject have facilities to do simple introspection at runtime.
Those facilities precluded gir and only provide informations about
signals and properties of a "living" instance.

Have a look at:
* g_signal_list_ids
http://developer.gnome.org/gobject/unstable/gobject-Signals.html#g-signal-list-ids
lists all signals for a specified GType

* g_signal_query
http://developer.gnome.org/gobject/unstable/gobject-Signals.html#g-signal-query
gives info about a specified signal

* g_object_class_list_properties
http://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-class-list-properties
 returns a list of GParamSpec* describing properties (type, name,
usage...)


Also, you might want to do that introspection for all the type hierachy
for a specific instance. To climb up the tree, use

g_type_class_peek_parent
http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-type-class-peek-parent

and g_type_interface_peek/g_type_interface_peek_parent
http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-type-class-peek-parent

Hope this helps, Happy Coding !




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]