summaryrefslogtreecommitdiff
path: root/vala/valamethodtype.vala
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2010-01-27 01:31:09 +0100
committerJürg Billeter <j@bitron.ch>2010-08-04 16:53:16 +0200
commit2707980d20bce1c71d2ca9f2cbf4c681225129b9 (patch)
tree3c437fd752309ac496f287b6e1bbc8660116d89f /vala/valamethodtype.vala
parentff63c4b8017beef13d61743c5f6d1edeb997f387 (diff)
downloadvala-2707980d20bce1c71d2ca9f2cbf4c681225129b9.tar.gz
Better error message for invalid number of arguments
Fixes bug 608187.
Diffstat (limited to 'vala/valamethodtype.vala')
-rw-r--r--vala/valamethodtype.vala41
1 files changed, 41 insertions, 0 deletions
diff --git a/vala/valamethodtype.vala b/vala/valamethodtype.vala
index a2ad6d4c0..87ec555b9 100644
--- a/vala/valamethodtype.vala
+++ b/vala/valamethodtype.vala
@@ -76,4 +76,45 @@ public class Vala.MethodType : DataType {
}
return null;
}
+
+ public string to_prototype_string (bool with_type_parameters = false) {
+ var proto = "%s %s (".printf (get_return_type ().to_string (), this.to_string ());
+
+ int i = 1;
+ foreach (FormalParameter param in get_parameters ()) {
+ if (i > 1) {
+ proto += ", ";
+ }
+
+ if (param.ellipsis) {
+ proto += "...";
+ continue;
+ }
+
+ if (param.direction == ParameterDirection.IN) {
+ if (param.variable_type.value_owned) {
+ proto += "owned ";
+ }
+ } else {
+ if (param.direction == ParameterDirection.REF) {
+ proto += "ref ";
+ } else if (param.direction == ParameterDirection.OUT) {
+ proto += "out ";
+ }
+ if (param.variable_type.is_weak ()) {
+ proto += "unowned ";
+ }
+ }
+
+ proto = "%s%s %s".printf (proto, param.variable_type.to_qualified_string (), param.name);
+
+ if (param.initializer != null) {
+ proto = "%s = %s".printf (proto, param.initializer.to_string ());
+ }
+
+ i++;
+ }
+
+ return proto + ")";
+ }
}