[vala/staging] codegen: Use gtype-boxed API for structs with "g_boxed_free" attribute
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Use gtype-boxed API for structs with "g_boxed_free" attribute
- Date: Tue, 8 Oct 2019 13:40:01 +0000 (UTC)
commit 3c4b42d7ba0c23af762f295379f01361e118a02f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Oct 8 15:07:58 2019 +0200
codegen: Use gtype-boxed API for structs with "g_boxed_free" attribute
See https://gitlab.gnome.org/GNOME/vala/issues/863
codegen/valaccodebasemodule.vala | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 1349a20aa..39303d62a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2752,7 +2752,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (dup_function == null) {
dup_function = "";
}
- } else if (cl != null && get_ccode_is_gboxed (cl)) {
+ } else if (get_ccode_is_gboxed (type.type_symbol)) {
// allow duplicates of gboxed instances
dup_function = generate_dup_func_wrapper (type);
if (dup_function == null) {
@@ -3062,11 +3062,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
push_function (function);
- unowned Class? cl = type.type_symbol as Class;
- assert (cl != null && get_ccode_is_gboxed (cl));
-
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_copy"));
- free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
+ free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (type.type_symbol)));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_return (free_call);
@@ -3154,10 +3151,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
push_function (function);
- unowned Class? cl = type.type_symbol as Class;
- if (cl != null && get_ccode_is_gboxed (cl)) {
+ if (get_ccode_is_gboxed (type.type_symbol)) {
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_free"));
- free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
+ free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (type.type_symbol)));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (free_call);
@@ -3260,8 +3256,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return null;
}
} else {
- unowned Class? cl = type.type_symbol as Class;
- if (cl != null && get_ccode_is_gboxed (cl)) {
+ if (get_ccode_is_gboxed (type.type_symbol)) {
unref_function = generate_free_func_wrapper (type);
} else {
if (is_free_function_address_of (type)) {
@@ -3273,7 +3268,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
} else {
if (type.nullable) {
- unref_function = get_ccode_free_function (type.type_symbol);
+ if (get_ccode_is_gboxed (type.type_symbol)) {
+ unref_function = generate_free_func_wrapper (type);
+ } else {
+ unref_function = get_ccode_free_function (type.type_symbol);
+ }
if (unref_function == null) {
if (type.type_symbol is Struct && ((Struct)
type.type_symbol).is_disposable ()) {
unref_function = generate_free_func_wrapper (type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]