mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Separate output into its own module
This commit is contained in:
parent
8cf793023d
commit
a24f16109f
33 changed files with 407 additions and 291 deletions
|
@ -133,44 +133,3 @@ class Property(AstNode):
|
|||
def property_docs(self):
|
||||
if self.gir_property is not None:
|
||||
return self.gir_property.doc
|
||||
|
||||
|
||||
def emit_xml(self, xml: XmlEmitter):
|
||||
values = self.children[Value]
|
||||
value = values[0] if len(values) == 1 else None
|
||||
|
||||
bind_flags = []
|
||||
if self.tokens["bind_source"] and not self.tokens["no_sync_create"]:
|
||||
bind_flags.append("sync-create")
|
||||
if self.tokens["inverted"]:
|
||||
bind_flags.append("invert-boolean")
|
||||
if self.tokens["bidirectional"]:
|
||||
bind_flags.append("bidirectional")
|
||||
bind_flags_str = "|".join(bind_flags) or None
|
||||
|
||||
props = {
|
||||
"name": self.tokens["name"],
|
||||
"bind-source": self.tokens["bind_source"],
|
||||
"bind-property": self.tokens["bind_property"],
|
||||
"bind-flags": bind_flags_str,
|
||||
}
|
||||
|
||||
if isinstance(value, TranslatedStringValue):
|
||||
props = { **props, **value.attrs }
|
||||
|
||||
if len(self.children[Object]) == 1:
|
||||
xml.start_tag("property", **props)
|
||||
self.children[Object][0].emit_xml(xml)
|
||||
xml.end_tag()
|
||||
elif value is None:
|
||||
if self.tokens["binding"]:
|
||||
xml.start_tag("binding", **props)
|
||||
for x in self.children:
|
||||
x.emit_xml(xml)
|
||||
xml.end_tag()
|
||||
else:
|
||||
xml.put_self_closing("property", **props);
|
||||
else:
|
||||
xml.start_tag("property", **props)
|
||||
value.emit_xml(xml)
|
||||
xml.end_tag()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue