Begin documenting properties, move them to the top-level module

This commit is contained in:
Joshua Goins 2025-03-02 17:16:11 -05:00
parent 3b26da6b57
commit 930aeb6956
27 changed files with 57 additions and 39 deletions

View file

@ -54,8 +54,8 @@ pub fn serialized_struct(_metadata: TokenStream, input: TokenStream)
// Add "None" field
let none_field_stream = quote! {
#[br(temp)]
#[bw(calc = crate::property::generic_property::GenericProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )]
none_field: crate::property::generic_property::GenericProperty
#[bw(calc = crate::property::GenericProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )]
none_field: crate::property::GenericProperty
};
let buffer = ::syn::parse::Parser::parse2(
syn::Field::parse_named,

View file

@ -141,6 +141,7 @@ fn calc_key_data_size_in_bytes(key_data: &ArrayKeyData) -> u32 {
}
}
/// An array.
#[binrw]
#[derive(Debug)]
pub struct ArrayProperty {

View file

@ -3,6 +3,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A boolean.
#[binrw]
#[derive(Debug)]
pub struct BoolProperty {

View file

@ -3,6 +3,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A enum.
#[binrw]
#[derive(Debug)]
pub struct EnumProperty {

View file

@ -2,6 +2,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A float.
#[binrw]
#[derive(Debug)]
pub struct FloatProperty {

View file

@ -5,6 +5,7 @@ use crate::{
save_object::generic::Property,
};
/// A generic property that has no name or type requirements.
#[binrw]
#[derive(Debug)]
pub struct GenericProperty {

View file

@ -2,6 +2,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A integer.
#[binrw]
#[derive(Debug)]
pub struct IntProperty {

View file

@ -5,7 +5,7 @@ use crate::{
structure::{Struct, guid::Guid},
};
use super::{PropertyBase, generic_property::GenericProperty};
use super::{GenericProperty, PropertyBase};
// parse until we can't parse no more. kind of a hack for how we run into the end of Persistent.Sav
#[binrw::parser(reader, endian)]
@ -270,6 +270,7 @@ fn calc_entry_size_in_bytes(prop: &MapProperty) -> u32 {
size
}
/// A map.
#[binrw]
#[derive(Debug)]
pub struct MapProperty {

View file

@ -1,14 +1,32 @@
pub mod array_property;
pub mod bool_property;
pub mod enum_property;
pub mod float_property;
pub mod generic_property;
pub mod int_property;
mod bool_property;
pub use self::bool_property::BoolProperty;
mod enum_property;
pub use self::enum_property::EnumProperty;
mod float_property;
pub use float_property::FloatProperty;
mod generic_property;
pub use self::generic_property::GenericProperty;
mod int_property;
pub use self::int_property::IntProperty;
pub mod map_property;
pub mod name_property;
mod name_property;
pub use self::name_property::NameProperty;
pub mod set_property;
pub mod str_property;
pub mod struct_property;
mod str_property;
pub use self::str_property::StrProperty;
mod struct_property;
pub use self::struct_property::StructProperty;
pub(crate) trait PropertyBase {
fn type_name() -> &'static str;

View file

@ -3,6 +3,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A name.
#[binrw]
#[derive(Debug)]
pub struct NameProperty {

View file

@ -2,8 +2,7 @@ use crate::common::{read_string_with_length, write_string_with_length};
use binrw::{BinRead, BinResult, binrw};
use super::{
PropertyBase,
generic_property::GenericProperty,
GenericProperty, PropertyBase,
map_property::{KeyType, MapSubStrProperty},
};
@ -73,6 +72,7 @@ fn custom_parser(
Ok(result)
}
/// A set.
#[binrw]
#[derive(Debug)]
pub struct SetProperty {

View file

@ -3,6 +3,7 @@ use binrw::binrw;
use super::PropertyBase;
/// A string.
#[binrw]
#[derive(Debug)]
pub struct StrProperty {

View file

@ -4,6 +4,7 @@ use crate::{
};
use binrw::binrw;
/// A structure.
#[binrw]
#[derive(Debug)]
pub struct StructProperty {

View file

@ -3,9 +3,8 @@ use binrw::{BinRead, BinResult, BinWrite, binrw};
use crate::{
common::{read_string_with_length, write_string_with_length},
property::{
array_property::ArrayProperty, bool_property::BoolProperty, float_property::FloatProperty,
int_property::IntProperty, map_property::MapProperty, name_property::NameProperty,
set_property::SetProperty, str_property::StrProperty, struct_property::StructProperty,
BoolProperty, FloatProperty, IntProperty, NameProperty, StrProperty, StructProperty,
array_property::ArrayProperty, map_property::MapProperty, set_property::SetProperty,
},
};

View file

@ -1,7 +1,4 @@
use crate::property::{
bool_property::BoolProperty, int_property::IntProperty, map_property::MapProperty,
str_property::StrProperty,
};
use crate::property::{BoolProperty, IntProperty, StrProperty, map_property::MapProperty};
#[paramacro::serialized_struct("Transform")]
#[derive(Debug)]

View file

@ -2,9 +2,8 @@ use binrw::binrw;
use crate::{
property::{
array_property::ArrayProperty, bool_property::BoolProperty, int_property::IntProperty,
map_property::MapProperty, name_property::NameProperty, set_property::SetProperty,
str_property::StrProperty,
BoolProperty, IntProperty, NameProperty, StrProperty, array_property::ArrayProperty,
map_property::MapProperty, set_property::SetProperty,
},
structure::{
build_data::DABuildDataStruct, da_tuning_point_data::DATuningPointData,

View file

@ -1,8 +1,5 @@
use crate::{
property::{
bool_property::BoolProperty, float_property::FloatProperty, int_property::IntProperty,
name_property::NameProperty, str_property::StrProperty,
},
property::{BoolProperty, FloatProperty, IntProperty, NameProperty, StrProperty},
structure::{
da_load_option::DALoadOptionStruct, datetime::DateTimeStruct,
save_slot_info::SaveSlotInfoStruct,

View file

@ -1,6 +1,6 @@
use std::fmt::Debug;
use crate::property::str_property::StrProperty;
use crate::property::StrProperty;
use super::{
da_assemble_id_data::DAAssembleIdDataStruct,

View file

@ -1,4 +1,4 @@
use crate::property::bool_property::BoolProperty;
use crate::property::BoolProperty;
use super::{
da_humanoid_coloring_data::DAHumanoidColoringDataStruct,

View file

@ -1,4 +1,4 @@
use crate::property::float_property::FloatProperty;
use crate::property::FloatProperty;
#[paramacro::serialized_struct("DAHumanoidFigureData")]
#[derive(Debug)]

View file

@ -1,4 +1,4 @@
use crate::property::int_property::IntProperty;
use crate::property::IntProperty;
#[paramacro::serialized_struct("DALoadOption")]
#[derive(Debug)]

View file

@ -1,4 +1,4 @@
use crate::property::int_property::IntProperty;
use crate::property::IntProperty;
#[paramacro::serialized_struct("DAModuleItemData")]
#[derive(Debug)]

View file

@ -1,4 +1,4 @@
use crate::property::enum_property::EnumProperty;
use crate::property::EnumProperty;
#[paramacro::serialized_struct("DATriggerData")]
#[derive(Debug)]

View file

@ -1,4 +1,4 @@
use crate::property::int_property::IntProperty;
use crate::property::IntProperty;
#[paramacro::serialized_struct("DATuningPointData")]
#[derive(Debug)]

View file

@ -1,4 +1,4 @@
use crate::property::name_property::NameProperty;
use crate::property::NameProperty;
use super::primary_asset_type::PrimaryAssetTypeStruct;

View file

@ -1,4 +1,4 @@
use crate::property::name_property::NameProperty;
use crate::property::NameProperty;
#[paramacro::serialized_struct("PrimaryAssetType")]
#[derive(Debug)]

View file

@ -1,6 +1,4 @@
use crate::property::{
array_property::ArrayProperty, name_property::NameProperty, str_property::StrProperty,
};
use crate::property::{NameProperty, StrProperty, array_property::ArrayProperty};
use super::datetime::DateTimeStruct;