]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Deprecate string.size () in favor of string.length
authorJürg Billeter <j@bitron.ch>
Fri, 20 Aug 2010 19:01:38 +0000 (21:01 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 20 Aug 2010 19:22:07 +0000 (21:22 +0200)
ccode/valaccodeconstant.vala
vala/valagenieparser.vala
vala/valagirparser.vala
vala/valaintegerliteral.vala
vapi/glib-2.0.vapi
vapigen/valagidlparser.vala
vapigen/valavapicheck.vala

index 0ac49ec3dcf6fbec2e0d3e5f32d035d782dcffe6..85e63c73e4c1ef8942a2754913164d7fc6275661 100644 (file)
@@ -48,7 +48,7 @@ public class Vala.CCodeConstant : CCodeExpression {
                var builder = new StringBuilder ("\"");
 
                char* p = _name;
-               char* end = p + _name.size ();
+               char* end = p + _name.length;
 
                // remove quotes
                p++;
index 415a9fed34819470175216e08fe68db11afbf8fc..3ae29c7ba4e9708eeb208a121710554dd4f56b9f 100644 (file)
@@ -826,7 +826,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                                                
                                                if (p_expr is StringLiteral) {
                                                        var s_exp = (StringLiteral) p_expr;
-                                                       var len = s_exp.value.size ();
+                                                       var len = s_exp.value.length;
                                                        
                                                        if (len > 2) {
                                                                string s = "\\n\"";
index 2ea8ee415ddd25e10e952acedea8e405a46ad49a..4ddfab7327ad60db4f2501996c3fa46da63e53ea 100644 (file)
@@ -309,17 +309,17 @@ public class Vala.GirParser : CodeVisitor {
                        common_prefix = cname;
                        while (common_prefix.length > 0 && !common_prefix.has_suffix ("_")) {
                                // FIXME: could easily be made faster
-                               common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                               common_prefix = common_prefix.ndup (common_prefix.length - 1);
                        }
                } else {
                        while (!cname.has_prefix (common_prefix)) {
-                               common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                               common_prefix = common_prefix.ndup (common_prefix.length - 1);
                        }
                }
                while (common_prefix.length > 0 && (!common_prefix.has_suffix ("_") ||
                       (cname.offset (common_prefix.length).get_char ().isdigit ()) && (cname.length - common_prefix.length) <= 1)) {
                        // enum values may not consist solely of digits
-                       common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                       common_prefix = common_prefix.ndup (common_prefix.length - 1);
                }
        }
 
index 297eb3e4266d65e7286a8712b10743018a039e96..b80fc9dd492d8338c94da8b537fc5ea859f311de 100644 (file)
@@ -69,13 +69,13 @@ public class Vala.IntegerLiteral : Literal {
                int l = 0;
                while (value.has_suffix ("l") || value.has_suffix ("L")) {
                        l++;
-                       value = value.ndup (value.size () - 1);
+                       value = value.ndup (value.length - 1);
                }
 
                bool u = false;
                if (value.has_suffix ("u") || value.has_suffix ("U")) {
                        u = true;
-                       value = value.ndup (value.size () - 1);
+                       value = value.ndup (value.length - 1);
                }
                
                int64 n = value.to_int64 ();
index 851cfc1e2ebfd6201dba3e1c38f04cf001e7fa48..15ab536475d97b0e29381642c2d9574a2b214003 100644 (file)
@@ -1064,6 +1064,7 @@ public class string {
                }
        }
 
+       [Deprecated (replacement = "string.length")]
        [CCode (cname = "strlen")]
        public size_t size ();
 
@@ -1133,10 +1134,10 @@ public class string {
                if (str == null) {
                        str_size = 0;
                } else {
-                       str_size = str.size ();
+                       str_size = str.length;
                }
 
-               string* result = GLib.malloc0 (this.size () - ((char*) end_string - (char*) start_string) + str_size + 1);
+               string* result = GLib.malloc0 (this.length - ((char*) end_string - (char*) start_string) + str_size + 1);
 
                char* dest = (char*) result;
 
@@ -1146,7 +1147,7 @@ public class string {
                GLib.Memory.copy (dest, str, str_size);
                dest += str_size;
 
-               GLib.Memory.copy (dest, end_string, end_string.size ());
+               GLib.Memory.copy (dest, end_string, end_string.length);
 
                return (owned) result;
        }
@@ -1175,15 +1176,15 @@ public class string {
        public uint8[] data {
                get {
                        unowned uint8[] res = (uint8[]) this;
-                       res.length = (int) this.size ();
+                       res.length = (int) this.length;
                        return res;
                }
        }
 
        public char[] to_utf8 () {
-               char[] result = new char[this.size () + 1];
+               char[] result = new char[this.length + 1];
                result.length--;
-               GLib.Memory.copy (result, this, this.size ());
+               GLib.Memory.copy (result, this, this.length);
                return result;
        }
 
index e9b518d03a087318ae693a1cdfd913336a0c4431..9ae5977622180e5adc999e0e01b9c9f665f2fdfa 100644 (file)
@@ -98,7 +98,7 @@ public class Vala.GIdlParser : CodeVisitor {
        }
        
        private void parse_file (SourceFile source_file) {
-               string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.size () - ".gi".size ()));
+               string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.length - ".gi".length));
 
                current_source_file = source_file;
 
@@ -1012,17 +1012,17 @@ public class Vala.GIdlParser : CodeVisitor {
                                common_prefix = value.name;
                                while (common_prefix.length > 0 && !common_prefix.has_suffix ("_")) {
                                        // FIXME: could easily be made faster
-                                       common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                                       common_prefix = common_prefix.ndup (common_prefix.length - 1);
                                }
                        } else {
                                while (!value.name.has_prefix (common_prefix)) {
-                                       common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                                       common_prefix = common_prefix.ndup (common_prefix.length - 1);
                                }
                        }
                        while (common_prefix.length > 0 && (!common_prefix.has_suffix ("_") ||
                               (value.name.offset (common_prefix.length).get_char ().isdigit ()) && (value.name.length - common_prefix.length) <= 1)) {
                                // enum values may not consist solely of digits
-                               common_prefix = common_prefix.ndup (common_prefix.size () - 1);
+                               common_prefix = common_prefix.ndup (common_prefix.length - 1);
                        }
                }
 
@@ -2377,7 +2377,7 @@ public class Vala.GIdlParser : CodeVisitor {
                }
 
                GLib.SList<string> attr_list = new GLib.SList<string> ();
-               var attr = new GLib.StringBuilder.sized (attributes.size ());
+               var attr = new GLib.StringBuilder.sized (attributes.length);
                var attributes_len = attributes.length;
                unowned string remaining = attributes;
                bool quoted = false, escaped = false;
@@ -2418,7 +2418,7 @@ public class Vala.GIdlParser : CodeVisitor {
        }
        
        private string eval (string s) {
-               return ((s.size () >= 2) && s.has_prefix ("\"") && s.has_suffix ("\"")) ? s.offset (1).ndup (s.size () - 2) : s;
+               return ((s.length >= 2) && s.has_prefix ("\"") && s.has_suffix ("\"")) ? s.offset (1).ndup (s.length - 2) : s;
        }
 
        private Signal? parse_signal (IdlNodeSignal sig_node) {
index 4a98c96802b4d9b3e39299e75cb8cbfa6ff34be6..b6fa644687835b40b0329761cd75b5237fff7cf9 100644 (file)
@@ -136,7 +136,7 @@ class Vala.VAPICheck : Object {
                                var tokens = line.split (" ", 2);
                                var symbol = tokens[0];
 
-                               if (symbol.size () > 0 && !_symbols.contains (symbol)) {
+                               if (symbol.length > 0 && !_symbols.contains (symbol)) {
                                        var src = new SourceReference (metadata, lineno, 1, lineno, (int)symbol.length);
                                        Report.error (src, "Symbol `%s' not found".printf (symbol));
                                }