From 20dc4e1132fefaa77d66b6a4e4e69e39ebcb74ec Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Fri, 31 May 2024 15:16:37 +0200 Subject: [PATCH] Use final annotation If final="1" is set we skip the heuristic to determine whether a class is final. Fixes: https://github.com/gtk-rs/gir/issues/1204 --- src/library_postprocessing.rs | 2 ++ src/parser.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/library_postprocessing.rs b/src/library_postprocessing.rs index 11747c6f5..b0291b979 100644 --- a/src/library_postprocessing.rs +++ b/src/library_postprocessing.rs @@ -450,6 +450,8 @@ impl Library { // The config might also be used to override a type that is wrongly // detected as final type otherwise *final_type + } else if klass.final_type { + true } else if klass.type_struct.is_none() { !self.has_subtypes(tid) } else { diff --git a/src/parser.rs b/src/parser.rs index cdbcb66f6..dae9c1704 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -173,6 +173,7 @@ impl Library { }; let is_abstract = elem.attr("abstract").map_or(false, |x| x == "1"); + let final_type = elem.attr("final").map_or(false, |x| x == "1"); let mut fns = Vec::new(); let mut signals = Vec::new(); @@ -255,7 +256,7 @@ impl Library { properties, parent, implements: impls, - final_type: false, // this will be set during postprocessing + final_type, doc, doc_deprecated, version,