Skip to content

Commit

Permalink
- fix: array elements that use a const not being referred to as an usize
Browse files Browse the repository at this point in the history
- remove: C++ include directives in generated rust
  • Loading branch information
RavenX8 committed Nov 28, 2024
1 parent c04ce0b commit 3e39650
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions generator/src/codegen/rust/codegen_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ impl<'a, W: Write> CodeSourceGenerator<'a, W> {
cg!(self, r#"use bincode::{{Encode, Decode}};"#);
cg!(self, r#"use crate::packet::PacketPayload;"#);

for content in packet.contents() {
use self::PacketContent::*;
match content {
Include(ref inc, system) => {
cg!(self, r#"use {};"#, inc);
},
_ => {}
};
}
cg!(self);

let iserialize = packet.contents().iter().filter_map(|elem| {
match elem {
Expand Down Expand Up @@ -223,7 +213,13 @@ impl<'a, W: Write> CodeSourceGenerator<'a, W> {
use ::flat_ast::Occurs::*;
let type_ = match o {
Unbounded => format!("Vec<{}>", rust_type),
Num(n) => format!("[{}; {}]", rust_type, n)
Num(n) => {
if n.parse::<usize>().is_ok() {
format!("[{}; {}]", rust_type, n)
} else {
format!("[{}; ({} as usize)]", rust_type, n)
}
}
};
(type_, "".to_string())
} else {
Expand Down

0 comments on commit 3e39650

Please sign in to comment.