use gobject_ast::model::{FileModel, FunctionDefItem};
use crate::{
ast_context::AstContext,
config::Config,
rules::{Rule, Violation},
};
pub struct NoGAutoMacros;
impl Rule for NoGAutoMacros {
fn name(&self) -> &'static str {
"no_g_auto_macros"
}
fn description(&self) -> &'static str {
"Forbid g_auto* macros (g_autoptr, g_autofree, etc.) for MSVC compatibility"
}
fn category(&self) -> crate::rules::Category {
crate::rules::Category::Portability
}
fn check_func_impl(
&self,
_ast_context: &AstContext,
_config: &Config,
func: &FunctionDefItem,
file: &FileModel,
violations: &mut Vec<Violation>,
) {
for stmt in &func.body_statements {
for decl in stmt.iter_declarations() {
if let Some(auto_macro) = &decl.type_info.auto_cleanup {
violations.push(self.violation_at(
&file.path,
&decl.location,
format!("{auto_macro} requires compiler cleanup attribute support",),
));
}
}
}
}
}