From: Jürg Billeter Date: Sun, 24 Aug 2014 08:53:32 +0000 (+0200) Subject: codegen: Remove support for GLib < 2.24 X-Git-Tag: 0.25.2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bba4322cdcc3ba535a8f9f4ce24403dc46dacfa9;p=thirdparty%2Fvala.git codegen: Remove support for GLib < 2.24 --- diff --git a/codegen/valaclassregisterfunction.vala b/codegen/valaclassregisterfunction.vala index cc9b95eeb..01aa54c74 100644 --- a/codegen/valaclassregisterfunction.vala +++ b/codegen/valaclassregisterfunction.vala @@ -51,7 +51,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction { } public override string get_base_init_func_name () { - if (class_reference.class_constructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) { + if (class_reference.class_constructor != null) { return "%s_base_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null)); } else { return "NULL"; @@ -67,7 +67,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction { } public override string get_base_finalize_func_name () { - if (class_reference.class_destructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) { + if (class_reference.class_destructor != null) { return "%s_base_finalize".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null)); } else { return "NULL"; diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala index 96b7c2a9e..928e67b66 100644 --- a/codegen/valagasyncmodule.vala +++ b/codegen/valagasyncmodule.vala @@ -23,20 +23,11 @@ using GLib; public class Vala.GAsyncModule : GtkModule { - bool needs_dummy_object (Method m) { - var t = m.parent_symbol as TypeSymbol; - return (t == null || !t.is_subtype_of (gobject_type) || m is CreationMethod || m.binding != MemberBinding.INSTANCE) - && !context.require_glib_version (2, 20); - } - CCodeStruct generate_data_struct (Method m) { string dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data"; var data = new CCodeStruct ("_" + dataname); data.add_field ("int", "_state_"); - if (needs_dummy_object (m)) { - data.add_field ("GObject*", "_dummy_object_"); - } data.add_field ("GObject*", "_source_object_"); data.add_field ("GAsyncResult*", "_res_"); data.add_field ("GSimpleAsyncResult*", "_async_result"); @@ -146,15 +137,6 @@ public class Vala.GAsyncModule : GtkModule { } } - if (needs_dummy_object (m)) { - // free dummy object being created in g_simple_async_result_new - var dummy_object = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_dummy_object_"); - var free_dummy_object = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref")); - free_dummy_object.add_argument (dummy_object); - - ccode.add_expression (free_dummy_object); - } - var freecall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free")); freecall.add_argument (new CCodeIdentifier (dataname)); freecall.add_argument (new CCodeIdentifier ("_data_")); @@ -229,19 +211,7 @@ public class Vala.GAsyncModule : GtkModule { create_result.add_argument (gobject_cast); } else { - if (context.require_glib_version (2, 20)) { - create_result.add_argument (new CCodeConstant ("NULL")); - } else { - // needs dummy object - var object_creation = new CCodeFunctionCall (new CCodeIdentifier ("g_object_newv")); - object_creation.add_argument (new CCodeConstant ("G_TYPE_OBJECT")); - object_creation.add_argument (new CCodeConstant ("0")); - object_creation.add_argument (new CCodeConstant ("NULL")); - - ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_dummy_object_"), object_creation); - - create_result.add_argument (new CCodeMemberAccess.pointer (data_var, "_dummy_object_")); - } + create_result.add_argument (new CCodeConstant ("NULL")); } create_result.add_argument (new CCodeIdentifier ("_callback_")); diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index c2c823058..8d547efdb 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -508,12 +508,6 @@ public class Vala.GTypeModule : GErrorModule { if (is_gtypeinstance) { if (cl.has_class_private_fields || has_class_locks) { decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sClassPrivate".printf (get_ccode_name (cl))))); - if (!context.require_glib_version (2, 24)) { - var cdecl = new CCodeDeclaration ("GQuark"); - cdecl.add_declarator (new CCodeVariableDeclarator ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl)), new CCodeConstant ("0"))); - cdecl.modifiers = CCodeModifiers.STATIC; - decl_space.add_type_declaration (cdecl); - } } /* only add the *Private struct if it is not empty, i.e. we actually have private data */ @@ -526,12 +520,7 @@ public class Vala.GTypeModule : GErrorModule { if (cl.has_class_private_fields || has_class_locks) { decl_space.add_type_member_declaration (type_priv_struct); - string macro; - if (context.require_glib_version (2, 24)) { - macro = "(G_TYPE_CLASS_GET_PRIVATE (klass, %s, %sClassPrivate))".printf (get_ccode_type_id (cl), get_ccode_name (cl)); - } else { - macro = "((%sClassPrivate *) g_type_get_qdata (G_TYPE_FROM_CLASS (klass), _vala_%s_class_private_quark))".printf (get_ccode_name (cl), get_ccode_lower_case_name (cl)); - } + string macro = "(G_TYPE_CLASS_GET_PRIVATE (klass, %s, %sClassPrivate))".printf (get_ccode_type_id (cl), get_ccode_name (cl)); decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_CLASS_PRIVATE(klass)".printf (get_ccode_upper_case_name (cl, null)), macro)); } decl_space.add_type_member_declaration (prop_enum); @@ -630,12 +619,12 @@ public class Vala.GTypeModule : GErrorModule { } - if (cl.class_constructor != null || (!context.require_glib_version (2, 24) && cl.has_class_private_fields)) { + if (cl.class_constructor != null) { add_base_init_function (cl); } add_class_init_function (cl); - if (cl.class_destructor != null || (!context.require_glib_version (2, 24) && cl.has_class_private_fields)) { + if (cl.class_destructor != null) { add_base_finalize_function (cl); } @@ -1143,48 +1132,6 @@ public class Vala.GTypeModule : GErrorModule { push_function (base_init); - if (!context.require_glib_version (2, 24) && cl.has_class_private_fields) { - ccode.add_declaration ("%sClassPrivate *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("priv")); - ccode.add_declaration ("%sClassPrivate *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("parent_priv", new CCodeConstant ("NULL"))); - ccode.add_declaration ("GType", new CCodeVariableDeclarator ("parent_type")); - - var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_parent")); - var ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_FROM_CLASS")); - ccall2.add_argument (new CCodeIdentifier ("klass")); - ccall.add_argument (ccall2); - ccode.add_assignment (new CCodeIdentifier ("parent_type"), ccall); - - ccode.open_if (new CCodeIdentifier ("parent_type")); - ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl, null)))); - ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek")); - ccall2.add_argument (new CCodeIdentifier ("parent_type")); - ccall.add_argument (ccall2); - ccode.add_assignment (new CCodeIdentifier ("parent_priv"), ccall); - ccode.close (); - - ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_new0")); - ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf(get_ccode_name (cl)))); - ccode.add_assignment (new CCodeIdentifier ("priv"), ccall); - - cfile.add_include ("string.h"); - - ccode.open_if (new CCodeIdentifier ("parent_priv")); - ccall = new CCodeFunctionCall (new CCodeIdentifier ("memcpy")); - ccall.add_argument (new CCodeIdentifier ("priv")); - ccall.add_argument (new CCodeIdentifier ("parent_priv")); - ccall.add_argument (new CCodeIdentifier ("sizeof (%sClassPrivate)".printf(get_ccode_name (cl)))); - ccode.add_expression (ccall); - ccode.close (); - - ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata")); - ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_FROM_CLASS")); - ccall2.add_argument (new CCodeIdentifier ("klass")); - ccall.add_argument (ccall2); - ccall.add_argument (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl)))); - ccall.add_argument (new CCodeIdentifier ("priv")); - ccode.add_expression (ccall); - } - pop_context (); } @@ -1651,25 +1598,6 @@ public class Vala.GTypeModule : GErrorModule { private void add_base_finalize_function (Class cl) { push_context (base_finalize_context); - if (!context.require_glib_version (2, 24) && cl.has_class_private_fields) { - ccode.open_block (); - - var cdecl = new CCodeDeclaration ("%sClassPrivate *".printf (get_ccode_name (cl))); - cdecl.add_declarator (new CCodeVariableDeclarator ("priv")); - ccode.add_statement (cdecl); - - var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl, null)))); - ccall.add_argument (new CCodeConstant ("klass")); - ccode.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("priv"), ccall))); - - ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free")); - ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf (get_ccode_name (cl)))); - ccall.add_argument (new CCodeIdentifier ("priv")); - ccode.add_statement (new CCodeExpressionStatement (ccall)); - - ccode.close (); - } - cfile.add_function_declaration (ccode); cfile.add_function (ccode); diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index 33a372fc9..b7c18f8a2 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -128,20 +128,6 @@ public abstract class Vala.TypeRegisterFunction { type_init.add_statement (get_type_interface_init_declaration ()); - if (cl != null && cl.has_class_private_fields && !context.require_glib_version (2, 24)) { - CCodeFunctionCall quark_reg_call; - - if (plugin) { - quark_reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_string")); - } else { - quark_reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string")); - } - - quark_reg_call.add_argument (new CCodeConstant ("\"Vala%sClassPrivate\"".printf (CCodeBaseModule.get_ccode_name (get_type_declaration ())))); - - type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ()))), quark_reg_call))); - } - CCodeFunctionCall reg_call; if (get_type_declaration () is Struct) { reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_type_register_static")); @@ -217,7 +203,7 @@ public abstract class Vala.TypeRegisterFunction { type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (type_id_name), reg_call))); } - if (cl != null && cl.has_class_private_fields && context.require_glib_version (2, 24)) { + if (cl != null && cl.has_class_private_fields) { CCodeFunctionCall add_class_private_call; add_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_class_private"));