GNOME Bugzilla – Bug 770734
Cannot get free-form attributes on properties.
Last modified: 2018-02-08 12:42:48 UTC
I'm trying to use free-form attributes, from Object class type, to properties and fields. But I can't get free-form attributes from property. I can sure that gir xml file contains attributes. But g_base_info_iterate_attributes() does not return any attributes. I suspect that either that the attributes are omitted in typelib, or that they aren't loaded in the GIPropertyInfo. C Comment: > ... > /** > * OnggiModule:version: (attributes onggi.tracked=true) > * > * Version of the module. > */ > ... GIR XML > ... > <property name="version" > writable="1" > construct-only="1" > transfer-ownership="none"> > <attribute name="onggi.tracked" value="true"/> > <doc xml:space="preserve">Version of the module.</doc> > <type name="guint" c:type="guint"/> > </property> > ...
I found another aspect of this issue. I found attributes of properties are attached to class, not their properties. Part of GIR XML for class "SubjectObject" > ... > <repository version="1.2" > xmlns="http://www.gtk.org/introspection/core/1.0" > xmlns:c="http://www.gtk.org/introspection/c/1.0" > xmlns:glib="http://www.gtk.org/introspection/glib/1.0"> > <package name="gobject-2.0"/> > <namespace name="Subject" > version="1.0" > shared-library="libsubject-1.0.so" > c:identifier-prefixes="Subject" > c:symbol-prefixes="subject"> > <class name="Object" > c:symbol-prefix="object" > c:type="SubjectObject" > glib:type-name="SubjectObject" > glib:get-type="subject_object_get_type" > glib:type-struct="ObjectClass"> > <doc xml:space="preserve">An instance structure.</doc> > <constructor name="new" c:identifier="subject_object_new"> > ... > <property name="prop-int" writable="1" transfer-ownership="none"> > <attribute name="subject.attr" value="Property"/> > <doc xml:space="preserve">An integer property.</doc> > <type name="gint" c:type="gint"/> > </property> > ... Part of the code that used to print out attributes: > void > dump_info (guint space, > GIBaseInfo *info) > { > GITypeInfo *tinfo = NULL; > > g_print ("%*s%s\n", space, "", g_base_info_get_name (info)); > > GIAttributeIter attr_iter = {0, }; > > gchar *attr_name; > gchar *attr_value; > > while (g_base_info_iterate_attributes (info, &attr_iter, &attr_name, &attr_value)) > g_print ("%*s%s: %s\n", space + 4, "", attr_name, attr_value); > > g_print ("\n"); > > ... And this is the result. > Object > subject.attr: Property > > parent_instance > > new > subject.attr: Constructor > ... > ... > > vfunc > subject.attr: VFuncWrapper > > prop-int > > sig > subject.attr: Signal > > a >... Also I just runned g-ir-generate Subject-1.0.typelib and here is part of result. > <repository version="1.0" > xmlns="http://www.gtk.org/introspection/core/1.0" > xmlns:c="http://www.gtk.org/introspection/c/1.0" > xmlns:glib="http://www.gtk.org/introspection/glib/1.0"> > <namespace name="Subject" version="1.0" shared-library="libsubject-1.0.so" c:prefix="Subject"> > <class name="Object" glib:type-struct="ObjectClass" glib:type-name="SubjectObject" glib:get-type="subject_object_get_type"> > <attribute name="subject.attr" value="Property"/> > <field name="parent_instance"> > <type name="any"/> > </field> > ... > ... > </method> > <property name="prop-int" writable="1" transfer-ownership="none"> > <type name="gint32"/> > </property> > <glib:signal name="sig" when="LAST"> > ... So, I'm suspecting that attributes are attached to class, either of when being compiled, or loaded. I'm also attaching the subject.c, subject.h, and Subject-1.0.gir, and gir that generated from `g-ir-generate Subject-1.0.gir`
Created attachment 341200 [details] subject.c
Created attachment 341201 [details] subject.h
Created attachment 341203 [details] dumpthing.c I wrote this to print out attributes.
Created attachment 341204 [details] Subject-1.0.gir
Created attachment 341205 [details] Subject-1.0-gen.gir This is generated from `g-ir-generate Subject-1.0.typelib`. Subject-1.0.typelib was generated from `g-ir-compiler Subject-1.0.gir`
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/162.