slow_blink 0.0.6 → 0.0.7

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/ext/slow_blink/ext_schema_parser/lexer.c +2793 -839
  3. data/ext/slow_blink/ext_schema_parser/lexer.h +14 -137
  4. data/ext/slow_blink/ext_schema_parser/parser.c +616 -670
  5. data/ext/slow_blink/ext_schema_parser/parser.h +6 -4
  6. data/ext/slow_blink/message/ext_compact_encoder/blink_compact.c +642 -0
  7. data/ext/slow_blink/message/ext_compact_encoder/blink_compact.h +411 -0
  8. data/ext/slow_blink/message/ext_compact_encoder/blink_debug.h +46 -0
  9. data/ext/slow_blink/message/ext_compact_encoder/blink_stream.c +314 -0
  10. data/ext/slow_blink/message/ext_compact_encoder/blink_stream.h +185 -0
  11. data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +382 -269
  12. data/lib/slow_blink/definition.rb +18 -53
  13. data/lib/slow_blink/dynamic_group.rb +8 -0
  14. data/lib/slow_blink/enum.rb +101 -0
  15. data/lib/slow_blink/field.rb +63 -33
  16. data/lib/slow_blink/generate_c/model.rb +89 -0
  17. data/lib/slow_blink/group.rb +119 -100
  18. data/lib/slow_blink/message/binary.rb +3 -4
  19. data/lib/slow_blink/message/boolean.rb +3 -4
  20. data/lib/slow_blink/message/date.rb +3 -4
  21. data/lib/slow_blink/message/decimal.rb +3 -5
  22. data/lib/slow_blink/message/{enumeration.rb → enum.rb} +17 -17
  23. data/lib/slow_blink/message/field.rb +77 -27
  24. data/lib/slow_blink/message/fixed.rb +5 -21
  25. data/lib/slow_blink/message/floating_point.rb +3 -4
  26. data/lib/slow_blink/message/group.rb +90 -161
  27. data/lib/slow_blink/message/integer.rb +24 -32
  28. data/lib/slow_blink/message/model.rb +50 -110
  29. data/lib/slow_blink/message/string.rb +3 -4
  30. data/lib/slow_blink/message/time.rb +5 -5
  31. data/lib/slow_blink/message/time_of_day.rb +5 -12
  32. data/lib/slow_blink/ref.rb +22 -71
  33. data/lib/slow_blink/schema.rb +64 -85
  34. data/lib/slow_blink/schema_buffer.rb +1 -4
  35. data/lib/slow_blink/static_group.rb +37 -0
  36. data/lib/slow_blink/string.rb +4 -5
  37. data/lib/slow_blink/sym.rb +8 -28
  38. data/lib/slow_blink/type.rb +10 -19
  39. data/lib/slow_blink/version.rb +1 -1
  40. data/lib/slow_blink.rb +1 -0
  41. data/test/tc_compact_encoder.rb +114 -147
  42. data/test/tc_inputs.rb +2 -4
  43. data/test/tc_model_string.rb +29 -0
  44. data/test/tc_schema_new.rb +212 -0
  45. metadata +17 -26
  46. data/ext/slow_blink/ext_schema_parser/common.h +0 -27
  47. data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +0 -258
  48. data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.h +0 -92
  49. data/lib/slow_blink/annotatable.rb +0 -48
  50. data/lib/slow_blink/annotation.rb +0 -47
  51. data/lib/slow_blink/enumeration.rb +0 -90
  52. data/lib/slow_blink/incremental_annotation.rb +0 -151
  53. data/lib/slow_blink/log.rb +0 -51
  54. data/lib/slow_blink/message/sequence.rb +0 -98
  55. data/lib/slow_blink/name_with_id.rb +0 -49
  56. data/lib/slow_blink/namespace.rb +0 -143
  57. data/lib/slow_blink/sequence.rb +0 -57
  58. data/test/tc_field.rb +0 -94
  59. data/test/tc_group.rb +0 -114
  60. data/test/tc_incr_annote.rb +0 -22
  61. data/test/tc_namespace.rb +0 -8
  62. data/test/tc_types.rb +0 -218
