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.
- checksums.yaml +4 -4
- data/ext/slow_blink/ext_compact_encoder/compact_encoder.c +258 -0
- data/ext/slow_blink/ext_compact_encoder/compact_encoder.h +92 -0
- data/ext/slow_blink/ext_compact_encoder/ext_compact_encoder.c +555 -0
- data/ext/slow_blink/ext_compact_encoder/extconf.rb +4 -0
- data/ext/slow_blink/ext_schema_parser/lexer.c +59 -59
- data/ext/slow_blink/ext_schema_parser/lexer.h +2 -2
- data/ext/slow_blink/ext_schema_parser/parser.c +380 -367
- data/ext/slow_blink/ext_schema_parser/parser.h +1 -1
- data/lib/slow_blink/annotatable.rb +1 -1
- data/lib/slow_blink/annotation.rb +5 -5
- data/lib/slow_blink/binary.rb +26 -0
- data/lib/slow_blink/boolean.rb +26 -0
- data/lib/slow_blink/compact_encoder.rb +45 -71
- data/lib/slow_blink/date.rb +25 -0
- data/lib/slow_blink/decimal.rb +26 -0
- data/lib/slow_blink/definition.rb +19 -10
- data/lib/slow_blink/enumeration.rb +14 -36
- data/lib/slow_blink/error.rb +19 -0
- data/lib/slow_blink/field.rb +3 -16
- data/lib/slow_blink/fixed.rb +26 -0
- data/lib/slow_blink/floating_point.rb +27 -0
- data/lib/slow_blink/group.rb +30 -43
- data/lib/slow_blink/incremental_annotation.rb +75 -21
- data/lib/slow_blink/integer.rb +65 -0
- data/lib/slow_blink/message/binary.rb +87 -0
- data/lib/slow_blink/message/boolean.rb +68 -0
- data/lib/slow_blink/message/date.rb +33 -0
- data/lib/slow_blink/message/decimal.rb +25 -0
- data/lib/slow_blink/message/enumeration.rb +69 -0
- data/lib/slow_blink/message/field.rb +73 -0
- data/lib/slow_blink/message/fixed.rb +84 -0
- data/lib/slow_blink/message/floating_point.rb +68 -0
- data/lib/slow_blink/message/group.rb +260 -0
- data/lib/slow_blink/message/integer.rb +217 -0
- data/lib/slow_blink/message/model.rb +202 -0
- data/lib/slow_blink/message/sequence.rb +85 -0
- data/lib/slow_blink/message/string.rb +95 -0
- data/lib/slow_blink/message/time.rb +78 -0
- data/lib/slow_blink/message/time_of_day.rb +132 -0
- data/lib/slow_blink/name_with_id.rb +2 -1
- data/lib/slow_blink/namespace.rb +140 -0
- data/lib/slow_blink/object.rb +29 -0
- data/lib/slow_blink/ref.rb +93 -0
- data/lib/slow_blink/schema.rb +94 -68
- data/lib/slow_blink/{component_reference.rb → schema_buffer.rb} +11 -22
- data/lib/slow_blink/sequence.rb +58 -0
- data/lib/slow_blink/string.rb +40 -0
- data/lib/slow_blink/sym.rb +4 -0
- data/lib/slow_blink/time.rb +30 -0
- data/lib/slow_blink/time_of_day.rb +30 -0
- data/lib/slow_blink/type.rb +7 -402
- data/lib/slow_blink/version.rb +1 -1
- data/lib/slow_blink.rb +1 -0
- data/rakefile +14 -3
- data/test/{integration/capture_stderr.rb → capture_stderr.rb} +0 -0
- data/test/tc_compact_encoder.rb +341 -0
- data/test/tc_field.rb +53 -0
- data/test/tc_group.rb +122 -0
- data/test/tc_incr_annote.rb +27 -0
- data/test/{integration/tc_inputs.rb → tc_inputs.rb} +7 -11
- data/test/tc_model.rb +65 -0
- data/test/tc_model_encode.rb +63 -0
- data/test/tc_namespace.rb +8 -0
- data/test/tc_types.rb +198 -0
- metadata +58 -11
- data/ext/slow_blink/ext_schema_parser/parser.l +0 -139
- data/ext/slow_blink/ext_schema_parser/parser.y +0 -932
- data/lib/slow_blink/message.rb +0 -43
@@ -0,0 +1,63 @@
|
|
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
|
+
require "test/unit"
|
21
|
+
require 'slow_blink'
|
22
|
+
|
23
|
+
class TestModelEncode < Test::Unit::TestCase
|
24
|
+
|
25
|
+
include SlowBlink
|
26
|
+
|
27
|
+
def test_think_blink
|
28
|
+
rawSchema = <<-eos
|
29
|
+
OrderExecuted/0x4c ->
|
30
|
+
string Symbol,
|
31
|
+
u64 OrderId,
|
32
|
+
u32 Price,
|
33
|
+
u32 Qty,
|
34
|
+
u8 MatchId
|
35
|
+
eos
|
36
|
+
schema = Schema.new(SchemaBuffer.new(rawSchema))
|
37
|
+
|
38
|
+
model = Message::Model.new(schema)
|
39
|
+
message = model.new do
|
40
|
+
group "OrderExecuted" do |g|
|
41
|
+
g["Symbol"] = "hey"
|
42
|
+
g["OrderId"] = 42
|
43
|
+
g["Price"] = 42
|
44
|
+
g["Qty"] = 42
|
45
|
+
g["MatchId"] = 42
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal("hey", message["Symbol"])
|
50
|
+
assert_equal(42, message["OrderId"])
|
51
|
+
assert_equal(42, message["Price"])
|
52
|
+
assert_equal(42, message["Qty"])
|
53
|
+
assert_equal(42, message["MatchId"])
|
54
|
+
|
55
|
+
output = message.to_compact
|
56
|
+
|
57
|
+
expected = "\x09\x4c\x03hey\x2a\x2a\x2a\x2a"
|
58
|
+
|
59
|
+
assert_equal(expected, output)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/test/tc_types.rb
ADDED
@@ -0,0 +1,198 @@
|
|
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
|
+
require "test/unit"
|
21
|
+
require 'slow_blink'
|
22
|
+
|
23
|
+
class TestTypes < Test::Unit::TestCase
|
24
|
+
|
25
|
+
include SlowBlink
|
26
|
+
|
27
|
+
def test_bool
|
28
|
+
input = "test -> bool test"
|
29
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
30
|
+
assert_equal(BOOLEAN, schema.ns[nil].group("test").field("test").type.class)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_u8
|
34
|
+
input = "test -> u8 test"
|
35
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
36
|
+
assert_equal(U8, schema.ns[nil].group("test").field("test").type.class)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_u16
|
40
|
+
input = "test -> u16 test"
|
41
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
42
|
+
assert_equal(U16, schema.ns[nil].group("test").field("test").type.class)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_u32
|
46
|
+
input = "test -> u32 test"
|
47
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
48
|
+
assert_equal(U32, schema.ns[nil].group("test").field("test").type.class)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_u64
|
52
|
+
input = "test -> u64 test"
|
53
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
54
|
+
assert_equal(U64, schema.ns[nil].group("test").field("test").type.class)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_i8
|
58
|
+
input = "test -> i8 test"
|
59
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
60
|
+
assert_equal(I8, schema.ns[nil].group("test").field("test").type.class)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_i16
|
64
|
+
input = "test -> i16 test"
|
65
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
66
|
+
assert_equal(I16, schema.ns[nil].group("test").field("test").type.class)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_i32
|
70
|
+
input = "test -> i32 test"
|
71
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
72
|
+
assert_equal(I32, schema.ns[nil].group("test").field("test").type.class)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_i64
|
76
|
+
input = "test -> i64 test"
|
77
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
78
|
+
assert_equal(I64, schema.ns[nil].group("test").field("test").type.class)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_f64
|
82
|
+
input = "test -> f64 test"
|
83
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
84
|
+
assert_equal(FLOATING_POINT, schema.ns[nil].group("test").field("test").type.class)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_string_without_size
|
88
|
+
input = "test -> string test"
|
89
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
90
|
+
assert_equal(STRING, schema.ns[nil].group("test").field("test").type.class)
|
91
|
+
assert_equal(nil, schema.ns[nil].group("test").field("test").type.size)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_string_with_size
|
95
|
+
input = "test -> string (42) test"
|
96
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
97
|
+
assert_equal(STRING, schema.ns[nil].group("test").field("test").type.class)
|
98
|
+
assert_equal(42, schema.ns[nil].group("test").field("test").type.size)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_binary_without_size
|
102
|
+
input = "test -> binary test"
|
103
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
104
|
+
assert_equal(BINARY, schema.ns[nil].group("test").field("test").type.class)
|
105
|
+
assert_equal(nil, schema.ns[nil].group("test").field("test").type.size)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_binary_with_size
|
109
|
+
input = "test -> binary (42) test "
|
110
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
111
|
+
assert_equal(BINARY, schema.ns[nil].group("test").field("test").type.class)
|
112
|
+
assert_equal(42, schema.ns[nil].group("test").field("test").type.size)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_fixed
|
116
|
+
input = "test -> fixed (42) test "
|
117
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
118
|
+
assert_equal(FIXED, schema.ns[nil].group("test").field("test").type.class)
|
119
|
+
assert_equal(42, schema.ns[nil].group("test").field("test").type.size)
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_enum
|
123
|
+
input = "colour = | blue"
|
124
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_enum_many
|
128
|
+
input = "colour = blue | white | red/5"
|
129
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_ref_enum
|
133
|
+
input = "colour = | blue test -> colour test"
|
134
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
135
|
+
assert_equal(REF, schema.ns[nil].group("test").field("test").type.class)
|
136
|
+
assert_equal(ENUMERATION, schema.ns[nil].group("test").field("test").type.ref.class)
|
137
|
+
assert_equal("blue", schema.ns[nil].group("test").field("test").type.ref.symbol("blue").name)
|
138
|
+
assert_equal(0, schema.ns[nil].group("test").field("test").type.ref.symbol("blue").val)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_ref_enum_many
|
142
|
+
input = "colour = blue | white | red/5 | orange test -> colour test"
|
143
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
144
|
+
assert_equal(REF, schema.ns[nil].group("test").field("test").type.class)
|
145
|
+
assert_equal(ENUMERATION, schema.ns[nil].group("test").field("test").type.ref.class)
|
146
|
+
assert_equal("blue", schema.ns[nil].group("test").field("test").type.ref.symbol("blue").name)
|
147
|
+
assert_equal(0, schema.ns[nil].group("test").field("test").type.ref.symbol("blue").val)
|
148
|
+
assert_equal("white", schema.ns[nil].group("test").field("test").type.ref.symbol("white").name)
|
149
|
+
assert_equal(1, schema.ns[nil].group("test").field("test").type.ref.symbol("white").val)
|
150
|
+
assert_equal("red", schema.ns[nil].group("test").field("test").type.ref.symbol("red").name)
|
151
|
+
assert_equal(5, schema.ns[nil].group("test").field("test").type.ref.symbol("red").val)
|
152
|
+
assert_equal("orange", schema.ns[nil].group("test").field("test").type.ref.symbol("orange").name)
|
153
|
+
assert_equal(6, schema.ns[nil].group("test").field("test").type.ref.symbol("orange").val)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_static_group
|
157
|
+
input = "static -> u8 one, u16 two test -> static one, string two"
|
158
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
159
|
+
assert_equal("one", schema.ns[nil].group("test").field("one").nameWithID.name)
|
160
|
+
assert_equal(REF, schema.ns[nil].group("test").field("one").type.class)
|
161
|
+
assert_equal(false, schema.ns[nil].group("test").field("one").type.dynamic?)
|
162
|
+
assert_equal("two", schema.ns[nil].group("test").field("two").nameWithID.name)
|
163
|
+
assert_equal(STRING, schema.ns[nil].group("test").field("two").type.class)
|
164
|
+
assert_equal("one", schema.ns[nil].group("test").field("one").type.ref.field("one").nameWithID.name)
|
165
|
+
assert_equal(U8, schema.ns[nil].group("test").field("one").type.ref.field("one").type.class)
|
166
|
+
assert_equal("two", schema.ns[nil].group("test").field("one").type.ref.field("two").nameWithID.name)
|
167
|
+
assert_equal(U16, schema.ns[nil].group("test").field("one").type.ref.field("two").type.class)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_dynamic_group
|
171
|
+
input = "dynamic -> u8 one, u16 two test -> dynamic * one, string two"
|
172
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
173
|
+
assert_equal("one", schema.ns[nil].group("test").field("one").nameWithID.name)
|
174
|
+
assert_equal(REF, schema.ns[nil].group("test").field("one").type.class)
|
175
|
+
assert_equal(true, schema.ns[nil].group("test").field("one").type.dynamic?)
|
176
|
+
assert_equal("two", schema.ns[nil].group("test").field("two").nameWithID.name)
|
177
|
+
assert_equal(STRING, schema.ns[nil].group("test").field("two").type.class)
|
178
|
+
assert_equal("one", schema.ns[nil].group("test").field("one").type.ref.field("one").nameWithID.name)
|
179
|
+
assert_equal(U8, schema.ns[nil].group("test").field("one").type.ref.field("one").type.class)
|
180
|
+
assert_equal("two", schema.ns[nil].group("test").field("one").type.ref.field("two").nameWithID.name)
|
181
|
+
assert_equal(U16, schema.ns[nil].group("test").field("one").type.ref.field("two").type.class)
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_dynamic_not_group
|
185
|
+
input = "thing = u8 one test -> thing * one, string two"
|
186
|
+
assert_raise do
|
187
|
+
Schema.new(SchemaBuffer.new(input))
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_any_group
|
192
|
+
input = "dynamic -> u8 one, u16 two test -> object one, string two"
|
193
|
+
schema = Schema.new(SchemaBuffer.new(input))
|
194
|
+
assert_equal("one", schema.ns[nil].group("test").field("one").nameWithID.name)
|
195
|
+
assert_equal(OBJECT, schema.ns[nil].group("test").field("one").type.class)
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slow_blink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Harper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -57,36 +57,75 @@ email: contact@cjh.id.au
|
|
57
57
|
executables: []
|
58
58
|
extensions:
|
59
59
|
- ext/slow_blink/ext_schema_parser/extconf.rb
|
60
|
+
- ext/slow_blink/ext_compact_encoder/extconf.rb
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
63
|
+
- ext/slow_blink/ext_compact_encoder/compact_encoder.c
|
64
|
+
- ext/slow_blink/ext_compact_encoder/compact_encoder.h
|
65
|
+
- ext/slow_blink/ext_compact_encoder/ext_compact_encoder.c
|
66
|
+
- ext/slow_blink/ext_compact_encoder/extconf.rb
|
62
67
|
- ext/slow_blink/ext_schema_parser/common.h
|
63
68
|
- ext/slow_blink/ext_schema_parser/extconf.rb
|
64
69
|
- ext/slow_blink/ext_schema_parser/lexer.c
|
65
70
|
- ext/slow_blink/ext_schema_parser/lexer.h
|
66
71
|
- ext/slow_blink/ext_schema_parser/parser.c
|
67
72
|
- ext/slow_blink/ext_schema_parser/parser.h
|
68
|
-
- ext/slow_blink/ext_schema_parser/parser.l
|
69
|
-
- ext/slow_blink/ext_schema_parser/parser.y
|
70
73
|
- lib/slow_blink.rb
|
71
74
|
- lib/slow_blink/annotatable.rb
|
72
75
|
- lib/slow_blink/annotation.rb
|
76
|
+
- lib/slow_blink/binary.rb
|
77
|
+
- lib/slow_blink/boolean.rb
|
73
78
|
- lib/slow_blink/compact_encoder.rb
|
74
|
-
- lib/slow_blink/
|
79
|
+
- lib/slow_blink/date.rb
|
80
|
+
- lib/slow_blink/decimal.rb
|
75
81
|
- lib/slow_blink/definition.rb
|
76
82
|
- lib/slow_blink/enumeration.rb
|
77
83
|
- lib/slow_blink/error.rb
|
78
84
|
- lib/slow_blink/field.rb
|
85
|
+
- lib/slow_blink/fixed.rb
|
86
|
+
- lib/slow_blink/floating_point.rb
|
79
87
|
- lib/slow_blink/group.rb
|
80
88
|
- lib/slow_blink/incremental_annotation.rb
|
81
|
-
- lib/slow_blink/
|
89
|
+
- lib/slow_blink/integer.rb
|
90
|
+
- lib/slow_blink/message/binary.rb
|
91
|
+
- lib/slow_blink/message/boolean.rb
|
92
|
+
- lib/slow_blink/message/date.rb
|
93
|
+
- lib/slow_blink/message/decimal.rb
|
94
|
+
- lib/slow_blink/message/enumeration.rb
|
95
|
+
- lib/slow_blink/message/field.rb
|
96
|
+
- lib/slow_blink/message/fixed.rb
|
97
|
+
- lib/slow_blink/message/floating_point.rb
|
98
|
+
- lib/slow_blink/message/group.rb
|
99
|
+
- lib/slow_blink/message/integer.rb
|
100
|
+
- lib/slow_blink/message/model.rb
|
101
|
+
- lib/slow_blink/message/sequence.rb
|
102
|
+
- lib/slow_blink/message/string.rb
|
103
|
+
- lib/slow_blink/message/time.rb
|
104
|
+
- lib/slow_blink/message/time_of_day.rb
|
82
105
|
- lib/slow_blink/name_with_id.rb
|
106
|
+
- lib/slow_blink/namespace.rb
|
107
|
+
- lib/slow_blink/object.rb
|
108
|
+
- lib/slow_blink/ref.rb
|
83
109
|
- lib/slow_blink/schema.rb
|
110
|
+
- lib/slow_blink/schema_buffer.rb
|
111
|
+
- lib/slow_blink/sequence.rb
|
112
|
+
- lib/slow_blink/string.rb
|
84
113
|
- lib/slow_blink/sym.rb
|
114
|
+
- lib/slow_blink/time.rb
|
115
|
+
- lib/slow_blink/time_of_day.rb
|
85
116
|
- lib/slow_blink/type.rb
|
86
117
|
- lib/slow_blink/version.rb
|
87
118
|
- rakefile
|
88
|
-
- test/
|
89
|
-
- test/
|
119
|
+
- test/capture_stderr.rb
|
120
|
+
- test/tc_compact_encoder.rb
|
121
|
+
- test/tc_field.rb
|
122
|
+
- test/tc_group.rb
|
123
|
+
- test/tc_incr_annote.rb
|
124
|
+
- test/tc_inputs.rb
|
125
|
+
- test/tc_model.rb
|
126
|
+
- test/tc_model_encode.rb
|
127
|
+
- test/tc_namespace.rb
|
128
|
+
- test/tc_types.rb
|
90
129
|
homepage: https://github.com/cjhdev/slow_blink
|
91
130
|
licenses:
|
92
131
|
- MIT
|
@@ -110,8 +149,16 @@ rubyforge_project:
|
|
110
149
|
rubygems_version: 2.5.1
|
111
150
|
signing_key:
|
112
151
|
specification_version: 4
|
113
|
-
summary: Blink Protocol in Ruby
|
152
|
+
summary: Blink Protocol in Ruby
|
114
153
|
test_files:
|
115
|
-
- test/
|
116
|
-
- test/
|
154
|
+
- test/tc_compact_encoder.rb
|
155
|
+
- test/tc_group.rb
|
156
|
+
- test/tc_inputs.rb
|
157
|
+
- test/tc_model_encode.rb
|
158
|
+
- test/tc_namespace.rb
|
159
|
+
- test/tc_types.rb
|
160
|
+
- test/capture_stderr.rb
|
161
|
+
- test/tc_model.rb
|
162
|
+
- test/tc_field.rb
|
163
|
+
- test/tc_incr_annote.rb
|
117
164
|
has_rdoc: yard
|
@@ -1,139 +0,0 @@
|
|
1
|
-
/* Blink Protocol Flex Configuration
|
2
|
-
*
|
3
|
-
* Cameron Harper 2016
|
4
|
-
*
|
5
|
-
* */
|
6
|
-
%{
|
7
|
-
|
8
|
-
/* includes ***********************************************************/
|
9
|
-
|
10
|
-
#include <float.h>
|
11
|
-
#include <ruby.h>
|
12
|
-
#include "parser.h"
|
13
|
-
|
14
|
-
/* static prototypes **************************************************/
|
15
|
-
|
16
|
-
/**
|
17
|
-
* - Inserted into lexer as part of the YY_USER_ACTION macro
|
18
|
-
* -
|
19
|
-
*
|
20
|
-
* @param[in] loc pointer to Bison location record
|
21
|
-
* @param[in] text
|
22
|
-
* @param[in] textLen length of text in bytes
|
23
|
-
*
|
24
|
-
* */
|
25
|
-
static void updateLocation(YYLTYPE *loc, const char *text, int textLen);
|
26
|
-
|
27
|
-
/* macros *************************************************************/
|
28
|
-
|
29
|
-
#define YY_USER_ACTION updateLocation(yylloc, yytext, yyleng);
|
30
|
-
|
31
|
-
/* generated **********************************************************/
|
32
|
-
|
33
|
-
%}
|
34
|
-
|
35
|
-
%top{
|
36
|
-
|
37
|
-
#include "common.h"
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
%option nounput
|
42
|
-
%option noinput
|
43
|
-
%option bison-bridge bison-locations
|
44
|
-
%option reentrant
|
45
|
-
%option noyywrap
|
46
|
-
%option debug
|
47
|
-
|
48
|
-
|
49
|
-
%x LITERAL_C
|
50
|
-
%x LITERAL_A
|
51
|
-
|
52
|
-
%%
|
53
|
-
|
54
|
-
"#"[^\r\n]* { /* skip comments */ }
|
55
|
-
|
56
|
-
"\"" { BEGIN(LITERAL_C); }
|
57
|
-
<LITERAL_C>[^\"]* { *yylval = rb_str_new(yytext, yyleng); return TOK_LITERAL; }
|
58
|
-
<LITERAL_C>"\"" { BEGIN(INITIAL); }
|
59
|
-
|
60
|
-
"'" { BEGIN(LITERAL_A); }
|
61
|
-
<LITERAL_A>[^']* { *yylval = rb_str_new(yytext, yyleng); return TOK_LITERAL; }
|
62
|
-
<LITERAL_A>"'" { BEGIN(INITIAL); }
|
63
|
-
|
64
|
-
"=" |
|
65
|
-
"," |
|
66
|
-
"?" |
|
67
|
-
"[" |
|
68
|
-
"]" |
|
69
|
-
"(" |
|
70
|
-
")" |
|
71
|
-
"*" |
|
72
|
-
"|" |
|
73
|
-
"." |
|
74
|
-
"/" |
|
75
|
-
"@" |
|
76
|
-
":" { return *yytext; }
|
77
|
-
|
78
|
-
"i8" { return TOK_I8; }
|
79
|
-
"i16" { return TOK_I16; }
|
80
|
-
"i32" { return TOK_I32; }
|
81
|
-
"i64" { return TOK_I64; }
|
82
|
-
"u8" { return TOK_U8; }
|
83
|
-
"u16" { return TOK_U16; }
|
84
|
-
"u32" { return TOK_U32; }
|
85
|
-
"u64" { return TOK_U64; }
|
86
|
-
"f64" { return TOK_F64; }
|
87
|
-
"decimal" { return TOK_DECIMAL; }
|
88
|
-
"date" { return TOK_DATE; }
|
89
|
-
"timeOfDayMilli" { return TOK_TIME_OF_DAY_MILLI; }
|
90
|
-
"timeOfDayNano" { return TOK_TIME_OF_DAY_NANO; }
|
91
|
-
"nanotime" { return TOK_NANO_TIME; }
|
92
|
-
"millitime" { return TOK_MILLI_TIME; }
|
93
|
-
"bool" { return TOK_BOOLEAN; }
|
94
|
-
"string" { return TOK_STRING; }
|
95
|
-
"object" { return TOK_OBJECT; }
|
96
|
-
"namespace" { return TOK_NAMESPACE; }
|
97
|
-
"type" { return TOK_TYPE; }
|
98
|
-
"schema" { return TOK_SCHEMA; }
|
99
|
-
"number" { return TOK_NUMBER; }
|
100
|
-
"fixed" { return TOK_FIXED; }
|
101
|
-
"binary" { return TOK_BINARY; }
|
102
|
-
|
103
|
-
"->" { return TOK_RIGHT_ARROW; }
|
104
|
-
"<-" { return TOK_LEFT_ARROW; }
|
105
|
-
|
106
|
-
[0][x][0-9a-fA-F]+ { unsigned int tmp = 0; sscanf(yytext, "%x", &tmp); *yylval = UINT2NUM(tmp); return TOK_HEX; }
|
107
|
-
[0-9]+ { unsigned int tmp = 0; sscanf(yytext, "%u", &tmp); *yylval = UINT2NUM(tmp); return TOK_UINT; }
|
108
|
-
[-][1-9][0-9]* { int tmp = 0; sscanf(yytext, "%i", &tmp); *yylval = INT2NUM(tmp); return TOK_INT; }
|
109
|
-
|
110
|
-
[_a-zA-Z][_a-zA-Z0-9]*[:][_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_C_NAME; }
|
111
|
-
[_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_NC_NAME; }
|
112
|
-
[\\][_a-zA-Z][_a-zA-Z0-9]* { *yylval = rb_str_new(yytext, yyleng); return TOK_ESCAPED_NC_NAME; }
|
113
|
-
|
114
|
-
.|\n {}
|
115
|
-
|
116
|
-
%%
|
117
|
-
|
118
|
-
/* static functions ***************************************************/
|
119
|
-
|
120
|
-
static void updateLocation(YYLTYPE *loc, const char *text, int textLen)
|
121
|
-
{
|
122
|
-
int i;
|
123
|
-
|
124
|
-
loc->first_line = loc->last_line;
|
125
|
-
loc->first_column = loc->last_column;
|
126
|
-
|
127
|
-
for(i=0; i < textLen; i++){
|
128
|
-
|
129
|
-
if(text[i] == '\n'){
|
130
|
-
|
131
|
-
loc->last_line++;
|
132
|
-
loc->last_column = 0;
|
133
|
-
}
|
134
|
-
else{
|
135
|
-
|
136
|
-
loc->last_column++;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|