slow_blink 0.0.2 → 0.0.3

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/ext/slow_blink/ext_compact_encoder/compact_encoder.c +258 -0
  3. data/ext/slow_blink/ext_compact_encoder/compact_encoder.h +92 -0
  4. data/ext/slow_blink/ext_compact_encoder/ext_compact_encoder.c +555 -0
  5. data/ext/slow_blink/ext_compact_encoder/extconf.rb +4 -0
  6. data/ext/slow_blink/ext_schema_parser/lexer.c +59 -59
  7. data/ext/slow_blink/ext_schema_parser/lexer.h +2 -2
  8. data/ext/slow_blink/ext_schema_parser/parser.c +380 -367
  9. data/ext/slow_blink/ext_schema_parser/parser.h +1 -1
  10. data/lib/slow_blink/annotatable.rb +1 -1
  11. data/lib/slow_blink/annotation.rb +5 -5
  12. data/lib/slow_blink/binary.rb +26 -0
  13. data/lib/slow_blink/boolean.rb +26 -0
  14. data/lib/slow_blink/compact_encoder.rb +45 -71
  15. data/lib/slow_blink/date.rb +25 -0
  16. data/lib/slow_blink/decimal.rb +26 -0
  17. data/lib/slow_blink/definition.rb +19 -10
  18. data/lib/slow_blink/enumeration.rb +14 -36
  19. data/lib/slow_blink/error.rb +19 -0
  20. data/lib/slow_blink/field.rb +3 -16
  21. data/lib/slow_blink/fixed.rb +26 -0
  22. data/lib/slow_blink/floating_point.rb +27 -0
  23. data/lib/slow_blink/group.rb +30 -43
  24. data/lib/slow_blink/incremental_annotation.rb +75 -21
  25. data/lib/slow_blink/integer.rb +65 -0
  26. data/lib/slow_blink/message/binary.rb +87 -0
  27. data/lib/slow_blink/message/boolean.rb +68 -0
  28. data/lib/slow_blink/message/date.rb +33 -0
  29. data/lib/slow_blink/message/decimal.rb +25 -0
  30. data/lib/slow_blink/message/enumeration.rb +69 -0
  31. data/lib/slow_blink/message/field.rb +73 -0
  32. data/lib/slow_blink/message/fixed.rb +84 -0
  33. data/lib/slow_blink/message/floating_point.rb +68 -0
  34. data/lib/slow_blink/message/group.rb +260 -0
  35. data/lib/slow_blink/message/integer.rb +217 -0
  36. data/lib/slow_blink/message/model.rb +202 -0
  37. data/lib/slow_blink/message/sequence.rb +85 -0
  38. data/lib/slow_blink/message/string.rb +95 -0
  39. data/lib/slow_blink/message/time.rb +78 -0
  40. data/lib/slow_blink/message/time_of_day.rb +132 -0
  41. data/lib/slow_blink/name_with_id.rb +2 -1
  42. data/lib/slow_blink/namespace.rb +140 -0
  43. data/lib/slow_blink/object.rb +29 -0
  44. data/lib/slow_blink/ref.rb +93 -0
  45. data/lib/slow_blink/schema.rb +94 -68
  46. data/lib/slow_blink/{component_reference.rb → schema_buffer.rb} +11 -22
  47. data/lib/slow_blink/sequence.rb +58 -0
  48. data/lib/slow_blink/string.rb +40 -0
  49. data/lib/slow_blink/sym.rb +4 -0
  50. data/lib/slow_blink/time.rb +30 -0
  51. data/lib/slow_blink/time_of_day.rb +30 -0
  52. data/lib/slow_blink/type.rb +7 -402
  53. data/lib/slow_blink/version.rb +1 -1
  54. data/lib/slow_blink.rb +1 -0
  55. data/rakefile +14 -3
  56. data/test/{integration/capture_stderr.rb → capture_stderr.rb} +0 -0
  57. data/test/tc_compact_encoder.rb +341 -0
  58. data/test/tc_field.rb +53 -0
  59. data/test/tc_group.rb +122 -0
  60. data/test/tc_incr_annote.rb +27 -0
  61. data/test/{integration/tc_inputs.rb → tc_inputs.rb} +7 -11
  62. data/test/tc_model.rb +65 -0
  63. data/test/tc_model_encode.rb +63 -0
  64. data/test/tc_namespace.rb +8 -0
  65. data/test/tc_types.rb +198 -0
  66. metadata +58 -11
  67. data/ext/slow_blink/ext_schema_parser/parser.l +0 -139
  68. data/ext/slow_blink/ext_schema_parser/parser.y +0 -932
  69. data/lib/slow_blink/message.rb +0 -43
