aboutsummaryrefslogtreecommitdiff
path: root/src/object.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/object.rs')
-rw-r--r--src/object.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/object.rs b/src/object.rs
index 5ad1441..5275eb7 100644
--- a/src/object.rs
+++ b/src/object.rs
@@ -1,7 +1,7 @@
use crate::helper::{AlignExt, Endianness, ReadExt};
use crate::serialized_file::TypeTreeNode;
use anyhow::Result;
-use log::debug;
+use log::{debug, trace};
use std::io::Seek;
use std::{collections::BTreeMap, io::Read};
@@ -10,6 +10,7 @@ pub enum Value {
Bool(bool),
U8(u8),
U16(u16),
+ I16(i16),
U32(u32),
I32(i32),
F32(f32),
@@ -28,11 +29,13 @@ pub fn read_value(
e: Endianness,
data: &mut (impl Read + Seek),
) -> Result<Value> {
- match ty.type_string.as_str() {
+ let r = match ty.type_string.as_str() {
"char" => Ok(Value::U8(data.read_u8()?)),
"int" => Ok(Value::I32(data.read_i32(e)?)),
"unsigned int" => Ok(Value::U32(data.read_u32(e)?)),
+ "UInt8" => Ok(Value::U8(data.read_u8()?)),
"UInt16" => Ok(Value::U16(data.read_u16(e)?)),
+ "SInt16" => Ok(Value::I16(data.read_i16(e)?)),
"SInt64" => Ok(Value::I64(data.read_i64(e)?)),
"bool" => Ok(Value::Bool(data.read_u8()? != 0)),
"float" => {
@@ -63,7 +66,7 @@ pub fn read_value(
let Value::I32(size) = read_value(&ty.children[0], e, data)? else {
unreachable!()
};
- debug!("array of size {size}");
+ trace!("array of size {size}");
let mut elems = Vec::new();
for _ in 0..size {
elems.push(read_value(&ty.children[1], e, data)?);
@@ -83,5 +86,9 @@ pub fn read_value(
class: ty.type_string.clone(),
})
}
+ };
+ if ty.post_align() {
+ data.align(4)?;
}
+ r
}