Skip to content

Commit

Permalink
codegen: Use {g,s}et_property annotation for alias
Browse files Browse the repository at this point in the history
  • Loading branch information
A6GibKm committed Jun 1, 2024
1 parent be0d072 commit 69e6ebc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analysis/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub struct Info {
/// this potential global function is defined
pub ns_id: NsId,
pub generate_doc: bool,
pub get_property: Option<String>,
pub set_property: Option<String>,
}

impl Info {
Expand Down Expand Up @@ -944,6 +946,8 @@ fn analyze_function(
hidden: false,
ns_id,
generate_doc,
get_property: func.get_property.clone(),
set_property: func.set_property.clone(),
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/codegen/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ pub fn generate(
if analysis.codegen_name() != analysis.func_name {
doc_alias(w, &analysis.func_name, comment_prefix, indent)?;
}
if let Some(get_property) = &analysis.get_property {
if get_property != &analysis.codegen_name() {

Check failure on line 110 in src/codegen/function.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, stable)

taken reference of right operand
doc_alias(w, get_property, comment_prefix, indent)?;
}
}
if let Some(set_property) = &analysis.set_property {
if set_property != &analysis.codegen_name() {

Check failure on line 115 in src/codegen/function.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, stable)

taken reference of right operand
doc_alias(w, set_property, comment_prefix, indent)?;
}
}
// Don't add a guard for public or copy/equal functions
let dead_code_cfg = if !analysis.visibility.is_public() && !analysis.is_special() {
"#[allow(dead_code)]"
Expand Down

0 comments on commit 69e6ebc

Please sign in to comment.