@@ -0,0 +1,140 @@
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
+ module SlowBlink
21
+
22
+ class Namespace
23
+
24
+ include Annotatable
25
+
26
+ # @return [Hash<Definition>]
27
+ attr_reader :definitions
28
+
29
+ # @return [Array<Group>]
30
+ attr_reader :groups
31
+
32
+ # @return [String]
33
+ attr_reader :name
34
+
35
+ # @return [Array<IncrementalAnnotation>]
36
+ attr_reader :incrAnnotations
37
+
38
+ # @!method self.parse(input, **opts)
39
+ #
40
+ # @param input [String] Blink Schema
41
+ # @param opts [Hash] options
42
+ # @option opts [String] :fileName filename to append to error message strings
43
+ # @return [Namespace]
44
+
45
+ # @private
46
+ #
47
+ # @param filename [nil,String]
48
+ # @param name [nil,String]
49
+ # @param defs [Array<Definition,Group>]
50
+ def initialize(filename, name, defs)
51
+
52
+ @filename = filename
53
+ @annotes = {}
54
+ @incrAnnotations = []
55
+ @groups = []
56
+ @definitions = {}
57
+ @name = name
58
+ @schema = nil
59
+
60
+ errors = 0
61
+
62
+ # populate table of definitions
63
+ # gather list of groups and incrAnnotations
64
+ # set namespace reference in each def
65
+ defs.each do |d|
66
+ if d.is_a? IncrementalAnnotation
67
+ @incrAnnotations << d
68
+ else
69
+ if @definitions[d.nameWithID.name]
70
+ puts "#{d.location}: error: duplicate definition name '#{d.nameWithID.name}' (first defined at #{definitions[d.nameWithID.name].location})"
71
+ errors += 1
72
+ else
73
+ @definitions[d.nameWithID.name] = d
74
+ if d.is_a? Group
75
+ @groups << d
76
+ end
77
+ d.namespace = self
78
+ end
79
+ end
80
+ end
81
+
82
+ if errors > 0
83
+ raise
84
+ end
85
+
86
+ end
87
+
88
+ # @param namespace [Namespace]
89
+ def merge!(namespace)
90
+ if namespace.name == @name
91
+ @incrAnnotations.concat(namespace.incrAnnotations)
92
+ namespace.definitions.each do |d|
93
+ if @definitions[d.nameWithID.name]
94
+ puts "#{d.location}: error: duplicate definition name '#{d.nameWithID.name}' (first defined at #{definitions[d.nameWithID.name].location})"
95
+ errors += 1
96
+ else
97
+ @definitions[d.nameWithID.name] = d
98
+ if d.is_a? Group
99
+ @groups << d
100
+ end
101
+ end
102
+ end
103
+ else
104
+ raise "error: cannot merge different namespaces"
105
+ end
106
+ end
107
+
108
+ # @param schema [Schema] common schema
109
+ # @param stack [Array] used to detect cycles
110
+ def link(schema, stack=[])
111
+ if @schema.nil?
112
+ errors = 0
113
+ @definitions.each do |name, d|
114
+ if !d.link(schema, stack.dup << self)
115
+ errors += 1
116
+ end
117
+ end
118
+ if errors == 0
119
+ @schema = schema
120
+ end
121
+ end
122
+ @schema
123
+ end
124
+
125
+ # @param name [String] unqualified name
126
+ # @return [Definition,Group]
127
+ def resolve(name)
128
+ @definitions[name]
129
+ end
130
+
131
+ def group(name)
132
+ @groups.detect{|g|g.nameWithID.name == name}
133
+ end
134
+
135
+ end
136
+
137
+ end
138
+
139
+
140
+
@@ -0,0 +1,29 @@
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
+ module SlowBlink
22
+
23
+ # any group
24
+ #
25
+ # Blink Specification 3.9
26
+ class OBJECT < Type
27
+ end
28
+
29
+ end
@@ -0,0 +1,93 @@
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
+ module SlowBlink
21
+
22
+ class REF < Type
23
+
24
+ # @return referenced object
25
+ attr_reader :ref
26
+
27
+ # @return [true] dynamic group reference
28
+ # @return [false] static reference
29
+ def dynamic?
30
+ @dynamic
31
+ end
32
+
33
+ # @return [String]
34
+ attr_reader :qname
35
+
36
+ # @private
37
+ #
38
+ # @param qname [String]
39
+ # @param dynamic [true,false]
40
+ # @param location [String]
41
+ def initialize(qname, dynamic, location)
42
+ @qname = qname
43
+ if qname.split(":").size == 1
44
+ @namespace = nil
45
+ @name = qname
46
+ else
47
+ @namespace = qname.split(":").first
48
+ @name = qname.split(":").last
49
+ end
50
+ @dynamic = dynamic
51
+ @ref = nil
52
+ super(location)
53
+ end
54
+
55
+ # @private
56
+ #
57
+ # @macro common_link
58
+ def link(schema, ns, stack=[])
59
+ if @schema.nil?
60
+ if @namespace
61
+ ref = schema.resolve(@namespace, @name)
62
+ else
63
+ ref = ns.resolve(@name) or schema.resolve(@namespace, @name)
64
+ end
65
+ if ref and ref.link(schema, stack << self)
66
+ # follow reference to get type
67
+ loop do
68
+ if ref.kind_of? Definition and ref.type.kind_of? REF
69
+ ref = ref.type.ref
70
+ else
71
+ if !ref.kind_of? Group
72
+ ref = ref.type
73
+ end
74
+ break
75
+ end
76
+ end
77
+ if @dynamic and !ref.kind_of? Group
78
+ puts "#{@location}: error: '#{@qname}' must resolve to a group with an ID"
79
+ else
80
+ @ref = ref
81
+ @schema = schema
82
+ end
83
+ else
84
+ puts "#{@location}: error: '#{@qname}' is not defined in schema"
85
+ end
86
+ end
87
+ @schema
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+
@@ -17,119 +17,145 @@
17
17
  # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
