]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add Signal attribute for signal declarations
authorJens Georg <mail@jensge.org>
Sat, 12 Sep 2009 12:25:45 +0000 (14:25 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 20 Mar 2010 13:22:08 +0000 (14:22 +0100)
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.

codegen/valagsignalmodule.vala
vala/valasignal.vala

index 8dda3ec573633c46bb43868b8c48c6f90c0a69f6..a6d0bb2e837515485790a199088131389c922088 100644 (file)
@@ -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 {
index 1b509a36af527598be28e20cfae5656702a45e20..9212389e7cad4778e6139eb60068212ecc1ba4a6 100644 (file)
@@ -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);
+                       }
                }
        }