[vala/0.48] codegen: Emit G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC() for structs
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Emit G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC() for structs
- Date: Mon, 21 Mar 2022 08:17:08 +0000 (UTC)
commit 18b07be9b71f1eb8c66b69d62d244575b7788386
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Feb 24 13:45:18 2022 +0100
codegen: Emit G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC() for structs
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1293
codegen/valaccodestructmodule.vala | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 2b685383d..dff0d9827 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -142,6 +142,22 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
}
+
+ if (context.profile == Profile.GOBJECT) {
+ generate_auto_cleanup_clear (st, decl_space);
+ }
+ }
+
+ void generate_auto_cleanup_clear (Struct st, CCodeFile decl_space) {
+ if (st.is_disposable ()
+ && (!context.use_header || decl_space.is_header)) {
+ string auto_cleanup_clear_func = get_ccode_destroy_function (st);
+ if (auto_cleanup_clear_func == null || auto_cleanup_clear_func == "") {
+ Report.error (st.source_reference, "internal error: auto_cleanup_clear_func
not available");
+ }
+ decl_space.add_type_member_declaration (new CCodeIdentifier
("G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (%s, %s)".printf (get_ccode_name (st), auto_cleanup_clear_func)));
+ decl_space.add_type_member_declaration (new CCodeNewline ());
+ }
}
public override void visit_struct (Struct st) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]