[vala/wip/issue/278: 2/2] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/278: 2/2] WIP
- Date: Wed, 19 Jun 2019 05:55:05 +0000 (UTC)
commit 7c0d0edc71612bfab0ccee11cf233f4260c2e8ba
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 e3d8d3b55..1e3937c72 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -657,6 +657,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 ())) {
// add feature test macros
foreach (unowned string feature_test_macro in get_ccode_feature_test_macros
(sym).split (",")) {
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 4c926dc0e..6a37640d7 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);
@@ -225,6 +231,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;
@@ -655,10 +665,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]