mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
xml: Fix flags and enums
GtkBuilder XML uses enum nicknames, full names, or integer values, but we accept GIR names, so passing those through doesn't work if the name has an underscore (which traditionally turns into a dash in the nickname). Avoid the problem by always writing the integer value of the enum member.
This commit is contained in:
parent
51d8969ced
commit
6c67e1fc5a
11 changed files with 34 additions and 14 deletions
|
@ -168,6 +168,20 @@ class NumberValue(Value):
|
|||
class Flag(AstNode):
|
||||
grammar = UseIdent("value")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.tokens["value"]
|
||||
|
||||
@property
|
||||
def value(self) -> T.Optional[int]:
|
||||
type = self.parent.parent.value_type
|
||||
if not isinstance(type, Enumeration):
|
||||
return None
|
||||
elif member := type.members.get(self.tokens["value"]):
|
||||
return member.value
|
||||
else:
|
||||
return None
|
||||
|
||||
@docs()
|
||||
def docs(self):
|
||||
type = self.parent.parent.value_type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue