cauterize 0.0.1.pre13 → 0.0.1.pre14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +33 -33
  3. data/.rspec +1 -1
  4. data/.travisci.yml +4 -4
  5. data/Gemfile +4 -4
  6. data/LICENSE.txt +21 -21
  7. data/README.md +177 -177
  8. data/Rakefile +54 -54
  9. data/bin/cauterize +61 -61
  10. data/cauterize.gemspec +27 -27
  11. data/example/Cauterize +68 -68
  12. data/example/build.sh +25 -25
  13. data/example/c_example_support/empty_main.c +1 -1
  14. data/example/c_example_support/example_project_config.c +11 -11
  15. data/example/c_example_support/example_project_config.h +15 -15
  16. data/example/ruby_ex.rb +14 -14
  17. data/lib/cauterize.rb +117 -117
  18. data/lib/cauterize/base_type.rb +78 -78
  19. data/lib/cauterize/builders.rb +41 -41
  20. data/lib/cauterize/builders/c/buildable.rb +91 -91
  21. data/lib/cauterize/builders/c/builtin.rb +43 -43
  22. data/lib/cauterize/builders/c/composite.rb +57 -57
  23. data/lib/cauterize/builders/c/enumeration.rb +60 -60
  24. data/lib/cauterize/builders/c/fixed_array.rb +74 -74
  25. data/lib/cauterize/builders/c/group.rb +143 -143
  26. data/lib/cauterize/builders/c/scalar.rb +34 -34
  27. data/lib/cauterize/builders/c/variable_array.rb +98 -98
  28. data/lib/cauterize/builders/cs/buildable.rb +59 -59
  29. data/lib/cauterize/builders/cs/builtin.rb +22 -22
  30. data/lib/cauterize/builders/cs/composite.rb +21 -21
  31. data/lib/cauterize/builders/cs/csarray.rb +32 -32
  32. data/lib/cauterize/builders/cs/enumeration.rb +21 -21
  33. data/lib/cauterize/builders/cs/fixed_array.rb +27 -27
  34. data/lib/cauterize/builders/cs/group.rb +32 -32
  35. data/lib/cauterize/builders/cs/scalar.rb +10 -10
  36. data/lib/cauterize/builders/cs/variable_array.rb +40 -34
  37. data/lib/cauterize/builders/doc/buildable.rb +30 -30
  38. data/lib/cauterize/builders/doc/builtin.rb +21 -21
  39. data/lib/cauterize/builders/doc/composite.rb +23 -23
  40. data/lib/cauterize/builders/doc/enumeration.rb +24 -24
  41. data/lib/cauterize/builders/doc/fixed_array.rb +26 -26
  42. data/lib/cauterize/builders/doc/group.rb +29 -29
  43. data/lib/cauterize/builders/doc/scalar.rb +21 -21
  44. data/lib/cauterize/builders/doc/variable_array.rb +26 -26
  45. data/lib/cauterize/builders/ruby/buildable.rb +11 -11
  46. data/lib/cauterize/builders/ruby/builtin.rb +25 -25
  47. data/lib/cauterize/builders/ruby/composite.rb +26 -26
  48. data/lib/cauterize/builders/ruby/enumeration.rb +27 -27
  49. data/lib/cauterize/builders/ruby/fixed_array.rb +20 -20
  50. data/lib/cauterize/builders/ruby/group.rb +35 -35
  51. data/lib/cauterize/builders/ruby/scalar.rb +19 -19
  52. data/lib/cauterize/builders/ruby/variable_array.rb +22 -22
  53. data/lib/cauterize/builtin.rb +62 -62
  54. data/lib/cauterize/c_builder.rb +103 -103
  55. data/lib/cauterize/cauterize.rb +76 -76
  56. data/lib/cauterize/composite.rb +64 -64
  57. data/lib/cauterize/cs_builder.rb +58 -58
  58. data/lib/cauterize/doc_builder.rb +34 -34
  59. data/lib/cauterize/enumeration.rb +98 -98
  60. data/lib/cauterize/fixed_array.rb +50 -50
  61. data/lib/cauterize/formatter.rb +67 -67
  62. data/lib/cauterize/group.rb +81 -81
  63. data/lib/cauterize/representation.rb +32 -32
  64. data/lib/cauterize/ruby_builder.rb +44 -44
  65. data/lib/cauterize/scalar.rb +53 -53
  66. data/lib/cauterize/snake_case.rb +21 -21
  67. data/lib/cauterize/variable_array.rb +55 -55
  68. data/lib/cauterize/version.rb +3 -3
  69. data/spec/base_type_spec.rb +251 -251
  70. data/spec/builders/c/buildable_spec.rb +25 -25
  71. data/spec/builders/c/builtin_spec.rb +22 -22
  72. data/spec/builders/c/composite_spec.rb +50 -50
  73. data/spec/builders/c/enumeration_spec.rb +95 -95
  74. data/spec/builders/c/fixed_array_spec.rb +36 -36
  75. data/spec/builders/c/group_spec.rb +140 -140
  76. data/spec/builders/c/scalar_spec.rb +26 -26
  77. data/spec/builders/c/variable_array_spec.rb +48 -48
  78. data/spec/builders/cs/buildable_spec.rb +8 -8
  79. data/spec/builders/cs/composite_spec.rb +32 -32
  80. data/spec/builders/cs/enumeration_spec.rb +33 -33
  81. data/spec/builders/cs/fixed_array_spec.rb +41 -41
  82. data/spec/builders/cs/group_spec.rb +56 -56
  83. data/spec/builders/cs/scalar_spec.rb +7 -7
  84. data/spec/builders/cs/variable_array_spec.rb +49 -45
  85. data/spec/builders/doc/buildable_spec.rb +25 -25
  86. data/spec/builders_spec.rb +57 -57
  87. data/spec/builtin_spec.rb +43 -43
  88. data/spec/c_builder_spec.rb +176 -176
  89. data/spec/cauterize_spec.rb +15 -15
  90. data/spec/composite_spec.rb +77 -77
  91. data/spec/cs_builder_spec.rb +115 -115
  92. data/spec/doc_builder_spec.rb +260 -260
  93. data/spec/enumeration_spec.rb +145 -145
  94. data/spec/fixed_array_spec.rb +61 -61
  95. data/spec/group_spec.rb +111 -111
  96. data/spec/ruby_builder_spec.rb +83 -83
  97. data/spec/ruby_generated_spec.rb +735 -735
  98. data/spec/scalar_spec.rb +44 -44
  99. data/spec/spec_helper.rb +122 -122
  100. data/spec/support/shared_examples_for_array_buildables.rb +22 -22
  101. data/spec/support/shared_examples_for_c_buildables.rb +103 -103
  102. data/spec/support/shared_examples_for_sane_c_buildables.rb +22 -22
  103. data/spec/support/shared_examples_for_stubbed_functions.rb +18 -18
  104. data/spec/support/spec_sample_model.rb +74 -74
  105. data/spec/test_main.c +13 -13
  106. data/spec/variable_array_spec.rb +73 -73
  107. data/support/c/src/cauterize.c +75 -75
  108. data/support/c/src/cauterize.h +60 -60
  109. data/support/c/src/cauterize_debug.h +29 -29
  110. data/support/c/src/cauterize_util.h +8 -8
  111. data/support/c/test/greatest.h +536 -536
  112. data/support/c/test/test.c +166 -166
  113. data/support/cs/src/CauterizeCompositeFormatter.cs +0 -0
  114. data/support/cs/src/CauterizeContainerFormatter.cs +0 -0
  115. data/support/cs/src/CauterizeEnumFormatter.cs +0 -0
  116. data/support/cs/src/CauterizeException.cs +15 -15
  117. data/support/cs/src/CauterizeFixedArrayFormatter.cs +2 -2
  118. data/support/cs/src/CauterizeFormatter.cs +0 -0
  119. data/support/cs/src/CauterizeGroupFormatter.cs +0 -0
  120. data/support/cs/src/CauterizeTypeFormatterFactory.cs +0 -0
  121. data/support/cs/src/CauterizeTypes.cs +46 -12
  122. data/support/cs/src/CauterizeVariableArrayFormatter.cs +1 -1
  123. data/support/cs/src/ICauterizeTypeFormatter.cs +0 -0
  124. data/support/cs/src/OrderAttribute.cs +0 -0
  125. data/support/cs/src/PrimitiveSupport.cs +12 -0
  126. data/support/cs/test/CauterizeCompositeFormatterTest.cs +0 -0
  127. data/support/cs/test/CauterizeEnumFormatterTest.cs +0 -0
  128. data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +0 -0
  129. data/support/cs/test/CauterizeFormatterTest.cs +0 -0
  130. data/support/cs/test/CauterizeGroupFormatterTest.cs +0 -0
  131. data/support/cs/test/CauterizeIntegrationTest.cs +0 -0
  132. data/support/cs/test/CauterizePrimitiveFormatterTest.cs +0 -0
  133. data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +0 -0
  134. data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +0 -0
  135. data/support/cs/test/OrderAttributeTest.cs +0 -0
  136. data/support/ruby/src/cauterize_ruby_baseclasses.rb +367 -367
  137. data/support/ruby/src/cauterize_ruby_builtins.rb +148 -148
  138. metadata +20 -20
