mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
parent
8ba4742efe
commit
bce852020c
2 changed files with 25 additions and 2 deletions
|
@ -341,6 +341,23 @@ class Signal(AstNode):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@validate("object")
|
||||||
|
def object_exists(self):
|
||||||
|
object_id = self.tokens["object"]
|
||||||
|
if object_id is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if object_id in ("true", "false"):
|
||||||
|
raise CompileError(
|
||||||
|
"Signal object must be object ID, not boolean value"
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.root.objects_by_id.get(object_id) is None:
|
||||||
|
raise CompileError(
|
||||||
|
f"Could not find object with ID '{object_id}'"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@docs("name")
|
@docs("name")
|
||||||
def signal_docs(self):
|
def signal_docs(self):
|
||||||
if self.gir_signal is not None:
|
if self.gir_signal is not None:
|
||||||
|
@ -351,7 +368,13 @@ class Signal(AstNode):
|
||||||
name = self.tokens["name"]
|
name = self.tokens["name"]
|
||||||
if self.tokens["detail_name"]:
|
if self.tokens["detail_name"]:
|
||||||
name += "::" + self.tokens["detail_name"]
|
name += "::" + self.tokens["detail_name"]
|
||||||
xml.put_self_closing("signal", name=name, handler=self.tokens["handler"], swapped="true" if self.tokens["swapped"] else None)
|
xml.put_self_closing(
|
||||||
|
"signal",
|
||||||
|
name=name,
|
||||||
|
handler=self.tokens["handler"],
|
||||||
|
swapped="true" if self.tokens["swapped"] else None,
|
||||||
|
object=self.tokens["object"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Value(ast.AstNode):
|
class Value(ast.AstNode):
|
||||||
|
|
|
@ -93,11 +93,11 @@ def parse(tokens) -> T.Tuple[ast.UI, T.Optional[MultipleErrors]]:
|
||||||
Op("=>"),
|
Op("=>"),
|
||||||
UseIdent("handler").expected("the name of a function to handle the signal"),
|
UseIdent("handler").expected("the name of a function to handle the signal"),
|
||||||
OpenParen().expected("argument list"),
|
OpenParen().expected("argument list"),
|
||||||
|
Optional(UseIdent("object")).expected("object identifier"),
|
||||||
CloseParen().expected("`)`"),
|
CloseParen().expected("`)`"),
|
||||||
ZeroOrMore(AnyOf(
|
ZeroOrMore(AnyOf(
|
||||||
Sequence(Keyword("swapped"), UseLiteral("swapped", True)),
|
Sequence(Keyword("swapped"), UseLiteral("swapped", True)),
|
||||||
Sequence(Keyword("after"), UseLiteral("after", True)),
|
Sequence(Keyword("after"), UseLiteral("after", True)),
|
||||||
Sequence(Keyword("object"), UseLiteral("object", True)),
|
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue