[vala/staging] codegen: Split out GTypeModule.generate_autoptr_cleanup()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Split out GTypeModule.generate_autoptr_cleanup()
- Date: Thu, 24 Feb 2022 12:46:17 +0000 (UTC)
commit 33510fe8fe76a569656de5cc69234c435149da14
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Feb 24 13:45:18 2022 +0100
codegen: Split out GTypeModule.generate_autoptr_cleanup()
codegen/valagtypemodule.vala | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 270548e72..1f600afe3 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -227,19 +227,23 @@ public class Vala.GTypeModule : GErrorModule {
}
// Custom unref-methods need to be emitted before G_DEFINE_AUTOPTR_CLEANUP_FUNC,
// so we guard against that special case and handle it in generate_method_declaration.
- if (!(base_class.is_compact && is_reference_counting (base_class))
+ generate_autoptr_cleanup (cl, base_class, decl_space);
+ }
+
+ void generate_autoptr_cleanup (ObjectTypeSymbol sym, Class cl, CCodeFile decl_space) {
+ if (!(cl.is_compact && is_reference_counting (cl))
&& (context.header_filename == null|| decl_space.file_type == CCodeFileType.PUBLIC_HEADER
- || (decl_space.file_type == CCodeFileType.INTERNAL_HEADER &&
base_class.is_internal_symbol()))) {
+ || (decl_space.file_type == CCodeFileType.INTERNAL_HEADER && cl.is_internal_symbol
()))) {
string autoptr_cleanup_func;
- if (is_reference_counting (base_class)) {
- autoptr_cleanup_func = get_ccode_unref_function (base_class);
+ if (is_reference_counting (cl)) {
+ autoptr_cleanup_func = get_ccode_unref_function (cl);
} else {
- autoptr_cleanup_func = get_ccode_free_function (base_class);
+ autoptr_cleanup_func = get_ccode_free_function (cl);
}
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)));
+ decl_space.add_type_member_declaration (new CCodeIdentifier
("G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, %s)".printf (get_ccode_name (sym), autoptr_cleanup_func)));
decl_space.add_type_member_declaration (new CCodeNewline ());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]