From: Rico Tzschichholz Date: Sun, 29 Sep 2019 16:28:28 +0000 (+0200) Subject: vala: Move common implementations to CallableType X-Git-Tag: 0.47.1~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f01dde88c36fff9b1bc60e1368a71062ed07a58c;p=thirdparty%2Fvala.git vala: Move common implementations to CallableType --- diff --git a/vala/valacallabletype.vala b/vala/valacallabletype.vala index c41e34cc9..d0db023bd 100644 --- a/vala/valacallabletype.vala +++ b/vala/valacallabletype.vala @@ -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? get_parameters () { + return callable_symbol.get_parameters (); + } + public override string to_prototype_string (string? override_name = null) { StringBuilder builder = new StringBuilder (); diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala index 1de80c509..d6a19b481 100644 --- a/vala/valadelegatetype.vala +++ b/vala/valadelegatetype.vala @@ -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? get_parameters () { - return delegate_symbol.get_parameters (); - } - public override string to_qualified_string (Scope? scope) { // logic temporarily duplicated from DataType class diff --git a/vala/valamethodtype.vala b/vala/valamethodtype.vala index b59b3f375..2ebef7451 100644 --- a/vala/valamethodtype.vala +++ b/vala/valamethodtype.vala @@ -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? get_parameters () { - return method_symbol.get_parameters (); - } - public override DataType copy () { return new MethodType (method_symbol); } diff --git a/vala/valasignaltype.vala b/vala/valasignaltype.vala index da38a2d05..db7934f99 100644 --- a/vala/valasignaltype.vala +++ b/vala/valasignaltype.vala @@ -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? get_parameters () { - return signal_symbol.get_parameters (); - } - public override DataType copy () { return new SignalType (signal_symbol); }