javonet-ruby-sdk 2.6.11 → 2.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/javonet-ruby-sdk/Binaries/Jvm/JavonetJvmRuntime.jar +0 -0
  4. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetActivationService.so +0 -0
  5. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetCppRuntimeNative.so +0 -0
  6. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetGoRuntimeNative.so +0 -0
  7. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetJvmRuntimeNative.so +0 -0
  8. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetNetcoreRuntimeNative.so +0 -0
  9. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetPhpRuntimeNative.so +0 -0
  10. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetPythonRuntimeNative.so +0 -0
  11. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libJavonetRubyRuntimeNative.so +0 -0
  12. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/libUtils.so +0 -0
  13. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/ARM64/version.txt +1 -1
  14. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetActivationService.so +0 -0
  15. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetCppRuntimeNative.so +0 -0
  16. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetGoRuntimeNative.so +0 -0
  17. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetJvmRuntimeNative.so +0 -0
  18. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetNetcoreRuntimeNative.so +0 -0
  19. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetNodejsRuntimeNative.so +0 -0
  20. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetPerlRuntimeNative.so +0 -0
  21. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetPhpRuntimeNative.so +0 -0
  22. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetPython2RuntimeNative.so +0 -0
  23. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetPythonRuntimeNative.so +0 -0
  24. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libJavonetRubyRuntimeNative.so +0 -0
  25. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/libUtils.so +0 -0
  26. data/lib/javonet-ruby-sdk/Binaries/Native/Linux/X64/version.txt +1 -1
  27. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetActivationService.dylib +0 -0
  28. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetCppRuntimeNative.dylib +0 -0
  29. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetGoRuntimeNative.dylib +0 -0
  30. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetJvmRuntimeNative.dylib +0 -0
  31. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetNetcoreRuntimeNative.dylib +0 -0
  32. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetPythonRuntimeNative.dylib +0 -0
  33. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libJavonetRubyRuntimeNative.dylib +0 -0
  34. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/libUtils.dylib +0 -0
  35. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/ARM64/version.txt +1 -1
  36. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetActivationService.dylib +0 -0
  37. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetCppRuntimeNative.dylib +0 -0
  38. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetGoRuntimeNative.dylib +0 -0
  39. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetJvmRuntimeNative.dylib +0 -0
  40. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetNetcoreRuntimeNative.dylib +0 -0
  41. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetNodejs2218RuntimeNative.dylib +0 -0
  42. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetNodejsRuntimeNative.dylib +0 -0
  43. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetPerlRuntimeNative.dylib +0 -0
  44. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetPhpRuntimeNative.dylib +0 -0
  45. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetPythonRuntimeNative.dylib +0 -0
  46. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libJavonetRubyRuntimeNative.dylib +0 -0
  47. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/libUtils.dylib +0 -0
  48. data/lib/javonet-ruby-sdk/Binaries/Native/MacOs/X64/version.txt +1 -1
  49. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/Configs.dll +0 -0
  50. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetActivationService.dll +0 -0
  51. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetCppRuntimeNative.dll +0 -0
  52. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetGoRuntimeNative.dll +0 -0
  53. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetJvmRuntimeNative.dll +0 -0
  54. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetNetcoreRuntimeNative.dll +0 -0
  55. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetPhpRuntimeNative.dll +0 -0
  56. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetPythonRuntimeNative.dll +0 -0
  57. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetRubyRuntimeNative.dll +0 -0
  58. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetTcpClient.dll +0 -0
  59. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/JavonetTcpTlsClient.dll +0 -0
  60. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/Utils.dll +0 -0
  61. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/ARM64/version.txt +0 -0
  62. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/Configs.dll +0 -0
  63. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetActivationService.dll +0 -0
  64. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetClrRuntimeNative.dll +0 -0
  65. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetCppRuntimeNative.dll +0 -0
  66. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetGoRuntimeNative.dll +0 -0
  67. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetJvmRuntimeNative.dll +0 -0
  68. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetNetcoreRuntimeNative.dll +0 -0
  69. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetNodejs2218RuntimeNative.dll +0 -0
  70. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetNodejsRuntimeNative.dll +0 -0
  71. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetPerlRuntimeNative.dll +0 -0
  72. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetPhp848RuntimeNative.dll +0 -0
  73. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetPhpRuntimeNative.dll +0 -0
  74. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetPython2RuntimeNative.dll +0 -0
  75. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetPythonRuntimeNative.dll +0 -0
  76. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetRubyRuntimeNative.dll +0 -0
  77. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetTcpClient.dll +0 -0
  78. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/JavonetTcpTlsClient.dll +0 -0
  79. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/Utils.dll +0 -0
  80. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X64/version.txt +1 -1
  81. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/Configs.dll +0 -0
  82. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetActivationService.dll +0 -0
  83. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetClrRuntimeNative.dll +0 -0
  84. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetCppRuntimeNative.dll +0 -0
  85. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetGoRuntimeNative.dll +0 -0
  86. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetJvmRuntimeNative.dll +0 -0
  87. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetNetcoreRuntimeNative.dll +0 -0
  88. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetPhpRuntimeNative.dll +0 -0
  89. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetPython2RuntimeNative.dll +0 -0
  90. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetPythonRuntimeNative.dll +0 -0
  91. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetTcpClient.dll +0 -0
  92. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/JavonetTcpTlsClient.dll +0 -0
  93. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/Utils.dll +0 -0
  94. data/lib/javonet-ruby-sdk/Binaries/Native/Windows/X86/version.txt +1 -1
  95. data/lib/javonet-ruby-sdk/Binaries/Netcore/Javonet.Netcore.Core.dll +0 -0
  96. data/lib/javonet-ruby-sdk/Binaries/Netcore/Javonet.Netcore.Plugins.dll +0 -0
  97. data/lib/javonet-ruby-sdk/Binaries/Netcore/Javonet.Netcore.Utils.dll +0 -0
  98. data/lib/javonet-ruby-sdk/Binaries/Nodejs/dist/sdk/InvocationContext.cjs +1 -11
  99. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Class/Load/XS/XS.so +0 -0
  100. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Data/UUID/UUID.so +0 -0
  101. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/FFI/Platypus/Platypus.so +0 -0
  102. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/List/Util/Util.so +0 -0
  103. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Moose/Moose.so +0 -0
  104. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/PPI/XS/XS.so +0 -0
  105. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Package/Stash/XS/XS.so +0 -0
  106. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Params/Util/Util.so +0 -0
  107. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/Want/Want.so +0 -0
  108. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/auto/share/dist/FFI-Platypus/lib/libplfill.so +0 -0
  109. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/x86_64-linux-gnu-thread-multi/perllocal.pod +93 -93
  110. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/lib/Javonet/Core/Exception/SdkExceptionHelper.pm +3 -3
  111. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/lib/Javonet/Core/Protocol/CommandDeserializer.pm +239 -183
  112. data/lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/lib/Javonet/Core/Protocol/CommandSerializer.pm +62 -51
  113. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/auto/Data/UUID/UUID.xs.dll +0 -0
  114. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/auto/PPI/XS/XS.xs.dll +0 -0
  115. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/auto/Scalar/Util/Numeric/Numeric.xs.dll +0 -0
  116. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/auto/Want/Want.xs.dll +0 -0
  117. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/auto/autobox/autobox.xs.dll +0 -0
  118. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/MSWin32-x64-multi-thread/perllocal.pod +25 -25
  119. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/lib/Javonet/Core/Exception/SdkExceptionHelper.pm +3 -3
  120. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/lib/Javonet/Core/Protocol/CommandDeserializer.pm +239 -183
  121. data/lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/lib/Javonet/Core/Protocol/CommandSerializer.pm +62 -51
  122. data/lib/javonet-ruby-sdk/Binaries/Php/javonet/core/webSocketClient/WebSocketClient.php +77 -35
  123. data/lib/javonet-ruby-sdk/Binaries/Python2/javonet/core/handler/ArrayGetItemHandler.py +3 -6
  124. data/lib/javonet-ruby-sdk/Binaries/Python2/javonet/core/handler/ArraySetItemHandler.py +24 -3
  125. data/lib/javonet-ruby-sdk/Binaries/Python2/javonet/core/protocol/CommandDeserializer.py +134 -196
  126. data/lib/javonet-ruby-sdk/Binaries/Python2/javonet/core/protocol/CommandSerializer.py +29 -29
  127. data/lib/javonet-ruby-sdk/Binaries/version.txt +1 -1
  128. data/lib/javonet-ruby-sdk/sdk/invocation_context.rb +12 -16
  129. metadata +2 -2
