slow_blink 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/ext/slow_blink/ext_schema_parser/parser.c +4 -4
- data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +5 -5
- data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +31 -18
- data/lib/slow_blink/annotatable.rb +20 -17
- data/lib/slow_blink/annotation.rb +20 -18
- data/lib/slow_blink/binary.rb +20 -17
- data/lib/slow_blink/boolean.rb +20 -17
- data/lib/slow_blink/date.rb +20 -17
- data/lib/slow_blink/decimal.rb +20 -17
- data/lib/slow_blink/definition.rb +21 -19
- data/lib/slow_blink/enumeration.rb +30 -26
- data/lib/slow_blink/field.rb +20 -17
- data/lib/slow_blink/fixed.rb +20 -17
- data/lib/slow_blink/floating_point.rb +20 -17
- data/lib/slow_blink/group.rb +21 -18
- data/lib/slow_blink/incremental_annotation.rb +21 -18
- data/lib/slow_blink/integer.rb +20 -17
- data/lib/slow_blink/log.rb +20 -17
- data/lib/slow_blink/message/binary.rb +23 -18
- data/lib/slow_blink/message/boolean.rb +22 -17
- data/lib/slow_blink/message/date.rb +23 -18
- data/lib/slow_blink/message/decimal.rb +38 -21
- data/lib/slow_blink/message/enumeration.rb +31 -21
- data/lib/slow_blink/message/field.rb +23 -18
- data/lib/slow_blink/message/fixed.rb +23 -19
- data/lib/slow_blink/message/floating_point.rb +22 -17
- data/lib/slow_blink/message/group.rb +90 -55
- data/lib/slow_blink/message/integer.rb +51 -24
- data/lib/slow_blink/message/model.rb +197 -131
- data/lib/slow_blink/message/sequence.rb +31 -25
- data/lib/slow_blink/message/string.rb +23 -18
- data/lib/slow_blink/message/time.rb +31 -25
- data/lib/slow_blink/message/time_of_day.rb +24 -18
- data/lib/slow_blink/name_with_id.rb +20 -17
- data/lib/slow_blink/namespace.rb +22 -19
- data/lib/slow_blink/object.rb +20 -17
- data/lib/slow_blink/parse_error.rb +26 -0
- data/lib/slow_blink/ref.rb +20 -17
- data/lib/slow_blink/schema.rb +26 -24
- data/lib/slow_blink/schema_buffer.rb +20 -17
- data/lib/slow_blink/sequence.rb +20 -17
- data/lib/slow_blink/string.rb +20 -17
- data/lib/slow_blink/sym.rb +20 -17
- data/lib/slow_blink/time.rb +20 -17
- data/lib/slow_blink/time_of_day.rb +20 -17
- data/lib/slow_blink/type.rb +20 -17
- data/lib/slow_blink/version.rb +21 -18
- data/lib/slow_blink.rb +19 -17
- data/test/tc_compact_encoder.rb +64 -30
- data/test/tc_group.rb +0 -19
- data/test/tc_incr_annote.rb +0 -21
- data/test/tc_model_decimal.rb +94 -0
- data/test/tc_model_dynamic_group.rb +0 -19
- data/test/tc_model_extension.rb +0 -19
- data/test/tc_model_sequence_of_string.rb +29 -0
- data/test/tc_model_static_group.rb +0 -19
- data/test/tc_model_think_blink.rb +0 -19
- data/test/tc_types.rb +0 -19
- metadata +8 -4
- data/lib/slow_blink/compact_encoder.rb +0 -72
- data/lib/slow_blink/error.rb +0 -23
@@ -1,57 +1,74 @@
|
|
1
|
-
#
|
1
|
+
# @license
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cameron Harper
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
2
14
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
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.
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
21
|
|
20
22
|
require 'bigdecimal'
|
21
23
|
|
22
24
|
module SlowBlink::Message
|
23
25
|
|
26
|
+
# @abstract
|
24
27
|
class DECIMAL
|
25
28
|
|
29
|
+
# @private
|
26
30
|
def self.from_compact!(input, stack)
|
27
31
|
e = input.getI8!
|
28
32
|
if e
|
29
33
|
m = input.getI64!
|
30
34
|
if m
|
31
|
-
self.new("#{m}E#{e}")
|
35
|
+
self.new("#{m}E#{e}")
|
32
36
|
else
|
33
|
-
raise
|
37
|
+
raise NullMantissa
|
34
38
|
end
|
35
39
|
else
|
36
40
|
nil
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
44
|
+
# @note calls {#set}(value)
|
40
45
|
def initialize(value)
|
41
46
|
set(value)
|
42
47
|
end
|
43
48
|
|
49
|
+
# @return [BigDecimal]
|
44
50
|
def get
|
45
51
|
@value
|
46
52
|
end
|
47
53
|
|
54
|
+
# Set a decimal value
|
55
|
+
# @param value [Numeric]
|
56
|
+
# @raise [TypeError]
|
48
57
|
def set(value)
|
49
58
|
@value = BigDecimal.new(value.to_s)
|
50
59
|
end
|
51
60
|
|
61
|
+
# @private
|
52
62
|
def to_compact(out)
|
53
|
-
|
54
|
-
|
63
|
+
|
64
|
+
split = @value.split
|
65
|
+
|
66
|
+
exponent = - split[1].size + split[3]
|
67
|
+
mantissa = split[0]*split[1].to_i
|
68
|
+
|
69
|
+
out.putI8(exponent)
|
70
|
+
out.putI64(mantissa)
|
71
|
+
|
55
72
|
end
|
56
73
|
|
57
74
|
end
|
@@ -1,24 +1,27 @@
|
|
1
|
-
#
|
1
|
+
# @license
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cameron Harper
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
2
14
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
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.
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
21
|
|
20
22
|
module SlowBlink::Message
|
21
23
|
|
24
|
+
# @abstract
|
22
25
|
class ENUMERATION
|
23
26
|
|
24
27
|
# @return [Hash] symbol => value table
|
@@ -26,10 +29,16 @@ module SlowBlink::Message
|
|
26
29
|
@symbols
|
27
30
|
end
|
28
31
|
|
32
|
+
# @private
|
29
33
|
def self.from_compact!(input, stack)
|
30
|
-
value = input.
|
34
|
+
value = input.getI32!
|
31
35
|
if value
|
32
|
-
|
36
|
+
symbol = @symbols.key(value)
|
37
|
+
if symbol
|
38
|
+
self.new(symbol)
|
39
|
+
else
|
40
|
+
raise WeakError10.new "W10: value '#{value}' does not correspond to any symbol in enumeration"
|
41
|
+
end
|
33
42
|
else
|
34
43
|
value
|
35
44
|
end
|
@@ -56,9 +65,10 @@ module SlowBlink::Message
|
|
56
65
|
@symbols = self.class.symbols
|
57
66
|
set(value)
|
58
67
|
end
|
59
|
-
|
68
|
+
|
69
|
+
# @private
|
60
70
|
def to_compact(out)
|
61
|
-
out.
|
71
|
+
out.putI32(@symbols[@value])
|
62
72
|
end
|
63
73
|
|
64
74
|
end
|
@@ -1,24 +1,27 @@
|
|
1
|
-
#
|
1
|
+
# @license
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cameron Harper
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
2
14
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
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.
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
21
|
|
20
22
|
module SlowBlink::Message
|
21
23
|
|
24
|
+
# @abstract
|
22
25
|
class Field
|
23
26
|
|
24
27
|
# @return [true,false] field is optional?
|
@@ -41,6 +44,7 @@ module SlowBlink::Message
|
|
41
44
|
@type
|
42
45
|
end
|
43
46
|
|
47
|
+
# @private
|
44
48
|
# @param input [String] Blink compact form
|
45
49
|
# @param stack [Array]
|
46
50
|
# @return [Field] instance of anonymous subclass of Field
|
@@ -87,6 +91,7 @@ module SlowBlink::Message
|
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
94
|
+
# @private
|
90
95
|
# @param out [String] output appended to this string
|
91
96
|
# @return [String]
|
92
97
|
def to_compact(out)
|
@@ -95,7 +100,7 @@ module SlowBlink::Message
|
|
95
100
|
elsif @opt
|
96
101
|
out.putNull
|
97
102
|
else
|
98
|
-
raise
|
103
|
+
raise IncompleteGroup.new "field '#{self.name}' must not be null"
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
@@ -1,33 +1,36 @@
|
|
1
|
-
#
|
1
|
+
# @license
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cameron Harper
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
2
14
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
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.
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
21
|
|
20
22
|
module SlowBlink::Message
|
21
23
|
|
24
|
+
# @abstract
|
22
25
|
class FIXED
|
23
26
|
|
24
27
|
# @note optionality affects how instances of this type are encoded
|
25
|
-
#
|
26
28
|
# @return [true,false] is optional
|
27
29
|
def self.opt?
|
28
30
|
@opt
|
29
31
|
end
|
30
|
-
|
32
|
+
|
33
|
+
# @private
|
31
34
|
def self.from_compact!(input, stack)
|
32
35
|
if @opt
|
33
36
|
value = input.getFixedOptional!
|
@@ -73,6 +76,7 @@ module SlowBlink::Message
|
|
73
76
|
set(value)
|
74
77
|
end
|
75
78
|
|
79
|
+
# @private
|
76
80
|
def to_compact(out)
|
77
81
|
if @opt
|
78
82
|
out.putFixedOptional(@value)
|
@@ -1,26 +1,30 @@
|
|
1
|
-
#
|
1
|
+
# @license
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cameron Harper
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
2
14
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
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.
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
21
|
|
20
22
|
module SlowBlink::Message
|
21
23
|
|
24
|
+
# @abstract
|
22
25
|
class FLOATING_POINT
|
23
26
|
|
27
|
+
# @private
|
24
28
|
def self.from_compact!(input, stack)
|
25
29
|
value = input.getF64!
|
26
30
|
if value
|
@@ -50,6 +54,7 @@ module SlowBlink::Message
|
|
50
54
|
set(value)
|
51
55
|
end
|
52
56
|
|
57
|
+
# @private
|
53
58
|
def to_compact(out)
|
54
59
|
out.putF64(@value)
|
55
60
|
end
|