GNOME Bugzilla – Bug 642757
"c:identifier" attribute not available on GIValueInfo
Last modified: 2015-02-07 16:52:05 UTC
It seems that all <member> elements in GIRs have a "c:identifier" attribute, but that attribute can only be accessed through the API for Function types. GIValueInfo has no such attribute. In PyGObject, we can retrieve the value_name for enums with GTypes, but for non GType enums we need to fill in the GEnumValue ourselves. "c:identifier" seems to be the value needed for GEnumValue.value_name. I looked into making a patch for this myself, since it is easy to expose it using the existing g_base_info_get_attribute(). However it would require using up some of the reserved padding on ValueBlob for another string pointer, and probably someone more knowledgeable should tell me if this is the right thing to do.
Created attachment 181592 [details] [review] Add "c:identifier" attribute to GIrNodeValue (for flags and enum values). Flags and enums with a GType have a value_nick and value_name strings available in the class struct. But for flags and enums without GType, we need to get this information from introspection. g_base_info_get_name() gives the string for value_nick. In the GIR, the attribute "c:identifier" is the string neede for value_name. This patch adds the "c:identifier" from GIR to the typelib for all flags and enum values. It can be retireved using g_base_info_get_attribute(info, "c:identifier").
Created attachment 181611 [details] [review] Add "c:identifier" attribute to GIrNodeValue (for flags and enum values). Same as previous patch, with tests added. Rest of commit message: Flags and enums with a GType have a value_nick and value_name strings available in the class struct. But for flags and enums without GType, we need to get this information from introspection. g_base_info_get_name() gives the string for value_nick. In the GIR, the attribute "c:identifier" is the string neede for value_name. This patch adds the "c:identifier" from GIR to the typelib for all flags and enum values. It can be retireved using g_base_info_get_attribute(info, "c:identifier").
Review of attachment 181611 [details] [review]: Looks great, thanks. Perhaps rename the test to just gitypelibtest.c and move the cidentifier parts to a specific function. As the test grows we'll probably use gtester etc.
Created attachment 181693 [details] [review] Add "c:identifier" attribute to GIrNodeValue (for flags and enum values). Same as previous patch with gitestcidentifier.c renamed to gitypelibtest.c
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]