diff --git a/src/codegen/sys/tests.rs b/src/codegen/sys/tests.rs index 886f07990..04367382c 100644 --- a/src/codegen/sys/tests.rs +++ b/src/codegen/sys/tests.rs @@ -8,6 +8,7 @@ use log::info; use crate::{ analysis::types::IsIncomplete, codegen::general, + config::gobjects::GStatus, env::Env, file_saver::save_to_file, library::{self, Bitfield, Enumeration, Namespace, Type, MAIN_NAMESPACE}, @@ -28,6 +29,7 @@ struct CConstant { name: String, /// Stringified value. value: String, + status: GStatus, } pub fn generate(env: &Env, crate_name: &str) { @@ -98,14 +100,10 @@ fn prepare_ctype(env: &Env, ns: &Namespace, t: &Type) -> Option { if is_name_made_up(name) { return None; } - let cfg_condition = env - .config - .objects - .get(&full_name) - .and_then(|obj| obj.cfg_condition.clone()); + let object = env.config.objects.get(&full_name); Some(CType { name: name.to_owned(), - cfg_condition, + cfg_condition: object.and_then(|obj| obj.cfg_condition.clone()), }) } @@ -127,6 +125,7 @@ fn prepare_cconsts(env: &Env) -> Vec { Some(CConstant { name: constant.c_identifier.clone(), value: value.to_owned(), + status: GStatus::Generate, // Assume generate because we skip ignored ones above }) }) .collect(); @@ -153,6 +152,7 @@ fn prepare_cconsts(env: &Env) -> Vec { .parse::() .map(|i| (i as u32).to_string()) .unwrap_or_else(|_| member.value.clone()), + status: member.status, }); } } @@ -163,6 +163,7 @@ fn prepare_cconsts(env: &Env) -> Vec { constants.push(CConstant { name: format!("(gint) {}", member.c_identifier), value: member.value.clone(), + status: member.status, }); } } @@ -280,6 +281,9 @@ fn generate_constant_c( writeln!(w, "{}", r"int main() {")?; for cconst in cconsts { + if cconst.status.ignored() { + continue; + } writeln!(w, " PRINT_CONSTANT({name});", name = cconst.name,)?; } @@ -530,6 +534,9 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &["# const RUST_CONSTANTS: &[(&str, &str)] = &["# )?; for cconst in cconsts { + if cconst.status.ignored() { + continue; + } writeln!( w, " (\"{name}\", \"{value}\"),", diff --git a/src/config/gobjects.rs b/src/config/gobjects.rs index b482ca7cf..a4be71c81 100644 --- a/src/config/gobjects.rs +++ b/src/config/gobjects.rs @@ -29,7 +29,7 @@ use crate::{ version::Version, }; -#[derive(Default, Clone, Copy, Debug, Eq, PartialEq)] +#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub enum GStatus { Manual, Generate,