]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Require and target GLib >= 2.16 79b1a3e39a3d2bac9fbe40c99336b3b89e374571
authorJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 09:25:01 +0000 (11:25 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 09:34:20 +0000 (11:34 +0200)
This allows valac to use g_strcmp0. The next stable release of vala
will happen three years after the release of GLib 2.16.0.

codegen/valaccodebasemodule.vala
codegen/valatyperegisterfunction.vala
compiler/valacompiler.vala
configure.ac

index d0b5a8c01a478fe41a791039dbbf80fb8fd36608..9c07a9da3d560ce7feac1cc7b42e901e2f73ede5 100644 (file)
@@ -243,7 +243,6 @@ public class Vala.CCodeBaseModule : CodeGenerator {
        public bool requires_array_free;
        public bool requires_array_move;
        public bool requires_array_length;
-       public bool requires_strcmp0;
 
        public Set<string> wrappers;
        Set<Symbol> generated_external_symbols;
@@ -547,44 +546,6 @@ public class Vala.CCodeBaseModule : CodeGenerator {
        public virtual void append_vala_array_length () {
        }
 
-       private void append_vala_strcmp0 () {
-               cfile.add_include ("string.h");;
-
-               var fun = new CCodeFunction ("_vala_strcmp0", "int");
-               fun.modifiers = CCodeModifiers.STATIC;
-               fun.add_parameter (new CCodeFormalParameter ("str1", "const char *"));
-               fun.add_parameter (new CCodeFormalParameter ("str2", "const char *"));
-               cfile.add_function_declaration (fun);
-
-               // (str1 != str2)
-               var cineq = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("str1"), new CCodeIdentifier ("str2"));
-
-               fun.block = new CCodeBlock ();
-
-               var cblock = new CCodeBlock ();
-               // if (str1 == NULL)
-               var cif = new CCodeIfStatement (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier ("str1"), new CCodeConstant ("NULL")), cblock);
-               // return -(str1 != str2);
-               cblock.add_statement (new CCodeReturnStatement (new CCodeUnaryExpression (CCodeUnaryOperator.MINUS, cineq)));
-               fun.block.add_statement (cif);
-
-               cblock = new CCodeBlock ();
-               // if (str2 == NULL)
-               cif = new CCodeIfStatement (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier ("str2"), new CCodeConstant ("NULL")), cblock);
-               // return (str1 != str2);
-               cblock.add_statement (new CCodeReturnStatement (cineq));
-               fun.block.add_statement (cif);
-
-               // strcmp (str1, str2)
-               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("strcmp"));
-               ccall.add_argument (new CCodeIdentifier ("str1"));
-               ccall.add_argument (new CCodeIdentifier ("str2"));
-               // return strcmp (str1, str2);
-               fun.block.add_statement (new CCodeReturnStatement (ccall));
-
-               cfile.add_function (fun);
-       }
-
        public override void visit_source_file (SourceFile source_file) {
                cfile = new CCodeFile ();
                
@@ -596,7 +557,6 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                requires_array_free = false;
                requires_array_move = false;
                requires_array_length = false;
-               requires_strcmp0 = false;
 
                wrappers = new HashSet<string> (str_hash, str_equal);
                generated_external_symbols = new HashSet<Symbol> ();
@@ -631,9 +591,6 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                if (requires_array_length) {
                        append_vala_array_length ();
                }
-               if (requires_strcmp0) {
-                       append_vala_strcmp0 ();
-               }
 
                if (gvaluecollector_h_needed) {
                        cfile.add_include ("gobject/gvaluecollector.h");
@@ -2422,8 +2379,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                        make_comparable_cexpression (ref variable_type, ref s1, ref variable_type, ref s2);
 
                        if (!(f.variable_type is NullType) && f.variable_type.compatible (string_type)) {
-                               requires_strcmp0 = true;
-                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_strcmp0"));
+                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strcmp0"));
                                ccall.add_argument (s1);
                                ccall.add_argument (s2);
                                cexp = ccall;
@@ -4753,8 +4709,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                                   || expr.operator == BinaryOperator.GREATER_THAN
                                   || expr.operator == BinaryOperator.LESS_THAN_OR_EQUAL
                                   || expr.operator == BinaryOperator.GREATER_THAN_OR_EQUAL) {
-                               requires_strcmp0 = true;
-                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_strcmp0"));
+                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strcmp0"));
                                ccall.add_argument (cleft);
                                ccall.add_argument (cright);
                                cleft = ccall;
@@ -4829,8 +4784,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                var cneedle = new CCodeIdentifier ("needle");
                CCodeBinaryExpression cif_condition;
                if (array_type.element_type.compatible (string_type)) {
-                       requires_strcmp0 = true;
-                       var ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_strcmp0"));
+                       var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strcmp0"));
                        ccall.add_argument (celement);
                        ccall.add_argument (cneedle);
                        cif_condition = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccall, new CCodeConstant ("0"));
index 0490b1af17f1650e7cc840ad619804b2ed21324b..b30d7efe6e580fa6ffbf89de56377b215326b7b8 100644 (file)
@@ -36,7 +36,7 @@ public abstract class Vala.TypeRegisterFunction {
         * Constructs the C function from the specified type.
         */
        public void init_from_type (bool plugin) {
-               bool use_thread_safe = context.require_glib_version (2, 14) && !plugin;
+               bool use_thread_safe = !plugin;
 
                bool fundamental = false;
                Class cl = get_type_declaration () as Class;
index 09c5aac9be30ae82ca64c6191eb4ea3c2e2a4076..46a1cf0f2f7844acf2ec3ada5f1e4992ccc8eff8 100644 (file)
@@ -240,7 +240,7 @@ class Vala.Compiler {
                        }
                } else if (context.profile == Profile.GOBJECT) {
                        int glib_major = 2;
-                       int glib_minor = 14;
+                       int glib_minor = 16;
                        if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
                                Report.error (null, "Invalid format for --target-glib");
                        }
index d1bc1c01eb2f2dab2bc779c11d161bffd917300e..5faa7c71732e136a2b389b8427c2cef3e91893a3 100644 (file)
@@ -76,7 +76,7 @@ AC_SUBST(vapigen_decl)
 AC_SUBST(gen_introspect_decl)
 AC_SUBST(vala_gen_introspect_decl)
 
-GLIB_REQUIRED=2.14.0
+GLIB_REQUIRED=2.16.0
 
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED)