[vala/staging: 2/4] codegen: Use g_value_*_pointer for nullable ValueType
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/4] codegen: Use g_value_*_pointer for nullable ValueType
- Date: Tue, 12 Sep 2017 06:50:09 +0000 (UTC)
commit 601fdc95cc53bf31c0b2f1b6c3268a51e95d5cdc
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 cd5ae3d..fb63d43 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 550f2f7..5dd0fc9 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]