From 1b04aac096fe89c65507be5146d2a9bd5b32e991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Seidel?= Date: Fri, 21 Oct 2022 09:49:34 +0200 Subject: [PATCH] feat!: achieve TIAX compatibility --- src/Document/Deserializer.st | 7 ---- .../GetValues/Test_GetValues_Arrays.st | 6 ++-- .../Test_GetValues_BasicDataTypes.st | 2 +- .../Test_GetValues_NestedElements.st | 10 +++--- test/Deserializer/TestFindKeyInBuffer.st | 8 ++--- test/Deserializer/TryParse/Test_TryParse.st | 36 +++++++++---------- 6 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/Document/Deserializer.st b/src/Document/Deserializer.st index 7903692..557633b 100644 --- a/src/Document/Deserializer.st +++ b/src/Document/Deserializer.st @@ -7,13 +7,6 @@ NAMESPACE Simatic.Ax.Json VAR PUBLIC buffer : REF_TO ARRAY[*] OF CHAR; END_VAR - //Temp method until ref_to array* possible - METHOD PUBLIC SetBuffer - VAR_INPUT - _buffer : REF_TO ARRAY[*] OF CHAR; - END_VAR - buffer := _buffer; - END_METHOD METHOD PRIVATE KeyIsInIndexSpan : BOOL VAR_INPUT key : STRING; diff --git a/test/Deserializer/GetValues/Test_GetValues_Arrays.st b/test/Deserializer/GetValues/Test_GetValues_Arrays.st index 2837751..0dc1536 100644 --- a/test/Deserializer/GetValues/Test_GetValues_Arrays.st +++ b/test/Deserializer/GetValues/Test_GetValues_Arrays.st @@ -27,7 +27,7 @@ CLASS Test_Deserializer_GetValues_Arrays END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'arraykey'; keyFound := deserializer.TryParse( key, value); @@ -44,7 +44,7 @@ CLASS Test_Deserializer_GetValues_Arrays END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'arraykey'; keyFound := deserializer.TryParse( key, value); @@ -61,7 +61,7 @@ CLASS Test_Deserializer_GetValues_Arrays END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'arraykey'; keyFound := deserializer.TryParse( key, value); diff --git a/test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st b/test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st index 6db743a..01f5114 100644 --- a/test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st +++ b/test/Deserializer/GetValues/Test_GetValues_BasicDataTypes.st @@ -27,7 +27,7 @@ CLASS Test_Deserializer_GetValues_BasicDataTypes END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); //TODO: ausbauen und ersetzen durch buffer in methode + deserializer.buffer := REF(buffer); key := 'key'; keyFound := deserializer.TryParse( key, value); diff --git a/test/Deserializer/GetValues/Test_GetValues_NestedElements.st b/test/Deserializer/GetValues/Test_GetValues_NestedElements.st index 982de6c..585b514 100644 --- a/test/Deserializer/GetValues/Test_GetValues_NestedElements.st +++ b/test/Deserializer/GetValues/Test_GetValues_NestedElements.st @@ -27,7 +27,7 @@ CLASS Test_Deserializer_GetValues_NestedElements END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); //TODO: ausbauen und ersetzen durch buffer in methode + deserializer.buffer := REF(buffer); key := 'arraykey'; keyFound := deserializer.TryParse( key, value); @@ -44,7 +44,7 @@ CLASS Test_Deserializer_GetValues_NestedElements END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key'; keyFound := deserializer.TryParse( key, value); @@ -66,7 +66,7 @@ CLASS Test_Deserializer_GetValues_NestedElements END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key'; keyFound := deserializer.TryParse( key, value); @@ -88,7 +88,7 @@ CLASS Test_Deserializer_GetValues_NestedElements END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key'; keyFound := deserializer.TryParse( key, value); @@ -110,7 +110,7 @@ CLASS Test_Deserializer_GetValues_NestedElements END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key'; keyFound := deserializer.TryParse( key, value); diff --git a/test/Deserializer/TestFindKeyInBuffer.st b/test/Deserializer/TestFindKeyInBuffer.st index bdf33ea..cd7927a 100644 --- a/test/Deserializer/TestFindKeyInBuffer.st +++ b/test/Deserializer/TestFindKeyInBuffer.st @@ -31,7 +31,7 @@ CLASS Test_FindKeyInBuffer END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key '; keyFound := deserializer.TryParse( key, value); @@ -58,7 +58,7 @@ CLASS Test_FindKeyInBuffer END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'nested'; keyFound := deserializer.TryParse( key, value); @@ -77,7 +77,7 @@ CLASS Test_FindKeyInBuffer END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'key '; keyFound := deserializer.TryParse( key, value); @@ -104,7 +104,7 @@ CLASS Test_FindKeyInBuffer END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key := 'simpleArray'; keyFound := deserializer.TryParse( key, value); diff --git a/test/Deserializer/TryParse/Test_TryParse.st b/test/Deserializer/TryParse/Test_TryParse.st index db7ef17..7f8540a 100644 --- a/test/Deserializer/TryParse/Test_TryParse.st +++ b/test/Deserializer/TryParse/Test_TryParse.st @@ -24,7 +24,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal('{"nestedkey1": 123}', value); @@ -41,7 +41,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal('123', value); @@ -58,7 +58,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); key:= 'leftBoundary'; keyFound := deserializer.TryParse( key, value); @@ -90,7 +90,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(123, value); @@ -107,7 +107,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(-128, value); @@ -124,7 +124,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(123, value); @@ -141,7 +141,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(1234, value); @@ -158,7 +158,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(123, value); @@ -175,7 +175,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(1234, value); @@ -192,7 +192,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(123, value); @@ -209,7 +209,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(USINT#123, value); @@ -226,7 +226,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(123, value); @@ -243,7 +243,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(UINT#1234, value); @@ -260,7 +260,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(UINT#123, value); @@ -277,7 +277,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(UDINT#1234, value); @@ -294,7 +294,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(UDINT#123, value); @@ -311,7 +311,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( key, value); Equal(ULINT#1234, value); @@ -328,7 +328,7 @@ CLASS TryParse END_VAR len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); - deserializer.SetBuffer(REF(buffer)); + deserializer.buffer := REF(buffer); keyFound := deserializer.TryParse( keyArray, value); Equal(ULINT#123, value);