C++: fix compilation when class name has an underscore

Fixes: #4659
This commit is contained in:
Olivier Goffart 2024-02-22 09:08:13 +01:00
parent 9cb1a4a4e0
commit b5abee6c8d
2 changed files with 14 additions and 5 deletions

View file

@ -810,6 +810,7 @@ fn generate_struct(
fields: &BTreeMap<String, Type>,
node: &syntax_nodes::ObjectType,
) {
let name = ident(name);
let mut members = node
.ObjectTypeMember()
.map(|n| crate::parser::identifier_text(&n).unwrap())
@ -836,11 +837,7 @@ fn generate_struct(
}),
));
file.declarations.push(Declaration::Struct(Struct {
name: name.into(),
members,
..Default::default()
}))
file.declarations.push(Declaration::Struct(Struct { name, members, ..Default::default() }))
}
fn generate_enum(file: &mut File, en: &std::rc::Rc<Enumeration>) {