[vala/0.50] girparser: Add support for "final" class attribute



commit a325e89242b234b5453499bfdf499bfb9402824a
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 7d7a68da6..71ebe31bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -735,6 +735,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 ad0dbf69d..3c11f8494 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]