18
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
19
 
20
- require 'slow_blink/annotatable'
21
-
22
- # @!macro [new] common_link
23
- #
24
- # Resolve symbols to definitions in schema
25
- #
26
- # @param schema [Schema] schema to link
27
- # @param stack [Array]
28
- #
29
- # @return [Schema] linked
30
- # @return [nil] not linked
31
- #
32
-
33
20
  module SlowBlink
34
21
 
35
22
  class Schema
36
23
 
37
- include Annotatable
24
+ # Initialise a Schema from one or more Blink Schema files
25
+ #
26
+ # @param filename [Array<String>]
27
+ def self.read(*filename)
28
+ input = []
29
+ if filename.size > 0
30
+ filename.each do |f|
31
+ input << SchemaBuffer.new(File.read(f), f)
32
+ end
33
+ self.new(*input)
34
+ else
35
+ raise "at least one file required"
36
+ end
37
+ end
38
38
 
39
- # @!method self.parse(input, **opts)
39
+ # Tagged groups are able to be serialised as dynamic groups
40
40
  #
41
- # Initialise a Schema object from Blink Schema input string
41
+ # - These groups are of interest to message code generators
42
42
  #
43
- # @param input [String] Blink Schema
44
- # @param opts [Hash] options
45
- # @option opts [String] :fileName file input originated from (for error messages)
46
- # @return [Schema]
47
-
48
- # @param namespace [nil,String]
49
- # @param defs [Array<Definition>]
50
- def initialize(namespace, defs)
51
- @nameWithID = NameWithID.new(nil,nil)
52
- @annotes = []
53
- @groups = {}
54
- errors = 0
55
-
56
- if namespace
57
- @namespace = namespace
43
+ # @return [Hash]
44
+ attr_reader :tagged
45
+
46
+ # @return [Array<Namespace>]
47
+ attr_reader :ns
48
+
49
+ # @param buffer [Array<SchemaBuffer>]
50
+ def initialize(*buffer)
51
+
52
+ if buffer.size > 0
53
+ namespace = []
54
+ buffer.each do |b|
55
+ namespace << Namespace.parse(b.buffer, filename: b.filename)
56
+ end
58
57
  else
