]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix GStrv properties in bindings
authorJürg Billeter <j@bitron.ch>
Sun, 28 Jun 2009 20:18:25 +0000 (22:18 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 28 Jun 2009 20:18:25 +0000 (22:18 +0200)
Fixes bug 587068.

codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodememberaccessmodule.vala
vala/valacodewriter.vala
vala/valaproperty.vala
vapi/gio-2.0.vapi
vapi/gtk+-2.0.vapi
vapi/gtksourceview-2.0.vapi
vapigen/valagidlparser.vala

index 5ba2acf473bac5c41753b6d23ccb65220e30b2d8..ceba7d6a3eb3eed58346f145d02419417ce83802 100644 (file)
@@ -274,8 +274,11 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
                                ccall.add_argument (new CCodeIdentifier (constant.get_cname ()));
                                return ccall;
                        } else if (array_expr.symbol_reference is Property) {
-                               Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
-                               return size[dim - 1];
+                               var prop = (Property) array_expr.symbol_reference;
+                               if (!prop.no_array_length) {
+                                       Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
+                                       return size[dim - 1];
+                               }
                        }
                } else if (array_expr is NullLiteral) {
                        return new CCodeConstant ("0");
index 23d056873c9e711f67c61b3bc2855f68e4dbdb62..e926e9203a57125b7d833dba9a91baabf78cf59f 100644 (file)
@@ -3803,7 +3803,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
                ccall.add_argument (cexpr);
 
                var array_type = prop.property_type as ArrayType;
-               if (array_type != null && rhs != null) {
+               if (array_type != null && !prop.no_array_length && rhs != null) {
                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                ccall.add_argument (head.get_array_length_cexpression (rhs, dim));
                        }
index 0c0344695834c2be91960c132ae0ca08a6a9d3c4..4bfd9163d5168ee7f2859587a039a333ad9c11a7 100644 (file)
@@ -259,7 +259,7 @@ internal class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                        expr.ccodenode = ccomma;
                                } else {
                                        var array_type = base_property.property_type as ArrayType;
-                                       if (array_type != null) {
+                                       if (array_type != null && !base_property.no_array_length) {
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                        var temp_var = get_temp_variable (int_type);
                                                        var ctemp = new CCodeIdentifier (temp_var.name);
index 72ba348c29ba3f5bc86f80d99542eaf7ca5c2f09..b924c84f12140989cbea8263e2e598bed7015b50 100644 (file)
@@ -917,7 +917,17 @@ public class Vala.CodeWriter : CodeVisitor {
                        write_indent ();
                        write_string ("[NoAccessorMethod]");
                }
-               
+               if (prop.property_type is ArrayType && prop.no_array_length) {
+                       write_indent ();
+                       write_string ("[CCode (array_length = false");
+
+                       if (prop.array_null_terminated) {
+                               write_string (", array_null_terminated = true");
+                       }
+
+                       write_string (")]");
+               }
+
                write_indent ();
                write_accessibility (prop);
 
index e00510c8225b86ab4762f53a3074a37a099b65e1..e807410efe05103f47e707204db146be958e0482 100644 (file)
@@ -146,6 +146,10 @@ public class Vala.Property : Member, Lockable {
         */
        public Expression default_expression { get; set; }
 
+       public bool no_array_length { get; set; }
+
+       public bool array_null_terminated { get; set; }
+
        /**
         * Nickname of this property.
         */
@@ -266,6 +270,12 @@ public class Vala.Property : Member, Lockable {
                if (a.has_argument ("notify")) {
                        notify = a.get_bool ("notify");
                }
+               if (a.has_argument ("array_length")) {
+                       no_array_length = !a.get_bool ("array_length");
+               }
+               if (a.has_argument ("array_null_terminated")) {
+                       array_null_terminated = a.get_bool ("array_null_terminated");
+               }
        }
 
        /**
index 960868fa8754d5b7aa45dc19a84aa4007cb88336..a6c907f4c0aa9b123b957127d88287b02fc017a4 100644 (file)
@@ -584,6 +584,7 @@ namespace GLib {
                [CCode (type = "GIcon*", has_construct_function = false)]
                public ThemedIcon.with_default_fallbacks (string iconname);
                public string name { construct; }
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] names { get; construct; }
                [NoAccessorMethod]
                public bool use_default_fallbacks { get; construct; }
index e9da66277e254dfb9a6d94e5959cc8de73738533..83f5711454b67a2590d6d675d63d66f783bebab9 100644 (file)
@@ -36,10 +36,13 @@ namespace Gtk {
                public void set_website (string website);
                public void set_website_label (string website_label);
                public void set_wrap_license (bool wrap_license);
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] artists { get; set; }
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] authors { get; set; }
                public string comments { get; set; }
                public string copyright { get; set; }
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] documenters { get; set; }
                public string license { get; set; }
                public Gdk.Pixbuf logo { get; set; }
@@ -3249,6 +3252,7 @@ namespace Gtk {
                public void set_value (double value);
                public Gtk.Adjustment adjustment { get; set; }
                [NoAccessorMethod]
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] icons { owned get; set; }
                [NoAccessorMethod]
                public Gtk.IconSize size { get; set; }
index aeeee24b29f07632c43b43f54127b0419b1a5297..e7c0f8df20d8db7dc174521f87cc06335c29c038 100644 (file)
@@ -68,7 +68,9 @@ namespace Gtk {
                [CCode (has_construct_function = false)]
                public SourceLanguageManager ();
                public void set_search_path ([CCode (array_length = false)] string[]? dirs);
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] language_ids { get; }
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] search_path { get; set; }
        }
        [CCode (cheader_filename = "gtksourceview/gtksourceview.h")]
@@ -193,7 +195,9 @@ namespace Gtk {
                public SourceStyleSchemeManager ();
                public void prepend_search_path (string path);
                public void set_search_path (string path);
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] scheme_ids { get; }
+               [CCode (array_length = false, array_null_terminated = true)]
                public string[] search_path { get; set; }
        }
        [CCode (cheader_filename = "gtksourceview/gtksourceview.h")]
index dd8d82d20aaf3bccf5e57c68d81cb55173357422..281019bffafe02d9eb2a464e436530334d258287 100644 (file)
@@ -1722,7 +1722,12 @@ public class Vala.GIdlParser : CodeVisitor {
                var prop = new Property (fix_prop_name (node.name), parse_type (prop_node.type), null, null, current_source_reference);
                prop.access = SymbolAccessibility.PUBLIC;
                prop.interface_only = true;
-               
+
+               if (prop_node.type.is_interface && prop_node.type.interface == "GStrv") {
+                       prop.no_array_length = true;
+                       prop.array_null_terminated = true;
+               }
+
                if (prop_node.readable) {
                        prop.get_accessor = new PropertyAccessor (true, false, false, prop.property_type.copy (), null, null);
                }