ynl 0.4.2 → 0.5.0
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/CHANGELOG.md +5 -0
- data/lib/ynl/family.rb +2 -1
- data/lib/ynl/generator.rb +317 -129
- data/lib/ynl/models.rb +12 -107
- data/lib/ynl/parser.rb +303 -214
- data/lib/ynl/version.rb +1 -1
- data/lib/ynl.rb +1 -51
- data/sig/generated/ynl/generator.rbs +11 -1
- data/sig/generated/ynl/models.rbs +5 -33
- data/sig/generated/ynl/parser.rbs +43 -20
- metadata +3 -3
data/lib/ynl/models.rb
CHANGED
|
@@ -4,53 +4,22 @@ module Ynl
|
|
|
4
4
|
:consts, :enums, :flags, :structs,
|
|
5
5
|
:attribute_sets, :sub_messages, :operations, :mcast_groups)
|
|
6
6
|
class Family
|
|
7
|
-
def resolve
|
|
8
|
-
structs.transform_values! {|s| s.resolve(self) }
|
|
9
|
-
sub_messages.transform_values! {|s| s.resolve(self) }
|
|
10
|
-
attribute_sets.transform_values! {|s| s.resolve(self) }
|
|
11
|
-
operations.transform_values! {|operation| operation.resolve(self) }
|
|
12
|
-
self
|
|
13
|
-
end
|
|
14
|
-
|
|
15
7
|
def find_type(name)
|
|
16
8
|
enums[name] or flags[name] or structs[name] or raise ParseError, "Unknown type: #{name}"
|
|
17
9
|
end
|
|
18
10
|
end
|
|
19
11
|
|
|
20
|
-
class Thunk
|
|
21
|
-
def initialize(&block)
|
|
22
|
-
@block = block
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def resolve(f)
|
|
26
|
-
raise ParseError, "Circular dependency" if @resolving
|
|
27
|
-
@resolving = true
|
|
28
|
-
@block.call(f)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
12
|
Const = ::Struct.new(:name, :value, :doc)
|
|
33
13
|
Check = ::Struct.new(:operation, :value)
|
|
34
14
|
|
|
35
15
|
class SubMessage
|
|
36
|
-
Format = ::Struct.new(:value, :fixed_header, :attribute_set)
|
|
37
|
-
def resolve(f)
|
|
38
|
-
self.fixed_header = fixed_header.resolve(f) if fixed_header.is_a?(Thunk)
|
|
39
|
-
self.attribute_set = attribute_set.resolve(f) if attribute_set.is_a?(Thunk)
|
|
40
|
-
self
|
|
41
|
-
end
|
|
42
|
-
end
|
|
16
|
+
Format = ::Struct.new(:value, :fixed_header, :attribute_set)
|
|
43
17
|
|
|
44
18
|
attr_reader :name, :formats
|
|
45
19
|
|
|
46
|
-
def initialize(name:)
|
|
20
|
+
def initialize(name:, formats:)
|
|
47
21
|
@name = name
|
|
48
|
-
@formats =
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def resolve(f)
|
|
52
|
-
formats.map! { it.resolve(f) }
|
|
53
|
-
self
|
|
22
|
+
@formats = formats
|
|
54
23
|
end
|
|
55
24
|
end
|
|
56
25
|
|
|
@@ -59,15 +28,11 @@ module Ynl
|
|
|
59
28
|
|
|
60
29
|
attr_reader :name, :entries, :doc
|
|
61
30
|
|
|
62
|
-
def initialize(name:, doc:)
|
|
31
|
+
def initialize(name:, entries:, doc:)
|
|
63
32
|
@name = name
|
|
64
|
-
@entries =
|
|
33
|
+
@entries = entries
|
|
65
34
|
@doc = doc
|
|
66
35
|
end
|
|
67
|
-
|
|
68
|
-
def resolve(f)
|
|
69
|
-
self
|
|
70
|
-
end
|
|
71
36
|
end
|
|
72
37
|
|
|
73
38
|
class Flags
|
|
@@ -75,47 +40,27 @@ module Ynl
|
|
|
75
40
|
|
|
76
41
|
attr_reader :name, :entries, :doc
|
|
77
42
|
|
|
78
|
-
def initialize(name:, doc:)
|
|
43
|
+
def initialize(name:, entries:, doc:)
|
|
79
44
|
@name = name
|
|
80
|
-
@entries =
|
|
45
|
+
@entries = entries
|
|
81
46
|
@doc = doc
|
|
82
47
|
end
|
|
83
|
-
|
|
84
|
-
def resolve(f)
|
|
85
|
-
self
|
|
86
|
-
end
|
|
87
48
|
end
|
|
88
49
|
|
|
89
50
|
class Struct
|
|
90
|
-
Member = ::Struct.new(:name, :type, :doc)
|
|
91
|
-
def resolve(f)
|
|
92
|
-
self.type = self.type.resolve(f)
|
|
93
|
-
self
|
|
94
|
-
end
|
|
95
|
-
end
|
|
51
|
+
Member = ::Struct.new(:name, :type, :doc)
|
|
96
52
|
|
|
97
53
|
attr_reader :name, :members, :doc
|
|
98
54
|
|
|
99
|
-
def initialize(name:, doc:)
|
|
55
|
+
def initialize(name:, members:, doc:)
|
|
100
56
|
@name = name
|
|
101
|
-
@members =
|
|
57
|
+
@members = members
|
|
102
58
|
@doc = doc
|
|
103
59
|
end
|
|
104
|
-
|
|
105
|
-
def resolve(f)
|
|
106
|
-
@members.map! {|m| m.resolve(f) }
|
|
107
|
-
self
|
|
108
|
-
end
|
|
109
60
|
end
|
|
110
61
|
|
|
111
62
|
class AttributeSet
|
|
112
63
|
Attribute = ::Struct.new(:name, :type, :value, :checks, :doc, :multi_attr, :enum, :enum_as_flags) do
|
|
113
|
-
def resolve(f)
|
|
114
|
-
self.type = type.resolve(f)
|
|
115
|
-
self.enum = enum.resolve(f) if enum
|
|
116
|
-
self
|
|
117
|
-
end
|
|
118
|
-
|
|
119
64
|
def multi?
|
|
120
65
|
multi_attr
|
|
121
66
|
end
|
|
@@ -123,19 +68,12 @@ module Ynl
|
|
|
123
68
|
|
|
124
69
|
attr_reader :name, :name_prefix, :attributes, :doc
|
|
125
70
|
|
|
126
|
-
def initialize(name:, name_prefix:, doc:)
|
|
71
|
+
def initialize(name:, name_prefix:, attributes:, doc:)
|
|
127
72
|
@name = name
|
|
128
73
|
@name_prefix = name_prefix
|
|
129
|
-
@attributes =
|
|
74
|
+
@attributes = attributes
|
|
130
75
|
@doc = doc
|
|
131
76
|
end
|
|
132
|
-
|
|
133
|
-
def resolve(f)
|
|
134
|
-
attributes.map! { it.resolve(f) }
|
|
135
|
-
self
|
|
136
|
-
rescue
|
|
137
|
-
raise ParseError, "Failed to resolve attribute set: #{name}"
|
|
138
|
-
end
|
|
139
77
|
end
|
|
140
78
|
|
|
141
79
|
class AttributeSubset
|
|
@@ -151,13 +89,6 @@ module Ynl
|
|
|
151
89
|
def attributes
|
|
152
90
|
@attributes
|
|
153
91
|
end
|
|
154
|
-
|
|
155
|
-
def resolve(f)
|
|
156
|
-
attributes.map! { it.resolve(f) }
|
|
157
|
-
self
|
|
158
|
-
rescue
|
|
159
|
-
raise ParseError, "Failed to resolve attribute subset: #{name}"
|
|
160
|
-
end
|
|
161
92
|
end
|
|
162
93
|
|
|
163
94
|
McastGroup = ::Struct.new(:name, :value, :doc)
|
|
@@ -175,13 +106,6 @@ module Ynl
|
|
|
175
106
|
@dumpit = dumpit
|
|
176
107
|
@notification = notification
|
|
177
108
|
end
|
|
178
|
-
|
|
179
|
-
def resolve(f)
|
|
180
|
-
@doit = @doit&.resolve(f)
|
|
181
|
-
@dumpit = @dumpit&.resolve(f)
|
|
182
|
-
@notification = @notification&.resolve(f)
|
|
183
|
-
self
|
|
184
|
-
end
|
|
185
109
|
end
|
|
186
110
|
|
|
187
111
|
class Notification
|
|
@@ -193,15 +117,6 @@ module Ynl
|
|
|
193
117
|
@source = source
|
|
194
118
|
@group = group
|
|
195
119
|
end
|
|
196
|
-
|
|
197
|
-
def resolve(f)
|
|
198
|
-
@message = @message.resolve(f)
|
|
199
|
-
@source = f.operations.fetch(@source) if @source
|
|
200
|
-
@group = f.mcast_groups.fetch(@group) if @group
|
|
201
|
-
self
|
|
202
|
-
rescue KeyError => error
|
|
203
|
-
raise ParseError, "Failed to resolve #{kind} notification: #{error.message}"
|
|
204
|
-
end
|
|
205
120
|
end
|
|
206
121
|
|
|
207
122
|
class RequestReply
|
|
@@ -211,12 +126,6 @@ module Ynl
|
|
|
211
126
|
@request = request
|
|
212
127
|
@reply = reply
|
|
213
128
|
end
|
|
214
|
-
|
|
215
|
-
def resolve(f)
|
|
216
|
-
@request = @request&.resolve(f)
|
|
217
|
-
@reply = @reply&.resolve(f)
|
|
218
|
-
self
|
|
219
|
-
end
|
|
220
129
|
end
|
|
221
130
|
|
|
222
131
|
class Message
|
|
@@ -226,10 +135,6 @@ module Ynl
|
|
|
226
135
|
@value = value
|
|
227
136
|
@attributes = attributes
|
|
228
137
|
end
|
|
229
|
-
|
|
230
|
-
def resolve(f)
|
|
231
|
-
self
|
|
232
|
-
end
|
|
233
138
|
end
|
|
234
139
|
end
|
|
235
140
|
end
|