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.
- checksums.yaml +4 -4
- data/ext/slow_blink/ext_schema_parser/lexer.c +2793 -839
- data/ext/slow_blink/ext_schema_parser/lexer.h +14 -137
- data/ext/slow_blink/ext_schema_parser/parser.c +616 -670
- data/ext/slow_blink/ext_schema_parser/parser.h +6 -4
- data/ext/slow_blink/message/ext_compact_encoder/blink_compact.c +642 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_compact.h +411 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_debug.h +46 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_stream.c +314 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_stream.h +185 -0
- data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +382 -269
- data/lib/slow_blink/definition.rb +18 -53
- data/lib/slow_blink/dynamic_group.rb +8 -0
- data/lib/slow_blink/enum.rb +101 -0
- data/lib/slow_blink/field.rb +63 -33
- data/lib/slow_blink/generate_c/model.rb +89 -0
- data/lib/slow_blink/group.rb +119 -100
- data/lib/slow_blink/message/binary.rb +3 -4
- data/lib/slow_blink/message/boolean.rb +3 -4
- data/lib/slow_blink/message/date.rb +3 -4
- data/lib/slow_blink/message/decimal.rb +3 -5
- data/lib/slow_blink/message/{enumeration.rb → enum.rb} +17 -17
- data/lib/slow_blink/message/field.rb +77 -27
- data/lib/slow_blink/message/fixed.rb +5 -21
- data/lib/slow_blink/message/floating_point.rb +3 -4
- data/lib/slow_blink/message/group.rb +90 -161
- data/lib/slow_blink/message/integer.rb +24 -32
- data/lib/slow_blink/message/model.rb +50 -110
- data/lib/slow_blink/message/string.rb +3 -4
- data/lib/slow_blink/message/time.rb +5 -5
- data/lib/slow_blink/message/time_of_day.rb +5 -12
- data/lib/slow_blink/ref.rb +22 -71
- data/lib/slow_blink/schema.rb +64 -85
- data/lib/slow_blink/schema_buffer.rb +1 -4
- data/lib/slow_blink/static_group.rb +37 -0
- data/lib/slow_blink/string.rb +4 -5
- data/lib/slow_blink/sym.rb +8 -28
- data/lib/slow_blink/type.rb +10 -19
- data/lib/slow_blink/version.rb +1 -1
- data/lib/slow_blink.rb +1 -0
- data/test/tc_compact_encoder.rb +114 -147
- data/test/tc_inputs.rb +2 -4
- data/test/tc_model_string.rb +29 -0
- data/test/tc_schema_new.rb +212 -0
- metadata +17 -26
- data/ext/slow_blink/ext_schema_parser/common.h +0 -27
- data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +0 -258
- data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.h +0 -92
- data/lib/slow_blink/annotatable.rb +0 -48
- data/lib/slow_blink/annotation.rb +0 -47
- data/lib/slow_blink/enumeration.rb +0 -90
- data/lib/slow_blink/incremental_annotation.rb +0 -151
- data/lib/slow_blink/log.rb +0 -51
- data/lib/slow_blink/message/sequence.rb +0 -98
- data/lib/slow_blink/name_with_id.rb +0 -49
- data/lib/slow_blink/namespace.rb +0 -143
- data/lib/slow_blink/sequence.rb +0 -57
- data/test/tc_field.rb +0 -94
- data/test/tc_group.rb +0 -114
- data/test/tc_incr_annote.rb +0 -22
- data/test/tc_namespace.rb +0 -8
- data/test/tc_types.rb +0 -218
@@ -1,92 +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
|
-
#ifndef COMPACT_ENCODER_H
|
24
|
-
#define COMPACT_ENCODER_H
|
25
|
-
|
26
|
-
|
27
|
-
/* includes ***********************************************************/
|
28
|
-
|
29
|
-
#include <stdint.h>
|
30
|
-
#include <stdbool.h>
|
31
|
-
|
32
|
-
/* functions **********************************************************/
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Encode a VLC null
|
36
|
-
*
|
37
|
-
* @param[out] out output buffer
|
38
|
-
* @param[in] outMax maximum byte length of `out`
|
39
|
-
*
|
40
|
-
* @return bytes successfully written to `out`
|
41
|
-
*
|
42
|
-
* */
|
43
|
-
uint8_t BLINK_putNull(uint8_t *out, uint32_t outMax);
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Return minimum number of bytes required to VLC encode unsigned integer value
|
47
|
-
*
|
48
|
-
* @param[in] value value to encode as VLC
|
49
|
-
*
|
50
|
-
* @return minimum bytes to VLC encode value
|
51
|
-
*
|
52
|
-
* */
|
53
|
-
uint8_t BLINK_getSizeUnsigned(uint64_t value);
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Return minimum number of bytes required to VLC encode signed integer value
|
57
|
-
*
|
58
|
-
* @param[in] value value to encode as VLC
|
59
|
-
*
|
60
|
-
* @return minimum bytes to VLC encode value
|
61
|
-
*
|
62
|
-
* */
|
63
|
-
uint8_t BLINK_getSizeSigned(int64_t value);
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Encode signed/unsigned integer as VLC
|
67
|
-
*
|
68
|
-
* @param[in] value signed or unsigned value to encode
|
69
|
-
* @param[in] isSigned `true` to indicated `value` is a signed integer
|
70
|
-
* @param[out] out output buffer
|
71
|
-
* @param[in] outMax maximum byte lenght of `out`
|
72
|
-
*
|
73
|
-
* @return bytes successfully written to `out`
|
74
|
-
*
|
75
|
-
* */
|
76
|
-
uint8_t BLINK_putVLC(uint64_t in, bool isSigned, uint8_t *out, uint32_t outMax);
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Decode signed/unsigned integer as VLC
|
80
|
-
*
|
81
|
-
* @param[in] in input buffer
|
82
|
-
* @param[in] inLen byte length of `in`
|
83
|
-
* @param[in] isSigned integer shall be intepreted as 2s complement
|
84
|
-
* @param[out] out output integer buffer
|
85
|
-
* @param[out] isNull set `true` if `in` decodes to NULL
|
86
|
-
*
|
87
|
-
* @return bytes successfully read from `in`
|
88
|
-
*
|
89
|
-
* */
|
90
|
-
uint8_t BLINK_getVLC(const uint8_t *in, uint32_t inLen, bool isSigned, uint64_t *out, bool *isNull);
|
91
|
-
|
92
|
-
#endif
|
@@ -1,48 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
module SlowBlink
|
24
|
-
|
25
|
-
module Annotatable
|
26
|
-
|
27
|
-
# @return [Array<Annotation>]
|
28
|
-
attr_reader :annotes
|
29
|
-
|
30
|
-
# @param annotes [Array<Annotation,Integer>]
|
31
|
-
def annote(annotes)
|
32
|
-
annotes.each do |a|
|
33
|
-
if a.is_a? Annotation
|
34
|
-
if @annotes[a.id]
|
35
|
-
puts "#{a.location}: warning: overriding previous annotation for id '#{a.id}'"
|
36
|
-
end
|
37
|
-
@annotes[a.id] = a
|
38
|
-
else
|
39
|
-
if @nameWithID.id
|
40
|
-
puts "#{a.location}: warning: overriding previous id"
|
41
|
-
end
|
42
|
-
@nameWithID.id = a.to_i
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,47 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
module SlowBlink
|
24
|
-
|
25
|
-
class Annotation
|
26
|
-
|
27
|
-
# @macro location
|
28
|
-
attr_reader :location
|
29
|
-
|
30
|
-
# @return [String]
|
31
|
-
attr_reader :id
|
32
|
-
|
33
|
-
# @return [Integer]
|
34
|
-
attr_reader :value
|
35
|
-
|
36
|
-
# @param id [String] any string
|
37
|
-
# @param value [String] any string
|
38
|
-
# @param location [String]
|
39
|
-
def initialize(id,value,location)
|
40
|
-
@id = id
|
41
|
-
@value = value
|
42
|
-
@location = value
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
@@ -1,90 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
module SlowBlink
|
23
|
-
|
24
|
-
class ENUMERATION
|
25
|
-
|
26
|
-
include Annotatable
|
27
|
-
|
28
|
-
attr_reader :symbols
|
29
|
-
|
30
|
-
def self.===(other)
|
31
|
-
self == other
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param syms [Array<Sym>] symbol list
|
35
|
-
def initialize(syms)
|
36
|
-
@annotes = {}
|
37
|
-
@rawSyms = syms
|
38
|
-
@symbols = {}
|
39
|
-
@schema = nil
|
40
|
-
end
|
41
|
-
|
42
|
-
# @api private
|
43
|
-
#
|
44
|
-
# Resolve references, enforce constraints, and detect cycles
|
45
|
-
#
|
46
|
-
# @param schema [Schema] schema this definition belongs to
|
47
|
-
# @param ns [Namespace] namespace this definition belongs to
|
48
|
-
# @param stack [nil, Array] objects that depend on this object
|
49
|
-
# @return [true,false] linked?
|
50
|
-
def link(schema, ns, stack=[])
|
51
|
-
if @schema.nil?
|
52
|
-
value = 0
|
53
|
-
@symbols = {}
|
54
|
-
@schema = schema
|
55
|
-
@rawSyms.each do |s|
|
56
|
-
if @symbols[s.name]
|
57
|
-
Log.error "#{s.location}: error: symbols within an enumeration must have unique names ('#{s.name}' first appears at #{@symbols[s.name].location})"
|
58
|
-
@schema = nil
|
59
|
-
else
|
60
|
-
if s.val
|
61
|
-
if @symbols.values.include? s.val
|
62
|
-
Log.error "#{s.location}: error: values of symbols must be distinct ('#{s.val}' first appears at #{@symbols[s.val].location})"
|
63
|
-
@schema = nil
|
64
|
-
else
|
65
|
-
value = s.val + 1
|
66
|
-
end
|
67
|
-
else
|
68
|
-
s.val = value
|
69
|
-
value += 1
|
70
|
-
end
|
71
|
-
@symbols[s.name] = s
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
@schema
|
76
|
-
end
|
77
|
-
|
78
|
-
# @param nameOrVal [String,Integer]
|
79
|
-
# @return [Sym]
|
80
|
-
# @return [nil]
|
81
|
-
def symbol(nameOrVal)
|
82
|
-
if nameOrVal.kind_of? String
|
83
|
-
@symbols[nameOrVal]
|
84
|
-
else
|
85
|
-
@symbols.values.detect{|s|s.val == nameOrVal.to_i}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
@@ -1,151 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
module SlowBlink
|
24
|
-
|
25
|
-
# Blink Specification 7.3
|
26
|
-
class IncrementalAnnotation
|
27
|
-
|
28
|
-
# @return [SchemaRef, DefinitionRef, DefinitionTypeRef, FieldRef, FieldTypeRef]
|
29
|
-
attr_reader :componentReference
|
30
|
-
|
31
|
-
# @return [Array<Integer,Annotation>]
|
32
|
-
attr_reader :annotes
|
33
|
-
|
34
|
-
# @macro location
|
35
|
-
attr_reader :location
|
36
|
-
|
37
|
-
# @param componentReference [SchemaRef, DefinitionRef, DefinitionTypeRef, FieldRef, FieldTypeRef] annotation target
|
38
|
-
# @param annotes [Array<Integer,Annotation>]
|
39
|
-
# @param location [String]
|
40
|
-
def initialize(componentReference, annotes, location)
|
41
|
-
@componentReference = componentReference
|
42
|
-
@annotes = annotes
|
43
|
-
@location = location
|
44
|
-
@schema = nil
|
45
|
-
end
|
46
|
-
|
47
|
-
# @api private
|
48
|
-
#
|
49
|
-
# Apply annotes to targets
|
50
|
-
#
|
51
|
-
# @param schema [Schema]
|
52
|
-
# @param namespace [Namespace] the namespace this annotation was defined in
|
53
|
-
#
|
54
|
-
def apply(schema, namespace)
|
55
|
-
if @schema.nil?
|
56
|
-
case @componentReference.class
|
57
|
-
when SchemaRef # this actually refers to the Namespace
|
58
|
-
namespace.annote(@annotes)
|
59
|
-
@schema = schema
|
60
|
-
when DefinitionRef
|
61
|
-
object = schema.resolve(@componentReference.namespace, @componentReference.name)
|
62
|
-
if object
|
63
|
-
object.annote(@annotes)
|
64
|
-
@schema = schema
|
65
|
-
end
|
66
|
-
when DefinitionTypeRef
|
67
|
-
object = schema.resolve(@componentReference.namespace, @componentReference.name)
|
68
|
-
if object
|
69
|
-
object.type.annote(@annotes)
|
70
|
-
@schema = schema
|
71
|
-
end
|
72
|
-
when FieldRef
|
73
|
-
object = schema.resolve(@componentReference.namespace, @componentReference.name)
|
74
|
-
if object
|
75
|
-
field = object.field(@componentReference.subname)
|
76
|
-
if field
|
77
|
-
field.annote(@annotes)
|
78
|
-
@schema = schema
|
79
|
-
end
|
80
|
-
end
|
81
|
-
when FieldTypeRef
|
82
|
-
object = schema.resolve(@componentReference.namespace, @componentReference.name)
|
83
|
-
if object
|
84
|
-
field = object.field(@componentReference.subname)
|
85
|
-
if field
|
86
|
-
field.type.annote(@annotes)
|
87
|
-
@schema = schema
|
88
|
-
end
|
89
|
-
end
|
90
|
-
else
|
91
|
-
raise ParseError.new "unknown component reference #{@componentReference.class}".freeze
|
92
|
-
end
|
93
|
-
end
|
94
|
-
@schema
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
# SCHEMA
|
100
|
-
class SchemaRef
|
101
|
-
def self.===(other)
|
102
|
-
self == other
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# qName
|
107
|
-
class DefinitionRef < SchemaRef
|
108
|
-
attr_reader :namespace
|
109
|
-
attr_reader :name
|
110
|
-
attr_reader :qname
|
111
|
-
# @param qName [String] name of the definition to annotate
|
112
|
-
def initialize(qname)
|
113
|
-
@qname = qname
|
114
|
-
if qname.split(":").size == 1
|
115
|
-
@namespace = nil
|
116
|
-
@name = qname
|
117
|
-
else
|
118
|
-
@namespace = qname.split(":").first
|
119
|
-
@name = qName.split(":").last
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
# qName.TYPE
|
125
|
-
class DefinitionTypeRef < DefinitionRef
|
126
|
-
end
|
127
|
-
|
128
|
-
# qName.name
|
129
|
-
class FieldRef < SchemaRef
|
130
|
-
attr_reader :namespace
|
131
|
-
attr_reader :name
|
132
|
-
attr_reader :qname
|
133
|
-
attr_reader :subname
|
134
|
-
def initialize(qname, name)
|
135
|
-
@qname = qname
|
136
|
-
if qname.split(":").size == 1
|
137
|
-
@namespace = nil
|
138
|
-
@name = qname
|
139
|
-
else
|
140
|
-
@namespace = qname.split(":").first
|
141
|
-
@name = qName.split(":").last
|
142
|
-
end
|
143
|
-
@subname = name
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# qName.name.TYPE
|
148
|
-
class FieldTypeRef < FieldRef
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
data/lib/slow_blink/log.rb
DELETED
@@ -1,51 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
module SlowBlink
|
24
|
-
|
25
|
-
class Log
|
26
|
-
|
27
|
-
@file = STDERR
|
28
|
-
|
29
|
-
def self.file=(file)
|
30
|
-
@file = file
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.file
|
34
|
-
@file
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.error(msg)
|
38
|
-
if @file
|
39
|
-
@file.puts(msg)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.info(msg)
|
44
|
-
if @file
|
45
|
-
@file.puts(msg)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,98 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
module SlowBlink::Message
|
23
|
-
|
24
|
-
# @abstract
|
25
|
-
class SEQUENCE
|
26
|
-
|
27
|
-
# @return the type that repeats in this SEQUENCE
|
28
|
-
def self.type
|
29
|
-
@type
|
30
|
-
end
|
31
|
-
|
32
|
-
# @private
|
33
|
-
def self.from_compact!(input, stack)
|
34
|
-
|
35
|
-
if stack.size < @maxRecursion
|
36
|
-
stack << self
|
37
|
-
else
|
38
|
-
raise RecursionLimit
|
39
|
-
end
|
40
|
-
|
41
|
-
value = []
|
42
|
-
size = input.getU32!
|
43
|
-
if size
|
44
|
-
while value.size < size do
|
45
|
-
value << @type.from_compact!(input, stack)
|
46
|
-
end
|
47
|
-
result = self.new(value)
|
48
|
-
else
|
49
|
-
result = nil
|
50
|
-
end
|
51
|
-
|
52
|
-
stack.pop
|
53
|
-
|
54
|
-
result
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
# @return [Array]
|
59
|
-
def get
|
60
|
-
@value.map{|v|v.get}
|
61
|
-
end
|
62
|
-
|
63
|
-
# Set value of a SEQUENCE
|
64
|
-
#
|
65
|
-
# @param value [Array]
|
66
|
-
# @raise [TypeError]
|
67
|
-
# @raise [RangeError]
|
68
|
-
def set(value)
|
69
|
-
@value = []
|
70
|
-
if value.kind_of? Array
|
71
|
-
value.each do |v|
|
72
|
-
if v.kind_of? self.class.type
|
73
|
-
@value << v
|
74
|
-
else
|
75
|
-
@value << self.class.type.new(v)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
else
|
79
|
-
raise TypeError.new "expecting an array"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# @note calls {#set}(value)
|
84
|
-
def initialize(value)
|
85
|
-
set(value)
|
86
|
-
end
|
87
|
-
|
88
|
-
# @private
|
89
|
-
def to_compact(out)
|
90
|
-
out.putU32(@value.size)
|
91
|
-
@value.each do |value|
|
92
|
-
value.to_compact(out)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
@@ -1,49 +0,0 @@
|
|
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.
|
14
|
-
#
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
module SlowBlink
|
24
|
-
class NameWithID
|
25
|
-
|
26
|
-
include Annotatable
|
27
|
-
|
28
|
-
# @return [String]
|
29
|
-
attr_reader :name
|
30
|
-
|
31
|
-
# @return [Integer,nil]
|
32
|
-
attr_reader :id
|
33
|
-
|
34
|
-
# @param name [String]
|
35
|
-
# @param id [nil,Integer]
|
36
|
-
def initialize(name, id)
|
37
|
-
@annotes = {}
|
38
|
-
@name = name
|
39
|
-
@id = id
|
40
|
-
end
|
41
|
-
|
42
|
-
# @api private
|
43
|
-
# @param value [Integer]
|
44
|
-
def id=(value)
|
45
|
-
@id = id
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|