@@ -0,0 +1,29 @@
1
+ require "test/unit"
2
+ require 'slow_blink'
3
+
4
+ class TestModelString < Test::Unit::TestCase
5
+
6
+ include SlowBlink
7
+
8
+ def setup
9
+ schema = Schema.new(SchemaBuffer.new("Test/0 -> string Field"))
10
+ @model = Message::Model.new(schema)
11
+ end
12
+
13
+ def test_init
14
+ assert_equal("hello", @model.group("Test").new("Field" => "hello")["Field"])
15
+ end
16
+
17
+ def test_encode_compact
18
+ output = @model.group("Test").new("Field" => "hello").encode_compact.force_encoding("ASCII-8BIT")
19
+ expected = "\x07\x00\x05hello".force_encoding("ASCII-8BIT")
20
+ assert_equal(expected, output)
21
+ end
22
+
23
+ def test_decode_compact
24
+ input = "\x07\x00\x05hello".force_encoding("ASCII-8BIT")
25
+ expected = "hello"
26
+ assert_equal(expected, @model.decode_compact(input)["Field"])
27
+ end
28
+
29
+ end
@@ -0,0 +1,212 @@
1
+ require "test/unit"
2
+ require 'slow_blink'
3
+
4
+ class TestTypes < Test::Unit::TestCase
5
+
6
+ include SlowBlink
7
+
8
+ def test_empty_group
9
+ input = "test"
10
+ Schema.new(SchemaBuffer.new(input))
11
+ end
12
+
13
+ def test_empty_super_group
14
+ input = <<-eos
15
+ super
16
+ empty : super
17
+ eos
18
+ Schema.new(SchemaBuffer.new(input))
19
+ end
20
+
21
+ def test_undefined_super_group
22
+ input = "empty : super"
23
+ assert_raise ParseError do
24
+ Schema.new(SchemaBuffer.new(input))
25
+ end
26
+ end
27
+
28
+ def test_group_is_super_group
29
+ input = "empty : empty"
30
+ assert_raise ParseError do
31
+ Schema.new(SchemaBuffer.new(input))
32
+ end
33
+ end
34
+
35
+ def test_group_is_super_group_by_intermediate
36
+ input = <<-eos
37
+ intermediate = empty
38
+ empty : intermediate
39
+ eos
40
+ assert_raise ParseError do
41
+ Schema.new(SchemaBuffer.new(input))
42
+ end
43
+ end
44
+
45
+ def test_super_group_is_dynamic
46
+ input = <<-eos
47
+ super
48
+ intermediate = super*
49
+ empty : intermediate
50
+ eos
51
+ assert_raise ParseError do
52
+ Schema.new(SchemaBuffer.new(input))
53
+ end
54
+ end
55
+
56
+ def test_super_group_is_sequence
57
+ input = <<-eos
58
+ super
59
+ intermediate = super []
60
+ empty : intermediate
61
+ eos
62
+ assert_raise ParseError do
63
+ Schema.new(SchemaBuffer.new(input))
64
+ end
65
+ end
66
+
67
+ def test_greeting
68
+ input = "Message/0 -> string Greeting"
69
+ Schema.new(SchemaBuffer.new(input))
70
+ end
71
+
72
+ def test_namespace_empty_group
73
+ input = "namespace test empty"
74
+ Schema.new(SchemaBuffer.new(input))
75
+ end
76
+
77
+ def test_enum_single
78
+ input = "test = | lonely"
79
+ Schema.new(SchemaBuffer.new(input))
80
+ end
81
+
82
+ def test_circular_type_reference
83
+ input = <<-eos
84
+ test = testTwo
85
+ testTwo = test
86
+ eos
87
+
88
+ assert_raise ParseError do
89
+ Schema.new(SchemaBuffer.new(input))
90
+ end
91
+ end
92
+
93
+ def test_duplicate_type_reference
94
+ input = <<-eos
95
+ test = u8
96
+ test = u16
97
+ eos
98
+
99
+ assert_raise ParseError do
100
+ Schema.new(SchemaBuffer.new(input))
101
+ end
102
+ end
103
+
104
+ def test_duplicate_type_group_definition
105
+ input = <<-eos
106
+ test = u8
107
+ test -> u16 field
108
+ eos
109
+ assert_raise ParseError do
110
+ Schema.new(SchemaBuffer.new(input))
111
+ end
112
+ end
113
+
114
+ def test_duplicate_group_definition
115
+ input = <<-eos
116
+ test -> u8 field
117
+ test -> u16 field
118
+ eos
119
+ assert_raise ParseError do
120
+ Schema.new(SchemaBuffer.new(input))
121
+ end
122
+ end
123
+
124
+ def test_duplicate_enum_definition
125
+ input = <<-eos
126
+ test = | bla
127
+ test = | bla
128
+ eos
129
+ assert_raise ParseError do
130
+ Schema.new(SchemaBuffer.new(input))
131
+ end
132
+ end
133
+
134
+ def test_duplicate_enum_field
135
+ input = "test = bla | bla"
136
+ assert_raise ParseError do
137
+ Schema.new(SchemaBuffer.new(input))
138
+ end
139
+ end
140
+
141
+ def test_ambiguous_enum_value
142
+ input = "Month = Jan/1 | Feb | Mar/2"
143
+ assert_raise ParseError do
144
+ Schema.new(SchemaBuffer.new(input))
145
+ end
146
+ end
147
+
148
+ def test_enum_value_upper_limit
149
+ input = "Month = | Jan/2147483648"
150
+ assert_raise ParseError do
151
+ Schema.new(SchemaBuffer.new(input))
152
+ end
153
+ end
154
+
155
+ def test_enum_value_lower_limit
156
+ input = "Month = | Jan/-2147483649"
157
+ assert_raise ParseError do
158
+ Schema.new(SchemaBuffer.new(input))
159
+ end
160
+ end
161
+
162
+ def test_duplicate_group_field
163
+ input = "test -> u8 bla, u8 bla"
164
+ assert_raise ParseError do
165
+ Schema.new(SchemaBuffer.new(input))
166
+ end
167
+ end
168
+
169
+ def test_super_group_shadow_field
170
+ input = <<-eos
171
+ super -> u8 field
172
+ test : super -> u16 field
173
+ eos
174
+ assert_raise ParseError do
175
+ Schema.new(SchemaBuffer.new(input))
176
+ end
177
+ end
178
+
179
+ def test_super_super_group_shadow_field
180
+ input = <<-eos
181
+ superSuper -> u8 field
182
+ super : superSuper -> u8 different
183
+ test : super -> u16 field
184
+ eos
185
+ assert_raise ParseError do
186
+ Schema.new(SchemaBuffer.new(input))
187
+ end
188
+ end
189
+
190
+ def test_incomplete_body
191
+ input = "test -> u8 field,"
192
+ assert_raise ParseError do
193
+ Schema.new(SchemaBuffer.new(input))
194
+ end
195
+ end
196
+
197
+ def test_incomplete_enum
198
+ input = "test = one |"
199
+ assert_raise ParseError do
200
+ Schema.new(SchemaBuffer.new(input))
201
+ end
202
+ end
203
+
204
+ def test_definition_annotes
205
+ input = <<-eos
206
+ @test='hello world'
207
+ enum = | something
208
+ eos
209
+ Schema.new(SchemaBuffer.new(input))
210
+ end
211
+
212
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slow_blink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Harper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-16 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -61,55 +61,52 @@ extensions:
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".yardopts"
64
- - ext/slow_blink/ext_schema_parser/common.h
65
64
  - ext/slow_blink/ext_schema_parser/extconf.rb