@@ -1,166 +1,166 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
-
4
- #include "cauterize.h"
5
- #include "greatest.h"
6
-
7
- GREATEST_MAIN_DEFS();
8
-
9
- TEST t_CauterizeInitAppend_works() {
10
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
11
- struct Cauterize m;
12
- uint8_t buffer[64] = { 0 };
13
-
14
- s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
15
-
16
- ASSERT_EQ(CA_OK, s);
17
- ASSERT_EQ(m.size, 64);
18
- ASSERT_EQ(m.used, 0);
19
- ASSERT_EQ(m.pos, 0);
20
-
21
- PASS();
22
- }
23
-
24
- TEST t_CauterizeInitRead_works() {
25
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
26
- struct Cauterize m;
27
- uint8_t buffer[64] = { 0 };
28
-
29
- s = CauterizeInitRead(&m, buffer, 13);
30
-
31
- ASSERT_EQ(CA_OK, s);
32
- ASSERT_EQ(m.size, 13);
33
- ASSERT_EQ(m.used, 13);
34
- ASSERT_EQ(m.pos, 0);
35
-
36
- PASS();
37
- }
38
-
39
- TEST t_CauterizeAppend_works() {
40
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
41
- struct Cauterize m;
42
- uint8_t buffer[64] = { 0 };
43
- char data[] = "Hello World";
44
-
45
- s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
46
- ASSERT_EQ(CA_OK, s);
47
-
48
- s = CauterizeAppend(&m, (uint8_t*)data, sizeof(data));
49
- ASSERT_EQ(CA_OK, s);
50
- ASSERT_EQ(m.used, sizeof(data));
51
- ASSERT_STR_EQ(data, (char*)m.buffer);
52
-
53
- PASS();
54
- }
55
-
56
- TEST t_CauterizeAppend_works_again() {
57
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
58
- struct Cauterize m;
59
- uint8_t buffer[64] = { 0 };
60
-
61
- char data_1[3] = "ABC";
62
- char data_2[] = "DEF";
63
-
64
- s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
65
- ASSERT_EQ(CA_OK, s);
66
-
67
- ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data_1, sizeof(data_1)));
68
- ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data_2, sizeof(data_2)));
69
-
70
- ASSERT_EQ(sizeof(data_1) + sizeof(data_2), m.used);
71
- ASSERT_STR_EQ("ABCDEF", (char*)m.buffer);
72
-
73
- PASS();
74
- }
75
-
76
- TEST t_CauterizeAppend_checks_space_needs() {
77
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
78
- struct Cauterize m;
79
- uint8_t buffer[64] = { 0 };
80
- char data[] = "Hello World";
81
-
82
- s = CauterizeInitAppend(&m, buffer, sizeof(data) - 5);
83
- ASSERT_EQ(CA_OK, s);
84
-
85
- s = CauterizeAppend(&m, (uint8_t*)data, sizeof(data));
86
- ASSERT_EQ(CA_ERR_NOT_ENOUGH_SPACE, s);
87
- ASSERT_EQ(m.used, 0);
88
-
89
- PASS();
90
- }
91
-
92
- TEST t_CauterizeRead_works() {
93
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
94
- struct Cauterize m;
95
- struct Cauterize n;
96
- uint8_t buffer[64] = { 0 };
97
- char data[] = "Hello World";
98
-
99
- ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
100
- ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
101
-
102
- ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
103
-
104
- char dest[64] = {0};
105
-
106
- s = CauterizeRead(&n, (uint8_t*)dest, 5);
107
- ASSERT_EQ(CA_OK, s);
108
- ASSERT_EQ(5, n.pos);
109
- ASSERT_STR_EQ("Hello", dest);
110
-
111
- PASS();
112
- }
113
-
114
- TEST t_CauterizeRead_works_again() {
115
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
116
- struct Cauterize m;
117
- struct Cauterize n;
118
- uint8_t buffer[64] = { 0 };
119
- char data[] = "Hello World";
120
-
121
- ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
122
- ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
123
-
124
- char dest[64] = {0};
125
-
126
- ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
127
- ASSERT_EQ(CA_OK, CauterizeRead(&n, (uint8_t*)dest, 5));
128
-
129
- s = CauterizeRead(&n, (uint8_t*)dest, 6);
130
- ASSERT_EQ(CA_OK, s);
131
- ASSERT_EQ(11, n.pos);
132
- ASSERT_STR_EQ(" World", dest);
133
-
134
- PASS();
135
- }
136
-
137
- TEST t_CauterizeRead_checks_data_needs() {
138
- CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
139
- struct Cauterize m;
140
- struct Cauterize n;
141
- uint8_t buffer[32] = { 0 };
142
- char data[] = "Hello World";
143
-
144
- ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
145
- ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
146
-
147
- char dest[64] = {0};
148
-
149
- ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
150
- s = CauterizeRead(&n, (uint8_t*)dest, sizeof(dest));
151
- ASSERT_EQ(CA_ERR_NOT_ENOUGH_DATA, s);
152
- ASSERT_EQ(0, n.pos);
153
-
154
- PASS();
155
- }
156
-
157
- GREATEST_SUITE(marshal) {
158
- /* test_suite.c is generated programatically by the Rakefile */
159
- #include "test_suite.c"
160
- }
161
-
162
- int main(int argc, char * argv[]) {
163
- GREATEST_MAIN_BEGIN();
164
- RUN_SUITE(marshal);
165
- GREATEST_MAIN_END();
166
- }
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ #include "cauterize.h"
5
+ #include "greatest.h"
6
+
7
+ GREATEST_MAIN_DEFS();
8
+
9
+ TEST t_CauterizeInitAppend_works() {
10
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
11
+ struct Cauterize m;
12
+ uint8_t buffer[64] = { 0 };
13
+
14
+ s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
15
+
16
+ ASSERT_EQ(CA_OK, s);
17
+ ASSERT_EQ(m.size, 64);
18
+ ASSERT_EQ(m.used, 0);
19
+ ASSERT_EQ(m.pos, 0);
20
+
21
+ PASS();
22
+ }
23
+
24
+ TEST t_CauterizeInitRead_works() {
25
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
26
+ struct Cauterize m;
27
+ uint8_t buffer[64] = { 0 };
28
+
29
+ s = CauterizeInitRead(&m, buffer, 13);
30
+
31
+ ASSERT_EQ(CA_OK, s);
32
+ ASSERT_EQ(m.size, 13);
33
+ ASSERT_EQ(m.used, 13);
34
+ ASSERT_EQ(m.pos, 0);
35
+
36
+ PASS();
37
+ }
38
+
39
+ TEST t_CauterizeAppend_works() {
40
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
41
+ struct Cauterize m;
42
+ uint8_t buffer[64] = { 0 };
43
+ char data[] = "Hello World";
44
+
45
+ s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
46
+ ASSERT_EQ(CA_OK, s);
47
+
48
+ s = CauterizeAppend(&m, (uint8_t*)data, sizeof(data));
49
+ ASSERT_EQ(CA_OK, s);
50
+ ASSERT_EQ(m.used, sizeof(data));
51
+ ASSERT_STR_EQ(data, (char*)m.buffer);
52
+
53
+ PASS();
54
+ }
55
+
56
+ TEST t_CauterizeAppend_works_again() {
57
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
58
+ struct Cauterize m;
59
+ uint8_t buffer[64] = { 0 };
60
+
61
+ char data_1[3] = "ABC";
62
+ char data_2[] = "DEF";
63
+
64
+ s = CauterizeInitAppend(&m, buffer, sizeof(buffer));
65
+ ASSERT_EQ(CA_OK, s);
66
+
67
+ ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data_1, sizeof(data_1)));
68
+ ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data_2, sizeof(data_2)));
69
+
70
+ ASSERT_EQ(sizeof(data_1) + sizeof(data_2), m.used);
71
+ ASSERT_STR_EQ("ABCDEF", (char*)m.buffer);
72
+
73
+ PASS();
74
+ }
75
+
76
+ TEST t_CauterizeAppend_checks_space_needs() {
77
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
78
+ struct Cauterize m;
79
+ uint8_t buffer[64] = { 0 };
80
+ char data[] = "Hello World";
81
+
82
+ s = CauterizeInitAppend(&m, buffer, sizeof(data) - 5);
83
+ ASSERT_EQ(CA_OK, s);
84
+
85
+ s = CauterizeAppend(&m, (uint8_t*)data, sizeof(data));
86
+ ASSERT_EQ(CA_ERR_NOT_ENOUGH_SPACE, s);
87
+ ASSERT_EQ(m.used, 0);
88
+
89
+ PASS();
90
+ }
91
+
92
+ TEST t_CauterizeRead_works() {
93
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
94
+ struct Cauterize m;
95
+ struct Cauterize n;
96
+ uint8_t buffer[64] = { 0 };
97
+ char data[] = "Hello World";
98
+
99
+ ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
100
+ ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
101
+
102
+ ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
103
+
104
+ char dest[64] = {0};
105
+
106
+ s = CauterizeRead(&n, (uint8_t*)dest, 5);
107
+ ASSERT_EQ(CA_OK, s);
108
+ ASSERT_EQ(5, n.pos);
109
+ ASSERT_STR_EQ("Hello", dest);
110
+
111
+ PASS();
112
+ }
113
+
114
+ TEST t_CauterizeRead_works_again() {
115
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
116
+ struct Cauterize m;
117
+ struct Cauterize n;
118
+ uint8_t buffer[64] = { 0 };
119
+ char data[] = "Hello World";
120
+
121
+ ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
122
+ ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
123
+
124
+ char dest[64] = {0};
125
+
126
+ ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
127
+ ASSERT_EQ(CA_OK, CauterizeRead(&n, (uint8_t*)dest, 5));
128
+
129
+ s = CauterizeRead(&n, (uint8_t*)dest, 6);
130
+ ASSERT_EQ(CA_OK, s);
131
+ ASSERT_EQ(11, n.pos);
132
+ ASSERT_STR_EQ(" World", dest);
133
+
134
+ PASS();
135
+ }
136
+
137
+ TEST t_CauterizeRead_checks_data_needs() {
138
+ CAUTERIZE_STATUS_T s = CA_ERR_GENERAL;
139
+ struct Cauterize m;
140
+ struct Cauterize n;
141
+ uint8_t buffer[32] = { 0 };
142
+ char data[] = "Hello World";
143
+
144
+ ASSERT_EQ(CA_OK, CauterizeInitAppend(&m, buffer, sizeof(buffer)));
145
+ ASSERT_EQ(CA_OK, CauterizeAppend(&m, (uint8_t*)data, sizeof(data)));
146
+
147
+ char dest[64] = {0};
148
+
149
+ ASSERT_EQ(CA_OK, CauterizeInitRead(&n, buffer, m.used));
150
+ s = CauterizeRead(&n, (uint8_t*)dest, sizeof(dest));
151
+ ASSERT_EQ(CA_ERR_NOT_ENOUGH_DATA, s);
152
+ ASSERT_EQ(0, n.pos);
153
+
154
+ PASS();
155
+ }
156
+
157
+ GREATEST_SUITE(marshal) {
158
+ /* test_suite.c is generated programatically by the Rakefile */
159
+ #include "test_suite.c"
160
+ }
161
+
162
+ int main(int argc, char * argv[]) {
163
+ GREATEST_MAIN_BEGIN();
164
+ RUN_SUITE(marshal);
165
+ GREATEST_MAIN_END();
166
+ }
File without changes
@@ -1,15 +1,15 @@
1
- using System;
2
-
3
- namespace Cauterize
4
- {
5
- public class CauterizeException : Exception
6
- {
7
- public CauterizeException(string message) : base(message)
8
- {
9
- }
10
-
11
- public CauterizeException(string message, Exception innerException) : base(message, innerException)
12
- {
13
- }
14
- }
15
- }
1
+ using System;
2
+
3
+ namespace Cauterize
4
+ {
5
+ public class CauterizeException : Exception
6
+ {
7
+ public CauterizeException(string message) : base(message)
8
+ {
9
+ }
10
+
11
+ public CauterizeException(string message, Exception innerException) : base(message, innerException)
12
+ {
13
+ }
14
+ }
15
+ }
@@ -15,9 +15,9 @@ namespace Cauterize
15
15
  var arrayType = arrayField.FieldType.GetElementType();
