]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Add support for "final" class attribute
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Jul 2021 12:34:39 +0000 (14:34 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 9 Aug 2021 05:51:00 +0000 (07:51 +0200)
tests/Makefile.am
tests/gir/class-final.test [new file with mode: 0644]
vala/valagirparser.vala

index 43d990bc5eccbf4366688600e917fda88063ff76..66a20f883b234d12b385a9b9eadab25dccf45348 100644 (file)
@@ -743,6 +743,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 (file)
index 0000000..51449f3
--- /dev/null
@@ -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 ();
+}
index 2345c355e6ddba0ec271b80024009198e41f1f31..5d0a709b0cff0a6224b374e4f8ae08fc5b40e5cb 100644 (file)
@@ -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));
                        }