[vala/wip/issue/278: 871/872] girparser: Add support for "final" class attribute
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/278: 871/872] girparser: Add support for "final" class attribute
- Date: Tue, 27 Jul 2021 16:28:17 +0000 (UTC)
commit 7bf72464c9cb2d7752f5842e2d82a8ccec82aef8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jul 27 14:34:39 2021 +0200
girparser: Add support for "final" class attribute
tests/Makefile.am | 1 +
tests/gir/class-final.test | 27 +++++++++++++++++++++++++++
vala/valagirparser.vala | 2 +-
3 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 503c60119..cc26ede8b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -751,6 +751,7 @@ TESTS = \
gir/async-result-pos.test \
gir/async-sync-out.test \
gir/class.test \
+ gir/class-final.test \
gir/constant.test \
gir/delegate-alias-without-target.test \
gir/delegate-anonymous.test \
diff --git a/tests/gir/class-final.test b/tests/gir/class-final.test
new file mode 100644
index 000000000..51449f3f0
--- /dev/null
+++ b/tests/gir/class-final.test
@@ -0,0 +1,27 @@
+GIR
+
+Input:
+
+<class name="Foo" c:type="TestFoo" glib:type-name="TestFoo" glib:get-type="test_foo_get_type"
glib:type-struct="FooClass" parent="GObject.Object">
+</class>
+<record name="FooClass" c:type="TestFooClass" glib:is-gtype-struct-for="Foo">
+</record>
+<record name="FooPrivate" c:type="TestFooPrivate" disguised="1"/>
+<class name="Bar" c:type="TestBar" glib:type-name="TestBar" glib:get-type="test_bar_get_type"
glib:type-struct="BarClass" parent="Test.Foo" final="1">
+</class>
+<record name="BarClass" c:type="TestBarClass" glib:is-gtype-struct-for="Bar">
+</record>
+<record name="BarPrivate" c:type="TestBarPrivate" disguised="1"/>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_bar_get_type ()")]
+public sealed class Bar : Test.Foo {
+ [CCode (has_construct_function = false)]
+ protected Bar ();
+}
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected Foo ();
+}
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 2345c355e..5d0a709b0 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2973,7 +2973,7 @@ public class Vala.GirParser : CodeVisitor {
if (current.new_symbol) {
cl = new Class (current.name, current.source_reference);
cl.is_abstract = metadata.get_bool (ArgumentType.ABSTRACT, reader.get_attribute
("abstract") == "1");
- cl.is_sealed = metadata.get_bool (ArgumentType.SEALED, false);
+ cl.is_sealed = metadata.get_bool (ArgumentType.SEALED, reader.get_attribute ("final")
== "1");
if (metadata.has_argument (ArgumentType.TYPE_GET_FUNCTION)) {
cl.set_attribute_string ("CCode", "type_get_function", metadata.get_string
(ArgumentType.TYPE_GET_FUNCTION));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]