3 * Copyright (C) 2007-2008 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
20 * Jürg Billeter <j@bitron.ch>
26 * The type of a method referencea.
28 public class Vala
.MethodType
: DataType
{
29 public Method method_symbol
{ get; set; }
31 public MethodType (Method method_symbol
) {
32 this
.method_symbol
= method_symbol
;
35 public override bool is_invokable () {
39 public override DataType?
get_return_type () {
40 return method_symbol
.return_type
;
43 public override List
<Parameter
>?
get_parameters () {
44 return method_symbol
.get_parameters ();
47 public override DataType
copy () {
48 return new
MethodType (method_symbol
);
51 public override bool compatible (DataType target_type
) {
52 var dt
= target_type as DelegateType
;
54 // method types incompatible to anything but delegates
58 return dt
.delegate_symbol
.matches_method (method_symbol
, dt
);
61 public override string to_qualified_string (Scope? scope
) {
62 return method_symbol
.get_full_name ();
65 public override Symbol?
get_member (string member_name
) {
66 if (method_symbol
.coroutine
&& member_name
== "begin") {
68 } else if (method_symbol
.coroutine
&& member_name
== "end") {
70 } else if (method_symbol
.coroutine
&& member_name
== "callback") {
71 return method_symbol
.get_callback_method ();
76 public string to_prototype_string (bool with_type_parameters
= false) {
77 var proto
= "%s %s (".printf (get_return_type ().to_string (), this
.to_string ());
80 foreach (Parameter param
in get_parameters ()) {
90 if (param
.direction
== ParameterDirection
.IN
) {
91 if (param
.variable_type
.value_owned
) {
95 if (param
.direction
== ParameterDirection
.REF
) {
97 } else if (param
.direction
== ParameterDirection
.OUT
) {
100 if (param
.variable_type
.is_weak ()) {
105 proto
= "%s%s %s".printf (proto
, param
.variable_type
.to_qualified_string (), param
.name
);
107 if (param
.initializer
!= null) {
108 proto
= "%s = %s".printf (proto
, param
.initializer
.to_string ());