[vala] Require and target GLib >= 2.16
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Require and target GLib >= 2.16
- Date: Sun, 10 Oct 2010 16:38:47 +0000 (UTC)
commit 79b1a3e39a3d2bac9fbe40c99336b3b89e374571
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 11:25:01 2010 +0200
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.
codegen/valaccodebasemodule.vala | 52 ++-------------------------------
codegen/valatyperegisterfunction.vala | 2 +-
compiler/valacompiler.vala | 2 +-
configure.ac | 2 +-
4 files changed, 6 insertions(+), 52 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d0b5a8c..9c07a9d 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<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"));
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index 0490b1a..b30d7ef 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 09c5aac..46a1cf0 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 d1bc1c0..5faa7c7 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]