[vala] girparser: Add array_null_terminated, fixes hand-written change in gio



commit 53710eed0797b48cfc71d8f8ace081238560e455
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Mar 2 22:52:24 2014 +0100

    girparser: Add array_null_terminated, fixes hand-written change in gio

 vala/valagirparser.vala        |   22 ++++++++++++++--------
 vapi/gio-2.0.vapi              |    2 +-
 vapi/metadata/Gio-2.0.metadata |    2 ++
 3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 1d8023e..e1f4f9d 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -54,6 +54,7 @@ public class Vala.GirParser : CodeVisitor {
                DEPRECATED_SINCE,
                ARRAY,
                ARRAY_LENGTH_IDX,
+               ARRAY_NULL_TERMINATED,
                DEFAULT,
                OUT,
                REF,
@@ -1611,7 +1612,7 @@ public class Vala.GirParser : CodeVisitor {
        /*
         * The changed is a faster way to check whether the type has changed and it may affect the C 
declaration.
         */
-       DataType? element_get_type (DataType orig_type, bool owned_by_default, ref bool no_array_length, out 
bool changed = null) {
+       DataType? element_get_type (DataType orig_type, bool owned_by_default, ref bool no_array_length, ref 
bool array_null_terminated, out bool changed = null) {
                changed = false;
                var type = orig_type;
 
@@ -1637,8 +1638,11 @@ public class Vala.GirParser : CodeVisitor {
                        type.nullable = metadata.get_bool (ArgumentType.NULLABLE, type.nullable);
                }
 
-               if (type is ArrayType && !(orig_type is ArrayType)) {
-                       no_array_length = true;
+               if (type is ArrayType) {
+                       if (!(orig_type is ArrayType)) {
+                               no_array_length = true;
+                       }
+                       array_null_terminated = metadata.get_bool (ArgumentType.ARRAY_NULL_TERMINATED, 
array_null_terminated);
                }
 
                return type;
@@ -2018,7 +2022,8 @@ public class Vala.GirParser : CodeVisitor {
                }
 
                bool no_array_length = false;
-               current.base_type = element_get_type (parse_type (null, null, true), true, ref 
no_array_length);
+               bool array_null_terminated = false;
+               current.base_type = element_get_type (parse_type (null, null, true), true, ref 
no_array_length, ref array_null_terminated);
 
                pop_node ();
                end_element ("alias");
@@ -2224,7 +2229,7 @@ public class Vala.GirParser : CodeVisitor {
                if (allow_none == "1") {
                        type.nullable = true;
                }
-               type = element_get_type (type, true, ref no_array_length);
+               type = element_get_type (type, true, ref no_array_length, ref array_null_terminated);
                end_element ("return-value");
                return type;
        }
@@ -2292,7 +2297,7 @@ public class Vala.GirParser : CodeVisitor {
                        }
 
                        bool changed;
-                       type = element_get_type (type, direction == "out" || direction == "inout", ref 
no_array_length, out changed);
+                       type = element_get_type (type, direction == "out" || direction == "inout", ref 
no_array_length, ref array_null_terminated, out changed);
                        if (!changed) {
                                // discard ctype, duplicated information
                                ctype = null;
@@ -2715,7 +2720,8 @@ public class Vala.GirParser : CodeVisitor {
 
                var type = parse_type ();
                bool no_array_length = true;
-               type = element_get_type (type, true, ref no_array_length);
+               bool array_null_terminated = false;
+               type = element_get_type (type, true, ref no_array_length, ref array_null_terminated);
 
                string name = current.name;
                string cname = current.girdata["name"];
@@ -2753,7 +2759,7 @@ public class Vala.GirParser : CodeVisitor {
                bool no_array_length;
                bool array_null_terminated;
                var type = parse_type (null, null, false, out no_array_length, out array_null_terminated);
-               type = element_get_type (type, true, ref no_array_length);
+               type = element_get_type (type, true, ref no_array_length, ref array_null_terminated);
                var prop = new Property (current.name, type, null, null, current.source_reference);
                prop.comment = comment;
                prop.access = SymbolAccessibility.PUBLIC;
diff --git a/vapi/gio-2.0.vapi b/vapi/gio-2.0.vapi
index 8b03fe6..5abd09e 100644
--- a/vapi/gio-2.0.vapi
+++ b/vapi/gio-2.0.vapi
@@ -279,7 +279,7 @@ namespace GLib {
        public class Application : GLib.Object, GLib.ActionGroup, GLib.ActionMap {
                [CCode (has_construct_function = false)]
                public Application (string? application_id, GLib.ApplicationFlags flags);
-               public void add_main_option_entries ([CCode (array_length = false, array_null_terminated = 
true)] GLib.OptionEntry[] entries);
+               public void add_main_option_entries ([CCode (array_length = false, array_null_terminated = 
true, type = "const GOptionEntry*")] GLib.OptionEntry[] entries);
                public void add_option_group (GLib.OptionGroup group);
                [NoWrapper]
                public virtual void add_platform_data (GLib.VariantBuilder builder);
diff --git a/vapi/metadata/Gio-2.0.metadata b/vapi/metadata/Gio-2.0.metadata
index 3f250ff..bf291b4 100644
--- a/vapi/metadata/Gio-2.0.metadata
+++ b/vapi/metadata/Gio-2.0.metadata
@@ -55,6 +55,8 @@ ActionEntry
   .change_state type="GLib.SimpleActionChangeStateCallback"
 ActionGroup
   .query_action#virtual_method virtual
+Application.add_main_option_entries
+  .entries array array_null_terminated
 Application.handle_local_options#virtual_method skip=false
 Application.local_command_line
   .arguments ref type="unowned string[]"


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