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/version.rb
CHANGED
data/lib/ynl.rb
CHANGED
|
@@ -25,19 +25,11 @@ module Ynl
|
|
|
25
25
|
# @private
|
|
26
26
|
module Types
|
|
27
27
|
Scalar = Data.define(:type, :byte_order) do
|
|
28
|
-
def resolve(f)
|
|
29
|
-
self
|
|
30
|
-
end
|
|
31
|
-
|
|
32
28
|
def rbs_type
|
|
33
29
|
'::Integer'
|
|
34
30
|
end
|
|
35
31
|
end
|
|
36
32
|
String = Struct.new do
|
|
37
|
-
def resolve(f)
|
|
38
|
-
self
|
|
39
|
-
end
|
|
40
|
-
|
|
41
33
|
def rbs_type
|
|
42
34
|
'::String'
|
|
43
35
|
end
|
|
@@ -45,21 +37,11 @@ module Ynl
|
|
|
45
37
|
Binary = Struct.new(:struct, :length, :display_hint) do
|
|
46
38
|
using Generator::Refinements
|
|
47
39
|
|
|
48
|
-
def resolve(f)
|
|
49
|
-
self.struct = struct.resolve(f) if self.struct
|
|
50
|
-
self
|
|
51
|
-
end
|
|
52
|
-
|
|
53
40
|
def rbs_type
|
|
54
41
|
struct ? 'Structs::' + struct.name.as_class_name : '::String'
|
|
55
42
|
end
|
|
56
43
|
end
|
|
57
44
|
PackedArray = Struct.new(:sub_type) do
|
|
58
|
-
def resolve(f)
|
|
59
|
-
self.sub_type = sub_type.resolve(f)
|
|
60
|
-
self
|
|
61
|
-
end
|
|
62
|
-
|
|
63
45
|
def rbs_type
|
|
64
46
|
"::Array[#{sub_type.rbs_type}]"
|
|
65
47
|
end
|
|
@@ -67,11 +49,6 @@ module Ynl
|
|
|
67
49
|
NestedAttributes = Struct.new(:attribute_set) do
|
|
68
50
|
using Generator::Refinements # FIXME:
|
|
69
51
|
|
|
70
|
-
def resolve(f)
|
|
71
|
-
self.attribute_set = attribute_set.resolve(f)
|
|
72
|
-
self
|
|
73
|
-
end
|
|
74
|
-
|
|
75
52
|
def rbs_type
|
|
76
53
|
'AttributeSets::' + attribute_set.name.as_class_name
|
|
77
54
|
end
|
|
@@ -79,11 +56,6 @@ module Ynl
|
|
|
79
56
|
NestTypeValue = Struct.new(:attribute_set, :type_values) do
|
|
80
57
|
using Generator::Refinements
|
|
81
58
|
|
|
82
|
-
def resolve(f)
|
|
83
|
-
self.attribute_set = attribute_set.resolve(f)
|
|
84
|
-
self
|
|
85
|
-
end
|
|
86
|
-
|
|
87
59
|
def rbs_type
|
|
88
60
|
type = 'AttributeSets::' + attribute_set.name.as_class_name
|
|
89
61
|
type_values.length.times { type = "::Hash[::Integer, #{type}]" }
|
|
@@ -91,52 +63,30 @@ module Ynl
|
|
|
91
63
|
end
|
|
92
64
|
end
|
|
93
65
|
SubMessage = Struct.new(:sub_message, :selector) do
|
|
94
|
-
def resolve(f)
|
|
95
|
-
self.sub_message = sub_message.resolve(f)
|
|
96
|
-
self
|
|
97
|
-
end
|
|
98
|
-
|
|
99
66
|
def rbs_type
|
|
100
|
-
'::Nl::
|
|
67
|
+
'::Nl::Message | ::Nl::RawAttributeValue'
|
|
101
68
|
end
|
|
102
69
|
end
|
|
103
70
|
|
|
104
71
|
Pad = Data.define(:length) do
|
|
105
|
-
def resolve(f)
|
|
106
|
-
self
|
|
107
|
-
end
|
|
108
|
-
|
|
109
72
|
def rbs_type
|
|
110
73
|
'nil'
|
|
111
74
|
end
|
|
112
75
|
end
|
|
113
76
|
|
|
114
77
|
Flag = Data.define do
|
|
115
|
-
def resolve(f)
|
|
116
|
-
self
|
|
117
|
-
end
|
|
118
|
-
|
|
119
78
|
def rbs_type
|
|
120
79
|
'::Integer'
|
|
121
80
|
end
|
|
122
81
|
end
|
|
123
82
|
|
|
124
83
|
Bitfield32 = Data.define do
|
|
125
|
-
def resolve(f)
|
|
126
|
-
self
|
|
127
|
-
end
|
|
128
|
-
|
|
129
84
|
def rbs_type
|
|
130
85
|
'::Nl::Bitfield32'
|
|
131
86
|
end
|
|
132
87
|
end
|
|
133
88
|
|
|
134
89
|
IndexedArray = Struct.new(:sub_type) do
|
|
135
|
-
def resolve(f)
|
|
136
|
-
self.sub_type = sub_type.resolve(f)
|
|
137
|
-
self
|
|
138
|
-
end
|
|
139
|
-
|
|
140
90
|
def rbs_type
|
|
141
91
|
"::Array[#{sub_type.rbs_type}]"
|
|
142
92
|
end
|
|
@@ -46,7 +46,7 @@ module Ynl
|
|
|
46
46
|
|
|
47
47
|
private def emit_singleton_class: () -> untyped
|
|
48
48
|
|
|
49
|
-
private def emit_const: (untyped name, untyped value, ?rbs: untyped, ?internal: untyped) -> untyped
|
|
49
|
+
private def emit_const: (untyped name, untyped value, ?rbs: untyped, ?internal: untyped, ?make_shareable: untyped) -> untyped
|
|
50
50
|
|
|
51
51
|
private def emit_value_definitions: (untyped namespace, untyped definitions) -> untyped
|
|
52
52
|
|
|
@@ -70,6 +70,10 @@ module Ynl
|
|
|
70
70
|
|
|
71
71
|
private def notification_layout: (untyped operation) -> untyped
|
|
72
72
|
|
|
73
|
+
private def emit_fixed_field_decode: (untyped struct, ?members: untyped) -> untyped
|
|
74
|
+
|
|
75
|
+
private def emit_payload_storage: (untyped header, untyped attribute_set, external: untyped) -> untyped
|
|
76
|
+
|
|
73
77
|
private def emit_message_class: (untyped name, untyped message, fixed_header: untyped, attribute_set: untyped, doc: untyped) -> untyped
|
|
74
78
|
|
|
75
79
|
private def emit_sub_messages: () -> untyped
|
|
@@ -146,6 +150,12 @@ module Ynl
|
|
|
146
150
|
|
|
147
151
|
private def to_datatype: (untyped type, untyped checks, ?owner: untyped) -> untyped
|
|
148
152
|
|
|
153
|
+
private def grouped_member_width: (untyped type) -> untyped
|
|
154
|
+
|
|
155
|
+
private def grouped_scalar_value: (untyped type, untyped offset) -> untyped
|
|
156
|
+
|
|
157
|
+
private def struct_member_reader: (untyped type) -> untyped
|
|
158
|
+
|
|
149
159
|
private def to_struct_member_datatype: (untyped type) -> untyped
|
|
150
160
|
|
|
151
161
|
private def to_checks: (untyped checks) -> untyped
|
|
@@ -5,17 +5,9 @@ module Ynl
|
|
|
5
5
|
Family: untyped
|
|
6
6
|
|
|
7
7
|
class Family
|
|
8
|
-
def resolve: () -> untyped
|
|
9
|
-
|
|
10
8
|
def find_type: (untyped name) -> untyped
|
|
11
9
|
end
|
|
12
10
|
|
|
13
|
-
class Thunk
|
|
14
|
-
def initialize: () ?{ (?) -> untyped } -> untyped
|
|
15
|
-
|
|
16
|
-
def resolve: (untyped f) -> untyped
|
|
17
|
-
end
|
|
18
|
-
|
|
19
11
|
Const: untyped
|
|
20
12
|
|
|
21
13
|
Check: untyped
|
|
@@ -27,9 +19,7 @@ module Ynl
|
|
|
27
19
|
|
|
28
20
|
attr_reader formats: untyped
|
|
29
21
|
|
|
30
|
-
def initialize: (name: untyped) -> untyped
|
|
31
|
-
|
|
32
|
-
def resolve: (untyped f) -> untyped
|
|
22
|
+
def initialize: (name: untyped, formats: untyped) -> untyped
|
|
33
23
|
end
|
|
34
24
|
|
|
35
25
|
class Enum
|
|
@@ -41,9 +31,7 @@ module Ynl
|
|
|
41
31
|
|
|
42
32
|
attr_reader doc: untyped
|
|
43
33
|
|
|
44
|
-
def initialize: (name: untyped, doc: untyped) -> untyped
|
|
45
|
-
|
|
46
|
-
def resolve: (untyped f) -> untyped
|
|
34
|
+
def initialize: (name: untyped, entries: untyped, doc: untyped) -> untyped
|
|
47
35
|
end
|
|
48
36
|
|
|
49
37
|
class Flags
|
|
@@ -55,9 +43,7 @@ module Ynl
|
|
|
55
43
|
|
|
56
44
|
attr_reader doc: untyped
|
|
57
45
|
|
|
58
|
-
def initialize: (name: untyped, doc: untyped) -> untyped
|
|
59
|
-
|
|
60
|
-
def resolve: (untyped f) -> untyped
|
|
46
|
+
def initialize: (name: untyped, entries: untyped, doc: untyped) -> untyped
|
|
61
47
|
end
|
|
62
48
|
|
|
63
49
|
class Struct
|
|
@@ -69,9 +55,7 @@ module Ynl
|
|
|
69
55
|
|
|
70
56
|
attr_reader doc: untyped
|
|
71
57
|
|
|
72
|
-
def initialize: (name: untyped, doc: untyped) -> untyped
|
|
73
|
-
|
|
74
|
-
def resolve: (untyped f) -> untyped
|
|
58
|
+
def initialize: (name: untyped, members: untyped, doc: untyped) -> untyped
|
|
75
59
|
end
|
|
76
60
|
|
|
77
61
|
class AttributeSet
|
|
@@ -85,9 +69,7 @@ module Ynl
|
|
|
85
69
|
|
|
86
70
|
attr_reader doc: untyped
|
|
87
71
|
|
|
88
|
-
def initialize: (name: untyped, name_prefix: untyped, doc: untyped) -> untyped
|
|
89
|
-
|
|
90
|
-
def resolve: (untyped f) -> untyped
|
|
72
|
+
def initialize: (name: untyped, name_prefix: untyped, attributes: untyped, doc: untyped) -> untyped
|
|
91
73
|
end
|
|
92
74
|
|
|
93
75
|
class AttributeSubset
|
|
@@ -100,8 +82,6 @@ module Ynl
|
|
|
100
82
|
def initialize: (name: untyped, superset: untyped, attributes: untyped, doc: untyped) -> untyped
|
|
101
83
|
|
|
102
84
|
def attributes: () -> untyped
|
|
103
|
-
|
|
104
|
-
def resolve: (untyped f) -> untyped
|
|
105
85
|
end
|
|
106
86
|
|
|
107
87
|
McastGroup: untyped
|
|
@@ -124,8 +104,6 @@ module Ynl
|
|
|
124
104
|
attr_reader notification: untyped
|
|
125
105
|
|
|
126
106
|
def initialize: (name: untyped, doc: untyped, flags: untyped, fixed_header: untyped, attribute_set: untyped, doit: untyped, dumpit: untyped, notification: untyped) -> untyped
|
|
127
|
-
|
|
128
|
-
def resolve: (untyped f) -> untyped
|
|
129
107
|
end
|
|
130
108
|
|
|
131
109
|
class Notification
|
|
@@ -138,8 +116,6 @@ module Ynl
|
|
|
138
116
|
attr_reader group: untyped
|
|
139
117
|
|
|
140
118
|
def initialize: (kind: untyped, message: untyped, source: untyped, group: untyped) -> untyped
|
|
141
|
-
|
|
142
|
-
def resolve: (untyped f) -> untyped
|
|
143
119
|
end
|
|
144
120
|
|
|
145
121
|
class RequestReply
|
|
@@ -148,8 +124,6 @@ module Ynl
|
|
|
148
124
|
attr_reader reply: untyped
|
|
149
125
|
|
|
150
126
|
def initialize: (request: untyped, reply: untyped) -> untyped
|
|
151
|
-
|
|
152
|
-
def resolve: (untyped f) -> untyped
|
|
153
127
|
end
|
|
154
128
|
|
|
155
129
|
class Message
|
|
@@ -158,8 +132,6 @@ module Ynl
|
|
|
158
132
|
attr_reader attributes: untyped
|
|
159
133
|
|
|
160
134
|
def initialize: (value: untyped, attributes: untyped) -> untyped
|
|
161
|
-
|
|
162
|
-
def resolve: (untyped f) -> untyped
|
|
163
135
|
end
|
|
164
136
|
end
|
|
165
137
|
end
|
|
@@ -11,51 +11,74 @@ module Ynl
|
|
|
11
11
|
# @rbs (String | _PathLike path) -> Models::Family
|
|
12
12
|
def self.parse_file: (String | _PathLike path) -> Models::Family
|
|
13
13
|
|
|
14
|
+
# Returns a complete, deeply frozen model graph.
|
|
14
15
|
# @return [Models::Family]
|
|
15
16
|
# @rbs () -> Models::Family
|
|
16
17
|
def parse: () -> Models::Family
|
|
17
18
|
|
|
18
|
-
private def
|
|
19
|
+
private def normalize: () -> untyped
|
|
20
|
+
|
|
21
|
+
private def materialize: () -> untyped
|
|
22
|
+
|
|
23
|
+
# Establish identities through ordinary constructors. Their owned arrays
|
|
24
|
+
# remain mutable until the corresponding members, attributes, or formats
|
|
25
|
+
# have been built; references can already point to these models.
|
|
26
|
+
private def declare_models: () -> untyped
|
|
27
|
+
|
|
28
|
+
private def declare_attribute_set: (untyped name) -> untyped
|
|
29
|
+
|
|
30
|
+
private def register: (untyped table, untyped model) -> untyped
|
|
31
|
+
|
|
32
|
+
private def reference: (untyped table, untyped name, untyped kind) -> untyped
|
|
33
|
+
|
|
34
|
+
private def find_type: (untyped name) -> untyped
|
|
35
|
+
|
|
36
|
+
private def build_definition: (untyped d) -> untyped
|
|
19
37
|
|
|
20
38
|
private def reject_enum_flags_name_collision: (untyped name, untyped other_definitions) -> untyped
|
|
21
39
|
|
|
22
|
-
private def
|
|
40
|
+
private def build_const: (untyped d) -> untyped
|
|
41
|
+
|
|
42
|
+
private def build_enum_flags: (untyped d, type: untyped) -> untyped
|
|
23
43
|
|
|
24
|
-
private def
|
|
44
|
+
private def build_struct_member_type: (untyped d) -> untyped
|
|
25
45
|
|
|
26
|
-
private def
|
|
46
|
+
private def build_attribute_type: (untyped d) -> untyped
|
|
27
47
|
|
|
28
|
-
private def
|
|
48
|
+
private def build_indexed_array_sub_type: (untyped d) -> untyped
|
|
29
49
|
|
|
30
|
-
private def
|
|
50
|
+
private def build_packed_array_sub_type: (untyped d) -> untyped
|
|
31
51
|
|
|
32
|
-
private def
|
|
52
|
+
private def build_byte_order: (untyped v) -> untyped
|
|
33
53
|
|
|
34
|
-
private def
|
|
54
|
+
private def build_struct: (untyped d) -> untyped
|
|
35
55
|
|
|
36
|
-
private def
|
|
56
|
+
private def build_checks: (untyped d) -> untyped
|
|
37
57
|
|
|
38
|
-
private def
|
|
58
|
+
private def build_check: (untyped op, untyped value_literal) -> untyped
|
|
39
59
|
|
|
40
|
-
private def
|
|
60
|
+
private def build_value: (untyped v) -> untyped
|
|
41
61
|
|
|
42
|
-
|
|
62
|
+
# Subsets depend on their parent's normalized contents, unlike ordinary
|
|
63
|
+
# references, which only need the target's identity. Expand that dependency
|
|
64
|
+
# separately so forward subsets work and inheritance cycles fail clearly.
|
|
65
|
+
private def attribute_definitions: (untyped name) -> untyped
|
|
43
66
|
|
|
44
|
-
private def
|
|
67
|
+
private def build_attribute_set: (untyped d) -> untyped
|
|
45
68
|
|
|
46
|
-
private def
|
|
69
|
+
private def build_attribute: (untyped d) -> untyped
|
|
47
70
|
|
|
48
|
-
private def
|
|
71
|
+
private def build_sub_message: (untyped d) -> untyped
|
|
49
72
|
|
|
50
|
-
private def
|
|
73
|
+
private def build_operation: (untyped d, request_id: untyped, reply_id: untyped) -> untyped
|
|
51
74
|
|
|
52
|
-
private def
|
|
75
|
+
private def build_notification: (untyped d, default_id: untyped) -> untyped
|
|
53
76
|
|
|
54
|
-
private def
|
|
77
|
+
private def build_request_reply: (untyped d, default_request_id: untyped, default_reply_id: untyped) -> untyped
|
|
55
78
|
|
|
56
|
-
private def
|
|
79
|
+
private def build_message: (untyped d, default_id: untyped) -> untyped
|
|
57
80
|
|
|
58
|
-
private def
|
|
81
|
+
private def build_mcast_group: (untyped d) -> untyped
|
|
59
82
|
|
|
60
83
|
private def translate_doc: (untyped doc) -> untyped
|
|
61
84
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ynl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kasumi Hanazuki
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.5.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.5.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: yaml
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|