retro_idl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/retro_idl/asn/ext_parser/ext_common.h +27 -0
- data/ext/retro_idl/asn/ext_parser/ext_parser.l +201 -0
- data/ext/retro_idl/asn/ext_parser/ext_parser.y +1207 -0
- data/ext/retro_idl/asn/ext_parser/extconf.rb +3 -0
- data/ext/retro_idl/asn/ext_parser/lexer.c +2873 -0
- data/ext/retro_idl/asn/ext_parser/lexer.h +366 -0
- data/ext/retro_idl/asn/ext_parser/parser.c +2963 -0
- data/ext/retro_idl/asn/ext_parser/parser.h +175 -0
- data/lib/retro_idl/asn/alternative_type.rb +43 -0
- data/lib/retro_idl/asn/asn.rb +309 -0
- data/lib/retro_idl/asn/asn_error.rb +2 -0
- data/lib/retro_idl/asn/base_type.rb +87 -0
- data/lib/retro_idl/asn/base_value.rb +75 -0
- data/lib/retro_idl/asn/bit_string.rb +44 -0
- data/lib/retro_idl/asn/boolean.rb +50 -0
- data/lib/retro_idl/asn/builtin_value.rb +51 -0
- data/lib/retro_idl/asn/choice.rb +95 -0
- data/lib/retro_idl/asn/component_type.rb +56 -0
- data/lib/retro_idl/asn/constraint.rb +162 -0
- data/lib/retro_idl/asn/defined_type.rb +61 -0
- data/lib/retro_idl/asn/defined_value.rb +82 -0
- data/lib/retro_idl/asn/enumerated.rb +127 -0
- data/lib/retro_idl/asn/enumeration_item.rb +103 -0
- data/lib/retro_idl/asn/integer.rb +84 -0
- data/lib/retro_idl/asn/location.rb +10 -0
- data/lib/retro_idl/asn/named_number.rb +83 -0
- data/lib/retro_idl/asn/null.rb +41 -0
- data/lib/retro_idl/asn/octetstring.rb +48 -0
- data/lib/retro_idl/asn/real.rb +36 -0
- data/lib/retro_idl/asn/sequence.rb +132 -0
- data/lib/retro_idl/asn/sequenceof.rb +62 -0
- data/lib/retro_idl/asn/single_value.rb +26 -0
- data/lib/retro_idl/asn/tag.rb +163 -0
- data/lib/retro_idl/asn/type_list.rb +121 -0
- data/lib/retro_idl/asn/value_assignment.rb +21 -0
- data/lib/retro_idl/asn/value_list.rb +48 -0
- data/lib/retro_idl.rb +20 -0
- data/rakefile +33 -0
- data/test/asn/ext_parser/capture_stderr.rb +20 -0
- data/test/asn/ext_parser/tc_ext_parser.rb +94 -0
- data/test/asn/parser/capture_stderr.rb +20 -0
- data/test/asn/parser/tc_parser.rb +90 -0
- metadata +133 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
class RetroIDL::ASN::BITSTRING < BaseType
|
3
|
+
|
4
|
+
TAG_CLASS_NUMBER = 3
|
5
|
+
TAG_CLASS = :universal
|
6
|
+
|
7
|
+
def initialize(**opts)
|
8
|
+
|
9
|
+
super(**opts)
|
10
|
+
@bitList = nil
|
11
|
+
if opts[:bitList]
|
12
|
+
@bitList = ValueList.new(opts[:bitList], NamedNumber)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# @macro common_link
|
18
|
+
def link(mod, stack)
|
19
|
+
|
20
|
+
if @mod.nil? or @mod != mod
|
21
|
+
@mod = nil
|
22
|
+
if @bitList.nil? or @bitList.link(mod, [])
|
23
|
+
super(mod, stack)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
@mod
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# @macro common_to_s
|
32
|
+
def to_s
|
33
|
+
|
34
|
+
result = "#{@tag} BIT STRING"
|
35
|
+
if @bitList
|
36
|
+
result << @bitList.to_s
|
37
|
+
end
|
38
|
+
result << " #{@constraint}"
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
@@ -0,0 +1,50 @@
|
|
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
|
+
class RetroIDL::ASN::BOOLEAN < BaseType
|
21
|
+
|
22
|
+
TAG_CLASS_NUMBER = 1
|
23
|
+
TAG_CLASS = :universal
|
24
|
+
|
25
|
+
# @macro common_to_s
|
26
|
+
def to_s
|
27
|
+
"#{@tag} BOOLEAN #{@constraint}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def evaluate(value)
|
31
|
+
|
32
|
+
if value.class != TrueClass and value.class != FalseClass
|
33
|
+
false
|
34
|
+
else
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def evaluateConstraint(value)
|
41
|
+
|
42
|
+
if evaluate(value) and ( @constraint or @constraint.evaluate(value) )
|
43
|
+
true
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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
|
+
# BuiltinValue aggregation
|
21
|
+
#
|
22
|
+
# X.680 section 17.2
|
23
|
+
class RetroIDL::ASN::BuiltinValue
|
24
|
+
|
25
|
+
def initialize(**opts)
|
26
|
+
|
27
|
+
@location = opts[:location]
|
28
|
+
@mod = nil
|
29
|
+
@value = opts[:value]
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
# return the Ruby native representation of this BuiltinType
|
34
|
+
#
|
35
|
+
# @return [Array, Hash, Numeric, String] native value
|
36
|
+
#
|
37
|
+
# @raise [ASNError] value cannot be returned if object is not linked
|
38
|
+
attr_reader :value
|
39
|
+
|
40
|
+
# @macro common_to_s
|
41
|
+
def to_s
|
42
|
+
|
43
|
+
"#{@value}"
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def link(mod, stack)
|
48
|
+
@mod = mod
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,95 @@
|
|
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
|
+
class RetroIDL::ASN::CHOICE < BaseType
|
22
|
+
|
23
|
+
def initialize(**opts)
|
24
|
+
|
25
|
+
super(**opts)
|
26
|
+
|
27
|
+
errors = false
|
28
|
+
|
29
|
+
@exception = opts[:exception]
|
30
|
+
@extensible = opts[:extensible]
|
31
|
+
@additional = nil
|
32
|
+
|
33
|
+
@root = TypeList.new(opts[:root], AlternativeType, self)
|
34
|
+
|
35
|
+
if opts[:additional]
|
36
|
+
|
37
|
+
@additional = TypeList.new(opts[:additional], AlternativeType, self)
|
38
|
+
|
39
|
+
@additional.list.each do |id, item|
|
40
|
+
|
41
|
+
if @root.list.keys.include? id
|
42
|
+
|
43
|
+
ASN.putError(item.location, "duplicate EnumerationItem")
|
44
|
+
errors = true
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
if errors
|
53
|
+
|
54
|
+
raise ASNError.new
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# @macro common_link
|
61
|
+
def link(mod, stack)
|
62
|
+
|
63
|
+
if @mod.nil? or @mod != mod
|
64
|
+
|
65
|
+
@mod = nil
|
66
|
+
|
67
|
+
if @root.nil? or @root.link(mod, stack)
|
68
|
+
|
69
|
+
if @additional.nil? or @additional.link(mod, stack)
|
70
|
+
|
71
|
+
|
72
|
+
super(mod, [])
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
@mod
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
# @macro common_to_s
|
85
|
+
def to_s
|
86
|
+
|
87
|
+
result = "#{@tag} CHOICE { #{@root} "
|
88
|
+
if @extensible
|
89
|
+
result << ", ... "
|
90
|
+
end
|
91
|
+
result << "} #{@constraint}"
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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
|
+
class RetroIDL::ASN::ComponentType
|
21
|
+
|
22
|
+
def initialize(**opts)
|
23
|
+
|
24
|
+
@optional = opts[:optional]
|
25
|
+
@type = RetroIDL::ASN.const_get(opts[:class]).new( **opts )
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def link(mod, stack)
|
30
|
+
|
31
|
+
@type.link(mod, stack.push(self))
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# @macro common_to_s
|
36
|
+
def to_s
|
37
|
+
|
38
|
+
@type.to_s
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [true] this component is optional
|
43
|
+
# @return [false] this component is not optional
|
44
|
+
def optional?
|
45
|
+
|
46
|
+
if @optional
|
47
|
+
true
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# reduce a crazy syntax into a set of ranges and values (for an integer)
|
2
|
+
# or for a size constraint...
|
3
|
+
#
|
4
|
+
#
|
5
|
+
|
6
|
+
class RetroIDL::ASN::Constraint
|
7
|
+
|
8
|
+
def initialize(**opts)
|
9
|
+
|
10
|
+
@location = opts[:location]
|
11
|
+
@root = []
|
12
|
+
@mod = nil
|
13
|
+
|
14
|
+
opts[:rootElementSetSpec].each do |element|
|
15
|
+
@root << RetroIDL::ASN.const_get(element[:class]).new(parent, element)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# @macro common_link
|
21
|
+
def link(mod, stack)
|
22
|
+
|
23
|
+
if @mod.nil? or @mod != mod
|
24
|
+
@mod = nil
|
25
|
+
@root.each do |element|
|
26
|
+
elem.link(@mod, [])
|
27
|
+
end
|
28
|
+
else
|
29
|
+
@mod
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
|
36
|
+
out = "( "
|
37
|
+
@root.each do |element|
|
38
|
+
puts element.class
|
39
|
+
out << element.to_s
|
40
|
+
end
|
41
|
+
out << " )"
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class Element
|
48
|
+
|
49
|
+
def initialize(parent, opts)
|
50
|
+
@parent = parent
|
51
|
+
@location = opts[:location]
|
52
|
+
end
|
53
|
+
|
54
|
+
def link(mod, stack)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
class SingleValue < Element
|
60
|
+
|
61
|
+
def initialize(parent, opts)
|
62
|
+
|
63
|
+
super
|
64
|
+
@value = RetroIDL::ASN.const_get(opts[:value][:class]).new(opts[:value])
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def link(mod, stack)
|
69
|
+
if @mod.nil? or @mod != mod
|
70
|
+
@mod = nil
|
71
|
+
if @value.link(mod, stack) == mod
|
72
|
+
if @parent.evaluate(@value)
|
73
|
+
@mod = mod
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_s
|
80
|
+
"#{@value}"
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class ValueRange < Element
|
86
|
+
|
87
|
+
def initialize(**opts)
|
88
|
+
|
89
|
+
super
|
90
|
+
@upper = RetroIDL::ASN.const_get(opts[:upper][:class]).new(opts[:upper])
|
91
|
+
@lower = RetroIDL::ASN.const_get(opts[:lower][:class]).new(opts[:lower])
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def link(mod, stack)
|
96
|
+
|
97
|
+
if @mod.nil? or @mod != mod
|
98
|
+
@mod = nil
|
99
|
+
if @upper.link(mod, stack) == mod
|
100
|
+
if @lower.link(mod, stack) == mod
|
101
|
+
if @parent.evaluate(@upper) and @parent.evaluate(@lower)
|
102
|
+
@mod = mod
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def to_s
|
110
|
+
"#{@lower} ... #{@upper}"
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
class SizeConstraint < Element
|
116
|
+
|
117
|
+
def initialize(**opts)
|
118
|
+
|
119
|
+
super
|
120
|
+
@constraint = Constraint.new(self, opts[:constraint])
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
def link(mod)
|
125
|
+
@constraint.link(mod)
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_s
|
129
|
+
"SIZE #{@constraint}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def evaluate
|
133
|
+
|
134
|
+
if @parent.class
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
class UnionMark < Element
|
141
|
+
def to_s
|
142
|
+
"|"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class ALL < Element
|
147
|
+
def to_s
|
148
|
+
"ALL"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
class IntersectionMark < Element
|
153
|
+
def to_s
|
154
|
+
"^"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
class EXCEPT < Element
|
159
|
+
def to_s
|
160
|
+
"EXCEPT"
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
class RetroIDL::ASN::DefinedType < BaseType
|
21
|
+
|
22
|
+
def initialize(**opts)
|
23
|
+
|
24
|
+
super(**opts)
|
25
|
+
|
26
|
+
if ASN.is_typereference?(@location, opts[:ref])
|
27
|
+
@symbol = opts[:ref]
|
28
|
+
else
|
29
|
+
raise ASNError
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
# @macro common_link
|
35
|
+
def link(mod, stack)
|
36
|
+
|
37
|
+
if @mod.nil? or @mod != mod
|
38
|
+
|
39
|
+
@mod = nil
|
40
|
+
|
41
|
+
if mod.symbols(@symbol)
|
42
|
+
|
43
|
+
if mod.symbols(@symbol).link(mod, stack)
|
44
|
+
|
45
|
+
super(mod, stack)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
else
|
50
|
+
|
51
|
+
ASN.putError(@location, "symbol is undefined")
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
@mod
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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
|
+
# X.680 section 17.3
|
22
|
+
class RetroIDL::ASN::DefinedValue
|
23
|
+
|
24
|
+
def initialize(**opts)
|
25
|
+
|
26
|
+
@location = opts[:location]
|
27
|
+
@mod = nil
|
28
|
+
|
29
|
+
if RetroIDL::ASN.is_identifier?(@location, **opts[:ref])
|
30
|
+
@symbol = opts[:ref].to_s
|
31
|
+
else
|
32
|
+
raise ASNError
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# @macro common_link
|
38
|
+
def link(mod, stack)
|
39
|
+
|
40
|
+
if @mod.nil? or @mod != mod
|
41
|
+
|
42
|
+
@mod = nil
|
43
|
+
|
44
|
+
if mod.symbol(@symbol)
|
45
|
+
|
46
|
+
if mod.symbol(@symbol).link(mod, [])
|
47
|
+
|
48
|
+
super(mod, stack)
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
else
|
53
|
+
|
54
|
+
ASN.putError(@location, "DefinedValue governing type is not defined")
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
@mod
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# return the Ruby native representation of this DefinedType
|
65
|
+
#
|
66
|
+
# @return [Array, Hash, Numeric, String] native value
|
67
|
+
#
|
68
|
+
# @raise [ASNError] value cannot be returned if object is not linked
|
69
|
+
def value
|
70
|
+
|
71
|
+
@mod.symbol(@symbol).value
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
# @macro common_to_s
|
76
|
+
def to_s
|
77
|
+
|
78
|
+
"#{@symbol}"
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|