Commit 8fb29e4a authored by Raffaele Sandrini's avatar Raffaele Sandrini Committed by Raffaele Sandrini
Browse files

add check to report an error on invalid method_header and method_body

2007-07-28  Raffaele Sandrini  <raffaele@sandrini.ch>

	* vala/parser.y: add check to report an error on invalid method_header
	  and method_body presence combinations
	* vala/valamethod.vala: add `is_imported' property

svn path=/trunk/; revision=411
parent f726d64a
2007-07-28 Raffaele Sandrini <raffaele@sandrini.ch>
* vala/parser.y: add check to report an error on invalid method_header
and method_body presence combinations
* vala/valamethod.vala: add `is_imported' property
2007-07-28 Philip Van Hoof <pvanhoof@gnome.org>
* doc/building.txt: Added some documentation about how to build your
......
......@@ -2506,10 +2506,33 @@ variable_initializer
method_declaration
: method_header method_body
{
$$ = $1;
ValaCodeNode *n = (ValaCodeNode*)$1;
ValaAttribute *a = vala_code_node_get_attribute (n, "Import");
gboolean imported;
if (a != NULL) {
imported = TRUE;
g_object_unref (a);
} else {
imported = FALSE;
}
$$ = $1;
vala_method_set_body ($$, $2);
if ($2 != NULL) {
g_object_unref ($2);
/* method must not be imported, abstract or from a VAPI file */
if (imported || vala_method_get_is_abstract ($1) || vala_source_file_get_pkg (current_source_file)) {
ValaSourceReference *sr = vala_code_node_get_source_reference (n);
vala_report_error (sr, "unexpected method body found");
g_object_unref (sr);
}
} else {
/* only imported, abstract and VAPI methods are allowed to have no body */
if (!imported && !vala_method_get_is_abstract ($1) && !vala_source_file_get_pkg (current_source_file)) {
ValaSourceReference *sr = vala_code_node_get_source_reference (n);
vala_report_error (sr, "expected method body got `;'");
g_object_unref (sr);
}
}
}
| error method_body
......
......@@ -127,6 +127,12 @@ public class Vala.Method : Member, Invokable {
}
}
/**
* Specifies whether this is an imported method i.e. the Import
* attribute ist set for this method.
*/
public bool is_imported { get; set; }
/**
* Specifies whether this method expects printf-style format arguments.
*/
......@@ -279,6 +285,8 @@ public class Vala.Method : Member, Invokable {
no_array_length = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
} else if (a.name == "Import") {
is_imported = true;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment