2007-11-22 Jürg Billeter <j@bitron.ch>
+ * vala/parser.y, vala/valacodecontext.vala,
+ vala/valacreationmethod.vala, vala/valasemanticanalyzer.vala,
+ vapigen/valagidlparser.vala: report error for missing return types in
+ methods
+
+ * vapi/glib-2.0.vapi: fix revealed typo
+
+2007-11-22 Jürg Billeter <j@bitron.ch>
+
* gobject-introspection/clexer.l, gobject-introspection/cparser.y,
gobject-introspection/gen-introspect.c: improve error reporting and
ignore get_type functions with parameters
ValaMethod *m;
ValaBlock *block;
src = vala_code_node_get_source_reference (VALA_CODE_NODE (cl));
- m = VALA_METHOD (vala_code_context_create_creation_method (context, NULL, src));
+ m = VALA_METHOD (vala_code_context_create_creation_method (context, vala_symbol_get_name (VALA_SYMBOL (cl)), NULL, src));
vala_method_set_instance (m, FALSE);
vala_symbol_set_access (VALA_SYMBOL (m), VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
block = vala_code_context_create_block (context, src);
GList *l;
ValaSourceReference *src = src_com(@5, $1);
- $$ = VALA_METHOD (vala_code_context_create_creation_method (context, $6, src));
+ $$ = VALA_METHOD (vala_code_context_create_creation_method (context, $5, $6, src));
g_free ($5);
g_free ($6);
g_object_unref (src);
return node;
}
- public CreationMethod! create_creation_method (string name, SourceReference source_reference = null) {
- var node = new CreationMethod (name, source_reference);
+ public CreationMethod! create_creation_method (string type_name, string name, SourceReference source_reference = null) {
+ var node = new CreationMethod (type_name, name, source_reference);
node.code_binding = codegen.create_creation_method_binding (node);
return node;
}
*/
public class Vala.CreationMethod : Method {
/**
+ * Specifies the name of the type this creation method belongs to.
+ */
+ public string type_name { get; set; }
+
+ /**
* Specifies the number of parameters this creation method sets.
*/
public int n_construction_params { get; set; }
-
+
/**
* Creates a new method.
*
* @param source_reference reference to source code
* @return newly created method
*/
- public CreationMethod (construct string name, construct SourceReference source_reference = null) {
+ public CreationMethod (construct string type_name, construct string name, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
public override void visit_creation_method (CreationMethod! m) {
m.return_type = new TypeReference ();
+ if (m.type_name != null && m.type_name != current_symbol.name) {
+ // type_name is null for constructors generated by GIdlParser
+ Report.error (m.source_reference, "missing return type in method `%s.%s´".printf (current_symbol.get_full_name (), m.type_name));
+ m.error = true;
+ return;
+ }
+
if (current_symbol is Class) {
m.return_type.data_type = (DataType) m.parent_symbol;
m.return_type.transfers_ownership = true;
public struct IConv {
[CCode (cname = "g_iconv_open")]
- public Iconv (string to_codeset, string from_codeset);
+ public IConv (string to_codeset, string from_codeset);
[CCode (cname = "g_iconv")]
public uint iconv (out string inbuf, out uint inbytes_left, out string outbuf, out uint outbytes_left);
public int close ();
Method m;
if (!is_interface && (f.is_constructor || node.name.has_prefix ("new"))) {
- m = new CreationMethod (node.name, current_source_reference);
+ m = new CreationMethod (null, node.name, current_source_reference);
if (m.name == "new") {
m.name = null;
} else if (m.name.has_prefix ("new_")) {