summaryrefslogtreecommitdiff
path: root/vala/valamemberaccess.vala
diff options
context:
space:
mode:
authorLorenz Wildberg <lorenz@wild-fisch.de>2021-12-04 19:05:42 +0000
committerRico Tzschichholz <ricotz@ubuntu.com>2022-01-04 14:51:37 +0100
commitd74400bfaae61a1e2c246382e627b0a9adf8c304 (patch)
treeca0ae596870df270819adcfbcac35b9d83585280 /vala/valamemberaccess.vala
parentde1682099945edfd8d23958cf45186aecbd0015e (diff)
downloadvala-d74400bfaae61a1e2c246382e627b0a9adf8c304.tar.gz
Support "emit" for explicit signal emission
If "foo" is a signal then "foo.emit (...);" is allowed now additionally to "foo (...);". This is required to emit dynamic signals.
Diffstat (limited to 'vala/valamemberaccess.vala')
-rw-r--r--vala/valamemberaccess.vala13
1 files changed, 13 insertions, 0 deletions
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index c8b3b267b..39a7af72c 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -390,6 +390,12 @@ public class Vala.MemberAccess : Expression {
}
}
+ if (inner.value_type is SignalType && member_name == "emit") {
+ // transform foo.sig.emit() to foo.sig()
+ parent_node.replace_expression (this, inner);
+ return true;
+ }
+
if (inner is MemberAccess) {
unowned MemberAccess ma = (MemberAccess) inner;
if (ma.prototype_access) {
@@ -499,6 +505,13 @@ public class Vala.MemberAccess : Expression {
s.access = SymbolAccessibility.PUBLIC;
dynamic_object_type.type_symbol.scope.add (null, s);
symbol_reference = s;
+ } else if (ma.member_name == "emit") {
+ // dynamic signal
+ var s = new DynamicSignal (inner.value_type, member_name, new VoidType (), source_reference);
+ s.access = SymbolAccessibility.PUBLIC;
+ s.add_parameter (new Parameter.with_ellipsis ());
+ dynamic_object_type.type_symbol.scope.add (null, s);
+ symbol_reference = s;
} else if (ma.member_name == "disconnect") {
error = true;
Report.error (ma.source_reference, "Use SignalHandler.disconnect() to disconnect from dynamic signal");