+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
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
}
/**
+ * 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.
*/
public bool printf_format { get; set; }
no_array_length = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
+ } else if (a.name == "Import") {
+ is_imported = true;
}
}
}