mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Tweak the way scopes work
Should make it clearer what a "variable" is and allow more flexibility in what a variable can be (previously it could only be an object, but now it can be e.g. a reference to the template or a special shortcut)
This commit is contained in:
parent
d7155981b1
commit
ae40f8416f
4 changed files with 37 additions and 12 deletions
|
@ -35,11 +35,29 @@ OBJECT_CONTENT_HOOKS = AnyOf()
|
|||
VALUE_HOOKS = AnyOf()
|
||||
|
||||
|
||||
class Scope:
|
||||
def get_variables(self) -> T.Iterator[str]:
|
||||
yield from self.get_objects().keys()
|
||||
class ScopeVariable:
|
||||
def __init__(self, name: str, gir_class: gir.GirType, xml_func):
|
||||
self._name = name
|
||||
self._gir_class = gir_class
|
||||
self._xml_func = xml_func
|
||||
|
||||
def get_objects(self) -> T.Dict[str, T.Any]:
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def gir_class(self) -> gir.GirType:
|
||||
return self._gir_class
|
||||
|
||||
def emit_xml(self, xml: XmlEmitter):
|
||||
if f := self._xml_func:
|
||||
f(xml)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
class Scope:
|
||||
@property
|
||||
def variables(self) -> T.Dict[str, ScopeVariable]:
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
|
@ -53,4 +71,3 @@ class Scope:
|
|||
@property
|
||||
def this_type_glib_name(self) -> T.Optional[str]:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue