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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/ext/slow_blink/ext_schema_parser/parser.c +245 -245
  3. data/lib/slow_blink/annotatable.rb +1 -2
  4. data/lib/slow_blink/annotation.rb +8 -1
  5. data/lib/slow_blink/compact_encoder.rb +1 -0
  6. data/lib/slow_blink/definition.rb +34 -10
  7. data/lib/slow_blink/enumeration.rb +15 -12
  8. data/lib/slow_blink/field.rb +9 -8
  9. data/lib/slow_blink/group.rb +61 -24
  10. data/lib/slow_blink/incremental_annotation.rb +7 -4
  11. data/lib/slow_blink/integer.rb +1 -1
  12. data/{test/tc_model.rb → lib/slow_blink/log.rb} +23 -40
  13. data/lib/slow_blink/message/binary.rb +39 -45
  14. data/lib/slow_blink/message/boolean.rb +25 -33
  15. data/lib/slow_blink/message/date.rb +2 -7
  16. data/lib/slow_blink/message/decimal.rb +1 -1
  17. data/lib/slow_blink/message/enumeration.rb +29 -33
  18. data/lib/slow_blink/message/field.rb +29 -37
  19. data/lib/slow_blink/message/fixed.rb +37 -45
  20. data/lib/slow_blink/message/floating_point.rb +24 -32
  21. data/lib/slow_blink/message/group.rb +172 -187
  22. data/lib/slow_blink/message/integer.rb +83 -132
  23. data/lib/slow_blink/message/model.rb +64 -63
  24. data/lib/slow_blink/message/sequence.rb +40 -48
  25. data/lib/slow_blink/message/string.rb +44 -51
  26. data/lib/slow_blink/message/time.rb +25 -40
  27. data/lib/slow_blink/message/time_of_day.rb +73 -86
  28. data/lib/slow_blink/name_with_id.rb +2 -6
  29. data/lib/slow_blink/namespace.rb +36 -36
  30. data/lib/slow_blink/ref.rb +29 -13
  31. data/lib/slow_blink/schema.rb +26 -10
  32. data/lib/slow_blink/schema_buffer.rb +14 -0
  33. data/lib/slow_blink/sequence.rb +16 -20
  34. data/lib/slow_blink/string.rb +0 -2
  35. data/lib/slow_blink/sym.rb +7 -5
  36. data/lib/slow_blink/type.rb +8 -5
  37. data/lib/slow_blink/version.rb +1 -1
  38. data/test/tc_field.rb +41 -0
  39. data/test/tc_group.rb +11 -0
  40. data/test/tc_model_static_group.rb +114 -0
  41. data/test/{tc_model_encode.rb → tc_model_think_blink.rb} +58 -13
  42. data/test/tc_types.rb +39 -0
  43. metadata +7 -6
@@ -19,7 +19,7 @@
19
19
 
20
20
  module SlowBlink::Message
21
21
 
22
- module DECIMAL
22
+ class DECIMAL
23
23
  end
24
24
 
25
25
  end
@@ -19,49 +19,45 @@
19
19
 
20
20
  module SlowBlink::Message
21
21
 
22
- module ENUMERATION
22
+ class ENUMERATION
23
23
 
24
- module CLASS
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
- module INSTANCE
30
+
33
31
 
34
- # @param v [String]
35
- def set(value)
36
- if value
37
- if self.symbols[value]
38
- @value = self.class.symbols[value]
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 "field may not be null"
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
- def get
50
- @value
51
- end
47
+ def get
48
+ @value
49
+ end
52
50
 
53
- def initialize(value)
54
- if value
55
- set(value)
56
- else
57
- @value = nil
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
- module Field
23
-
24
- module CLASS
22
+ class Field
25
23
 
26
- # @return [true,false] field is optional?
27
- def opt?
28
- @opt
29
- end
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
- def from_compact!(input)
46
- @type.from_compact!(input)
47
- end
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
- module INSTANCE
39
+ def self.type
40
+ @type
41
+ end
52
42
 
53
- def initialize(value)
54
- @value = self.class.type.new(value)
55
- end
43
+ def self.from_compact!(input)
44
+ @type.from_compact!(input)
45
+ end
56
46
 
57
- def set(value)
58
- @value.set(value)
59
- end
47
+ def initialize(value)
48
+ @value = self.class.type.new(value)
49
+ end
60
50
 
61
- def get
62
- @value.get
63
- end
51
+ def set(value)
52
+ @value.set(value)
53
+ end
64
54
 
65
- def to_compact(out)
66
- @value.to_compact(out)
67
- end
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
- module FIXED
23
-
24
- module CLASS
25
-
26
- def from_compact!(input)
27
- if opt?
28
- self.new(input.getFixedOptional!)
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
- module INSTANCE
32
+ def self.size
33
+ @type.size
34
+ end
41
35
 
42
- def set(value)
43
- if value
44
- if value.kind_of? String
45
- if value.size == self.class.size
46
- @value = value
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 "expecting string"
42
+ raise Error.new "must be #{@size} bytes"
52
43
  end
53
- elsif self.class.opt?
54
- @value = nil
55
44
  else
56
- raise Error.new "value unacceptable"
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
- def get
61
- @value
62
- end
54
+ def get
55
+ @value
56
+ end
63
57
 
64
- def initialize(value)
65
- if value
66
- set(value)
67
- else
68
- @value = nil
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
- def to_compact(out)
73
- if self.opt?
74
- out.putFixedOptional(@value)
75
- else
76
- out.putFixed(@value)
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
- module FLOATING_POINT
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
- module INSTANCE
33
-
34
- def set(value)
35
- if value
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 Error.new "value unacceptable"
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
- def get
49
- @value
50
- end
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
- def to_compact(out)
61
- out.putF64(@value)
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