59
- @namespace = nil
58
+ raise "at least one buffer required"
60
59
  end
61
60
 
62
- @defs = {}
63
-
64
- # populate table of definitions
65
- defs.each do |d|
66
- if !d.is_a? IncrementalAnnotation
67
- if @defs[d.nameWithID.name]
68
- puts "#{d.location}: error: duplicate definition name"
61
+ @ns = {}
62
+ @tagged = {}
63
+
64
+ errors = 0
65
+
66
+ # gather and merge namespaces
67
+ namespace.each do |ns|
68
+ if @ns[ns.name]
69
+ begin
70
+ @ns[ns.name].merge!(ns)
71
+ rescue
69
72
  errors += 1
70
- else
71
- @defs[d.nameWithID.name] = d
72
73
  end
74
+ else
75
+ @ns[ns.name] = ns
73
76
  end
74
77
  end
75
78
 
76
- # now apply incremental annotation
77
- defs.each do |d|
78
- if d === IncrementalAnnotation
79
- d.link(schema)
79
+ # apply incremental annotation in order of input
80
+ namespace.each do |ns|
81
+ ns.incrAnnotations.each do |a|
82
+ a.apply(self, ns)
83
+ end
84
+ end
85
+
86
+ # gather tagged groups and detect duplicates
87
+ @ns.each do |name, ns|
88
+ ns.groups.each do |g|
89
+ if g.nameWithID.id
90
+ if @tagged[g.nameWithID.id]
91
+ puts "error: duplicate group id"
92
+ errors += 1
93
+ else
94
+ @tagged[g.nameWithID.id] = g
95
+ end
96
+ end
80
97
  end
81
98
  end
82
99
 
83
- # now link the definitions
84
- @defs.each do |name, d|
85
- if !d.link(self)
100
+ # resolve all references
101
+ @ns.each do |name, ns|
102
+ if !ns.link(self)
86
103
  errors += 1
87
104
  end
88
105
  end
89
-
106
+
90
107
  if errors > 0
91
108
  raise Error.new "#{errors} errors"
92
109
  end
93
110
 
94
111
  end
95
112
 
96
- # @param name [String] definition or group name
97
- # @return [Definition]
98
- # @return [Group]
99
- def symbol(name)
100
- @defs[name]
101
- end
102
-
103
- # @param nameOrID [String,Integer] group name or id
104
- # @return [Group] group exists
105
- # @return [nil] group does not exist
106
- def group(nameOrID)
107
- if nameOrID.kind_of? String
108
- @groups[nameOrID]
113
+ # resolve a name to a definition in any namespace
114
+ #
115
+ # @param namespace [String,nil]
116
+ # @param name [String]
117
+ # @return [Definition,Group]
118
+ def resolve(namespace, name)
119
+ if @ns[namespace]
120
+ @ns[namespace].resolve(name)
109
121
  else
110
- @groups.values.detect{|g|g.nameWithID.id == nameOrID}
111
- end
122
+ nil
123
+ end
112
124
  end
113
-
125
+
114
126
  end
115
127
 
116
128
  end
117
129
 
118
- require 'slow_blink/compact_encoder'
130
+ require 'slow_blink/schema_buffer'
131
+ require 'slow_blink/annotatable'
132
+ require 'slow_blink/namespace'
119
133
  require 'slow_blink/error'
134
+ require 'slow_blink/ext_compact_encoder'
120
135
  require 'slow_blink/version'
121
136
  require 'slow_blink/annotation'
122
137
  require 'slow_blink/incremental_annotation'
123
138
  require 'slow_blink/group'
124
139
  require 'slow_blink/field'
125
- require 'slow_blink/component_reference'
126
140
  require 'slow_blink/definition'
