[vala/staging: 3/3] codegen: Emit G_DEFINE_AUTOPTR_CLEANUP_FUNC() for classes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 3/3] codegen: Emit G_DEFINE_AUTOPTR_CLEANUP_FUNC() for classes
- Date: Mon, 17 Sep 2018 14:09:46 +0000 (UTC)
commit 38781a502b7381ef5383ae282fa33ddda9b493ed
Author: Rico Tzschichholz <ricotz t-online de>
Date: Tue Jul 31 13:16:48 2018 +0200
codegen: Emit G_DEFINE_AUTOPTR_CLEANUP_FUNC() for classes
This requires --target-glib=2.44
Fixes https://gitlab.gnome.org/GNOME/vala/issues/670
codegen/valagtypemodule.vala | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 6b60f7ef3..4b39cbbee 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -188,6 +188,23 @@ public class Vala.GTypeModule : GErrorModule {
type_fun.init_from_type (context, in_plugin, true);
decl_space.add_type_member_declaration (type_fun.get_declaration ());
}
+
+ if (context.require_glib_version (2, 44)) {
+ var base_class = cl;
+ while (base_class.base_class != null) {
+ base_class = base_class.base_class;
+ }
+ string autoptr_cleanup_func;
+ if (!is_gtypeinstance && !is_gsource) {
+ autoptr_cleanup_func = get_ccode_free_function (base_class);
+ } else {
+ autoptr_cleanup_func = get_ccode_unref_function (base_class);
+ }
+ if (autoptr_cleanup_func == null || autoptr_cleanup_func == "") {
+ Report.error (cl.source_reference, "internal error: autoptr_cleanup_func not
available");
+ }
+ decl_space.add_type_member_declaration (new CCodeIdentifier
("G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, %s)".printf (get_ccode_name (cl), autoptr_cleanup_func)));
+ }
}
public override void generate_class_struct_declaration (Class cl, CCodeFile decl_space) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]