From: Juerg Billeter Date: Thu, 22 Nov 2007 15:25:54 +0000 (+0000) Subject: report error for missing return types in methods X-Git-Tag: VALA_0_1_5~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42bfd9537e9b28e10f6ca7730186af3b072fa7e1;p=thirdparty%2Fvala.git report error for missing return types in methods 2007-11-22 Juerg Billeter * 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 svn path=/trunk/; revision=696 --- diff --git a/ChangeLog b/ChangeLog index 20020b157..2ba281ee8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-11-22 Jürg Billeter + + * 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 * gobject-introspection/clexer.l, gobject-introspection/cparser.y, diff --git a/vala/parser.y b/vala/parser.y index 6003b4fcb..e1645458e 100644 --- a/vala/parser.y +++ b/vala/parser.y @@ -2561,7 +2561,7 @@ class_declaration 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); @@ -2957,7 +2957,7 @@ method_header 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); diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index 89a3efb14..b015d1287 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -417,8 +417,8 @@ public class Vala.CodeContext : Object { 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; } diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 8cf91a009..818ad6996 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -27,11 +27,16 @@ using GLib; * Represents a type creation method. */ 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. * @@ -39,7 +44,7 @@ public class Vala.CreationMethod : 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) { diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index b4f5ba2c8..5c9bed547 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -440,6 +440,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor { 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; diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 9a8411a6b..81e73e78e 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1361,7 +1361,7 @@ namespace GLib { 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 (); diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index dff94e653..2d21bf6f5 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -998,7 +998,7 @@ public class Vala.GIdlParser : CodeVisitor { 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_")) {