diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-17 16:25:05 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-17 16:25:05 +0100 |
| commit | 384789a6bb24bee810684a39bb60b2e1389ec154 (patch) | |
| tree | f48b3131c7facc31a7dd97a4ef27fe3a331c0600 /common | |
| parent | 9a8d337f60541cec09917dbf4741992715a8edaf (diff) | |
| download | jellything-384789a6bb24bee810684a39bb60b2e1389ec154.tar jellything-384789a6bb24bee810684a39bb60b2e1389ec154.tar.bz2 jellything-384789a6bb24bee810684a39bb60b2e1389ec154.tar.zst | |
i64 json/debug support
Diffstat (limited to 'common')
| -rw-r--r-- | common/object/src/inspect.rs | 1 | ||||
| -rw-r--r-- | common/object/src/json.rs | 30 | ||||
| -rw-r--r-- | common/object/src/registry.rs | 1 | ||||
| -rw-r--r-- | common/object/src/value.rs | 2 |
4 files changed, 12 insertions, 22 deletions
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::<Object>(i).unwrap()), x if x == U32 => s.field(info.name, &self.1.get_typed::<u32>(i).unwrap()), x if x == U64 => s.field(info.name, &self.1.get_typed::<u64>(i).unwrap()), + x if x == I64 => s.field(info.name, &self.1.get_typed::<i64>(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::<Object>(i).unwrap()); - multi_insert(&mut o, key, val); - } - x if x == U32 => { - let val = ob.get_typed::<u32>(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == U64 => { - let val = ob.get_typed::<u64>(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == F64 => { - let val = ob.get_typed::<f64>(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::<Object>(i).unwrap()), + x if x == U32 => ob.get_typed::<u32>(i).unwrap().into(), + x if x == U64 => ob.get_typed::<u64>(i).unwrap().into(), + x if x == I64 => ob.get_typed::<i64>(i).unwrap().into(), + x if x == F64 => ob.get_typed::<f64>(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::<u32>(); pub const U64: TypeId = TypeId::of::<u64>(); + pub const I64: TypeId = TypeId::of::<i64>(); pub const F64: TypeId = TypeId::of::<f64>(); } 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<Self> { - u32::load_aligned(buf).map(|x| x as i64) + u64::load_aligned(buf).map(|x| x as i64) } } impl ValueStore for i64 { |