From 9633992493bffe90c1b2fd00be602f707beafca9 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 9 Jul 2024 14:54:01 -0400 Subject: fix!: integers are signed by default --- generator/src/main.rs | 6 ++++-- generator/src/methods.rs | 6 ++++-- generator/src/structs.rs | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'generator') diff --git a/generator/src/main.rs b/generator/src/main.rs index 5d9d2c7..f69df2d 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -94,8 +94,10 @@ fn schema_type_name( } .to_string(), Primitive::Integer => match schema.format.as_deref() { - Some("int32") => "u32", - Some("int64") => "u64", + Some("uint32") => "u32", + Some("uint64") => "u64", + Some("int32") => "i32", + Some("int64") => "i64", _ => "u32", } .to_string(), diff --git a/generator/src/methods.rs b/generator/src/methods.rs index 6877437..75bb7db 100644 --- a/generator/src/methods.rs +++ b/generator/src/methods.rs @@ -222,8 +222,10 @@ pub fn param_type_inner( } .into(), ParameterType::Integer => match format.as_deref() { - Some("int32") => "u32", - Some("int64") => "u64", + Some("uint32") => "u32", + Some("uint64") => "u64", + Some("int32") => "i32", + Some("int64") => "i64", _ => "u32", } .into(), diff --git a/generator/src/structs.rs b/generator/src/structs.rs index 6a74dc1..4bd4418 100644 --- a/generator/src/structs.rs +++ b/generator/src/structs.rs @@ -547,12 +547,18 @@ fn create_header_struct( } }, ParameterType::Integer => match header.format.as_deref() { - Some("int64") => { + Some("uint64") => { imp.push_str("s.parse::().map_err(|_| StructureError::HeaderParseFailed)") } - Some("int32") | _ => { + Some("uint32") => { imp.push_str("s.parse::().map_err(|_| StructureError::HeaderParseFailed)") } + Some("int64") => { + imp.push_str("s.parse::().map_err(|_| StructureError::HeaderParseFailed)") + } + Some("int32") | _ => { + imp.push_str("s.parse::().map_err(|_| StructureError::HeaderParseFailed)") + } }, ParameterType::Boolean => { imp.push_str("s.parse::().map_err(|_| StructureError::HeaderParseFailed)") @@ -584,8 +590,10 @@ fn create_header_struct( Some("double") | _ => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", }, ParameterType::Integer => match items.format.as_deref() { - Some("int64") => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", - Some("int32") | _ => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", + Some("uint64") => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", + Some("uint32") => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", + Some("int64") => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", + Some("int32") | _ => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", }, ParameterType::Boolean => "s.parse::()).collect::, _>>().map_err(|_| StructureError::HeaderParseFailed)", ParameterType::Array => eyre::bail!("nested arrays not supported in headers"), -- cgit v1.2.3