divine 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/README.md +285 -2
- data/divine.gemspec +2 -2
- data/lib/divine.rb +0 -0
- data/lib/divine/code_generators/code_generator.rb +0 -0
- data/lib/divine/code_generators/csharp.rb +24 -50
- data/lib/divine/code_generators/java.rb +22 -28
- data/lib/divine/code_generators/javascript.rb +19 -33
- data/lib/divine/code_generators/ruby.rb +17 -34
- data/lib/divine/dsl.rb +47 -8
- data/lib/divine/graph_generator/graph_generator.rb +0 -0
- data/lib/divine/version.rb +1 -1
- data/test/basic_complex_test/basic_complex_test.rb +0 -0
- data/test/basic_complex_test/java_test/JavaTest.java +0 -0
- data/test/basic_complex_test/js_test/js_testBasic.js +1 -5
- data/test/basic_complex_test/js_test/js_testComplex.js +1 -5
- data/test/basic_complex_test/ruby_test/ruby_test.rb +0 -0
- data/test/binaryTree_test/binaryTree_test.rb +1 -0
- data/test/binaryTree_test/csharp_test/csharp_test.cs +8 -0
- data/test/binaryTree_test/graph.png +0 -0
- data/test/binaryTree_test/java_test/JavaTest.java +9 -0
- data/test/binaryTree_test/js_test/js_test.js +9 -5
- data/test/binaryTree_test/ruby_test/ruby_test.rb +10 -2
- data/test/complex_test/complex_test.rb +0 -0
- data/test/complex_test/csharp_test/csharp_test.cs +0 -0
- data/test/complex_test/graph.png +0 -0
- data/test/complex_test/java_test/JavaTest.java +0 -0
- data/test/complex_test/js_test/js_test.js +1 -5
- data/test/complex_test/ruby_test/ruby_test.rb +0 -0
- data/test/dynamic_int_test/csharp_test/csharp_test.cs +0 -0
- data/test/dynamic_int_test/dynamic_int_test.rb +0 -0
- data/test/dynamic_int_test/java_test/JavaTest.java +0 -0
- data/test/dynamic_int_test/js_test/js_test.js +1 -5
- data/test/dynamic_int_test/ruby_test/ruby_test.rb +0 -0
- data/test/ipv6_test/csharp_test/csharp_test.cs +0 -0
- data/test/ipv6_test/ipv6_test.rb +0 -0
- data/test/ipv6_test/java_test/JavaTest.java +0 -0
- data/test/ipv6_test/js_test/js_test.js +1 -5
- data/test/ipv6_test/ruby_test/ruby_test.rb +0 -0
- data/test/lib/csharp/nunit.framework.dll +0 -0
- data/test/lib/java/junit.jar +0 -0
- data/test/signed_int_test/csharp_test/csharp_test.cs +0 -0
- data/test/signed_int_test/java_test/JavaTest.java +0 -0
- data/test/signed_int_test/js_test/js_test.js +1 -5
- data/test/signed_int_test/ruby_test/ruby_test.rb +0 -0
- data/test/signed_int_test/signed_int_test.rb +0 -0
- data/test/unify_test/unify_test.rb +0 -0
- metadata +18 -34
- data/test/basic_complex_test/graph.jpg +0 -0
- data/test/dynamic_int_test/graph.jpg +0 -0
- data/test/ipv6_test/graph.jpg +0 -0
- data/test/signed_int_test/graph.jpg +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 586169794d6b8461baab4af10ef57a52e178039a
|
4
|
+
data.tar.gz: 3939d4f5eb57f2b3a30f272044f7dd74ef46a4cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9624587d78882b3d5b0cd6e6c730c4ebfc907673d648d23ed8b9a3e0e213435cc9c5fbfcb7255257fa5151471fd4bcace450a6f485bbc50744ddaabb2495ac5
|
7
|
+
data.tar.gz: d73c7a67534c01c66fa1832269d926c4c4c9195acc1bfc9b293cc6430010fa9006fe438a93be9515e836c357b5b8949e4ebacf6d6f8f518779ef5b9926f68847
|
data/.gitignore
CHANGED
@@ -31,7 +31,14 @@ test/binaryTree_test/js_test/test_binaryTree.js
|
|
31
31
|
test/complex_test/js_test/test_complex.js
|
32
32
|
test/ipv6_test/js_test/test_ipv6.js
|
33
33
|
test/signed_int_test/js_test/test_signed_int.js
|
34
|
+
test/binaryTree_test/csharp_test/test_binaryTree.cs
|
35
|
+
test/complex_test/csharp_test/test_complex.cs
|
36
|
+
test/dynamic_int_test/csharp_test/test_dynamic_int.cs
|
37
|
+
test/ipv6_test/csharp_test/test_ipv6.cs
|
38
|
+
test/signed_int_test/csharp_test/test_signed_int.cs
|
34
39
|
bin.babel
|
35
40
|
bin.babel.csharp
|
36
41
|
bin.babel.rb
|
37
42
|
bin.babel.js
|
43
|
+
*.jpg
|
44
|
+
.project
|
data/README.md
CHANGED
@@ -6,7 +6,105 @@ This software is still under active development and testing.
|
|
6
6
|
|
7
7
|
We support C#, Java, Ruby and Javascript at the moment.
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
## Supported types
|
11
|
+
|
12
|
+
<table>
|
13
|
+
<tr>
|
14
|
+
<th>Name</th>
|
15
|
+
<th>Range</th>
|
16
|
+
<th>Range (hex)</th>
|
17
|
+
<th>Description</th>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td>int8</td>
|
21
|
+
<td>0-255</td>
|
22
|
+
<td>0x00-0xFF</td>
|
23
|
+
<td>Unsinged integer stored in a singe byte</td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td>int16</td>
|
27
|
+
<td>0-65,535</td>
|
28
|
+
<td>0x00-0xFFFF</td>
|
29
|
+
<td>Unsinged integer stored in two bytes</td>
|
30
|
+
</tr>
|
31
|
+
<tr>
|
32
|
+
<td>int24</td>
|
33
|
+
<td>0-16,777,215</td>
|
34
|
+
<td>0x00-0xFFFFFF</td>
|
35
|
+
<td>Unsinged integer stored in three bytes</td>
|
36
|
+
</tr>
|
37
|
+
<tr>
|
38
|
+
<td>int32</td>
|
39
|
+
<td>0-4,294,967,295</td>
|
40
|
+
<td>0x00-0xFFFFFFFF</td>
|
41
|
+
<td>Unsinged integer stored in four bytes</td>
|
42
|
+
</tr>
|
43
|
+
<tr>
|
44
|
+
<td>dint63</td>
|
45
|
+
<td>0-9,223,372,036,854,775,807</td>
|
46
|
+
<td>0x00-0x7FFFFFFFFFFFFFFF</td>
|
47
|
+
<td>The dynamic int 63 will use between 1 to 9 bytes to represent the value. It will use 1 bit/byte to keep information if the next byte is used for the dynamic int
|
48
|
+
<table>
|
49
|
+
<tr><th>Size</th><th>Max value</th></tr>
|
50
|
+
<tr><td>1 byte</td><td>127</td></tr>
|
51
|
+
<tr><td>2 bytes</td><td>16,383</td></tr>
|
52
|
+
<tr><td>3 bytes</td><td>2,097,151</td></tr>
|
53
|
+
<tr><td>4 bytes</td><td>268,435,455</td></tr>
|
54
|
+
<tr><td>5 bytes</td><td>34,359,738,367</td></tr>
|
55
|
+
<tr><td>6 bytes</td><td>4,398,046,511,103</td></tr>
|
56
|
+
<tr><td>7 bytes</td><td>562,949,953,421,311</td></tr>
|
57
|
+
<tr><td>8 bytes</td><td>72,057,594,037,927,935</td></tr>
|
58
|
+
<tr><td>9 bytes</td><td>9,223,372,036,854,775,807</td></tr>
|
59
|
+
</table>
|
60
|
+
</td>
|
61
|
+
</tr>
|
62
|
+
<tr>
|
63
|
+
<td>sint32</td>
|
64
|
+
<td>-2,147,483,648 to 2,147,483,647</td>
|
65
|
+
<td></td>
|
66
|
+
<td>A signed integer that requires 4 bytes</td>
|
67
|
+
</tr>
|
68
|
+
<tr>
|
69
|
+
<td>sint64</td>
|
70
|
+
<td>-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807</td>
|
71
|
+
<td></td>
|
72
|
+
<td>A signed integer that requires 8 bytes</td>
|
73
|
+
</tr>
|
74
|
+
</table>
|
75
|
+
|
76
|
+
<table>
|
77
|
+
<tr>
|
78
|
+
<th>Name</th>
|
79
|
+
<th>Description</th>
|
80
|
+
</tr>
|
81
|
+
<tr>
|
82
|
+
<td>bool</td>
|
83
|
+
<td>Write a boolean value requiring 1 byte</td>
|
84
|
+
</tr>
|
85
|
+
<tr>
|
86
|
+
<td>binary</td>
|
87
|
+
<td>Write a byte array of max 4,294,967,295 bytes</td>
|
88
|
+
</tr>
|
89
|
+
<tr>
|
90
|
+
<td>string</td>
|
91
|
+
<td>A UTF-8 based string of max 65,535 bytes (and one UTF8 char is represented by between 1 to 4 bytes)</td>
|
92
|
+
</tr>
|
93
|
+
<tr>
|
94
|
+
<td>ip_number</td>
|
95
|
+
<td>A IPv4 or IPv6 number as a string. An IPv4 number require 5 bytes, while an IPv6 number will require somewhere between 3-17 bytes.</td>
|
96
|
+
</tr>
|
97
|
+
<tr>
|
98
|
+
<td>list</td>
|
99
|
+
<td>A list of items</td>
|
100
|
+
</tr>
|
101
|
+
<tr>
|
102
|
+
<td>map</td>
|
103
|
+
<td>A hash-map of key/value items</td>
|
104
|
+
</tr>
|
105
|
+
</table>
|
106
|
+
|
107
|
+
## Example 1
|
10
108
|
|
11
109
|
|
12
110
|
```ruby
|
@@ -97,6 +195,181 @@ c2.deserialize(new BabelDataReader(ca));
|
|
97
195
|
console.log(c2);
|
98
196
|
```
|
99
197
|
|
198
|
+
## Example 2
|
199
|
+
```ruby
|
200
|
+
require 'divine'
|
201
|
+
|
202
|
+
struct 'SignedInt' do
|
203
|
+
list :list1, :sint32
|
204
|
+
list :list2, :sint64
|
205
|
+
end
|
206
|
+
|
207
|
+
Divine::GraphGenerator.new.draw(".", "graph", "jpg")
|
208
|
+
|
209
|
+
Divine::CodeGenerator.new.generate(:java, file: 'test.java')
|
210
|
+
Divine::CodeGenerator.new.generate(:csharp, file: 'test.cs')
|
211
|
+
```
|
212
|
+
a Java example that uses the generated file test.java
|
213
|
+
```java
|
214
|
+
import java.io.ByteArrayInputStream;
|
215
|
+
import java.io.File;
|
216
|
+
import java.io.FileInputStream;
|
217
|
+
import java.io.FileOutputStream;
|
218
|
+
import java.io.IOException;
|
219
|
+
import java.util.ArrayList;
|
220
|
+
|
221
|
+
public class JavaTest {
|
222
|
+
|
223
|
+
public void testSignedInt() throws IOException {
|
224
|
+
SignedInt ser = buildObj();
|
225
|
+
|
226
|
+
serialize(ser);
|
227
|
+
byte[] res = deserialize();
|
228
|
+
|
229
|
+
SignedInt deser = new SignedInt();
|
230
|
+
deser.deserialize(new ByteArrayInputStream(res));
|
231
|
+
|
232
|
+
compare(ser, deser);
|
233
|
+
}
|
234
|
+
|
235
|
+
public SignedInt buildObj() {
|
236
|
+
SignedInt obj = new SignedInt();
|
237
|
+
obj.list1 = new ArrayList<Integer>(){{
|
238
|
+
add(-1);
|
239
|
+
add(-2);
|
240
|
+
add(-3);
|
241
|
+
add(Integer.MAX_VALUE);
|
242
|
+
add(Integer.MIN_VALUE);
|
243
|
+
}};
|
244
|
+
|
245
|
+
obj.list2 = new ArrayList<Long>(){{
|
246
|
+
add(-1L);
|
247
|
+
add(-2L);
|
248
|
+
add(-3L);
|
249
|
+
add( (long)Math.pow(2, 54-1)-1 );
|
250
|
+
add( (long)(Math.pow(2, (54-1)) - Math.pow(2, 54)) );
|
251
|
+
}};
|
252
|
+
|
253
|
+
return obj;
|
254
|
+
}
|
255
|
+
|
256
|
+
public void compare(SignedInt obj1, SignedInt obj2) {
|
257
|
+
for (int i = 0; i < obj1.list1.size(); i++){
|
258
|
+
System.out.println("Ser = " + obj1.list1.get(i) + ", Deser = " + obj2.list1.get(i));
|
259
|
+
}
|
260
|
+
for (int i = 0; i < obj1.list2.size(); i++){
|
261
|
+
System.out.println("Ser = " + obj1.list2.get(i) + ", Deser = " + obj2.list2.get(i));
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
public void serialize(Divine obj) throws IOException {
|
266
|
+
byte[] data = obj.serialize();
|
267
|
+
File file = new File("bin.babel");
|
268
|
+
try {
|
269
|
+
new FileOutputStream(file).write(data);
|
270
|
+
} catch (Exception e) {
|
271
|
+
e.printStackTrace();
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
public byte[] deserialize() throws IOException{
|
276
|
+
File file = new File("bin.babel");
|
277
|
+
byte[] data = new byte[(int) file.length()];
|
278
|
+
try {
|
279
|
+
new FileInputStream(file).read(data);
|
280
|
+
} catch (Exception e) {
|
281
|
+
e.printStackTrace();
|
282
|
+
}
|
283
|
+
return data;
|
284
|
+
}
|
285
|
+
|
286
|
+
}
|
287
|
+
```
|
288
|
+
And a C# example that uses the generated file test.cs
|
289
|
+
```csharp
|
290
|
+
using System;
|
291
|
+
using System.Collections.Generic;
|
292
|
+
using System.Text;
|
293
|
+
using System.IO;
|
294
|
+
using divine;
|
295
|
+
|
296
|
+
namespace test
|
297
|
+
{
|
298
|
+
class divine
|
299
|
+
{
|
300
|
+
public static void Main(String[] args)
|
301
|
+
{
|
302
|
+
SignedInt ser = buildObj();
|
303
|
+
serialize(ser);
|
304
|
+
byte[] res = deserialize();
|
305
|
+
|
306
|
+
SignedInt deser = new SignedInt();
|
307
|
+
deser.deserialize(new MemoryStream(res));
|
308
|
+
|
309
|
+
compare(ser, deser);
|
310
|
+
|
311
|
+
System.Console.Read();
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
public static SignedInt buildObj() {
|
316
|
+
SignedInt obj = new SignedInt();
|
317
|
+
obj.list1.Add(-1);
|
318
|
+
obj.list1.Add(-2);
|
319
|
+
obj.list1.Add(-3);
|
320
|
+
obj.list1.Add(int.MaxValue);
|
321
|
+
obj.list1.Add(int.MinValue);
|
322
|
+
|
323
|
+
obj.list2.Add(-1);
|
324
|
+
obj.list2.Add(-2);
|
325
|
+
obj.list2.Add(-3);
|
326
|
+
obj.list2.Add( (long) Math.Pow(2, 53) -1 );
|
327
|
+
obj.list2.Add( (long) (Math.Pow(2, 53) - Math.Pow(2, 54)) );
|
328
|
+
return obj;
|
329
|
+
}
|
330
|
+
|
331
|
+
public static void compare(SignedInt obj1, SignedInt obj2)
|
332
|
+
{
|
333
|
+
for (int i = 0; i < obj1.list1.Count; i++)
|
334
|
+
{
|
335
|
+
System.Console.Write("Ser = " + obj1.list1[i] + ", Deser = " + obj2.list1[i] + "\n");
|
336
|
+
}
|
337
|
+
for (int i = 0; i < obj1.list2.Count; i++)
|
338
|
+
{
|
339
|
+
System.Console.Write("Ser = " + obj1.list2[i] + ", Deser = " + obj2.list2[i] + "\n");
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
public static void serialize(Divine obj)
|
344
|
+
{
|
345
|
+
try
|
346
|
+
{
|
347
|
+
byte[] data = obj.serialize();
|
348
|
+
File.WriteAllBytes("bin.babel", data);
|
349
|
+
}
|
350
|
+
catch (System.IO.IOException ex)
|
351
|
+
{
|
352
|
+
throw ex;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
public static byte[] deserialize()
|
357
|
+
{
|
358
|
+
try
|
359
|
+
{
|
360
|
+
byte[] data = File.ReadAllBytes("bin.babel");
|
361
|
+
return data;
|
362
|
+
}
|
363
|
+
catch (System.IO.IOException ex)
|
364
|
+
{
|
365
|
+
throw ex;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
|
369
|
+
}
|
370
|
+
}
|
371
|
+
```
|
372
|
+
|
100
373
|
### Versioning
|
101
374
|
```ruby
|
102
375
|
require 'divine'
|
@@ -164,7 +437,17 @@ Divine::GraphGenerator.new.draw(".", "graph", "jpg")
|
|
164
437
|
```
|
165
438
|
|
166
439
|
|
440
|
+
## Caveats
|
441
|
+
Javascript does only support numbers in the range of -9,007,199,254,740,992 to 9,007,199,254,740,991, a runtime error is thrown if you try to deserialize bigger number.
|
442
|
+
|
443
|
+
|
167
444
|
## Change log
|
445
|
+
Version 0.0.5
|
446
|
+
|
447
|
+
* Adapted to docile 1.1.5
|
448
|
+
* Removed short_binary
|
449
|
+
|
450
|
+
|
168
451
|
Version 0.0.4
|
169
452
|
|
170
453
|
* Added dint63 (Dynamic Int 63)
|
@@ -173,7 +456,7 @@ Version 0.0.4
|
|
173
456
|
Version 0.0.3
|
174
457
|
|
175
458
|
* Added C# code generator
|
176
|
-
* Added sint64 (Signed Int 64)
|
459
|
+
* Added sint32 and sint64 (Signed Int 32 and 64)
|
177
460
|
* Added versioning and freezing
|
178
461
|
|
179
462
|
|
data/divine.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency(%q<docile>, [">= 1.
|
20
|
+
gem.add_dependency(%q<docile>, [">= 1.1.0"])
|
21
21
|
gem.add_dependency(%q<erubis>, [">= 2.7.0"])
|
22
|
-
gem.add_dependency(%q<ruby-graphviz>, [">= 1.0
|
22
|
+
gem.add_dependency(%q<ruby-graphviz>, [">= 1.2.0"])
|
23
23
|
end
|
data/lib/divine.rb
CHANGED
File without changes
|
File without changes
|
@@ -105,7 +105,7 @@ namespace divine
|
|
105
105
|
// Force utf8
|
106
106
|
try
|
107
107
|
{
|
108
|
-
return System.Text.Encoding.UTF8.GetString(readBytes(
|
108
|
+
return System.Text.Encoding.UTF8.GetString(readBytes((int)readDint63(data), data));
|
109
109
|
}
|
110
110
|
catch (System.IO.IOException ex)
|
111
111
|
{
|
@@ -131,7 +131,7 @@ namespace divine
|
|
131
131
|
{
|
132
132
|
try
|
133
133
|
{
|
134
|
-
long c =
|
134
|
+
long c = readDint63(data);
|
135
135
|
if (c > int.MaxValue)
|
136
136
|
{
|
137
137
|
throw new System.IndexOutOfRangeException("Binary data to big for csharp");
|
@@ -144,23 +144,11 @@ namespace divine
|
|
144
144
|
}
|
145
145
|
}
|
146
146
|
|
147
|
-
protected byte[] readShortBinary(MemoryStream data)
|
148
|
-
{
|
149
|
-
try
|
150
|
-
{
|
151
|
-
return readBytes(readInt8(data), data);
|
152
|
-
}
|
153
|
-
catch (System.IO.IOException ex)
|
154
|
-
{
|
155
|
-
throw ex;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
147
|
protected String readIpNumber(MemoryStream data)
|
160
148
|
{
|
161
149
|
try
|
162
150
|
{
|
163
|
-
byte[] ips =
|
151
|
+
byte[] ips = readBytes(readInt8(data), data);
|
164
152
|
if (ips.Length == 4)
|
165
153
|
{
|
166
154
|
return readIpv4Number(ips);
|
@@ -313,7 +301,7 @@ namespace divine
|
|
313
301
|
for (int i = matches.Count - 1; i >= 0 ; i--)
|
314
302
|
{
|
315
303
|
String val = matches[i].Value;
|
316
|
-
val += new String(
|
304
|
+
val += new String('0', (7 - val.Length)) + Math.Min(i, 1);
|
317
305
|
charArray = val.ToCharArray();
|
318
306
|
Array.Reverse(charArray);
|
319
307
|
String str = new String(charArray);
|
@@ -338,7 +326,7 @@ namespace divine
|
|
338
326
|
{
|
339
327
|
raiseError("Too large string: " + bs.Length + " bytes");
|
340
328
|
}
|
341
|
-
|
329
|
+
writeDint63((long)bs.Length, output);
|
342
330
|
output.Write(bs, 0, bs.Length);
|
343
331
|
}
|
344
332
|
catch (System.IO.IOException ex)
|
@@ -355,7 +343,7 @@ namespace divine
|
|
355
343
|
{
|
356
344
|
raiseError("Too large binary: " + v.Length + " bytes");
|
357
345
|
}
|
358
|
-
|
346
|
+
writeDint63((long)v.Length, output);
|
359
347
|
output.Write(v, 0, v.Length);
|
360
348
|
}
|
361
349
|
catch (System.IO.IOException ex)
|
@@ -384,23 +372,6 @@ namespace divine
|
|
384
372
|
}
|
385
373
|
}
|
386
374
|
|
387
|
-
protected void writeShortBinary(byte[] v, MemoryStream output)
|
388
|
-
{
|
389
|
-
try
|
390
|
-
{
|
391
|
-
if (v.Length > 0xFF)
|
392
|
-
{
|
393
|
-
raiseError("Too large short_binary: " + v.Length + " bytes");
|
394
|
-
}
|
395
|
-
writeInt8((byte)v.Length, output);
|
396
|
-
output.Write(v, 0, v.Length);
|
397
|
-
}
|
398
|
-
catch (System.IO.IOException ex)
|
399
|
-
{
|
400
|
-
throw ex;
|
401
|
-
}
|
402
|
-
}
|
403
|
-
|
404
375
|
protected void writeIpNumber(String v, MemoryStream output)
|
405
376
|
{
|
406
377
|
try
|
@@ -437,7 +408,8 @@ namespace divine
|
|
437
408
|
}
|
438
409
|
if (ss.Length == 0 || ss.Length == 4)
|
439
410
|
{
|
440
|
-
|
411
|
+
writeInt8((byte)ss.Length, output);
|
412
|
+
output.Write(ss, 0, ss.Length);
|
441
413
|
}
|
442
414
|
else
|
443
415
|
{
|
@@ -627,7 +599,6 @@ EOS
|
|
627
599
|
# * string --> ""
|
628
600
|
# * ip_number--> ""
|
629
601
|
# * binary --> new byte[0]
|
630
|
-
# * short_binary --> new byte[0]
|
631
602
|
# * list --> new List<type>()
|
632
603
|
# * map --> new Dictionary<keyType, valueType>()
|
633
604
|
|
@@ -650,12 +621,14 @@ EOS
|
|
650
621
|
|
651
622
|
else
|
652
623
|
case types
|
653
|
-
when :binary
|
624
|
+
when :binary
|
654
625
|
"new byte[0]"
|
655
626
|
when :int8, :int16, :int32, :sint32, :sint64, :dint63
|
656
627
|
"0"
|
657
628
|
when :string, :ip_number
|
658
629
|
"\"\""
|
630
|
+
when :bool
|
631
|
+
"false"
|
659
632
|
else
|
660
633
|
if $all_structs[types]
|
661
634
|
types
|
@@ -677,7 +650,6 @@ EOS
|
|
677
650
|
# * string --> string
|
678
651
|
# * ip_number--> string
|
679
652
|
# * binary --> byte[]
|
680
|
-
# * short_binary --> byte[]
|
681
653
|
# * list --> List<type>
|
682
654
|
# * map --> Dictionary<keyType, valueType>
|
683
655
|
|
@@ -703,20 +675,22 @@ EOS
|
|
703
675
|
|
704
676
|
else
|
705
677
|
case types
|
706
|
-
when :binary
|
678
|
+
when :binary
|
707
679
|
"byte[]"
|
708
680
|
when :int8
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
681
|
+
"byte"
|
682
|
+
when :int16
|
683
|
+
"ushort"
|
684
|
+
when :int32
|
713
685
|
"uint"
|
714
686
|
when :sint32
|
715
|
-
|
716
|
-
|
687
|
+
"int"
|
688
|
+
when :sint64, :dint63
|
717
689
|
"long"
|
718
690
|
when :string, :ip_number
|
719
691
|
"string"
|
692
|
+
when :bool
|
693
|
+
"bool"
|
720
694
|
else
|
721
695
|
if $all_structs[types]
|
722
696
|
types
|
@@ -739,7 +713,7 @@ EOS
|
|
739
713
|
nv = get_fresh_variable_name
|
740
714
|
idx = get_fresh_variable_name
|
741
715
|
return [
|
742
|
-
"
|
716
|
+
"writeDint63((long)#{var}.Count, baos);",
|
743
717
|
"for(int #{idx}=0; #{idx}<#{var}.Count; #{idx}++) {",
|
744
718
|
:indent,
|
745
719
|
"#{csharp_get_type_declaration types[1]} #{nv} = #{var}[#{idx}];",
|
@@ -751,7 +725,7 @@ EOS
|
|
751
725
|
nv1 = get_fresh_variable_name
|
752
726
|
nv2 = get_fresh_variable_name
|
753
727
|
return [
|
754
|
-
"
|
728
|
+
"writeDint63((long)#{var}.Count, baos);",
|
755
729
|
"foreach (#{csharp_get_type_declaration types[1]} #{nv1} in #{var}.Keys) {",
|
756
730
|
:indent,
|
757
731
|
"#{csharp_get_type_declaration types[2]} #{nv2} = #{var}[#{nv1}];",
|
@@ -791,7 +765,7 @@ EOS
|
|
791
765
|
iter = get_fresh_variable_name
|
792
766
|
return [
|
793
767
|
"#{"#{csharp_get_type_declaration(types)} " unless var.include? "this."}#{var} = #{csharp_get_empty_declaration(types)};",
|
794
|
-
"uint #{count} = this.
|
768
|
+
"uint #{count} = (uint)this.readDint63(bais);",
|
795
769
|
"for(int #{iter}=0; #{iter}<#{count}; #{iter}++) {",
|
796
770
|
:indent,
|
797
771
|
csharp_deserialize_internal(nv, types[1]),
|
@@ -805,7 +779,7 @@ EOS
|
|
805
779
|
nv2 = get_fresh_variable_name
|
806
780
|
iter = get_fresh_variable_name
|
807
781
|
return ["#{"#{csharp_get_type_declaration(types)} " unless var.include? "this."}#{var} = #{csharp_get_empty_declaration(types)};",
|
808
|
-
"uint #{count} =
|
782
|
+
"uint #{count} = (uint)readDint63(bais);",
|
809
783
|
"for(int #{iter}=0; #{iter}<#{count}; #{iter}++) {",
|
810
784
|
:indent,
|
811
785
|
csharp_deserialize_internal(nv1, types[1]),
|