While building GXml, I encounter this for most files:
GICOMP GXml-0.3.gir
/usr/share/gir-1.0/Gee-0.8.gir:8:51: warning: element annotation from state 6 is unknown, ignoring
...
/usr/share/gir-1.0/Gee-0.8.gir:3383:50: warning: element annotation from state 15 is unknown, ignoring
...
/usr/share/gir-1.0/Gee-0.8.gir:3992:1: warning: element property from state 23 is unknown, ignoring
...
GXml-0.3.gir:10:51: warning: element annotation from state 6 is unknown, ignoring
GXml-0.3.gir:28:1: warning: element errordomain from state 6 is unknown, ignoring
The GObject Introspection compiler apparently has an issue with some elements in .gir files. Looking at /usr/share/gir-1.0/Gee-0.8.gir, it's in XML. Then I looked in gobject-introspection, and at it's girparser.c file, where the warning is printed.
The property element
There I found a large conditional branching block of code, start_element_handler (), that tried to identify elements by their name and their state. If an element starts with 'p', it checks which p-elements it could be, and one such check calls start_property (), which checks if the element name is "property" and its context's state (is it either STATE_CLASS or STATE_INTERFACE?). The element "property" is part of the third warning above.
A quick grep of Gee-0.8.gir (grep -P "(^\t<|<property)" /usr/share/gir-1.0/Gee-0.8.gir | grep -B 1 "<property" | grep -P -v "<property") shows that the parent of every property element is a class or interface, except for one, which is a <record>, and corresponds to the line number for the warning.
Indeed, some more grepping (grep -P "(^\t<|<property)" /usr/share/gir-1.0/Gee-0.8.gir | grep -B 1 "<property" | grep -P -v "<property" | sed -r -e 's,.* name="([^"]*)".*,\1,g' | grep -v "\-\-" | while read line; do grep " $line.*{$" /usr/share/vala/vapi/gee-0.8.vapi ; done) reveals that every other structure with a property extends from GLib.Object, whereas Lazy does not. So, while Vala allows this property on this record, the girparser doesn't expect it there.
https://live.gnome.org/Vala/Manual/Classes#Types_of_class
^ this explains the difference a little, with GObject-derived classes supporting managed properties, and Fundamental GType classes (which I think <record> corresponds to) supporting unmanaged ones.
I probably need to file a bug. :) Solutions will be extending what the girparser expects, reducing what valac allows, or just simply avoiding using certain features (if I really want to ignore the warning badly enough).
The annotation element
Looking at girparser.c, there's no handling for "annotation" at all that I can find.
Inside the Gee-0.8.gir file, some problematic annotations are these:
<namespace name="Gee" version="0.8" c:prefix="Gee">
<annotation key="ccode.gir-version" value="0.8"/>
<annotation key="ccode.gir-namespace" value="Gee"/>
...
<property name="equal-func" writable="1">
<annotation key="ccode.notify" value="false"/>
<type name="Gee.EqualDataFunc" c:type="GeeEqualDataFunc"/>
</property>
I wonder how prevalent such annotations are, and what provokes them. I'm trying to create a test case right now, so I can file a bug.
So, for my GXml warnings, the annotations are in my Attr.vala file, with this line above the namespace start:
[CCode (gir_namespace = "GXml", gir_version = "0.3")]
I'm not sure that I actually want to avoid that.
Bug filed
For now, I've file a bug, 702824. I'm not sure what the most desirable outcome is, but perhaps annotation and properties in records could be acknowledged and not warned about.
Keine Kommentare:
Kommentar veröffentlichen