[vala/staging: 3/10] Require and target GLib >= 2.48



commit 1229ead2f945d913b3264f898f363aa4bf46f217
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Mar 14 13:54:12 2019 +0100

    Require and target GLib >= 2.48
    
    The next stable release of vala will happen 3.5 years after the
    release of GLib 2.48.0.
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/671

 codegen/valaccodemethodmodule.vala | 11 ++----
 codegen/valagasyncmodule.vala      | 78 +-------------------------------------
 codegen/valagtypemodule.vala       | 30 +++++++--------
 configure.ac                       |  2 +-
 vapi/glib-2.0.vapi                 |  5 ---
 5 files changed, 19 insertions(+), 107 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 2269742e9..88d4ddb60 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -142,14 +142,9 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 
                CCodeExpression task_is_complete;
 
-               if (context.require_glib_version (2, 44)) {
-                       var task_complete = new CCodeFunctionCall (new CCodeIdentifier 
("g_task_get_completed"));
-                       task_complete.add_argument (async_result_expr);
-                       task_is_complete = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, 
task_complete);
-               } else {
-                       var task_complete = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
-                       task_is_complete = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, 
task_complete);
-               }
+               var task_complete = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_completed"));
+               task_complete.add_argument (async_result_expr);
+               task_is_complete = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, 
task_complete);
 
                ccode.open_while (task_is_complete);
                var task_context = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_context"));
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 65ba99ff5..dfc308f4d 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -30,12 +30,7 @@ public class Vala.GAsyncModule : GtkModule {
                data.add_field ("int", "_state_");
                data.add_field ("GObject*", "_source_object_");
                data.add_field ("GAsyncResult*", "_res_");
-
                data.add_field ("GTask*", "_async_result");
-               if (!context.require_glib_version (2, 44)) {
-                       data.add_field ("GAsyncReadyCallback", "_callback_");
-                       data.add_field ("gboolean", "_task_complete_");
-               }
 
                if (m is CreationMethod) {
                        data.add_field ("GType", "object_type");
@@ -161,58 +156,9 @@ public class Vala.GAsyncModule : GtkModule {
                return freefunc;
        }
 
-       void generate_async_ready_callback_wrapper (Method m, string function_name) {
-               var function = new CCodeFunction (function_name, "void");
-               function.modifiers = CCodeModifiers.STATIC;
-
-               function.add_parameter (new CCodeParameter ("*source_object", "GObject"));
-               function.add_parameter (new CCodeParameter ("*res", "GAsyncResult"));
-               function.add_parameter (new CCodeParameter ("*user_data", "void"));
-
-               push_function (function);
-
-               // Set _task_complete_ to false after calling back to the real func
-               var async_result_cast = new CCodeFunctionCall (new CCodeIdentifier ("G_TASK"));
-               async_result_cast.add_argument (new CCodeIdentifier ("res"));
-
-               var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
-               ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_task_data_"));
-
-               var get_data_call = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_task_data"));
-               get_data_call.add_argument (async_result_cast);
-
-               var data_var = new CCodeIdentifier ("_task_data_");
-               ccode.add_assignment (data_var, get_data_call);
-
-               var task_inner_callback = new CCodeMemberAccess.pointer (data_var, "_callback_");
-               var callback_is_nonnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, 
task_inner_callback, new CCodeConstant ("NULL"));
-
-               ccode.open_if (callback_is_nonnull);
-               var nested_callback = new CCodeFunctionCall (task_inner_callback);
-               nested_callback.add_argument (new CCodeIdentifier ("source_object"));
-               nested_callback.add_argument (new CCodeIdentifier ("res"));
-               nested_callback.add_argument (new CCodeIdentifier ("user_data"));
-               ccode.add_expression (nested_callback);
-               ccode.close ();
-
-               ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_task_complete_"), new 
CCodeConstant ("TRUE"));
-
-               pop_function ();
-
-               cfile.add_function_declaration (function);
-               cfile.add_function (function);
-       }
-
        void generate_async_function (Method m) {
                push_context (new EmitContext ());
 
-               string? callback_wrapper = null;
-
-               if (!context.require_glib_version (2, 44)) {
-                       callback_wrapper = get_ccode_real_name (m) + "_async_ready_wrapper";
-                       generate_async_ready_callback_wrapper (m, callback_wrapper);
-               }
-
                var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
                var asyncfunc = new CCodeFunction (get_ccode_real_name (m), "void");
                var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -261,10 +207,6 @@ public class Vala.GAsyncModule : GtkModule {
                ccode.add_declaration (dataname + "*", new CCodeVariableDeclarator ("_data_"));
                ccode.add_assignment (data_var, dataalloc);
 
-               if (!context.require_glib_version (2, 44)) {
-                       ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_callback_"), new 
CCodeConstant ("_callback_"));
-               }
-
                var create_result = new CCodeFunctionCall (new CCodeIdentifier ("g_task_new"));
 
                var t = m.parent_symbol as TypeSymbol;
@@ -293,25 +235,11 @@ public class Vala.GAsyncModule : GtkModule {
                        create_result.add_argument (new CCodeIdentifier (get_ccode_name (cancellable_param)));
                }
 
-               if (context.require_glib_version (2, 44)) {
-                       create_result.add_argument (new CCodeIdentifier ("_callback_"));
-               } else {
-                       create_result.add_argument (new CCodeIdentifier (callback_wrapper));
-               }
+               create_result.add_argument (new CCodeIdentifier ("_callback_"));
                create_result.add_argument (new CCodeIdentifier ("_user_data_"));
 
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_async_result"), 
create_result);
 