66
65
  - ext/slow_blink/ext_schema_parser/lexer.c
67
66
  - ext/slow_blink/ext_schema_parser/lexer.h
68
67
  - ext/slow_blink/ext_schema_parser/parser.c
69
68
  - ext/slow_blink/ext_schema_parser/parser.h
70
- - ext/slow_blink/message/ext_compact_encoder/compact_encoder.c
71
- - ext/slow_blink/message/ext_compact_encoder/compact_encoder.h
69
+ - ext/slow_blink/message/ext_compact_encoder/blink_compact.c
70
+ - ext/slow_blink/message/ext_compact_encoder/blink_compact.h
71
+ - ext/slow_blink/message/ext_compact_encoder/blink_debug.h
72
+ - ext/slow_blink/message/ext_compact_encoder/blink_stream.c
73
+ - ext/slow_blink/message/ext_compact_encoder/blink_stream.h
72
74
  - ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c
73
75
  - ext/slow_blink/message/ext_compact_encoder/extconf.rb
74
76
  - lib/slow_blink.rb
75
- - lib/slow_blink/annotatable.rb
76
- - lib/slow_blink/annotation.rb
77
77
  - lib/slow_blink/binary.rb
78
78
  - lib/slow_blink/boolean.rb
79
79
  - lib/slow_blink/date.rb
