[vala/wip/girparser: 2/3] girparser: Respect "fixed-size" of arrays



commit 1b5e7a27e60567f5a92ccff7a1b9db45c240691c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue May 31 16:50:21 2016 +0200

    girparser: Respect "fixed-size" of arrays

 vala/valagirparser.vala |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index ec6371a..159ce9f 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2484,6 +2484,7 @@ public class Vala.GirParser : CodeVisitor {
                string type_name = reader.get_attribute ("name");
                ctype = null;
 
+               var fixed_length = -1;
                array_length_idx = -1;
                no_array_length = true;
                array_null_terminated = true;
@@ -2501,6 +2502,7 @@ public class Vala.GirParser : CodeVisitor {
                                        array_null_terminated = false;
                                }
                                if (reader.get_attribute ("fixed-size") != null) {
+                                       fixed_length = int.parse (reader.get_attribute ("fixed-size"));
                                        array_null_terminated = false;
                                }
                                if (reader.get_attribute ("c:type") == "GStrv") {
@@ -2514,7 +2516,13 @@ public class Vala.GirParser : CodeVisitor {
                                var element_type = parse_type ();
                                element_type.value_owned = transfer_elements;
                                end_element ("array");
-                               return new ArrayType (element_type, 1, src);
+
+                               var array_type = new ArrayType (element_type, 1, src);
+                               if (fixed_length > 0) {
+                                       array_type.fixed_length = true;
+                                       array_type.length = new IntegerLiteral (fixed_length.to_string ());
+                               }
+                               return array_type;
                        }
                } else if (reader.name == "callback"){
                        parse_callback ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]