16
16
  if (arrayType == typeof (Byte))
17
17
  {
18
- var arraySize = (int) t.GetField("MySize").GetValue(null);
18
+ var arraySize = (ulong) t.GetField("MySize").GetValue(null);
19
19
  var arrayData = new byte[arraySize];
20
- serializationStream.Read(arrayData, 0, arraySize);
20
+ serializationStream.Read(arrayData, 0, (int)arraySize);
21
21
  var ret = t.GetConstructor(new Type[] {typeof (Byte[])}).Invoke(new object[] {arrayData});
22
22
  return ret;
23
23
  }
File without changes
File without changes
@@ -1,11 +1,16 @@
1
1
  using System;
2
+ using System.Diagnostics;
3
+ using System.Linq;
4
+ using Cauterize.Common;
2
5
 
3
6
  namespace Cauterize
4
7
  {
5
- public class CauterizeInfo {
8
+ public class CauterizeInfo
9
+ {
6
10
  public string Name;
7
11
  public string GeneratedVersion;
8
12
  public string GeneratedDate;
13
+
9
14
  public int ModelHashLength;
10
15
  public byte[] ModelHash;
11
16
  }
@@ -31,7 +36,7 @@ namespace Cauterize
31
36
  {
32
37
  var enumProp = OrderAttribute.GetPropertyByOrder(GetType(), 0);
33
38
  var value = enumProp.GetValue(this, null);
34
- var index = (int) value + 1;
39
+ var index = (int)value + 1;
35
40
  var prop = OrderAttribute.GetPropertyByOrder(GetType(), index);
36
41
  if (prop != null)
37
42
  {
@@ -46,21 +51,22 @@ namespace Cauterize
46
51
 
47
52
  public abstract class CauterizeFixedArray
48
53
  {
54
+ public abstract object[] ObjectArray();
49
55
  }
50
56
 
51
57
  public abstract class CauterizeFixedArrayTyped<T> : CauterizeFixedArray
52
58
  {
53
59
  private T[] _data;
54
60
 
55
- protected abstract int Size { get; }
56
-
61
+ protected abstract ulong Size { get; }
62
+
57
63
  protected void Allocate(T[] data)
58
64
  {
59
- Allocate(data.Length);
65
+ Allocate((ulong)data.Length);
60
66
  Array.Copy(data, _data, data.Length);
61
67
  }
62
68
 
63
- protected void Allocate(int size)
69
+ protected void Allocate(ulong size)
64
70
  {
65
71
  if (size != Size)
66
72
  {
@@ -91,27 +97,36 @@ namespace Cauterize
91
97
 
92
98
  public T[] GetArray()
93
99
  {
94
- return _data;
100
+ return _data;
101
+ }
102
+
103
+ public override object[] ObjectArray()
104
+ {
105
+ var objArr = new object[_data.Length];
106
+ Array.Copy(_data, objArr, objArr.Length);
107
+ return objArr;
95
108
  }
96
109
  }
97
110
 
98
111
  public abstract class CauterizeVariableArray
99
112
  {
113
+ public abstract object[] ObjectArray();
100
114
  }
101
115
 
116
+ [DebuggerDisplay("{DebuggerDisplay}")]
102
117
  public abstract class CauterizeVariableArrayTyped<T> : CauterizeVariableArray
103
118
  {
104
119
  private T[] _data;
105
120
 
106
- protected abstract int MaxSize { get; }
107
-
121
+ protected abstract ulong MaxSize { get; }
122
+
108
123
  protected void Allocate(T[] data)
109
124
  {
110
- Allocate(data.Length);
125
+ Allocate((ulong)data.Length);
111
126
  Array.Copy(data, _data, data.Length);
112
127
  }
113
128
 
114
- protected void Allocate(int size)
129
+ protected void Allocate(ulong size)
115
130
  {
116
131
  if (size > MaxSize)
117
132
  {
@@ -125,6 +140,18 @@ namespace Cauterize
125
140
  return array._data;
126
141
  }
127
142
 
143
+ public string DebuggerDisplay
144
+ {
145
+ get
146
+ {
147
+ var result = this.ToString();
148
+ var bytes = _data as byte[];
149
+ if (bytes != null)
150
+ result = StringExtensions.BytesToString(bytes) + " " + result;
151
+ return result;
152
+ }
153
+ }
154
+
128
155
  public override string ToString()
129
156
  {
130
157
  var result = "[";
@@ -142,7 +169,14 @@ namespace Cauterize
142
169
 
143
170
  public T[] GetArray()
144
171
  {
145
- return _data;
172
+ return _data;
173
+ }
174
+
175
+ public override object[] ObjectArray()
176
+ {
177
+ var objArr = new object[_data.Length];
178
+ Array.Copy(_data, objArr, objArr.Length);
179
+ return objArr;
146
180
  }
147
181
  }
148
182
  }