mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Change the way values work
Change the parsing for values to make them more reusable, in particular for when I implement extensions.
This commit is contained in:
parent
6938267952
commit
1df46b5a06
30 changed files with 707 additions and 291 deletions
|
@ -21,15 +21,25 @@
|
|||
from .attributes import BaseAttribute
|
||||
from .gobject_object import ObjectContent, validate_parent_type
|
||||
from .common import *
|
||||
from .contexts import ValueTypeCtx
|
||||
from .values import Value
|
||||
|
||||
|
||||
class LayoutProperty(BaseAttribute):
|
||||
class LayoutProperty(AstNode):
|
||||
tag_name = "property"
|
||||
|
||||
@property
|
||||
def value_type(self):
|
||||
def name(self) -> str:
|
||||
return self.tokens["name"]
|
||||
|
||||
@property
|
||||
def value(self) -> Value:
|
||||
return self.children[Value][0]
|
||||
|
||||
@context(ValueTypeCtx)
|
||||
def value_type(self) -> ValueTypeCtx:
|
||||
# there isn't really a way to validate these
|
||||
return None
|
||||
return ValueTypeCtx(None)
|
||||
|
||||
@validate("name")
|
||||
def unique_in_parent(self):
|
||||
|
@ -41,11 +51,7 @@ class LayoutProperty(BaseAttribute):
|
|||
|
||||
layout_prop = Group(
|
||||
LayoutProperty,
|
||||
Statement(
|
||||
UseIdent("name"),
|
||||
":",
|
||||
VALUE_HOOKS.expected("a value"),
|
||||
),
|
||||
Statement(UseIdent("name"), ":", Err(Value, "Expected a value")),
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue