[vala/wip/issue/278: 214/214] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/278: 214/214] WIP
- Date: Wed, 8 Jan 2020 09:44:07 +0000 (UTC)
commit ac3217b7910f9764f5a2b9a1a6a1b4f9ff1678f1
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 9e836b1d7..0b1a12df4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -663,6 +663,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 17c0690b3..9b01796b8 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;
@@ -673,10 +683,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]