127
141
  require 'slow_blink/type'
142
+ require 'slow_blink/integer'
143
+ require 'slow_blink/decimal'
144
+ require 'slow_blink/floating_point'
145
+ require 'slow_blink/string'
146
+ require 'slow_blink/binary'
147
+ require 'slow_blink/fixed'
148
+ require 'slow_blink/date'
149
+ require 'slow_blink/time_of_day'
150
+ require 'slow_blink/time'
151
+ require 'slow_blink/sequence'
152
+ require 'slow_blink/ref'
153
+ require 'slow_blink/object'
154
+ require 'slow_blink/boolean'
128
155
  require 'slow_blink/enumeration'
129
156
  require 'slow_blink/sym'
130
157
  require 'slow_blink/name_with_id'
131
158
  require 'slow_blink/ext_schema_parser'
132
- require 'slow_blink/message'
133
159
 
134
160
 
135
161
 
@@ -19,32 +19,21 @@
19
19
 
20
20
  module SlowBlink
21
21
 
22
- # SCHEMA
23
- class SchemaRef
24
- end
25
-
26
- # qName
27
- class DefinitionRef < SchemaRef
28
- # @param qName [String] name of the definition to annotate
29
- def initialize(qName)
30
- @qName = qName
31
- end
32
- end
22
+ class SchemaBuffer
33
23
 
34
- # qName.TYPE
35
- class DefinitionTypeRef < DefinitionRef
36
- end
24
+ # @return [String]
25
+ attr_reader :buffer
37
26
 
38
- # qName.name
39
- class FieldRef < SchemaRef
40
- def initialize(qName, name)
41
- @qName = qName
42
- @name = name
27
+ # @return [String]
28
+ attr_reader :filename
29
+
30
+ # @param buffer [String] the contents of the file
31
+ # @param filename [String] name of the file (for error reporting)
32
+ def initialize(buffer, filename=nil)
33
+ @filename = filename
34
+ @buffer = buffer
43
35
  end
44
- end
45
36
 
46
- # qName.name.TYPE
47
- class FieldTypeRef < FieldRef
48
37
  end
49
38
 
50
39
  end
@@ -0,0 +1,58 @@
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
+ module SlowBlink
21
+
22
+ # Blink Specification 3.12
23
+ class SEQUENCE < Type
24
+
25
+ # @return [Type]
26
+ attr_reader :type
27
+
28
+ # @private
29
+ #
30
+ # @param type [Type] repeating type
31
+ # @param location [String]
32
+ def initialize(type, location)
33
+ @type = nil
34
+ @rawType = type
35
+ super(location)
36
+ end
37
+
38
+ # @private
39
+ #
40
+ # @macro common_link
41
+ def link(schema, stack=[])
42
+ if @schema.nil?
43
+ case @rawType.class
44
+ when REF
45
+ schema.definition(@rawType)
46
+ when SEQUENCE
47
+ puts "error: sequence of sequence is not permitted"
48
+ else
49
+ @type = @rawType
50
+ @schema = schema
51
+ end
52
+ end
53
+ @schema
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,40 @@
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
+ module SlowBlink
21
+
22
+ # Blink Specification 3.2
23
+ class STRING < Type
24
+
25
+ # @return [Integer] maximum size
26
+ # @return [nil] no maximum size
27
+ attr_reader :size
28
+
29
+ # @private
30
+ #
31
+ # @param size [Integer] maximum size
32
+ # @param location [String]
33
+ def initialize(size, location)
34
+ @size = size
35
+ super(location)
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -31,6 +31,10 @@ module SlowBlink
31
31
  # @return [Integer]
32
32
  attr_reader :val
33
33
 
34
+ def val=(value)
35
+ @val = value.to_i
36
+ end
37
+
34
38
  # @private
35
39
  #
36
40
  # @param name [String]
@@ -0,0 +1,30 @@
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
+ module SlowBlink
21
+
22
+ # Blink Specification 3.9
23
+ class MILLI_TIME < Type
24
+ end
25
+
26
+ # Blink Specification 3.9
27
+ class NANO_TIME < Type
28
+ end
29
+
30
+ end