From: Jürg Billeter Date: Sun, 10 Oct 2010 09:25:01 +0000 (+0200) Subject: Require and target GLib >= 2.16 X-Git-Tag: 0.11.1~153 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fkeep-around%2F79b1a3e39a3d2bac9fbe40c99336b3b89e374571;p=thirdparty%2Fvala.git Require and target GLib >= 2.16 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. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index d0b5a8c01..9c07a9da3 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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 wrappers; Set 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 (str_hash, str_equal); generated_external_symbols = new HashSet (); @@ -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")); diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index 0490b1af1..b30d7efe6 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -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; diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 09c5aac9b..46a1cf0f2 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -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"); } diff --git a/configure.ac b/configure.ac index d1bc1c01e..5faa7c717 100644 --- a/configure.ac +++ b/configure.ac @@ -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)