-               if (!context.require_glib_version (2, 44)) {
-                       var task_completed_var = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
-                       var callback = new CCodeIdentifier ("_callback_");
-                       var callback_is_null = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, 
callback, new CCodeConstant ("NULL"));
-
-                       ccode.open_if (callback_is_null);
-                       ccode.add_assignment (task_completed_var, new CCodeConstant ("TRUE"));
-                       ccode.close ();
-               }
-
                var attach_data_call = new CCodeFunctionCall (new CCodeIdentifier ("g_task_set_task_data"));
 
                attach_data_call.add_argument (new CCodeMemberAccess.pointer (data_var, "_async_result"));
@@ -717,10 +645,6 @@ public class Vala.GAsyncModule : GtkModule {
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_source_object_"), new 
CCodeIdentifier ("source_object"));
                ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_res_"), new CCodeIdentifier 
("_res_"));
 
-               if (!context.require_glib_version (2, 44)) {
-                       ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_task_complete_"), 
new CCodeConstant ("TRUE"));
-               }
-
                var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m) + "_co"));
                ccall.add_argument (data_var);
                ccode.add_expression (ccall);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 63ae8a153..a8c98cdcf 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -191,22 +191,20 @@ public class Vala.GTypeModule : GErrorModule {
                        decl_space.add_type_member_declaration (type_fun.get_declaration ());
                }
 
-               if (context.require_glib_version (2, 44)) {
-                       var base_class = cl;
-                       while (base_class.base_class != null) {
-                               base_class = base_class.base_class;
-                       }
-                       string autoptr_cleanup_func;
-                       if (!is_gtypeinstance && !is_gsource) {
-                               autoptr_cleanup_func = get_ccode_free_function (base_class);
-                       } else {
-                               autoptr_cleanup_func = get_ccode_unref_function (base_class);
-                       }
-                       if (autoptr_cleanup_func == null || autoptr_cleanup_func == "") {
-                               Report.error (cl.source_reference, "internal error: autoptr_cleanup_func not 
available");
-                       }
-                       decl_space.add_type_member_declaration (new CCodeIdentifier 
("G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, %s)".printf (get_ccode_name (cl), autoptr_cleanup_func)));
+               var base_class = cl;
+               while (base_class.base_class != null) {
+                       base_class = base_class.base_class;
+               }
+               string autoptr_cleanup_func;
+               if (!is_gtypeinstance && !is_gsource) {
+                       autoptr_cleanup_func = get_ccode_free_function (base_class);
+               } else {
+                       autoptr_cleanup_func = get_ccode_unref_function (base_class);
+               }
+               if (autoptr_cleanup_func == null || autoptr_cleanup_func == "") {
+                       Report.error (cl.source_reference, "internal error: autoptr_cleanup_func not 
available");
                }
+               decl_space.add_type_member_declaration (new CCodeIdentifier ("G_DEFINE_AUTOPTR_CLEANUP_FUNC 
(%s, %s)".printf (get_ccode_name (cl), autoptr_cleanup_func)));
        }
 
        public override void generate_class_struct_declaration (Class cl, CCodeFile decl_space) {
@@ -2040,7 +2038,7 @@ public class Vala.GTypeModule : GErrorModule {
                                }
                        }
                }
-               if (context.require_glib_version (2, 42) && !prop.notify) {
+               if (!prop.notify) {
                        pflags = "%s%s".printf (pflags, " | G_PARAM_EXPLICIT_NOTIFY");
                }
                if (prop.version.deprecated) {
diff --git a/configure.ac b/configure.ac
index 74d69b822..408dfd86f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,7 +143,7 @@ done
 AC_SUBST(TEST_CFLAGS)
 
 
-GLIB_REQUIRED=2.40.0
+GLIB_REQUIRED=2.48.0
 LIBGVC_REQUIRED=2.16
 
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED)
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 7aad7bc73..58dddb663 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -3913,13 +3913,8 @@ namespace GLib {
        }
 
        [Compact]
-#if GLIB_2_44
        [Version (since = "2.44")]
        [CCode (ref_function = "g_option_group_ref", unref_function = "g_option_group_unref", type_id = 
"G_TYPE_OPTION_GROUP")]
-#else
-       [Version (since = "2.6")]
-       [CCode (free_function = "g_option_group_free")]
-#endif
        public class OptionGroup {
                public OptionGroup (string name, string description, string help_description, void* user_data 
= null, DestroyNotify? destroy = null);
                public void add_entries ([CCode (array_length = false, array_null_terminated = true)] 
OptionEntry[] entries);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]