80
80
  - lib/slow_blink/decimal.rb
81
81
  - lib/slow_blink/definition.rb
82
- - lib/slow_blink/enumeration.rb
82
+ - lib/slow_blink/dynamic_group.rb
83
+ - lib/slow_blink/enum.rb
83
84
  - lib/slow_blink/field.rb
84
85
  - lib/slow_blink/fixed.rb
85
86
  - lib/slow_blink/floating_point.rb
87
+ - lib/slow_blink/generate_c/model.rb
86
88
  - lib/slow_blink/group.rb
87
- - lib/slow_blink/incremental_annotation.rb
88
89
  - lib/slow_blink/integer.rb
89
- - lib/slow_blink/log.rb
90
90
  - lib/slow_blink/message/binary.rb
91
91
  - lib/slow_blink/message/boolean.rb
92
92
  - lib/slow_blink/message/date.rb
93
93
  - lib/slow_blink/message/decimal.rb
94
- - lib/slow_blink/message/enumeration.rb
94
+ - lib/slow_blink/message/enum.rb
95
95
  - lib/slow_blink/message/field.rb
96
96
  - lib/slow_blink/message/fixed.rb
97
97
  - lib/slow_blink/message/floating_point.rb
98
98
  - lib/slow_blink/message/group.rb
99
99
  - lib/slow_blink/message/integer.rb
100
100
  - lib/slow_blink/message/model.rb
101
- - lib/slow_blink/message/sequence.rb
102
101
  - lib/slow_blink/message/string.rb
103
102
  - lib/slow_blink/message/time.rb
104
103
  - lib/slow_blink/message/time_of_day.rb
105
- - lib/slow_blink/name_with_id.rb
106
- - lib/slow_blink/namespace.rb
107
104
  - lib/slow_blink/object.rb
108
105
  - lib/slow_blink/parse_error.rb
109
106
  - lib/slow_blink/ref.rb
110
107
  - lib/slow_blink/schema.rb
111
108
  - lib/slow_blink/schema_buffer.rb
112
- - lib/slow_blink/sequence.rb
109
+ - lib/slow_blink/static_group.rb
113
110
  - lib/slow_blink/string.rb
114
111
  - lib/slow_blink/sym.rb
115
112
  - lib/slow_blink/time.rb
@@ -119,18 +116,15 @@ files:
119
116
  - rakefile
120
117
  - test/capture_stderr.rb
121
118
  - test/tc_compact_encoder.rb
122
- - test/tc_field.rb
123
- - test/tc_group.rb
124
- - test/tc_incr_annote.rb
125
119
  - test/tc_inputs.rb
126
120
  - test/tc_model_decimal.rb
127
121
  - test/tc_model_dynamic_group.rb
128
122
  - test/tc_model_extension.rb
129
123
  - test/tc_model_sequence_of_string.rb
130
124
  - test/tc_model_static_group.rb
125
+ - test/tc_model_string.rb
131
126
  - test/tc_model_think_blink.rb
132
- - test/tc_namespace.rb
133
- - test/tc_types.rb
127
+ - test/tc_schema_new.rb
134
128
  homepage: https://github.com/cjhdev/slow_blink
135
129
  licenses:
136
130
  - MIT
@@ -151,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
145
  version: '0'
152
146
  requirements: []
153
147
  rubyforge_project:
154
- rubygems_version: 2.4.8
148
+ rubygems_version: 2.6.8
155
149
  signing_key:
