Release 0.7.8
[vala-lang.git] / vala / valadelegatetype.vala
blob331f1e7b7e4be15610d79a4bbac05eeca15186ab
1 /* valadelegatetype.vala
3 * Copyright (C) 2007-2009 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * The type of an instance of a delegate.
28 public class Vala.DelegateType : DataType {
29 public Delegate delegate_symbol { get; set; }
31 public DelegateType (Delegate delegate_symbol) {
32 this.delegate_symbol = delegate_symbol;
35 public override bool is_invokable () {
36 return true;
39 public override DataType? get_return_type () {
40 return delegate_symbol.return_type;
43 public override List<FormalParameter>? get_parameters () {
44 return delegate_symbol.get_parameters ();
47 public override string to_qualified_string (Scope? scope) {
48 string s = delegate_symbol.get_full_name ();
49 if (nullable) {
50 s += "?";
52 return s;
55 public override DataType copy () {
56 var result = new DelegateType (delegate_symbol);
57 result.source_reference = source_reference;
58 result.value_owned = value_owned;
59 result.nullable = nullable;
61 foreach (DataType arg in get_type_arguments ()) {
62 result.add_type_argument (arg.copy ());
65 return result;
68 public override string? get_cname () {
69 return delegate_symbol.get_cname ();
72 public override List<Symbol> get_symbols () {
73 var symbols = new ArrayList<Symbol> ();
74 symbols.add (delegate_symbol);
75 return symbols;
78 public override string? get_type_id () {
79 return "G_TYPE_POINTER";
82 public override bool check (SemanticAnalyzer analyzer) {
83 return delegate_symbol.check (analyzer);
86 public override bool is_disposable () {
87 return delegate_symbol.has_target && value_owned;