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 string?
get_cname () {
69 public override Symbol?
get_member (string member_name
) {
70 if (method_symbol
.coroutine
&& member_name
== "begin") {
72 } else if (method_symbol
.coroutine
&& member_name
== "end") {
74 } else if (method_symbol
.coroutine
&& member_name
== "callback") {
75 return method_symbol
.get_callback_method ();
80 public string to_prototype_string (bool with_type_parameters
= false) {
81 var proto
= "%s %s (".printf (get_return_type ().to_string (), this
.to_string ());
84 foreach (Parameter param
in get_parameters ()) {
94 if (param
.direction
== ParameterDirection
.IN
) {
95 if (param
.variable_type
.value_owned
) {
99 if (param
.direction
== ParameterDirection
.REF
) {
101 } else if (param
.direction
== ParameterDirection
.OUT
) {
104 if (param
.variable_type
.is_weak ()) {
109 proto
= "%s%s %s".printf (proto
, param
.variable_type
.to_qualified_string (), param
.name
);
111 if (param
.initializer
!= null) {
112 proto
= "%s = %s".printf (proto
, param
.initializer
.to_string ());