156
150
  specification_version: 4
157
151
  summary: Blink Protocol in Ruby
@@ -160,13 +154,10 @@ test_files:
160
154
  - test/tc_model_extension.rb
161
155
  - test/tc_model_decimal.rb
162
156
  - test/tc_compact_encoder.rb
163
- - test/tc_group.rb
164
157
  - test/tc_inputs.rb
165
- - test/tc_namespace.rb
158
+ - test/tc_model_string.rb
166
159
  - test/tc_model_sequence_of_string.rb
167
- - test/tc_types.rb
168
160
  - test/capture_stderr.rb
169
161
  - test/tc_model_think_blink.rb
170
- - test/tc_field.rb
162
+ - test/tc_schema_new.rb
171
163
  - test/tc_model_dynamic_group.rb
172
- - test/tc_incr_annote.rb
@@ -1,27 +0,0 @@
1
- #ifndef COMMON_H
2
- #define COMMON_H
3
-
4
- /* Value type. */
5
- #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
6
- #include <ruby.h>
7
- typedef VALUE YYSTYPE;
8
- # define YYSTYPE_IS_TRIVIAL 1
9
- # define YYSTYPE_IS_DECLARED 1
10
- #endif
11
-
12
- /* Location type. */
13
- #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
14
- typedef struct YYLTYPE YYLTYPE;
15
- struct YYLTYPE
16
- {
17
- int first_line;
18
- int first_column;
19
- int last_line;
20
- int last_column;
21
- };
22
- # define YYLTYPE_IS_DECLARED 1
23
- # define YYLTYPE_IS_TRIVIAL 1
24
- #endif
25
-
26
-
27
- #endif
@@ -1,258 +0,0 @@
1
- /* Copyright (c) 2016 Cameron Harper
2
- *
3
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- * this software and associated documentation files (the "Software"), to deal in
5
- * the Software without restriction, including without limitation the rights to
6
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- * the Software, and to permit persons to whom the Software is furnished to do so,
8
- * subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all
11
- * copies or substantial portions of the Software.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
- *
20
- *
21
- * */
22
-
23
- /* includes ***********************************************************/
24
-
25
- #include "compact_encoder.h"
26
-
27
- /* functions **********************************************************/
28
-
29
- uint8_t BLINK_putNull(uint8_t *out, uint32_t outMax)
30
- {
31
- uint8_t retval = 0U;
32
-
33
- if(outMax > 0){
34
-
35
- *out = 0xC0U;
36
- retval = 1U;
37
- }
38
-
39
- return retval;
40
- }
41
-
42
- uint8_t BLINK_getSizeUnsigned(uint64_t value)
43
- {
44
- uint8_t retval;
45
-
46
- if(value <= 0x7fUL){
47
- retval = 1U;
48
- }
49
- else if(value <= 0x3fffUL){
50
- retval = 2U;
51
- }
52
- else if(value <= 0xffffUL){
53
- retval = 3U;
54
- }
55
- else if(value <= 0xffffffUL){
56
- retval = 4U;
57
- }
58
- else if(value <= 0xffffffffUL){
59
- retval = 5U;
60
- }
61
- else if(value <= 0xffffffffffUL){
62
- retval = 6U;
63
- }
64
- else if(value <= 0xffffffffffffUL){
65
- retval = 7U;
66
- }
67
- else if(value <= 0xffffffffffffffUL){
68
- retval = 8U;
69
- }
70
- else{
71
- retval = 9U;
72
- }
73
-
74
- return retval;
75
- }
76
-
77
- uint8_t BLINK_getSizeSigned(int64_t value)
78
- {
79
- uint8_t retval;
80
- uint8_t i;
81
-
82
- if(value < 0){
83
-
84
- if(value >= -64){
85
-
86
- retval = 1U;
87
- }
88
- else if(value >= -8192){
89
-
90
- retval = 2U;
91
- }
92
- else{
93
-
94
- int64_t min = -32768;
95
- retval = 3U;
96
-
97
- for(i=0; i < 6; i++){
98
-
99
- if((min << (i*8)) <= value){
100
-
101
- break;
102
- }
103
- else{
104
-
105
- retval++;
106
- }
107
- }
108
- }
109
- }
110
- else{
111
-
112
- if(value <= 0x3fL){
113
- retval = 1U;
114
- }
115
- else if(value <= 0x1fffL){
116
- retval = 2U;
117
- }
118
- else if(value <= 0x7fffL){
119
- retval = 3U;
120
- }
121
- else if(value <= 0x7fffffL){
122
- retval = 4U;
123
- }
124
- else if(value <= 0x7fffffffL){
125
- retval = 5U;
126
- }
127
- else if(value <= 0x7fffffffffL){
128
- retval = 6U;
129
- }
130
- else if(value <= 0x7fffffffffffL){
131
- retval = 7U;
132
- }
133
- else if(value <= 0x7fffffffffffffL){
134
- retval = 8U;
135
- }
136
- else{
137
- retval = 9U;
138
- }
139
- }
140
-
141
- return retval;
142
- }
143
-
144
- uint8_t BLINK_putVLC(uint64_t in, bool isSigned, uint8_t *out, uint32_t outMax)
145
- {
146
- uint8_t bytes = (isSigned) ? BLINK_getSizeSigned((int64_t)in) : BLINK_getSizeUnsigned(in);
147
- uint8_t retval = 0U;
148
- uint8_t i;
149
-
150
- if(outMax >= bytes){
151
-
152
- if(bytes == 1){
153
-
154
- *out = (uint8_t)(in & 0x7f);
155
- }
156
- else if(bytes == 2){
157
-
158
- out[0] = 0x80 | (uint8_t)(in & 0x3f);
159
- out[1] = (uint8_t)(in >> 6);
160
- }
161
- else{
162
-
163
- out[0] = 0xC0U | bytes-1;
164
- for(i=1; i < bytes; i++){
165
-
166
- out[i] = (uint8_t)(in >> ((i-1)*8));
167
- }
168
- }
169
- retval = bytes;
170
- }
171
-
172
- return retval;
173
- }
174
-
175
- uint8_t BLINK_getVLC(const uint8_t *in, uint32_t inLen, bool isSigned, uint64_t *out, bool *isNull)
176
- {
177
- uint8_t retval = 0U;
178
- uint8_t bytes;
179
- uint8_t i;
180
-
181
- *isNull = false;
182
-
183
- if(inLen > 0){
184
-
185
- if(*in < 0xc0){
186
-
187
- if(*in < 0x80){
188
-
189
- if(isSigned && ((*in & 0x40) == 0x40)){
190
-
191
- *out = 0xffffffffffffffc0;
192
- }
193
- else{
194
-
195
- *out = 0x0;
196
- }
197
- *out |= (uint64_t)(*in & 0x7f);
198
- retval = 1U;
199
- }
200
- else{
201
-
202
- if(inLen >= 2){
203
-
204
- if(isSigned && ((in[1] & 0x80) == 0x80)){
205
-
206
- *out = 0xffffffffffffff00;
207
- }
208
- else{
209
-
210
- *out = 0x0;
211
- }
212
- *out |= (uint64_t)in[1];
213
- *out <<= 6;
214
- *out |= (uint64_t)(in[0] & 0x3fU);
215
- retval = 2U;
216
- }
217
- }
218
- }
219
- else if(*in == 0xc0){
220
-
221
- *isNull = true;
222
- retval = 1U;
223
- }
224
- else{
225
-
226
- bytes = *in & 0x3fU;
227
-
228
- if(inLen >= (1U + bytes)){
229
-
230
- if(bytes <= 8U){
231
-
232
- if(isSigned && ((in[bytes] & 0x80U) == 0x80U)){
233
-
234
- *out = 0xffffffffffff00U | in[bytes];
235
- }
236
- else{
237
-
238
- *out = in[bytes];
239
- }
240
-
241
- for(i=bytes-1; i != 0U; i--){
242
-
243
- *out <<= 8;
244
- *out |= in[i];
245
- }
246
-
247
- retval = bytes + 1U;
248
- }
249
- }
250
- }
251
- }
252
-
253
- return retval;
254
- }
255
-
256
-
257
-
258
-