add variant support for menus

This commit is contained in:
jgcodes2020 2024-12-14 14:00:09 -05:00
parent f894301571
commit a75adc7d1b
4 changed files with 39 additions and 13 deletions

View file

@ -393,7 +393,9 @@ class VariantValue(AstNode):
@validate()
def validate_for_type(self) -> None:
expected_type = self.context[ValueTypeCtx].value_type
if (
if expected_type is None:
pass
elif (
isinstance(expected_type, gir.IntType)
or isinstance(expected_type, gir.UIntType)
or isinstance(expected_type, gir.FloatType)
@ -402,7 +404,7 @@ class VariantValue(AstNode):
raise CompileError(f"Cannot convert variant to number")
elif isinstance(expected_type, gir.StringType):
raise CompileError("Cannot convert variant to string")
if isinstance(expected_type, gir.Boxed) and expected_type.full_name == "GLib.Variant":
elif isinstance(expected_type, gir.Boxed) and expected_type.full_name == "GLib.Variant":
pass
else:
raise CompileError(f"Cannot convert variant into {expected_type.full_name}")