From 384789a6bb24bee810684a39bb60b2e1389ec154 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 17 Feb 2026 16:25:05 +0100 Subject: i64 json/debug support --- common/object/src/inspect.rs | 1 + common/object/src/json.rs | 30 +++++++++--------------------- common/object/src/registry.rs | 1 + common/object/src/value.rs | 2 +- 4 files changed, 12 insertions(+), 22 deletions(-) (limited to 'common/object/src') diff --git a/common/object/src/inspect.rs b/common/object/src/inspect.rs index bc217f0..cfab5c3 100644 --- a/common/object/src/inspect.rs +++ b/common/object/src/inspect.rs @@ -28,6 +28,7 @@ impl Debug for Inspector<'_, Object<'_>> { x if x == OBJECT => s.field(info.name, &self.1.get_typed::(i).unwrap()), x if x == U32 => s.field(info.name, &self.1.get_typed::(i).unwrap()), x if x == U64 => s.field(info.name, &self.1.get_typed::(i).unwrap()), + x if x == I64 => s.field(info.name, &self.1.get_typed::(i).unwrap()), _ => { nonexhaustive = true; &mut s diff --git a/common/object/src/json.rs b/common/object/src/json.rs index c2ee678..0aa4cbd 100644 --- a/common/object/src/json.rs +++ b/common/object/src/json.rs @@ -21,31 +21,19 @@ pub fn object_to_json(reg: &Registry, ob: Object<'_>) -> Value { }; let key = info.name.to_string(); - match ty { - x if x == STR => { - let val = ob.get_typed::<&str>(i).unwrap().to_string().into(); - multi_insert(&mut o, key, val); - } - x if x == OBJECT => { - let val = object_to_json(reg, ob.get_typed::(i).unwrap()); - multi_insert(&mut o, key, val); - } - x if x == U32 => { - let val = ob.get_typed::(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == U64 => { - let val = ob.get_typed::(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == F64 => { - let val = ob.get_typed::(i).unwrap().into(); - multi_insert(&mut o, key, val); - } + let val = match ty { + x if x == STR => ob.get_typed::<&str>(i).unwrap().to_string().into(), + x if x == OBJECT => object_to_json(reg, ob.get_typed::(i).unwrap()), + x if x == U32 => ob.get_typed::(i).unwrap().into(), + x if x == U64 => ob.get_typed::(i).unwrap().into(), + x if x == I64 => ob.get_typed::(i).unwrap().into(), + x if x == F64 => ob.get_typed::(i).unwrap().into(), _ => { nonexhaustive = true; + continue; } }; + multi_insert(&mut o, key, val); } if nonexhaustive { o.insert("_nonexhaustive".to_owned(), Value::Bool(true)); diff --git a/common/object/src/registry.rs b/common/object/src/registry.rs index f3ed7df..5f1f36e 100644 --- a/common/object/src/registry.rs +++ b/common/object/src/registry.rs @@ -16,6 +16,7 @@ pub mod types { pub const BINARY: TypeId = TypeId::of::<&[u8]>(); pub const U32: TypeId = TypeId::of::(); pub const U64: TypeId = TypeId::of::(); + pub const I64: TypeId = TypeId::of::(); pub const F64: TypeId = TypeId::of::(); } diff --git a/common/object/src/value.rs b/common/object/src/value.rs index 086f2fd..733e3a0 100644 --- a/common/object/src/value.rs +++ b/common/object/src/value.rs @@ -123,7 +123,7 @@ impl ValueStore for f64 { impl Value<'_> for i64 { const ALIGNED: bool = true; fn load_aligned(buf: &[u32]) -> Option { - u32::load_aligned(buf).map(|x| x as i64) + u64::load_aligned(buf).map(|x| x as i64) } } impl ValueStore for i64 { -- cgit v1.3