]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
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 20020b1571c738e4bdc03cfe3fab3658796621d1..2ba281ee836e42dd5cb75afa417d6199092f73d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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,
index 6003b4fcb25c0ed186c79812afc4f35035c1807b..e1645458ef2e35311264b1b76ef271d023739515 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 89a3efb14269a387b955d6f46461f736723251e5..b015d1287568f53cd1666e291ac237e6abf9ec76 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 8cf91a009c5c16ff9fa1bf9788a8eba6787ead62..818ad6996e821862c264d07e191ace67f01266d3 100644 (file)
@@ -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) {
index b4f5ba2c875efe3da1bf62d65ad472c155aad818..5c9bed5475295f3f20ba1f4ba062bb709b7f53b9 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 9a8411a6b6df0f0334488a9bf62adafe9d3c2a5f..81e73e78e6f3fce4bca78961695bfe1fd9729e38 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 dff94e653d782bdecf0e24dc56078e1bd5794141..2d21bf6f5771d8ae231acf8ade7e59a609c783e7 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_")) {