From: Jens Georg Date: Sat, 12 Sep 2009 12:25:45 +0000 (+0200) Subject: Add Signal attribute for signal declarations X-Git-Tag: 0.8.0~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef604756c677206c12088b2dcd9d1b886b3f9545;p=thirdparty%2Fvala.git Add Signal attribute for signal declarations This supports the following arguments: - detailed (bool) -> G_SIGNAL_DETAILED - run (string) ["first", "last", "cleanup"] -> G_SIGNAL_RUN_* - no_recurse (bool) -> G_SIGNAL_NO_RECURSE - action (bool) -> G_SIGNAL_ACTION - no_hooks (bool) -> G_SIGNAL_NO_HOOKS The default is unchanged (G_SIGNAL_RUN_LAST and nothing else). Fixes bug 577623. --- diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala index 8dda3ec57..a6d0bb2e8 100644 --- a/codegen/valagsignalmodule.vala +++ b/codegen/valagsignalmodule.vala @@ -367,7 +367,32 @@ internal class Vala.GSignalModule : GObjectModule { var cl = sig.parent_symbol as Class; csignew.add_argument (new CCodeConstant ("\"%s\"".printf (sig.get_cname ()))); csignew.add_argument (new CCodeIdentifier (type.get_type_id ())); - csignew.add_argument (new CCodeConstant ("G_SIGNAL_RUN_LAST")); + string[] flags = new string[0]; + if (sig.run_type == "first") { + flags += "G_SIGNAL_RUN_FIRST"; + } else if (sig.run_type == "cleanup") { + flags += "G_SIGNAL_RUN_CLEANUP"; + } else { + flags += "G_SIGNAL_RUN_LAST"; + } + if (sig.is_detailed) { + flags += "G_SIGNAL_DETAILED"; + } + + if (sig.no_recurse) { + flags += "G_SIGNAL_NO_RECURSE"; + } + + if (sig.is_action) { + flags += "G_SIGNAL_ACTION"; + } + + if (sig.no_hooks) { + flags += "G_SIGNAL_NO_HOOKS"; + } + + csignew.add_argument (new CCodeConstant (string.joinv (" | ", flags))); + if (sig.default_handler == null) { csignew.add_argument (new CCodeConstant ("0")); } else { diff --git a/vala/valasignal.vala b/vala/valasignal.vala index 1b509a36a..9212389e7 100644 --- a/vala/valasignal.vala +++ b/vala/valasignal.vala @@ -64,6 +64,17 @@ public class Vala.Signal : Member, Lockable { * */ public Method default_handler { get; private set; } + public bool is_detailed { get; set; } + + public bool no_recurse { get; set; } + + public string run_type { get; set; } + + public bool is_action { get; set; } + + public bool no_hooks { get; set; } + + private string cname; private bool lock_used = false; @@ -83,6 +94,7 @@ public class Vala.Signal : Member, Lockable { public Signal (string name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) { base (name, source_reference, comment); this.return_type = return_type; + this.run_type = "last"; } /** @@ -199,6 +211,33 @@ public class Vala.Signal : Member, Lockable { } } + void process_signal_attribute (Attribute a) { + if (a.has_argument ("detailed")) { + is_detailed = a.get_bool ("detailed"); + } + if (a.has_argument ("no_recurse")) { + no_recurse = a.get_bool ("no_recurse"); + } + if (a.has_argument ("run")) { + var arg = a.get_string ("run"); + if (arg == "first") { + run_type = "first"; + } else if (arg == "last") { + run_type = "last"; + } else if (arg == "cleanup") { + run_type = "cleanup"; + } + } + + if (a.has_argument ("action")) { + is_action = a.get_bool ("action"); + } + + if (a.has_argument ("no_hooks")) { + no_hooks = a.get_bool ("no_hooks"); + } + } + /** * Process all associated attributes. */ @@ -207,6 +246,9 @@ public class Vala.Signal : Member, Lockable { if (a.name == "HasEmitter") { has_emitter = true; } + if (a.name == "Signal") { + process_signal_attribute (a); + } } }