From 4ba6dc193f5065ee03f3ae365c920c97af90066b Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Sun, 2 Jun 2024 13:32:55 +0200 Subject: [PATCH] codegen: Avoid double alias on badly annotated fn If both the setter and getter for a property have the same annotation we would add the same alias twice. e.g. get_property or org.gtk.get_property set on the setter, the we would add the doc alias twice. --- src/codegen/function.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/codegen/function.rs b/src/codegen/function.rs index aec69e43c..f5f4b5c3d 100644 --- a/src/codegen/function.rs +++ b/src/codegen/function.rs @@ -106,12 +106,13 @@ pub fn generate( if analysis.codegen_name() != analysis.func_name { doc_alias(w, &analysis.func_name, comment_prefix, indent)?; } + // TODO Warn the user if both get_property and set_property are set as it is + // an error on the gir data. if let Some(get_property) = &analysis.get_property { if get_property != analysis.codegen_name() { doc_alias(w, get_property, comment_prefix, indent)?; } - } - if let Some(set_property) = &analysis.set_property { + } else if let Some(set_property) = &analysis.set_property { if set_property != analysis.codegen_name() { doc_alias(w, set_property, comment_prefix, indent)?; }