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
|
@ -62,8 +62,17 @@ class UI(AstNode, Scope):
|
|||
def objects_by_id(self):
|
||||
return { obj.tokens["id"]: obj for obj in self.iterate_children_recursive() if obj.tokens["id"] is not None }
|
||||
|
||||
def get_objects(self):
|
||||
return self.objects_by_id
|
||||
@property
|
||||
def variables(self):
|
||||
def emit_xml(xml: XmlEmitter, obj_id: str):
|
||||
xml.start_tag("constant")
|
||||
xml.put_text(obj_id)
|
||||
xml.end_tag()
|
||||
|
||||
return {
|
||||
id: ScopeVariable(id, obj.gir_class, lambda xml: emit_xml(xml, id))
|
||||
for id, obj in self.objects_by_id.items()
|
||||
}
|
||||
|
||||
@validate()
|
||||
def gir_errors(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue