From f01dde88c36fff9b1bc60e1368a71062ed07a58c Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sun, 29 Sep 2019 18:28:28 +0200 Subject: [PATCH] vala: Move common implementations to CallableType --- vala/valacallabletype.vala | 18 ++++++++++++++++++ vala/valadelegatetype.vala | 12 ------------ vala/valamethodtype.vala | 12 ------------ vala/valasignaltype.vala | 12 ------------ 4 files changed, 18 insertions(+), 36 deletions(-) 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); } -- 2.47.2