[vala/db8c411392f89cf8fc0268d4819f15755d0c4137: 7/9] codegen: Use g_value_*_pointer for nullable ValueType



commit 5a1fc9e0c2021984e5c53920b58a8d02bb3d99c0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Jul 14 10:03:52 2017 +0200

    codegen: Use g_value_*_pointer for nullable ValueType
    
    Changes the internal property ABI for current users!
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784927

 codegen/valaccodebasemodule.vala |    8 ++++----
 codegen/valagobjectmodule.vala   |   11 ++---------
 2 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 90b84d4..68c02a2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -630,7 +630,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
        public CCodeIdentifier get_value_setter_function (DataType type_reference) {
                var array_type = type_reference as ArrayType;
-               if (type_reference.data_type != null) {
+               if (!(type_reference is ValueType && type_reference.nullable) && type_reference.data_type != 
null) {
                        return new CCodeIdentifier (get_ccode_set_value_function (type_reference.data_type));
                } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
                        // G_TYPE_STRV
@@ -642,7 +642,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
        public CCodeIdentifier get_value_taker_function (DataType type_reference) {
                var array_type = type_reference as ArrayType;
-               if (type_reference.data_type != null) {
+               if (!(type_reference is ValueType && type_reference.nullable) && type_reference.data_type != 
null) {
                        return new CCodeIdentifier (get_ccode_take_value_function (type_reference.data_type));
                } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
                        // G_TYPE_STRV
@@ -652,9 +652,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                }
        }
 
-       CCodeIdentifier get_value_getter_function (DataType type_reference) {
+       public CCodeIdentifier get_value_getter_function (DataType type_reference) {
                var array_type = type_reference as ArrayType;
-               if (type_reference.data_type != null) {
+               if (!(type_reference is ValueType && type_reference.nullable) && type_reference.data_type != 
null) {
                        return new CCodeIdentifier (get_ccode_get_value_function (type_reference.data_type));
                } else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
                        // G_TYPE_STRV
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 6c3496b..cc87792 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -341,12 +341,12 @@ public class Vala.GObjectModule : GTypeModule {
                        ccode.add_case (new CCodeIdentifier ("%s_PROPERTY".printf (get_ccode_upper_case_name 
(prop))));
                        ccall = new CCodeFunctionCall (cfunc);
                        ccall.add_argument (cself);
+                       var cgetcall = new CCodeFunctionCall (get_value_getter_function (prop.property_type));
+                       cgetcall.add_argument (new CCodeIdentifier ("value"));
                        if (prop.property_type is ArrayType && 
((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) {
                                ccode.open_block ();
                                ccode.add_declaration ("gpointer", new CCodeVariableDeclarator ("boxed"));
 
-                               var cgetcall = new CCodeFunctionCall (new CCodeIdentifier 
("g_value_get_boxed"));
-                               cgetcall.add_argument (new CCodeIdentifier ("value"));
                                ccode.add_assignment (new CCodeIdentifier ("boxed"), cgetcall);
                                ccall.add_argument (new CCodeIdentifier ("boxed"));
 
@@ -359,13 +359,6 @@ public class Vala.GObjectModule : GTypeModule {
                                add_guarded_expression (prop, ccall);
                                ccode.close ();
                        } else {
-                               var cgetcall = new CCodeFunctionCall ();
-                               if (prop.property_type.data_type != null) {
-                                       cgetcall.call = new CCodeIdentifier (get_ccode_get_value_function 
(prop.property_type.data_type));
-                               } else {
-                                       cgetcall.call = new CCodeIdentifier ("g_value_get_pointer");
-                               }
-                               cgetcall.add_argument (new CCodeIdentifier ("value"));
                                ccall.add_argument (cgetcall);
                                add_guarded_expression (prop, ccall);
                        }


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