std::array uses length #define now
This commit is contained in:
parent
3ba2eadf3e
commit
0b418a728f
@ -29,6 +29,7 @@ pub fn header(config: &Config, in_data: &[u8]) -> Result<String, HeaderGeneratio
|
||||
// Header guard
|
||||
|
||||
if config.language == Language::Cpp {
|
||||
// C++ style
|
||||
write!(
|
||||
buf,
|
||||
"#if !defined({}){}",
|
||||
@ -36,6 +37,7 @@ pub fn header(config: &Config, in_data: &[u8]) -> Result<String, HeaderGeneratio
|
||||
)
|
||||
.unwrap();
|
||||
} else {
|
||||
// C style
|
||||
write!(buf, "#ifndef {}{}", config.guard_name, config.line_ending).unwrap();
|
||||
}
|
||||
write!(buf, "#define {}{}", config.guard_name, config.line_ending).unwrap();
|
||||
@ -73,7 +75,7 @@ pub fn with_contents(
|
||||
with_definition(config, in_data, buf)?;
|
||||
write!(buf, "#else{}", config.line_ending).unwrap();
|
||||
with_includes(config, buf);
|
||||
with_declaration(config, in_data, buf);
|
||||
with_declaration(config, buf);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -171,7 +173,7 @@ pub fn with_definition(
|
||||
buf,
|
||||
"{}{} = {};{}",
|
||||
modifiers,
|
||||
data_type_and_symbol(config, in_data),
|
||||
data_type_and_symbol(config),
|
||||
match config.container_type {
|
||||
ContainerType::CArray(_) => with_array_initialiser(in_data),
|
||||
ContainerType::StdArray(_) => with_array_initialiser(in_data),
|
||||
@ -184,14 +186,14 @@ pub fn with_definition(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn with_declaration(config: &Config, in_data: &[u8], buf: &mut String) {
|
||||
pub fn with_declaration(config: &Config, buf: &mut String) {
|
||||
let modifiers = declaration_modifiers(config);
|
||||
|
||||
write!(
|
||||
buf,
|
||||
"{}{};{}",
|
||||
modifiers,
|
||||
data_type_and_symbol(config, in_data),
|
||||
data_type_and_symbol(config),
|
||||
config.line_ending
|
||||
)
|
||||
.unwrap();
|
||||
@ -246,7 +248,7 @@ pub fn length_symbol(config: &Config) -> String {
|
||||
out_str
|
||||
}
|
||||
|
||||
pub fn data_type_and_symbol(config: &Config, in_data: &[u8]) -> String {
|
||||
pub fn data_type_and_symbol(config: &Config) -> String {
|
||||
let u8_type = match config.language {
|
||||
Language::C => "uint8_t",
|
||||
Language::Cpp => "std::uint8_t",
|
||||
@ -275,7 +277,7 @@ pub fn data_type_and_symbol(config: &Config, in_data: &[u8]) -> String {
|
||||
ByteType::U8 => u8_type,
|
||||
ByteType::I8 => i8_type,
|
||||
},
|
||||
in_data.len(),
|
||||
length_sym,
|
||||
config.symbol_name
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user