report error for missing return types in methods
authorJuerg Billeter <j@bitron.ch>
Thu, 22 Nov 2007 15:25:54 +0000 (15:25 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Thu, 22 Nov 2007 15:25:54 +0000 (15:25 +0000)
2007-11-22  Juerg 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

svn path=/trunk/; revision=696

ChangeLog
vala/parser.y
vala/valacodecontext.vala
vala/valacreationmethod.vala
vala/valasemanticanalyzer.vala
vapi/glib-2.0.vapi
vapigen/valagidlparser.vala

index 20020b1..2ba281e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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
index 6003b4f..e164545 100644 (file)
@@ -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);
index 89a3efb..b015d12 100644 (file)
@@ -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;
        }
index 8cf91a0..818ad69 100644 (file)
@@ -28,10 +28,15 @@ using GLib;
  */
 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) {
index b4f5ba2..5c9bed5 100644 (file)
@@ -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;
index 9a8411a..81e73e7 100644 (file)
@@ -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 ();
index dff94e6..2d21bf6 100644 (file)
@@ -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_")) {