]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Move common implementations to CallableType
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 29 Sep 2019 16:28:28 +0000 (18:28 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Sep 2019 12:43:00 +0000 (14:43 +0200)
vala/valacallabletype.vala
vala/valadelegatetype.vala
vala/valamethodtype.vala
vala/valasignaltype.vala

index c41e34cc99c2477f9c8f7cde2f93f7a56255825b..d0db023bd0d23e10d100e6ae7efb18f0c1f530b7 100644 (file)
@@ -26,10 +26,28 @@ using GLib;
  * A callable type, i.e. a delegate, method, or signal type.
  */
 public abstract class Vala.CallableType : DataType {
+       public weak Callable callable_symbol {
+               get {
+                       return (Callable) symbol;
+               }
+       }
+
        protected CallableType (Symbol symbol) {
                base.with_symbol (symbol);
        }
 
+       public override bool is_invokable () {
+               return true;
+       }
+
+       public override unowned DataType? get_return_type () {
+               return callable_symbol.return_type;
+       }
+
+       public override unowned List<Parameter>? get_parameters () {
+               return callable_symbol.get_parameters ();
+       }
+
        public override string to_prototype_string (string? override_name = null) {
                StringBuilder builder = new StringBuilder ();
 
index 1de80c509953d131d6b945daa128d161e50cde3d..d6a19b481434fed53206ff70f654cc8a2338fd4b 100644 (file)
@@ -39,18 +39,6 @@ public class Vala.DelegateType : CallableType {
                this.is_called_once = (delegate_symbol.get_attribute_string ("CCode", "scope") == "async");
        }
 
-       public override bool is_invokable () {
-               return true;
-       }
-
-       public override unowned DataType? get_return_type () {
-               return delegate_symbol.return_type;
-       }
-
-       public override unowned List<Parameter>? get_parameters () {
-               return delegate_symbol.get_parameters ();
-       }
-
        public override string to_qualified_string (Scope? scope) {
                // logic temporarily duplicated from DataType class
 
index b59b3f375ac60fd7439bb8304041fb20d7490543..2ebef745171c6f77b356e427cf2ad24b74abc1c4 100644 (file)
@@ -36,18 +36,6 @@ public class Vala.MethodType : CallableType {
                base (method_symbol);
        }
 
-       public override bool is_invokable () {
-               return true;
-       }
-
-       public override unowned DataType? get_return_type () {
-               return method_symbol.return_type;
-       }
-
-       public override unowned List<Parameter>? get_parameters () {
-               return method_symbol.get_parameters ();
-       }
-
        public override DataType copy () {
                return new MethodType (method_symbol);
        }
index da38a2d05e43c142790c9cf4908f40e50094b68d..db7934f99167110727bf01b78875d470c331e26e 100644 (file)
@@ -40,18 +40,6 @@ public class Vala.SignalType : CallableType {
                base (signal_symbol);
        }
 
-       public override bool is_invokable () {
-               return true;
-       }
-
-       public override unowned DataType? get_return_type () {
-               return signal_symbol.return_type;
-       }
-
-       public override unowned List<Parameter>? get_parameters () {
-               return signal_symbol.get_parameters ();
-       }
-
        public override DataType copy () {
                return new SignalType (signal_symbol);
        }