slow_blink 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/slow_blink/ext_schema_parser/parser.c +245 -245
- data/lib/slow_blink/annotatable.rb +1 -2
- data/lib/slow_blink/annotation.rb +8 -1
- data/lib/slow_blink/compact_encoder.rb +1 -0
- data/lib/slow_blink/definition.rb +34 -10
- data/lib/slow_blink/enumeration.rb +15 -12
- data/lib/slow_blink/field.rb +9 -8
- data/lib/slow_blink/group.rb +61 -24
- data/lib/slow_blink/incremental_annotation.rb +7 -4
- data/lib/slow_blink/integer.rb +1 -1
- data/{test/tc_model.rb → lib/slow_blink/log.rb} +23 -40
- data/lib/slow_blink/message/binary.rb +39 -45
- data/lib/slow_blink/message/boolean.rb +25 -33
- data/lib/slow_blink/message/date.rb +2 -7
- data/lib/slow_blink/message/decimal.rb +1 -1
- data/lib/slow_blink/message/enumeration.rb +29 -33
- data/lib/slow_blink/message/field.rb +29 -37
- data/lib/slow_blink/message/fixed.rb +37 -45
- data/lib/slow_blink/message/floating_point.rb +24 -32
- data/lib/slow_blink/message/group.rb +172 -187
- data/lib/slow_blink/message/integer.rb +83 -132
- data/lib/slow_blink/message/model.rb +64 -63
- data/lib/slow_blink/message/sequence.rb +40 -48
- data/lib/slow_blink/message/string.rb +44 -51
- data/lib/slow_blink/message/time.rb +25 -40
- data/lib/slow_blink/message/time_of_day.rb +73 -86
- data/lib/slow_blink/name_with_id.rb +2 -6
- data/lib/slow_blink/namespace.rb +36 -36
- data/lib/slow_blink/ref.rb +29 -13
- data/lib/slow_blink/schema.rb +26 -10
- data/lib/slow_blink/schema_buffer.rb +14 -0
- data/lib/slow_blink/sequence.rb +16 -20
- data/lib/slow_blink/string.rb +0 -2
- data/lib/slow_blink/sym.rb +7 -5
- data/lib/slow_blink/type.rb +8 -5
- data/lib/slow_blink/version.rb +1 -1
- data/test/tc_field.rb +41 -0
- data/test/tc_group.rb +11 -0
- data/test/tc_model_static_group.rb +114 -0
- data/test/{tc_model_encode.rb → tc_model_think_blink.rb} +58 -13
- data/test/tc_types.rb +39 -0
- metadata +7 -6
@@ -19,49 +19,45 @@
|
|
19
19
|
|
20
20
|
module SlowBlink::Message
|
21
21
|
|
22
|
-
|
22
|
+
class ENUMERATION
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
def from_compact!(input)
|
27
|
-
self.new(input.getU32!)
|
28
|
-
end
|
24
|
+
|
29
25
|
|
26
|
+
def self.from_compact!(input)
|
27
|
+
self.new(input.getU32!)
|
30
28
|
end
|
31
29
|
|
32
|
-
|
30
|
+
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
else
|
40
|
-
raise Error.new "symbol '#{value}' not defined in enumeration"
|
41
|
-
end
|
42
|
-
elsif self.class.opt?
|
43
|
-
@value = nil
|
32
|
+
# @param v [String]
|
33
|
+
def set(value)
|
34
|
+
if value
|
35
|
+
if self.symbols[value]
|
36
|
+
@value = self.class.symbols[value]
|
44
37
|
else
|
45
|
-
raise Error.new "
|
46
|
-
end
|
38
|
+
raise Error.new "symbol '#{value}' not defined in enumeration"
|
39
|
+
end
|
40
|
+
elsif self.class.opt?
|
41
|
+
@value = nil
|
42
|
+
else
|
43
|
+
raise Error.new "field may not be null"
|
47
44
|
end
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
def get
|
48
|
+
@value
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_compact(out)
|
62
|
-
out.putU32(@value ? self.class.symbols[@value] : nil)
|
51
|
+
def initialize(value)
|
52
|
+
if value
|
53
|
+
set(value)
|
54
|
+
else
|
55
|
+
@value = nil
|
63
56
|
end
|
64
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_compact(out)
|
60
|
+
out.putU32(@value ? self.class.symbols[@value] : nil)
|
65
61
|
end
|
66
62
|
|
67
63
|
end
|
@@ -19,53 +19,45 @@
|
|
19
19
|
|
20
20
|
module SlowBlink::Message
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
module CLASS
|
22
|
+
class Field
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# @return [String] field name
|
32
|
-
def name
|
33
|
-
@name
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Integer,nil] field ID
|
37
|
-
def id
|
38
|
-
@id
|
39
|
-
end
|
40
|
-
|
41
|
-
def type
|
42
|
-
@type
|
43
|
-
end
|
24
|
+
# @return [true,false] field is optional?
|
25
|
+
def self.opt?
|
26
|
+
@opt
|
27
|
+
end
|
44
28
|
|
45
|
-
|
46
|
-
|
47
|
-
|
29
|
+
# @return [String] field name
|
30
|
+
def self.name
|
31
|
+
@name
|
32
|
+
end
|
48
33
|
|
34
|
+
# @return [Integer,nil] field ID
|
35
|
+
def self.id
|
36
|
+
@id
|
49
37
|
end
|
50
38
|
|
51
|
-
|
39
|
+
def self.type
|
40
|
+
@type
|
41
|
+
end
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
def self.from_compact!(input)
|
44
|
+
@type.from_compact!(input)
|
45
|
+
end
|
56
46
|
|
57
|
-
|
58
|
-
|
59
|
-
|
47
|
+
def initialize(value)
|
48
|
+
@value = self.class.type.new(value)
|
49
|
+
end
|
60
50
|
|
61
|
-
|
62
|
-
|
63
|
-
|
51
|
+
def set(value)
|
52
|
+
@value.set(value)
|
53
|
+
end
|
64
54
|
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
def get
|
56
|
+
@value.get
|
57
|
+
end
|
68
58
|
|
59
|
+
def to_compact(out)
|
60
|
+
@value.to_compact(out)
|
69
61
|
end
|
70
62
|
|
71
63
|
end
|
@@ -19,66 +19,58 @@
|
|
19
19
|
|
20
20
|
module SlowBlink::Message
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
else
|
30
|
-
self.new(input.getFixed!)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def size
|
35
|
-
@type.size
|
22
|
+
class FIXED
|
23
|
+
|
24
|
+
def self.from_compact!(input)
|
25
|
+
if opt?
|
26
|
+
self.new(input.getFixedOptional!)
|
27
|
+
else
|
28
|
+
self.new(input.getFixed!)
|
36
29
|
end
|
37
|
-
|
38
30
|
end
|
39
31
|
|
40
|
-
|
32
|
+
def self.size
|
33
|
+
@type.size
|
34
|
+
end
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
raise Error.new "must be #{@size} bytes"
|
49
|
-
end
|
36
|
+
def set(value)
|
37
|
+
if value
|
38
|
+
if value.kind_of? String
|
39
|
+
if value.size == self.class.size
|
40
|
+
@value = value
|
50
41
|
else
|
51
|
-
raise "
|
42
|
+
raise Error.new "must be #{@size} bytes"
|
52
43
|
end
|
53
|
-
elsif self.class.opt?
|
54
|
-
@value = nil
|
55
44
|
else
|
56
|
-
raise
|
45
|
+
raise "expecting string"
|
57
46
|
end
|
47
|
+
elsif self.class.opt?
|
48
|
+
@value = nil
|
49
|
+
else
|
50
|
+
raise Error.new "value unacceptable"
|
58
51
|
end
|
52
|
+
end
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
def get
|
55
|
+
@value
|
56
|
+
end
|
63
57
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
58
|
+
def initialize(value)
|
59
|
+
if value
|
60
|
+
set(value)
|
61
|
+
else
|
62
|
+
@value = nil
|
70
63
|
end
|
64
|
+
end
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
66
|
+
def to_compact(out)
|
67
|
+
if self.opt?
|
68
|
+
out.putFixedOptional(@value)
|
69
|
+
else
|
70
|
+
out.putFixed(@value)
|
78
71
|
end
|
79
|
-
|
80
72
|
end
|
81
|
-
|
73
|
+
|
82
74
|
end
|
83
75
|
|
84
76
|
end
|
@@ -19,48 +19,40 @@
|
|
19
19
|
|
20
20
|
module SlowBlink::Message
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
module CLASS
|
25
|
-
|
26
|
-
def from_compact!(input)
|
27
|
-
self.new(input.getF64!)
|
28
|
-
end
|
22
|
+
class FLOATING_POINT
|
29
23
|
|
24
|
+
def self.from_compact!(input)
|
25
|
+
self.new(input.getF64!)
|
30
26
|
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if value.kind_of? Numeric
|
37
|
-
@value = value
|
38
|
-
else
|
39
|
-
raise "expecting float"
|
40
|
-
end
|
41
|
-
elsif self.class.opt?
|
42
|
-
@value = nil
|
28
|
+
def set(value)
|
29
|
+
if value
|
30
|
+
if value.kind_of? Numeric
|
31
|
+
@value = value
|
43
32
|
else
|
44
|
-
raise
|
33
|
+
raise "expecting float"
|
45
34
|
end
|
35
|
+
elsif self.class.opt?
|
36
|
+
@value = nil
|
37
|
+
else
|
38
|
+
raise Error.new "value unacceptable"
|
46
39
|
end
|
40
|
+
end
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def initialize(value)
|
53
|
-
if value
|
54
|
-
set(value)
|
55
|
-
else
|
56
|
-
@value = nil
|
57
|
-
end
|
58
|
-
end
|
42
|
+
def get
|
43
|
+
@value
|
44
|
+
end
|
59
45
|
|
60
|
-
|
61
|
-
|
46
|
+
def initialize(value)
|
47
|
+
if value
|
48
|
+
set(value)
|
49
|
+
else
|
50
|
+
@value = nil
|
62
51
|
end
|
52
|
+
end
|
63
53
|
|
54
|
+
def to_compact(out)
|
55
|
+
out.putF64(@value)
|
64
56
|
end
|
65
57
|
|
66
58
|
end
|