summaryrefslogtreecommitdiff
path: root/codegen/valagsignalmodule.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-08-07 18:54:51 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2020-08-07 19:04:45 +0200
commit5da90d7c5bfe9a977720221717c774300c24484c (patch)
treed6e230318f55ecd5ac9ed06d9f75513d7c949c61 /codegen/valagsignalmodule.vala
parent01914cd1303b34bb583044f49370e7d21a6d44e8 (diff)
downloadvala-5da90d7c5bfe9a977720221717c774300c24484c.tar.gz
codegen: Support non-virtual signals with default handler
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1056
Diffstat (limited to 'codegen/valagsignalmodule.vala')
-rw-r--r--codegen/valagsignalmodule.vala11
1 files changed, 9 insertions, 2 deletions
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 108622815..e005f6b38 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -347,7 +347,12 @@ public class Vala.GSignalModule : GObjectModule {
}
public override CCodeExpression get_signal_creation (Signal sig, TypeSymbol type) {
- var csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
+ CCodeFunctionCall csignew;
+ if (sig.default_handler == null || sig.is_virtual) {
+ csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
+ } else {
+ csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new_class_handler"));
+ }
csignew.add_argument (new CCodeConstant ("\"%s\"".printf (get_ccode_name (sig))));
csignew.add_argument (new CCodeIdentifier (get_ccode_type_id (type)));
string[] flags = new string[0];
@@ -383,7 +388,7 @@ public class Vala.GSignalModule : GObjectModule {
if (sig.default_handler == null) {
csignew.add_argument (new CCodeConstant ("0"));
- } else {
+ } else if (sig.is_virtual) {
var struct_offset = new CCodeFunctionCall (new CCodeIdentifier ("G_STRUCT_OFFSET"));
if (type is Class) {
struct_offset.add_argument (new CCodeIdentifier ("%sClass".printf (get_ccode_name (type))));
@@ -393,6 +398,8 @@ public class Vala.GSignalModule : GObjectModule {
}
struct_offset.add_argument (new CCodeIdentifier (get_ccode_vfunc_name (sig.default_handler)));
csignew.add_argument (struct_offset);
+ } else {
+ csignew.add_argument (new CCodeCastExpression (new CCodeIdentifier (get_ccode_real_name (sig.default_handler)), "GCallback"));
}
csignew.add_argument (new CCodeConstant ("NULL"));
csignew.add_argument (new CCodeConstant ("NULL"));