GNOME Bugzilla – Bug 786931
rnc/rng files specify "class" as mandatory for objects, but the parser treats it as optional
Last modified: 2017-09-25 13:27:50 UTC
gtkbuilder.rnc says: object = element object { attribute id { xsd:ID } ?, attribute class { text }, attribute type-func { text } ?, attribute constructor { text } ?, (property | signal | child | ANY) * } However, the parser uses G_MARKUP_COLLECT_OPTIONAL when looking for the "class" attribute. Apart from the aesthetics of it, enforcing "class" as a mandatory attribute for "object":s is a nice idea because it can help Vala [1]. For GTK+ template classes, the Vala compiler ensures that all [GtkChild] class members in Vala have a matching XML object with the right type. However, it doesn't know about "type-func". So, if only the "type-func" attribute is used, then it will fail to compile because it won't know about the XML object. See vala/codegen/valagtkmodule.vala It seems easier to fix this in GtkBuilder than to teach valac to get the type from the "type-func". But I know little about Vala, so I might be wrong. Since this will break existing run-time behaviour, it can only be done in master, and not fit for gtk3. Although, note that "class" attributes are vastly more common than "type-func", so breakage should be minimum. [1] https://bugs.webkit.org/show_bug.cgi?id=175937#c16
Just to be clear, the suggestion is to make the GtkBuilder parser throw and error if class is missing ? Thats fine with me. Will you write a patch ?
(In reply to Matthias Clasen from comment #1) > Just to be clear, the suggestion is to make the GtkBuilder parser throw and > error if class is missing ? Thats fine with me. Will you write a patch ? Yes and yes. I have a rough patch ready but got stuck with libepoxy-1.4.3 not working with mesa-17.0.x [1]. Will finish it tomorrow. [1] https://bugs.gentoo.org/show_bug.cgi?id=623926
Created attachment 359999 [details] [review] GtkBuilder: Enforce "class" as a mandatory attribute for <object>
Created attachment 360000 [details] [review] GtkBuilder: Enforce "class" as a mandatory attribute for <object>
Review of attachment 360000 [details] [review]: looks good to me
Comment on attachment 360000 [details] [review] GtkBuilder: Enforce "class" as a mandatory attribute for <object> Thanks for the review. Pushed to master.