[vala/wip/issue/278: 37/37] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/278: 37/37] WIP
- Date: Wed, 5 Feb 2020 11:54:38 +0000 (UTC)
commit bde25bb342442712c2fa8200a989e39450c5a707
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Jun 17 15:48:08 2019 +0200
WIP
codegen/valaccodebasemodule.vala | 4 ++++
codegen/valagtypemodule.vala | 28 +++++++++++++++++++---------
2 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 52bc6d930..09164bc67 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -675,6 +675,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (sym is Constant && ((Constant) sym).value is InitializerList) {
return false;
}
+ // sealed classes are special
+ if (sym is Class && ((Class) sym).is_sealed) {
+ return false;
+ }
if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header &&
!sym.is_internal_symbol ())
|| (sym.is_extern && get_ccode_header_filenames (sym).length > 0)) {
// add feature test macros
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index cbb38398e..1acb3279e 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -75,17 +75,23 @@ public class Vala.GTypeModule : GErrorModule {
macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (get_ccode_type_id
(cl), get_ccode_name (cl));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf
(get_ccode_type_cast_function (cl)), macro));
- macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (get_ccode_type_id
(cl), get_ccode_name (cl));
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(klass)".printf
(get_ccode_class_type_function (cl)), macro));
+ if (!(cl.is_sealed && decl_space.is_header)) {
+ macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf
(get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement
("%s(klass)".printf (get_ccode_class_type_function (cl)), macro));
+ }
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (get_ccode_type_id (cl));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf
(get_ccode_type_check_function (cl)), macro));
- macro = "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))".printf (get_ccode_type_id (cl));
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(klass)".printf
(get_ccode_class_type_check_function (cl)), macro));
+ if (!(cl.is_sealed && decl_space.is_header)) {
+ macro = "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))".printf (get_ccode_type_id
(cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement
("%s(klass)".printf (get_ccode_class_type_check_function (cl)), macro));
+ }
- macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (get_ccode_type_id
(cl), get_ccode_name (cl));
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf
(get_ccode_class_get_function (cl)), macro));
+ if (!(cl.is_sealed && decl_space.is_header)) {
+ macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf
(get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf
(get_ccode_class_get_function (cl)), macro));
+ }
decl_space.add_type_declaration (new CCodeNewline ());
}
@@ -183,7 +189,7 @@ public class Vala.GTypeModule : GErrorModule {
}
}
- if (is_gtypeinstance) {
+ if (is_gtypeinstance && !(cl.is_sealed && decl_space.is_header)) {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%sClass".printf
(get_ccode_name (cl)), new CCodeVariableDeclarator ("%sClass".printf (get_ccode_name (cl)))));
var type_fun = new ClassRegisterFunction (cl);
@@ -231,6 +237,10 @@ public class Vala.GTypeModule : GErrorModule {
generate_class_declaration (cl, decl_space);
+ if (cl.is_sealed && decl_space.is_header) {
+ return;
+ }
+
bool is_gtypeinstance = !cl.is_compact;
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
@@ -609,10 +619,10 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_type_declaration (prop_array_decl);
}
- if (!cl.is_internal_symbol ()) {
+ if (!cl.is_internal_symbol () || cl.is_sealed) {
generate_class_struct_declaration (cl, header_file);
}
- if (!cl.is_private_symbol ()) {
+ if (!cl.is_private_symbol () || cl.is_sealed) {
generate_class_struct_declaration (cl, internal_header_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]