Skip to content

Commit

Permalink
add ExDoubleConst and fix expression docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaturtlesandwich committed Apr 8, 2024
1 parent 4052fe3 commit 8538de7
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions unreal_asset/unreal_asset_kismet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pub enum EExprToken {
ExInt64Const = 0x35,
/// 64-bit unsigned integer constant.
ExUInt64Const = 0x36,
/// Double-precision floating point constant.
ExDoubleConst = 0x37,
/// A casting operator for primitives which reads the type as the subsequent byte
ExPrimitiveCast = 0x38,
/// Set the value of an arbitrary set
Expand Down Expand Up @@ -373,7 +375,7 @@ macro_rules! declare_expression {
$v:ident: $t:ty
),*
) => {
/// $name
#[doc = stringify!($name)]
#[derive(FNameContainer, Debug, Clone, PartialEq, Eq, Hash)]
pub struct $name {
/// Kismet token
Expand Down Expand Up @@ -882,6 +884,8 @@ pub enum KismetExpression {
ExInt64Const,
/// 64-bit unsigned integer constant.
ExUInt64Const,
/// Double-precision floating point constant.
ExDoubleConst,
/// A casting operator for primitives which reads the type as the subsequent byte
ExPrimitiveCast,
/// Set the value of an arbitrary set
Expand Down Expand Up @@ -983,7 +987,7 @@ impl Eq for KismetExpression {}
impl KismetExpression {
/// Read a `KismetExpression` from an asset
pub fn new<Reader: ArchiveReader>(asset: &mut Reader) -> Result<Self, Error> {
let token: EExprToken = asset.read_u8()?.try_into()?;
let token: EExprToken = dbg!(asset.read_u8()?.try_into()?);
let expr: Result<Self, Error> = match token {
EExprToken::ExLocalVariable => Ok(ExLocalVariable::new(asset)?.into()),
EExprToken::ExInstanceVariable => Ok(ExInstanceVariable::new(asset)?.into()),
Expand Down Expand Up @@ -1031,6 +1035,7 @@ impl KismetExpression {
EExprToken::ExUnicodeStringConst => Ok(ExUnicodeStringConst::new(asset)?.into()),
EExprToken::ExInt64Const => Ok(ExInt64Const::new(asset)?.into()),
EExprToken::ExUInt64Const => Ok(ExUInt64Const::new(asset)?.into()),
EExprToken::ExDoubleConst => Ok(ExDoubleConst::new(asset)?.into()),
EExprToken::ExPrimitiveCast => Ok(ExPrimitiveCast::new(asset)?.into()),
EExprToken::ExSetSet => Ok(ExSetSet::new(asset)?.into()),
EExprToken::ExEndSet => Ok(ExEndSet::new(asset)?.into()),
Expand Down Expand Up @@ -2955,3 +2960,19 @@ implement_value_expression!(ExIntConst, i32, read_i32, write_i32, LE);
implement_value_expression!(ExIntConstByte, u8, read_u8, write_u8);
implement_value_expression!(ExSkipOffsetConst, u32, read_u32, write_u32, LE);
implement_value_expression!(ExUInt64Const, u64, read_u64, write_u64, LE);
declare_expression!(ExDoubleConst, #[doc = " Value"]value:OrderedFloat<f64>);
impl ExDoubleConst {
#[doc = " Read `ExDoubleConst` from an asset"]
pub fn new<Reader: ArchiveReader>(asset: &mut Reader) -> Result<Self, Error> {
Ok(ExDoubleConst {
token: EExprToken::ExDoubleConst,
value: OrderedFloat(asset.read_f64::<LE>()?),
})
}
}
impl KismetExpressionTrait for ExDoubleConst {
fn write<Writer: ArchiveWriter>(&self, asset: &mut Writer) -> Result<usize, Error> {
asset.write_f64::<LE>(self.value.0)?;
Ok(size_of::<OrderedFloat<f64>>())
}
}

0 comments on commit 8538de7

Please sign in to comment.