]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: improve support for changing symbol types away from instance
authorEvan Nemerson <evan@nemerson.com>
Mon, 26 May 2014 02:40:55 +0000 (19:40 -0700)
committerEvan Nemerson <evan@nemerson.com>
Wed, 28 May 2014 20:17:32 +0000 (13:17 -0700)
This makes it possible to move a symbol from an instance method of one
type to a constructor of another, or to a static method.

vala/valagirparser.vala

index d60dffb01c8708f11bdcff4f43252081eb5efde4..f35f1ecbc011f195202a9c969bd8767b7d5fc83a 100644 (file)
@@ -2246,7 +2246,11 @@ public class Vala.GirParser : CodeVisitor {
                closure_idx = -1;
                destroy_idx = -1;
 
-               start_element ("parameter");
+               string element_type = reader.name;
+               if (current_token != MarkupTokenType.START_ELEMENT || (element_type != "parameter" && element_type != "instance-parameter")) {
+                       Report.error (get_current_src (), "expected start element of `parameter' or `instance-parameter'");
+               }
+               start_element (element_type);
                string name = reader.get_attribute ("name");
                if (name == null) {
                        name = default_name;
@@ -2337,7 +2341,7 @@ public class Vala.GirParser : CodeVisitor {
                                param.initializer = null;
                        }
                }
-               end_element ("parameter");
+               end_element (element_type);
                return param;
        }
 
@@ -2972,7 +2976,8 @@ public class Vala.GirParser : CodeVisitor {
                        next ();
 
                        while (current_token == MarkupTokenType.START_ELEMENT) {
-                               if (reader.name == "instance-parameter") {
+                               if (reader.name == "instance-parameter" &&
+                                   !(symbol_type == "function" || symbol_type == "constructor")) {
                                        skip_element ();
                                        continue;
                                }