Fix type check for flags when only one is present

When only one flag is specified, it's parsed as an IdentValue rather
than a FlagsValue, so IdentValue needs to be able to type check flags
(aka bitfields) properly.

Fixes #47
This commit is contained in:
James Westman 2022-03-02 13:57:30 -06:00
parent 4b42016837
commit bebe784d1d
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
3 changed files with 8 additions and 1 deletions

View file

@ -129,7 +129,7 @@ class IdentValue(Value):
def validate_for_type(self):
type = self.parent.value_type
if isinstance(type, gir.Enumeration):
if isinstance(type, gir.Enumeration) or isinstance(type, gir.Bitfield):
if self.tokens["value"] not in type.members:
raise CompileError(
f"{self.tokens['value']} is not a member of {type.full_name}",

View file

@ -4,3 +4,7 @@ using Gio 2.0;
Gio.Application {
flags: is_service | handles_open;
}
EventControllerScroll {
flags: vertical;
}

View file

@ -4,4 +4,7 @@
<object class="GApplication">
<property name="flags">is_service|handles_open</property>
</object>
<object class="GtkEventControllerScroll">
<property name="flags">vertical</property>
</object>
</interface>