From 2ef69dc166e425acc08c605292115e16ec52e317 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:20:08 -0800 Subject: [PATCH 1/2] Make unit/void case explicit and support more tuples in union spec --- Stellar-contract-spec.x | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Stellar-contract-spec.x b/Stellar-contract-spec.x index 56c3adf..4dac71f 100644 --- a/Stellar-contract-spec.x +++ b/Stellar-contract-spec.x @@ -135,11 +135,31 @@ struct SCSpecUDTStructV0 SCSpecUDTStructFieldV0 fields<40>; }; -struct SCSpecUDTUnionCaseV0 +struct SCSpecUDTUnionCaseVoidV0 { string doc; string name<60>; - SCSpecTypeDef *type; +}; + +struct SCSpecUDTUnionCaseTupleV0 +{ + string doc; + string name<60>; + SCSpecTypeDef type<12>; +}; + +enum SCSpecUDTUnionCaseV0Kind +{ + SC_SPEC_UDT_UNION_CASE_VOID_V0 = 0, + SC_SPEC_UDT_UNION_CASE_TUPLE_V0 = 1, +}; + +union SCSpecUDTUnionCaseV0 switch (SCSpecUDTUnionCaseV0Kind kind) +{ +case SC_SPEC_UDT_UNION_CASE_VOID_V0: + SCSpecUDTUnionCaseVoidV0 void; +case SC_SPEC_UDT_UNION_CASE_TUPLE_V0: + SCSpecUDTUnionCaseTupleV0 tuple; }; struct SCSpecUDTUnionV0 From 3a6327df8b53dc8d742852ab8856ea55653c395c Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:02:10 -0800 Subject: [PATCH 2/2] avoid void --- Stellar-contract-spec.x | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Stellar-contract-spec.x b/Stellar-contract-spec.x index 4dac71f..468146a 100644 --- a/Stellar-contract-spec.x +++ b/Stellar-contract-spec.x @@ -157,9 +157,9 @@ enum SCSpecUDTUnionCaseV0Kind union SCSpecUDTUnionCaseV0 switch (SCSpecUDTUnionCaseV0Kind kind) { case SC_SPEC_UDT_UNION_CASE_VOID_V0: - SCSpecUDTUnionCaseVoidV0 void; + SCSpecUDTUnionCaseVoidV0 voidCase; case SC_SPEC_UDT_UNION_CASE_TUPLE_V0: - SCSpecUDTUnionCaseTupleV0 tuple; + SCSpecUDTUnionCaseTupleV0 tupleCase; }; struct SCSpecUDTUnionV0