mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Implement float XPC type
This commit is contained in:
@@ -61,6 +61,7 @@ pub enum XPCType {
|
|||||||
|
|
||||||
Int64 = 0x00003000,
|
Int64 = 0x00003000,
|
||||||
UInt64 = 0x00004000,
|
UInt64 = 0x00004000,
|
||||||
|
Double = 0x00005000,
|
||||||
|
|
||||||
Date = 0x00007000,
|
Date = 0x00007000,
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ impl TryFrom<u32> for XPCType {
|
|||||||
0x0000f000 => Ok(Self::Dictionary),
|
0x0000f000 => Ok(Self::Dictionary),
|
||||||
0x0000e000 => Ok(Self::Array),
|
0x0000e000 => Ok(Self::Array),
|
||||||
0x00003000 => Ok(Self::Int64),
|
0x00003000 => Ok(Self::Int64),
|
||||||
|
0x00005000 => Ok(Self::Double),
|
||||||
0x00004000 => Ok(Self::UInt64),
|
0x00004000 => Ok(Self::UInt64),
|
||||||
0x00007000 => Ok(Self::Date),
|
0x00007000 => Ok(Self::Date),
|
||||||
0x00009000 => Ok(Self::String),
|
0x00009000 => Ok(Self::String),
|
||||||
@@ -96,6 +98,7 @@ pub enum XPCObject {
|
|||||||
Dictionary(Dictionary),
|
Dictionary(Dictionary),
|
||||||
Array(Vec<XPCObject>),
|
Array(Vec<XPCObject>),
|
||||||
|
|
||||||
|
Double(f64),
|
||||||
Int64(i64),
|
Int64(i64),
|
||||||
UInt64(u64),
|
UInt64(u64),
|
||||||
|
|
||||||
@@ -122,7 +125,7 @@ impl From<plist::Value> for XPCObject {
|
|||||||
plist::Value::Boolean(v) => XPCObject::Bool(v),
|
plist::Value::Boolean(v) => XPCObject::Bool(v),
|
||||||
plist::Value::Data(v) => XPCObject::Data(v),
|
plist::Value::Data(v) => XPCObject::Data(v),
|
||||||
plist::Value::Date(_) => todo!(),
|
plist::Value::Date(_) => todo!(),
|
||||||
plist::Value::Real(_) => todo!(),
|
plist::Value::Real(f) => XPCObject::Double(f),
|
||||||
plist::Value::Integer(v) => XPCObject::Int64(v.as_signed().unwrap()),
|
plist::Value::Integer(v) => XPCObject::Int64(v.as_signed().unwrap()),
|
||||||
plist::Value::String(v) => XPCObject::String(v),
|
plist::Value::String(v) => XPCObject::String(v),
|
||||||
plist::Value::Uid(_) => todo!(),
|
plist::Value::Uid(_) => todo!(),
|
||||||
@@ -136,6 +139,7 @@ impl XPCObject {
|
|||||||
match self {
|
match self {
|
||||||
Self::Bool(v) => plist::Value::Boolean(*v),
|
Self::Bool(v) => plist::Value::Boolean(*v),
|
||||||
Self::Uuid(uuid) => plist::Value::String(uuid.to_string()),
|
Self::Uuid(uuid) => plist::Value::String(uuid.to_string()),
|
||||||
|
Self::Double(f) => plist::Value::Real(*f),
|
||||||
Self::UInt64(v) => plist::Value::Integer({ *v }.into()),
|
Self::UInt64(v) => plist::Value::Integer({ *v }.into()),
|
||||||
Self::Int64(v) => plist::Value::Integer({ *v }.into()),
|
Self::Int64(v) => plist::Value::Integer({ *v }.into()),
|
||||||
Self::Date(d) => plist::Value::Date(plist::Date::from(*d)),
|
Self::Date(d) => plist::Value::Date(plist::Date::from(*d)),
|
||||||
@@ -192,6 +196,10 @@ impl XPCObject {
|
|||||||
buf.extend_from_slice(&content_buf);
|
buf.extend_from_slice(&content_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XPCObject::Double(f) => {
|
||||||
|
buf.extend_from_slice(&(XPCType::Double as u32).to_le_bytes());
|
||||||
|
buf.extend_from_slice(&f.to_le_bytes());
|
||||||
|
}
|
||||||
XPCObject::Int64(num) => {
|
XPCObject::Int64(num) => {
|
||||||
buf.extend_from_slice(&(XPCType::Int64 as u32).to_le_bytes());
|
buf.extend_from_slice(&(XPCType::Int64 as u32).to_le_bytes());
|
||||||
buf.extend_from_slice(&num.to_le_bytes());
|
buf.extend_from_slice(&num.to_le_bytes());
|
||||||
@@ -299,6 +307,11 @@ impl XPCObject {
|
|||||||
}
|
}
|
||||||
Ok(XPCObject::Array(ret))
|
Ok(XPCObject::Array(ret))
|
||||||
}
|
}
|
||||||
|
XPCType::Double => {
|
||||||
|
let mut buf: [u8; 8] = Default::default();
|
||||||
|
cursor.read_exact(&mut buf)?;
|
||||||
|
Ok(XPCObject::Double(f64::from_le_bytes(buf)))
|
||||||
|
}
|
||||||
XPCType::Int64 => {
|
XPCType::Int64 => {
|
||||||
let mut buf: [u8; 8] = Default::default();
|
let mut buf: [u8; 8] = Default::default();
|
||||||
cursor.read_exact(&mut buf)?;
|
cursor.read_exact(&mut buf)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user