GNOME Bugzilla – Bug 702824
Element _ from state _ is unknown: annotation, and property for record
Last modified: 2018-05-22 14:50:25 UTC
Created attachment 247462 [details] Example Vala file I like to address compiler warnings to reduce noise, and because I feel that warnings should (but I know they don't always) relay something meaningful. When I'm compiling GXml, it makes use of libgee, and the g-ir-compiler is called on libgee's .gir, and generates a lot of warnings. CCLD libgxml.la 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:9:53: 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 [9 more like above on different lines] /usr/share/gir-1.0/Gee-0.8.gir:3992:1: warning: element property from state 23 is unknown, ignoring /usr/share/gir-1.0/Gee-0.8.gir:4031:50: warning: element annotation from state 15 is unknown, ignoring [5 more like above on different lines] GXml-0.3.gir:10:51: warning: element annotation from state 6 is unknown, ignoring GXml-0.3.gir:11:54: warning: element annotation from state 6 is unknown, ignoring GXml-0.3.gir:28:1: warning: element errordomain from state 6 is unknown, ignoring GXml-0.3.gir:45:1: warning: element errordomain from state 6 is unknown, ignoring make[1]: Leaving directory `/home/richard/mine/software/gnome/gxml/gxml/gxml' The g-ir-compiler dislikes annotations found anywhere, apparently, and dislikes property elements not in a GObject-derived class or in a interface. (The one it complains about is in record). I looked at my jhbuild check of gobject-introspection, and looked at ./girepository/girparser.c, where the error is printed. There's start_element_handler () which processes elements by their name, but it doesn't seem to handle "annotation" at all. It usually handles "property" elements, but not if its not from STATE_CLASS or STATE_INTERFACE, so ones in <record>s (corresponding to non-GObject Vala classes) are ignored. STEPS TO REPRODUCE: 1. download Test.vala (attached), trivial library with one property and an annotation 2. compile GIR with something like $ valac -H Test.h -X -fPIC -X -shared --library=Test --gir=TestNS-0.1.gir Test.vala -o libTest.so $ g-ir-compiler TestNS-0.1.gir --output=TestNS-0.1.typelib ACTUAL RESULTS: The g-ir-compiler step generates these warnings: TestNS-0.1.gir:6:51: warning: element annotation from state 6 is unknown, ignoring TestNS-0.1.gir:7:56: warning: element annotation from state 6 is unknown, ignoring TestNS-0.1.gir:15:1: warning: element property from state 23 is unknown, ignoring EXPECTED RESULTS: Either have an option to acknowledge and dismiss these (perhaps annotations only really exist for Vala and so the g-ir-compiler shouldn't know about them) or have the g-ir-compiler recognise them and handle them usefully. Alternatively, documentation somewhere explaining why these are warnings, and how we might avoid them would be useful.
1) I'm not aware of there being a <annotation> element written to .gir files by g-ir-scanner, but there is an <attribute> element (see [1]) which is used to represent free form annotations like those generated by valac. Except we don't seem to like <attribute> on <namespace> either (same type of warning as above with [2]), which might simply be an oversight in girparser.c ? Anyway, I have a suspicion valac should not generate <annotation> but <attribute> instead. 2) Not sure about the property thing but as far as I understand, from g-i's point of view <property> represents a GObject object property so a valid parent element would be <class> but not <record>. I am certain though that my knowledge of all things vala is just about zero, which is only slightly less than everything else, so who knows ;) [1] https://git.gnome.org/browse/gobject-introspection/tree/tests/scanner/Regress-1.0-expected.gir#n145 [2] <?xml version="1.0"?> <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="Test"/> <c:include name="Test.h"/> <namespace name="TestNS" version="0.1" c:prefix="TestNS"> <annotation key="ccode.gir-version" value="0.1"/> <annotation key="ccode.gir-namespace" value="TestNS"/> <record name="Test"> <constructor name="new" c:identifier="test_ns_test_new"> <return-value transfer-ownership="full"> <type name="TestNS.Test" c:type="TestNSTest*"/> </return-value> </constructor> <property name="prop"> <type name="gint" c:type="gint"/> </property> </record> </namespace> </repository>
Seems like this is a valac bug then. Even if not, the valac developers should know why valagirwriter.vala uses <annotation>.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Re-assigning.
-- 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/vala/issues/386.