From 765357e0d65c3f869344d8e86321fbed72edbcd6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 8 Aug 2026 23:06:06 +0100 Subject: Support nested constructed native types in java-transient-0 --- .../data/transient0/HobgoblinTransient0Data.java | 41 +++++++++++++++++++++- .../15-transient-0/output/rust/src/gen/data.rs | 1 + .../output/rust/src/gen/data/transient_0.rs | 4 ++- 3 files changed, 44 insertions(+), 2 deletions(-) (limited to 'examples/15-transient-0/output') diff --git a/examples/15-transient-0/output/java/src/main/java/org/zwobble/example/types/data/transient0/HobgoblinTransient0Data.java b/examples/15-transient-0/output/java/src/main/java/org/zwobble/example/types/data/transient0/HobgoblinTransient0Data.java index 0044a4a..1eea54c 100644 --- a/examples/15-transient-0/output/java/src/main/java/org/zwobble/example/types/data/transient0/HobgoblinTransient0Data.java +++ b/examples/15-transient-0/output/java/src/main/java/org/zwobble/example/types/data/transient0/HobgoblinTransient0Data.java @@ -276,11 +276,13 @@ public final class HobgoblinTransient0Data { public static void encodeStructWithGenericNative(org.zwobble.example.types.data.StructWithGenericNative value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.encodeGenericNative(value.a(), outputStream, sharedValues, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::encodeInt32, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::encodeString); + org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.encodeGenericNative(value.b(), outputStream, sharedValues, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::encode$constructedType$0, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::encode$constructedType$1); } public static org.zwobble.example.types.data.StructWithGenericNative decodeStructWithGenericNative(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { var a = org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.decodeGenericNative(inputStream, sharedValues, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::decodeInt32, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::decodeString); - return new org.zwobble.example.types.data.StructWithGenericNative(a); + var b = org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.decodeGenericNative(inputStream, sharedValues, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::decode$constructedType$0, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::decode$constructedType$1); + return new org.zwobble.example.types.data.StructWithGenericNative(a, b); } public static void encodeStructWithBox(org.zwobble.example.types.data.StructWithBox value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { @@ -498,6 +500,43 @@ public final class HobgoblinTransient0Data { return new org.zwobble.example.types.data.StructWithSharedSumAndVariant(a, b); } + private static void encode$constructedType$0(java.util.Optional value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { + org.zwobble.example.types.transient0.HobgoblinTransient0Builtins.encodeBool(value.isPresent(), outputStream, sharedValues); + if (value.isPresent()) { + org.zwobble.example.types.transient0.HobgoblinTransient0Builtins.encodeString(value.get(), outputStream, sharedValues); + } + } + + private static java.util.Optional decode$constructedType$0(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { + var value$isPresent = org.zwobble.example.types.transient0.HobgoblinTransient0Builtins.decodeBool(inputStream, sharedValues); + java.util.Optional value; + if (value$isPresent) { + var value$element = org.zwobble.example.types.transient0.HobgoblinTransient0Builtins.decodeString(inputStream, sharedValues); + value = java.util.Optional.of(value$element); + } else { + value = java.util.Optional.empty(); + } + return value; + } + + private static void encode$constructedType$1(org.zwobble.example.types.data.GenericNative, org.zwobble.example.types.data.GenericNative> value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { + org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.encodeGenericNative(value, outputStream, sharedValues, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::encode$constructedType$0, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::encode$constructedType$2); + } + + private static org.zwobble.example.types.data.GenericNative, org.zwobble.example.types.data.GenericNative> decode$constructedType$1(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { + var value = org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.decodeGenericNative(inputStream, sharedValues, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::decode$constructedType$0, org.zwobble.example.types.data.transient0.HobgoblinTransient0Data::decode$constructedType$2); + return value; + } + + private static void encode$constructedType$2(org.zwobble.example.types.data.GenericNative value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { + org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.encodeGenericNative(value, outputStream, sharedValues, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::encodeString, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::encodeString); + } + + private static org.zwobble.example.types.data.GenericNative decode$constructedType$2(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { + var value = org.zwobble.example.types.data.transient0.HobgoblinTransient0Data.decodeGenericNative(inputStream, sharedValues, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::decodeString, org.zwobble.example.types.transient0.HobgoblinTransient0Builtins::decodeString); + return value; + } + // Custom area start: org.zwobble.example.types.data.transient0.HobgoblinTransient0Data body public static void encodeNative( Native value, diff --git a/examples/15-transient-0/output/rust/src/gen/data.rs b/examples/15-transient-0/output/rust/src/gen/data.rs index 856d60f..6f1d5b5 100644 --- a/examples/15-transient-0/output/rust/src/gen/data.rs +++ b/examples/15-transient-0/output/rust/src/gen/data.rs @@ -124,6 +124,7 @@ pub struct StructWithNative { #[derive(Clone, Debug, Hash, PartialEq)] pub struct StructWithGenericNative { pub a: crate::data::GenericNative::<::core::primitive::i32, ::std::string::String>, + pub b: crate::data::GenericNative::<::std::option::Option::<::std::string::String>, crate::data::GenericNative::<::std::option::Option::<::std::string::String>, crate::data::GenericNative::<::std::string::String, ::std::string::String>>>, } #[derive(Clone, Debug, Hash, PartialEq)] diff --git a/examples/15-transient-0/output/rust/src/gen/data/transient_0.rs b/examples/15-transient-0/output/rust/src/gen/data/transient_0.rs index c497b57..383a564 100644 --- a/examples/15-transient-0/output/rust/src/gen/data/transient_0.rs +++ b/examples/15-transient-0/output/rust/src/gen/data/transient_0.rs @@ -275,13 +275,15 @@ pub fn decode_struct_with_native(reader: &mut impl std::io::Read, shared_values: } pub fn encode_struct_with_generic_native(value: &crate::data::StructWithGenericNative, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> { + todo!(); todo!(); ::std::io::Result::Ok(()) } pub fn decode_struct_with_generic_native(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::>) -> ::std::io::Result:: { let a = todo!(); - ::std::io::Result::Ok(crate::data::StructWithGenericNative { a: a }) + let b = todo!(); + ::std::io::Result::Ok(crate::data::StructWithGenericNative { a: a, b: b }) } pub fn encode_struct_with_box(value: &crate::data::StructWithBox, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> { -- cgit v1.2.3