@@ -40,7 +40,7 @@ sub send_exception_to_app_insights {
40
40
  }
41
41
  catch ( $e ) {
42
42
  $javonet_version = "2.0.0";
43
- }
43
+ };
44
44
 
45
45
  my $node_name = eval {hostname()} || "Unknown Host";
46
46
 
@@ -86,8 +86,8 @@ sub send_exception_to_app_insights {
86
86
  return $response_code;
87
87
  }
88
88
  catch ( $e ) {
89
- return Exception->new($e);
89
+ return 500;
90
90
  }
91
91
  }
92
92
 
93
- 1;
93
+ 1;
@@ -9,202 +9,258 @@ use aliased 'Javonet::Core::Protocol::TypeDeserializer' => 'TypeDeserializer';
9
9
  use Exporter qw(import);
10
10
  our @EXPORT = qw(deserialize);
11
11
 
12
- # Static deserialize method - takes byte array and returns Command
12
+ # Static deserialize method
13
13
  sub deserialize {
14
14
  my ($class, $byte_array_ref) = @_;
15
15
  my @buffer = ref $byte_array_ref eq 'ARRAY' ? @$byte_array_ref : @$byte_array_ref;
16
16
  my $position = 11; # Start position after header
17
+
17
18
  my $command = PerlCommand->new(
18
19
  runtime => $buffer[0],
19
20
  command_type => $buffer[10],
20
21
  payload => []
21
22
  );
22
23
 
23
- # Helper function to check if at end
24
- my $isAtEnd = sub {
25
- my $length = @buffer;
26
- return $position == $length;
27
- };
28
-
29
- # Define read functions first (they will be referenced by readObject and readCommand)
30
- my $readString = sub {
31
- my $p = $position;
32
- my $string_encoding_mode = $buffer[$p + 1];
33
- my @int_buffer = @buffer[$p + 2 .. $p + 5];
34
- my $size = TypeDeserializer->deserializeInt(\@int_buffer);
35
- $position += 6;
36
- $p = $position;
37
- $position += $size;
38
- my @string_buffer = @buffer[$p .. $p + $size - 1];
39
- my $decodedString = TypeDeserializer->deserializeString($string_encoding_mode, \@string_buffer);
40
- return $decodedString;
41
- };
42
-
43
- my $readInt = sub {
44
- $position += 2;
45
- my $p = $position;
46
- $position += 4;
47
- my @int_buffer = @buffer[$p .. $p + 3];
48
- return TypeDeserializer->deserializeInt(\@int_buffer);
49
- };
50
-
51
- my $readBool = sub {
52
- $position += 2;
53
- my $p = $position;
54
- $position += 1;
55
- my $bool_buffer = $buffer[$p];
56
- return TypeDeserializer->deserializeBool($bool_buffer);
57
- };
58
-
59
- my $readFloat = sub {
60
- $position += 2;
61
- my $p = $position;
62
- $position += 4;
63
- my @float_buffer = @buffer[$p .. $p + 3];
64
- return TypeDeserializer->deserializeFloat(\@float_buffer);
65
- };
66
-
67
- my $readByte = sub {
68
- $position += 2;
69
- my $p = $position;
70
- $position += 1;
71
- my $byte_buffer = $buffer[$p];
72
- return TypeDeserializer->deserializeByte($byte_buffer);
73
- };
74
-
75
- my $readChar = sub {
76
- $position += 2;
77
- my $p = $position;
78
- $position += 1;
79
- my $char_buffer = $buffer[$p];
80
- return TypeDeserializer->deserializeChar($char_buffer);
81
- };
82
-
83
- my $readLongLong = sub {
84
- $position += 2;
85
- my $p = $position;
86
- $position += 8;
87
- my @longlong_buffer = @buffer[$p .. $p + 7];
88
- return TypeDeserializer->deserializeLongLong(\@longlong_buffer);
89
- };
90
-
91
- my $readDouble = sub {
92
- $position += 2;
93
- my $p = $position;
94
- $position += 8;
95
- my @double_buffer = @buffer[$p .. $p + 7];
96
- return TypeDeserializer->deserializeDouble(\@double_buffer);
97
- };
98
-
99
- my $readUnsignedLongLong = sub {
100
- $position += 2;
101
- my $p = $position;
102
- $position += 8;
103
- my @ulonglong_buffer = @buffer[$p .. $p + 7];
104
- return TypeDeserializer->deserializeULongLong(\@ulonglong_buffer);
105
- };
106
-
107
- my $readUnsignedInt = sub {
108
- $position += 2;
109
- my $p = $position;
110
- $position += 4;
111
- my @uint_buffer = @buffer[$p .. $p + 3];
112
- return TypeDeserializer->deserializeUInt(\@uint_buffer);
113
- };
114
-
115
- my $readUndef = sub {
116
- $position += 2;
117
- my $p = $position;
118
- $position += 1;
119
- my $undef_buffer = $buffer[$p];
120
- return TypeDeserializer->deserializeUndef($undef_buffer);
121
- };
122
-
123
- # Declare readObject first for mutual recursion
124
- my $readObject;
125
-
126
- # Helper function to read command recursively (needs readObject)
127
- my $readCommandRecursively;
128
- $readCommandRecursively = sub {
129
- my ($numberOfArgumentInPayloadLeft, $cmd) = @_;
130
-
131
- if ($numberOfArgumentInPayloadLeft == 0) {
132
- return $cmd;
133
- }
134
- else {
135
- my $p = $position;
136
- my @int_buffer = @buffer[$p + 1 .. $p + 4];
137
- my $argSize = TypeDeserializer->deserializeInt(\@int_buffer);
138
- $cmd = $cmd->AddArgToPayload($readObject->($buffer[$p]));
139
- return $readCommandRecursively->($numberOfArgumentInPayloadLeft - 1, $cmd);
140
- }
141
- };
142
-
143
- # Helper function to read command (needs readCommandRecursively and readObject)
144
- my $readCommand = sub {
145
- my $p = $position;
146
- my @int_buffer = @buffer[$p + 1 .. $p + 4];
147
- my $numberOfArgumentInPayload = TypeDeserializer->deserializeInt(\@int_buffer);
148
- my $runtime = $buffer[$p + 5];
149
- my $commandType = $buffer[$p + 6];
150
-
151
- $position += 7;
152
- my $returnCommand = PerlCommand->new(runtime => $runtime, command_type => $commandType);
153
- return $readCommandRecursively->($numberOfArgumentInPayload, $returnCommand);
154
- };
155
-
156
- # Helper function to read object (references all read functions)
157
- $readObject = sub {
158
- my ($type_num) = @_;
159
- if ($type_num == Type->get_type('Command')) {
160
- return $readCommand->();
161
- }
162
- elsif ($type_num == Type->get_type('JavonetString')) {
163
- return $readString->();
164
- }
165
- elsif ($type_num == Type->get_type('JavonetInteger')) {
166
- return $readInt->();
167
- }
168
- elsif ($type_num == Type->get_type('JavonetBool')) {
169
- return $readBool->();
170
- }
171
- elsif ($type_num == Type->get_type('JavonetFloat')) {
172
- return $readFloat->();
173
- }
174
- elsif ($type_num == Type->get_type('JavonetByte')) {
175
- return $readByte->();
176
- }
177
- elsif ($type_num == Type->get_type('JavonetChar')) {
178
- return $readChar->();
179
- }
180
- elsif ($type_num == Type->get_type('JavonetLongLong')) {
181
- return $readLongLong->();
182
- }
183
- elsif ($type_num == Type->get_type('JavonetDouble')) {
184
- return $readDouble->();
185
- }
186
- elsif ($type_num == Type->get_type('JavonetUnsignedLongLong')) {
187
- return $readUnsignedLongLong->();
188
- }
189
- elsif ($type_num == Type->get_type('JavonetUnsignedInteger')) {
190
- return $readUnsignedInt->();
191
- }
192
- elsif ($type_num == Type->get_type('JavonetNull')) {
193
- return $readUndef->();
194
- }
195
- else {
196
- die "Type is not supported: $type_num";
197
- }
198
- };
199
-
200
-
201
- # Decode the command
202
- while (!$isAtEnd->()) {
203
- $command = $command->AddArgToPayload($readObject->($buffer[$position]));
204
- # Note: position is managed inside readObject and helper functions
24
+ # Use position reference to simulate ref parameter
25
+ my $position_ref = \$position;
26
+
27
+ while ($position < @buffer) {
28
+ $command = $command->AddArgToPayload(ReadObject(\@buffer, $position_ref));
205
29
  }
206
30
 
207
31
  return $command;
208
32
  }
209
33
 
34
+ # ReadObject
35
+ sub ReadObject {
36
+ my ($buffer_ref, $position_ref) = @_;
37
+ my @buffer = @$buffer_ref;
38
+ my $position = $$position_ref;
39
+
40
+ my $type = $buffer[$position];
41
+
42
+ if ($type == Type->get_type('Command')) {
43
+ return ReadCommand($buffer_ref, $position_ref);
44
+ }
45
+ elsif ($type == Type->get_type('JavonetString')) {
46
+ return ReadString($buffer_ref, $position_ref);
47
+ }
48
+ elsif ($type == Type->get_type('JavonetInteger')) {
49
+ return ReadInt($buffer_ref, $position_ref);
50
+ }
51
+ elsif ($type == Type->get_type('JavonetBool')) {
52
+ return ReadBool($buffer_ref, $position_ref);
53
+ }
54
+ elsif ($type == Type->get_type('JavonetFloat')) {
55
+ return ReadFloat($buffer_ref, $position_ref);
56
+ }
57
+ elsif ($type == Type->get_type('JavonetByte')) {
58
+ return ReadByte($buffer_ref, $position_ref);
59
+ }
60
+ elsif ($type == Type->get_type('JavonetChar')) {
61
+ return ReadChar($buffer_ref, $position_ref);
62
+ }
63
+ elsif ($type == Type->get_type('JavonetLongLong')) {
64
+ return ReadLong($buffer_ref, $position_ref);
65
+ }
66
+ elsif ($type == Type->get_type('JavonetDouble')) {
67
+ return ReadDouble($buffer_ref, $position_ref);
68
+ }
69
+ elsif ($type == Type->get_type('JavonetUnsignedLongLong')) {
70
+ return ReadULong($buffer_ref, $position_ref);
71
+ }
72
+ elsif ($type == Type->get_type('JavonetUnsignedInteger')) {
73
+ return ReadUInt($buffer_ref, $position_ref);
74
+ }
75
+ elsif ($type == Type->get_type('JavonetNull')) {
76
+ return ReadNull($buffer_ref, $position_ref);
77
+ }
78
+ else {
79
+ die "NotImplementedException: Type not supported: $type";
80
+ }
81
+ }
82
+
83
+ # ReadCommand
84
+ sub ReadCommand {
85
+ my ($buffer_ref, $position_ref) = @_;
86
+ my @buffer = @$buffer_ref;
87
+ my $p = $$position_ref;
88
+
89
+ # Read numberOfElements from bytes p+1 to p+4
90
+ my @int_buffer = @buffer[$p + 1 .. $p + 4];
91
+ my $numberOfElements = TypeDeserializer->deserializeInt(\@int_buffer);
92
+
93
+ my $runtime = $buffer[$p + 5];
94
+ my $commandType = $buffer[$p + 6];
95
+
96
+ $$position_ref += 7;
97
+
98
+ # Read all payload elements at once
99
+ my @payload = ();
100
+ for (my $i = 0; $i < $numberOfElements; $i++) {
101
+ push @payload, ReadObject($buffer_ref, $position_ref);
102
+ }
103
+
104
+ return PerlCommand->new(
105
+ runtime => $runtime,
106
+ command_type => $commandType,
107
+ payload => \@payload
108
+ );
109
+ }
110
+
111
+ # ReadString
112
+ sub ReadString {
113
+ my ($buffer_ref, $position_ref) = @_;
114
+ my @buffer = @$buffer_ref;
115
+ my $p = $$position_ref;
116
+
117
+ my $mode = $buffer[$p + 1];
118
+ my @int_buffer = @buffer[$p + 2 .. $p + 5];
119
+ my $size = TypeDeserializer->deserializeInt(\@int_buffer);
120
+
121
+ $$position_ref += 6;
122
+ $p = $$position_ref;
123
+ $$position_ref += $size;
124
+
125
+ my @string_buffer = @buffer[$p .. $p + $size - 1];
126
+ return TypeDeserializer->deserializeString($mode, \@string_buffer);
127
+ }
128
+
129
+ # ReadInt
130
+ sub ReadInt {
131
+ my ($buffer_ref, $position_ref) = @_;
132
+ my @buffer = @$buffer_ref;
133
+ my $size = 4;
134
+
135
+ $$position_ref += 2;
136
+ my $p = $$position_ref;
137
+ $$position_ref += $size;
138
+
139
+ my @int_buffer = @buffer[$p .. $p + $size - 1];
140
+ return TypeDeserializer->deserializeInt(\@int_buffer);
141
+ }
142
+
143
+ # ReadBool
144
+ sub ReadBool {
145
+ my ($buffer_ref, $position_ref) = @_;
146
+ my @buffer = @$buffer_ref;
147
+ my $size = 1;
148
+
149
+ $$position_ref += 2;
150
+ my $p = $$position_ref;
151
+ $$position_ref += $size;
152
+
153
+ return TypeDeserializer->deserializeBool($buffer[$p]);
154
+ }
155
+
156
+ # ReadFloat
157
+ sub ReadFloat {
158
+ my ($buffer_ref, $position_ref) = @_;
159
+ my @buffer = @$buffer_ref;
160
+ my $size = 4;
161
+
162
+ $$position_ref += 2;
163
+ my $p = $$position_ref;
164
+ $$position_ref += $size;
165
+
166
+ my @float_buffer = @buffer[$p .. $p + $size - 1];
167
+ return TypeDeserializer->deserializeFloat(\@float_buffer);
168
+ }
169
+
170
+ # ReadByte
171
+ sub ReadByte {
172
+ my ($buffer_ref, $position_ref) = @_;
173
+ my @buffer = @$buffer_ref;
174
+ my $size = 1;
175
+
176
+ $$position_ref += 2;
177
+ my $p = $$position_ref;
178
+ $$position_ref += $size;
179
+
180
+ return TypeDeserializer->deserializeByte($buffer[$p]);
181
+ }
182
+
183
+ # ReadChar
184
+ sub ReadChar {
185
+ my ($buffer_ref, $position_ref) = @_;
186
+ my @buffer = @$buffer_ref;
187
+ my $size = 1;
188
+
189
+ $$position_ref += 2;
190
+ my $p = $$position_ref;
191
+ $$position_ref += $size;
192
+
193
+ return TypeDeserializer->deserializeChar($buffer[$p]);
194
+ }
195
+
196
+ # ReadLong
197
+ sub ReadLong {
198
+ my ($buffer_ref, $position_ref) = @_;
199
+ my @buffer = @$buffer_ref;
200
+ my $size = 8;
201
+
202
+ $$position_ref += 2;
203
+ my $p = $$position_ref;
204
+ $$position_ref += $size;
205
+
206
+ my @longlong_buffer = @buffer[$p .. $p + $size - 1];
207
+ return TypeDeserializer->deserializeLongLong(\@longlong_buffer);
208
+ }
209
+
210
+ # ReadDouble
211
+ sub ReadDouble {
212
+ my ($buffer_ref, $position_ref) = @_;
213
+ my @buffer = @$buffer_ref;
214
+ my $size = 8;
215
+
216
+ $$position_ref += 2;
217
+ my $p = $$position_ref;
218
+ $$position_ref += $size;
219
+
220
+ my @double_buffer = @buffer[$p .. $p + $size - 1];
221
+ return TypeDeserializer->deserializeDouble(\@double_buffer);
222
+ }
223
+
224
+ # ReadULong
225
+ sub ReadULong {
226
+ my ($buffer_ref, $position_ref) = @_;
227
+ my @buffer = @$buffer_ref;
228
+ my $size = 8;
229
+
230
+ $$position_ref += 2;
231
+ my $p = $$position_ref;
232
+ $$position_ref += $size;
233
+
234
+ my @ulonglong_buffer = @buffer[$p .. $p + $size - 1];
235
+ return TypeDeserializer->deserializeULongLong(\@ulonglong_buffer);
236
+ }
237
+
238
+ # ReadUInt
239
+ sub ReadUInt {
240
+ my ($buffer_ref, $position_ref) = @_;
241
+ my @buffer = @$buffer_ref;
242
+ my $size = 4;
243
+
244
+ $$position_ref += 2;
245
+ my $p = $$position_ref;
246
+ $$position_ref += $size;
247
+
248
+ my @uint_buffer = @buffer[$p .. $p + $size - 1];
249
+ return TypeDeserializer->deserializeUInt(\@uint_buffer);
250
+ }
251
+
252
+ # ReadNull
253
+ sub ReadNull {
254
+ my ($buffer_ref, $position_ref) = @_;
255
+ my @buffer = @$buffer_ref;
256
+ my $size = 1;
257
+
258
+ $$position_ref += 2;
259
+ my $p = $$position_ref;
260
+ $$position_ref += $size;
261
+
262
+ # Note: deserializeUndef doesn't use the buffer, but we match C# structure
263
+ return TypeDeserializer->deserializeUndef();
264
+ }
265
+
210
266
  1;
@@ -8,81 +8,92 @@ use aliased 'Javonet::Sdk::Core::RuntimeLib' => 'RuntimeLib', qw(get_runtime);
8
8
  use aliased 'Javonet::Sdk::Core::Type' => 'Type', qw(get_type);
9
9
  use aliased 'Javonet::Core::Protocol::TypeSerializer' => 'TypeSerializer';
10
10
  use aliased 'Javonet::Sdk::Core::TypesHandler' => 'TypesHandler';
11
+ use aliased 'Javonet::Core::Handler::ReferencesCache' => 'ReferencesCache';
12
+ use aliased 'Javonet::Sdk::Core::PerlCommandType' => 'PerlCommandType';
11
13
  use Javonet::Sdk::Internal::ConnectionType;
12
- use Thread::Queue;
13
14
 
14
15
  use Exporter qw(import);
15
- our @EXPORT = qw(serialize serialize_tcp_address serialize_recursively insert_into_buffer);
16
-
17
- my @byte_buffer = ();
18
- my $queue = Thread::Queue->new();
16
+ our @EXPORT = qw(serialize serialize_connection_data);
19
17
 
20
18
  sub serialize {
21
19
  my ($class, $root_command, $connection_type, $tcp_address, $runtimeVersion) = @_;
22
- @byte_buffer = ();
23
- $queue = Thread::Queue->new();
24
- $queue->insert(0, $root_command);
25
- $class->insert_into_buffer(($root_command->{runtime}, $runtimeVersion));
26
- $class->insert_into_buffer($class->serialize_tcp_address($connection_type, $tcp_address));
27
- $class->insert_into_buffer(Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl'), $root_command->{command_type});
28
- $class->serialize_recursively();
20
+ $runtimeVersion = 0 unless defined $runtimeVersion;
21
+
22
+ # Local buffer instead of global
23
+ my @byte_buffer = ();
24
+
25
+ # Helper to insert data into buffer
26
+ my $insert_into_buffer = sub {
27
+ my (@data) = @_;
28
+ push @byte_buffer, @data;
29
+ };
30
+
31
+ # Write runtime and version
32
+ $insert_into_buffer->($root_command->{runtime}, $runtimeVersion);
33
+
34
+ # Write connection data
35
+ my @connection_data = $class->serialize_connection_data($connection_type, $tcp_address);
36
+ $insert_into_buffer->(@connection_data);
37
+
38
+ # Write runtime name and command type header for Perl runtime
39
+ $insert_into_buffer->(
40
+ Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl'),
41
+ $root_command->{command_type}
42
+ );
43
+
44
+ # Serialize payload recursively
45
+ $class->serialize_recursively($root_command, $insert_into_buffer);
46
+
29
47
  return @byte_buffer;
30
48
  }
31
49
 
32
- sub serialize_tcp_address {
50
+ sub serialize_connection_data {
33
51
  my ($class, $connection_type, $tcp_address) = @_;
34
- my @tcp_byte_array;
35
- if (Javonet::Sdk::Internal::ConnectionType::get_connection_type('Tcp') eq $connection_type) {
52
+ if (defined $connection_type &&
53
+ Javonet::Sdk::Internal::ConnectionType::get_connection_type('Tcp') eq $connection_type) {
36
54
  my @tcp_array = split(':', $tcp_address);
37
55
  my @tcp_ip = split('\\.', $tcp_array[0]);
38
56
  my @bytes_port = unpack "C*", pack "v", $tcp_array[1];
39
- @tcp_byte_array = (Javonet::Sdk::Internal::ConnectionType::get_connection_type('Tcp'), @tcp_ip, @bytes_port);
40
- return @tcp_byte_array;
57
+ return (Javonet::Sdk::Internal::ConnectionType::get_connection_type('Tcp'), @tcp_ip, @bytes_port);
41
58
  }
42
59
  else {
43
- @tcp_byte_array = (Javonet::Sdk::Internal::ConnectionType::get_connection_type('InMemory'), 0, 0, 0, 0, 0, 0);
44
- return @tcp_byte_array;
60
+ return (Javonet::Sdk::Internal::ConnectionType::get_connection_type('InMemory'), 0, 0, 0, 0, 0, 0);
45
61
  }
46
62
  }
47
63
 
64
+ # Recursively serialize command payload - matches C# SerializeRecursively
48
65
  sub serialize_recursively {
49
- my ($class) = @_;
50
- my $left = $queue->pending();
51
- if ($left == 0) {
52
- return @byte_buffer;
53
- }
54
- my $command = $queue->dequeue();
55
- $queue->insert(0, $command->drop_first_payload_argument());
56
- my $current_payload_ref = $command->{payload};
57
- my @cur_payload = @$current_payload_ref;
58
- my $payload_len = @cur_payload;
59
- if ($payload_len > 0) {
60
- if (!defined $cur_payload[0]) {
61
- $class->insert_into_buffer(TypeSerializer->serializePrimitive(undef));
66
+ my ($class, $command, $insert_into_buffer) = @_;
67
+
68
+ my $payload_ref = $command->{payload};
69
+ my @payload = @$payload_ref;
70
+
71
+ foreach my $item (@payload) {
72
+ if (defined $item && ref $item eq 'Javonet::Sdk::Core::PerlCommand') {
73
+ # Item is a Command - serialize it and recurse
74
+ my @command_bytes = TypeSerializer->serializeCommand($item);
75
+ $insert_into_buffer->(@command_bytes);
76
+ $class->serialize_recursively($item, $insert_into_buffer);
62
77
  }
63
- elsif ($cur_payload[0]->isa("Javonet::Sdk::Core::PerlCommand")) {
64
- my $inner_command = $cur_payload[0];
65
- $class->insert_into_buffer(TypeSerializer->serializeCommand($inner_command));
66
- $queue->insert(0, $inner_command);
67
- }
68
- elsif (TypesHandler->is_primitive_or_none($cur_payload[0])) {
69
- my @result = TypeSerializer->serializePrimitive($cur_payload[0]);
70
- $class->insert_into_buffer(@result);
78
+ elsif (TypesHandler->is_primitive_or_none($item)) {
79
+ # Item is primitive or null
80
+ my @primitive_bytes = TypeSerializer->serializePrimitive($item);
81
+ $insert_into_buffer->(@primitive_bytes);
71
82
  }
72
83
  else {
73
- die "Unsupported payload item type: " . ref($cur_payload[0]) . " for payload item: $cur_payload[0].";
84
+ # Item is a reference - cache it and create a Reference command
85
+ my $reference_cache = ReferencesCache->new();
86
+ my $guid = $reference_cache->cache_reference($item);
87
+ my $reference_command = PerlCommand->new(
88
+ runtime => Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl'),
89
+ command_type => PerlCommandType->get_command_type('Reference'),
90
+ payload => [$guid]
91
+ );
92
+ my @command_bytes = TypeSerializer->serializeCommand($reference_command);
93
+ $insert_into_buffer->(@command_bytes);
94
+ $class->serialize_recursively($reference_command, $insert_into_buffer);
74
95
  }
75
- return $class->serialize_recursively();
76
96
  }
77
- else {
78
- $queue->dequeue();
79
- }
80
- return $class->serialize_recursively();
81
- }
82
-
83
- sub insert_into_buffer {
84
- my ($class, @arguments) = @_;
85
- @byte_buffer = (@byte_buffer, @arguments);
86
97
  }
87
98
 
88
99
  1;