mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-12 14:46:17 +00:00
Add support for structure types and enums being nested in structure types (#119)
* Add support for structure types and enums being nested in structure types * Fix formatting
This commit is contained in:
@@ -740,6 +740,7 @@ pub struct StructureType {
|
|||||||
pub byte_size: Option<u32>,
|
pub byte_size: Option<u32>,
|
||||||
pub members: Vec<StructureMember>,
|
pub members: Vec<StructureMember>,
|
||||||
pub bases: Vec<StructureBase>,
|
pub bases: Vec<StructureBase>,
|
||||||
|
pub inner_types: Vec<UserDefinedType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -1687,6 +1688,9 @@ pub fn struct_def_string(
|
|||||||
if let Some(byte_size) = t.byte_size {
|
if let Some(byte_size) = t.byte_size {
|
||||||
writeln!(out, " // total size: {byte_size:#X}")?;
|
writeln!(out, " // total size: {byte_size:#X}")?;
|
||||||
}
|
}
|
||||||
|
for inner_type in &t.inner_types {
|
||||||
|
writeln!(out, "{};", &indent_all_by(4, &ud_type_def(info, typedefs, inner_type, false)?))?;
|
||||||
|
}
|
||||||
let mut vis = match t.kind {
|
let mut vis = match t.kind {
|
||||||
StructureKind::Struct => Visibility::Public,
|
StructureKind::Struct => Visibility::Public,
|
||||||
StructureKind::Class => Visibility::Private,
|
StructureKind::Class => Visibility::Private,
|
||||||
@@ -1999,6 +2003,7 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result<StructureType> {
|
|||||||
|
|
||||||
let mut members = Vec::new();
|
let mut members = Vec::new();
|
||||||
let mut bases = Vec::new();
|
let mut bases = Vec::new();
|
||||||
|
let mut inner_types = Vec::new();
|
||||||
for child in tag.children(&info.tags) {
|
for child in tag.children(&info.tags) {
|
||||||
match child.kind {
|
match child.kind {
|
||||||
TagKind::Inheritance => bases.push(process_inheritance_tag(info, child)?),
|
TagKind::Inheritance => bases.push(process_inheritance_tag(info, child)?),
|
||||||
@@ -2013,13 +2018,15 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result<StructureType> {
|
|||||||
TagKind::GlobalVariable => {
|
TagKind::GlobalVariable => {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
TagKind::StructureType
|
TagKind::StructureType | TagKind::ClassType => {
|
||||||
| TagKind::ArrayType
|
inner_types.push(UserDefinedType::Structure(process_structure_tag(info, child)?))
|
||||||
| TagKind::EnumerationType
|
}
|
||||||
| TagKind::UnionType
|
TagKind::EnumerationType => inner_types
|
||||||
| TagKind::ClassType
|
.push(UserDefinedType::Enumeration(process_enumeration_tag(info, child)?)),
|
||||||
| TagKind::SubroutineType
|
TagKind::UnionType => {
|
||||||
| TagKind::PtrToMemberType => {
|
inner_types.push(UserDefinedType::Union(process_union_tag(info, child)?))
|
||||||
|
}
|
||||||
|
TagKind::ArrayType | TagKind::SubroutineType | TagKind::PtrToMemberType => {
|
||||||
// Variable type, ignore
|
// Variable type, ignore
|
||||||
}
|
}
|
||||||
kind => bail!("Unhandled StructureType child {:?}", kind),
|
kind => bail!("Unhandled StructureType child {:?}", kind),
|
||||||
@@ -2036,6 +2043,7 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result<StructureType> {
|
|||||||
byte_size,
|
byte_size,
|
||||||
members,
|
members,
|
||||||
bases,
|
bases,
|
||||||
|
inner_types,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user