ridl 2.5.6 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  require 'ridl/node'
14
13
 
@@ -22,7 +21,7 @@ module IDL
22
21
  false
23
22
  end
24
23
 
25
- def instantiate(_context)
24
+ def instantiate(_)
26
25
  self
27
26
  end
28
27
 
@@ -38,8 +37,7 @@ module IDL
38
37
  def initialize(node)
39
38
  if $DEBUG
40
39
  unless IDL::AST::Const === node || (IDL::AST::TemplateParam === node && node.idltype.is_a?(IDL::Type::Const))
41
- raise RuntimeError,
42
- "#{node.scoped_name} must be constant: #{node.class.name}."
40
+ raise "#{node.scoped_name} must be constant: #{node.class.name}."
43
41
  end
44
42
  end
45
43
  @node = node
@@ -49,9 +47,9 @@ module IDL
49
47
  def is_template?
50
48
  @node.is_template?
51
49
  end
52
- def instantiate(_context)
50
+ def instantiate(instantiation_context)
53
51
  if self.is_template?
54
- cp = IDL::AST::TemplateParam.concrete_param(_context, @node)
52
+ cp = IDL::AST::TemplateParam.concrete_param(instantiation_context, @node)
55
53
  cp.is_a?(Expression) ? cp : ScopedName.new(cp)
56
54
  else
57
55
  self
@@ -70,8 +68,7 @@ module IDL
70
68
  def initialize(node)
71
69
  if $DEBUG
72
70
  if not IDL::AST::Enumerator === node
73
- raise RuntimeError,
74
- "#{node.scoped_name} must be enumerator: #{node.class.name}."
71
+ raise "#{node.scoped_name} must be enumerator: #{node.class.name}."
75
72
  end
76
73
  end
77
74
  @node = node
@@ -88,9 +85,8 @@ module IDL
88
85
  n = self.class::NUMBER_OF_OPERANDS
89
86
 
90
87
  if _operands.size != n
91
- raise RuntimeError,
92
- format("%s must receive %d operand%s.",
93
- self.typename, n, if (n>1) then "s" else "" end)
88
+ raise format("%s must receive %d operand%s.",
89
+ self.typename, n, if (n > 1) then "s" else "" end)
94
90
  end
95
91
 
96
92
  unless _operands.any? { |o| o.is_template? }
@@ -108,15 +104,14 @@ module IDL
108
104
  @operands.any? { |o| o.is_template? }
109
105
  end
110
106
 
111
- def instantiate(_context)
112
- self.is_template? ? self.class.new(*@operands.collect { |o| o.instantiate(_context) }) : self
107
+ def instantiate(instantiation_context)
108
+ self.is_template? ? self.class.new(*@operands.collect { |o| o.instantiate(instantiation_context) }) : self
113
109
  end
114
110
 
115
111
  def Operation.suite_type(*types)
116
112
  types.each do |t|
117
113
  if not self::Applicable.include? t.class
118
- raise RuntimeError,
119
- "#{self.name} cannot be applicable for #{t.typename}"
114
+ raise "#{self.name} cannot be applicable for #{t.typename}"
120
115
  end
121
116
  end
122
117
 
@@ -174,8 +169,7 @@ module IDL
174
169
 
175
170
  t = IDL::Type::Boolean
176
171
  if (t1 == t && t2 != t) or (t1 != t && t2 == t)
177
- raise RuntimeError,
178
- "#{self.name} about #{t1.typename} and #{t2.typename} is illegal."
172
+ raise "#{self.name} about #{t1.typename} and #{t2.typename} is illegal."
179
173
  end
180
174
  end
181
175
  end
@@ -190,10 +184,9 @@ module IDL
190
184
  superclass.checktype(*types)
191
185
 
192
186
  # it's expected that Double, LongDouble is a Float.
193
- s1,s2 = IDL::Type::Float, IDL::Type::Fixed
187
+ s1, s2 = IDL::Type::Float, IDL::Type::Fixed
194
188
  if (t1 === s1 && t2 === s2) or (t1 === s2 && t2 === s1)
195
- raise RuntimeError,
196
- "#{self.name} about #{t1.typename} and #{t2.typename} is illegal."
189
+ raise "#{self.name} about #{t1.typename} and #{t2.typename} is illegal."
197
190
  end
198
191
  end
199
192
  end
@@ -217,7 +210,7 @@ module IDL
217
210
  Applicable = Integer2::Applicable
218
211
  def calculate(op)
219
212
  if @idltype.is_unsigned?()
220
- (2**@idltype.bits-1)-op
213
+ (2**@idltype.bits - 1) - op
221
214
  else
222
215
  ~op
223
216
  end
@@ -225,51 +218,50 @@ module IDL
225
218
  end
226
219
 
227
220
  class Or < Boolean2
228
- def calculate(lop,rop); lop | rop; end
221
+ def calculate(lop, rop); lop | rop; end
229
222
  end
230
223
  class And < Boolean2
231
- def calculate(lop,rop); lop & rop; end
224
+ def calculate(lop, rop); lop & rop; end
232
225
  end
233
226
  class Xor < Boolean2
234
- def calculate(lop,rop); lop ^ rop; end
227
+ def calculate(lop, rop); lop ^ rop; end
235
228
  end
236
229
 
237
230
  class Shift < Integer2
238
231
  protected
239
232
  def check_rop(rop)
240
233
  if not (0...64) === rop
241
- raise RuntimeError,
242
- "right operand for shift must be in the range 0 <= right operand < 64: #{rop}."
234
+ raise "right operand for shift must be in the range 0 <= right operand < 64: #{rop}."
243
235
  end
244
236
  end
245
237
  end
246
238
  class LShift < Shift
247
- def calculate(lop,rop)
239
+ def calculate(lop, rop)
248
240
  check_rop(rop)
249
241
  lop << rop
250
242
  end
251
243
  end
252
244
  class RShift < Shift
253
- def calculate(lop,rop)
245
+ def calculate(lop, rop)
254
246
  check_rop(rop)
255
247
  lop >> rop
256
248
  end
257
249
  end
258
250
 
259
251
  class Add < Float2
260
- def calculate(lop,rop); lop + rop; end
252
+ def calculate(lop, rop); lop + rop; end
261
253
  end
262
254
  class Minus < Float2
263
- def calculate(lop,rop); lop - rop; end
255
+ def calculate(lop, rop); lop - rop; end
264
256
  end
265
257
  class Mult < Float2
266
- def calculate(lop,rop); lop * rop; end
258
+ def calculate(lop, rop); lop * rop; end
267
259
  end
268
260
  class Div < Float2
269
- def calculate(lop,rop); lop / rop; end
261
+ def calculate(lop, rop); lop / rop; end
270
262
  end
271
263
  class Mod < Integer2
272
- def calculate(lop,rop); lop % rop; end
264
+ def calculate(lop, rop); lop % rop; end
273
265
  end
274
266
  end #of class Operation
275
267
  end #of class Expression
data/lib/ridl/genfile.rb CHANGED
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  require 'tempfile'
14
13
  require 'fileutils'
@@ -68,7 +67,7 @@ module IDL
68
67
  class Content
69
68
  def initialize(sections = {})
70
69
  # copy content map transforming all keys to symbols
71
- @sections = sections.inject({}) {|m,(k,v)| m[k.to_sym] = v; m }
70
+ @sections = sections.inject({}) {|m, (k, v)| m[k.to_sym] = v; m }
72
71
  end
73
72
 
74
73
  def sections
@@ -97,7 +96,7 @@ module IDL
97
96
  @path = path
98
97
  @fullpath = File.expand_path(path)
99
98
  @name = File.basename(path)
100
- @ext = File.extname(path).sub(/^\./,'')
99
+ @ext = File.extname(path).sub(/^\./, '')
101
100
  else
102
101
  @path = @fullpath = @name = @ext = ''
103
102
  end
@@ -110,7 +109,7 @@ module IDL
110
109
  :output_file => nil,
111
110
  :create_missing_dir => false
112
111
  }.merge(opts)
113
- if @options[:regenerate] && File.exists?(@fullpath)
112
+ if @options[:regenerate] && File.exist?(@fullpath)
114
113
  parse_regeneration_content
115
114
  else
116
115
  @content = Content.new
@@ -160,7 +159,7 @@ module IDL
160
159
  fgen = @fout
161
160
  @fout = nil
162
161
  fgen.close(false) # close but do NOT unlink
163
- if File.exists?(@fullpath)
162
+ if File.exist?(@fullpath)
164
163
  # create temporary backup
165
164
  ftmp = Tempfile.new(@name)
166
165
  ftmp_name = ftmp.path.dup
@@ -225,22 +224,22 @@ module IDL
225
224
  if regen_marker_re =~ line
226
225
  case $1
227
226
  when 'BEGIN'
228
- raise RuntimeError, "ERROR: Found unterminated regeneration section starting at #{@path}:#{in_section.last}." if in_section
227
+ raise "ERROR: Found unterminated regeneration section starting at #{@path}:#{in_section.last}." if in_section
229
228
  in_section = [$2, linenr]
230
229
  section = []
231
230
  when 'END'
232
- raise RuntimeError, "ERROR: Found unmatched regeneration end at #{@path}:#{linenr}." unless in_section && ($2 == in_section.first)
231
+ raise "ERROR: Found unmatched regeneration end at #{@path}:#{linenr}." unless in_section && ($2 == in_section.first)
233
232
  sections[$2] = section
234
233
  in_section = nil
235
234
  section = []
236
235
  when 'HEADER_END'
237
- raise RuntimeError, "ERROR: Found illegal header end marker at #{@path}:#{linenr}." unless _keep_header && in_section &&
236
+ raise "ERROR: Found illegal header end marker at #{@path}:#{linenr}." unless _keep_header && in_section &&
238
237
  ('HEADER' == in_section.first ) && (0 == in_section.last)
239
238
  sections[$2] = section
240
239
  in_section = nil
241
240
  section = []
242
241
  else
243
- raise RuntimeError, "ERROR: Found invalid regeneration marker at #{@path}:#{linenr}."
242
+ raise "ERROR: Found invalid regeneration marker at #{@path}:#{linenr}."
244
243
  end
245
244
  elsif in_section
246
245
  section << line
data/lib/ridl/node.rb CHANGED
@@ -8,7 +8,6 @@
8
8
  # included with this program.
9
9
  #
10
10
  # Copyright (c) Remedy IT Expertise BV
11
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
11
  #--------------------------------------------------------------------
13
12
  module IDL::AST
14
13
 
@@ -20,7 +19,7 @@ module IDL::AST
20
19
  @id = id.to_sym
21
20
  # copy field map transforming all keys to symbols and
22
21
  # detecting nested annotation objects
23
- @fields = fields.inject({}) do |m,(k,v)|
22
+ @fields = fields.inject({}) do |m, (k, v)|
24
23
  m[k.to_sym] = case v
25
24
  when Array
26
25
  v.collect { |ve| Hash === ve ? Annotation.new(*ve.to_a.first) : ve }
@@ -49,9 +48,9 @@ module IDL::AST
49
48
  end
50
49
 
51
50
  class Annotations
52
- def initialize(stack = [], index = {})
53
- @index = index
54
- @stack = stack
51
+ def initialize
52
+ @index = {}
53
+ @stack = []
55
54
  end
56
55
 
57
56
  def empty?
@@ -75,23 +74,13 @@ module IDL::AST
75
74
  self[annid].each(&block)
76
75
  end
77
76
 
78
- def clear
79
- @index.clear
80
- @stack.clear
81
- end
82
-
83
77
  def concat(anns)
84
- (anns || []).each {|_ann| self << _ann }
85
- end
86
-
87
- def dup
88
- self.class.new(@stack.dup, @index.dup)
78
+ anns.each {|_ann| self << _ann } if anns
89
79
  end
90
80
  end
91
81
 
92
82
  class Leaf
93
83
  attr_reader :name, :intern
94
- attr_reader :lm_name
95
84
  attr_accessor :enclosure
96
85
  attr_reader :scopes
97
86
  attr_reader :prefix
@@ -105,26 +94,26 @@ module IDL::AST
105
94
  _name ||= ''
106
95
  _name = IDL::Scanner::Identifier.new(_name, _name) unless IDL::Scanner::Identifier === _name
107
96
  @name = _name
108
- @lm_name = self.class.mk_name(_name.checked_name, _enclosure.nil? ? false : _enclosure.scopes.size>0).freeze
97
+ @lm_name = nil
109
98
  @intern = _name.rjust(1).downcase.intern
110
99
  @enclosure = _enclosure
111
- @scopes = if @enclosure.nil? then [] else (@enclosure.scopes.dup << self) end
100
+ @scopes = if @enclosure then (@enclosure.scopes.dup << self) else [] end
112
101
  @prefix = ''
113
102
  @repo_id = nil
114
103
  @repo_ver = nil
115
104
  @annotations = Annotations.new
116
105
  end
117
106
 
118
- def unescaped_name
119
- @name.unescaped_name
107
+ def lm_name
108
+ @lm_name ||= @name.checked_name.dup
120
109
  end
121
110
 
122
- def parsed_name_scope
123
- (@enclosure ? @enclosure.parsed_name_scope : '') + '::' + @name
111
+ def lm_scopes
112
+ @lm_scopes ||= if @enclosure then (@enclosure.lm_scopes.dup << lm_name) else [] end
124
113
  end
125
114
 
126
- def lm_name_for_scope
127
- lm_name
115
+ def unescaped_name
116
+ @name.unescaped_name
128
117
  end
129
118
 
130
119
  def scoped_name
@@ -132,52 +121,47 @@ module IDL::AST
132
121
  end
133
122
 
134
123
  def scoped_lm_name
135
- @scoped_lm_name ||= @scopes.collect{|s| s.lm_name_for_scope }.join('::').freeze
124
+ @scoped_lm_name ||= lm_scopes.join("::").freeze
136
125
  end
137
126
 
138
127
  def marshal_dump
139
- [@name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations]
128
+ [@name, lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations]
140
129
  end
141
130
 
142
131
  def marshal_load(vars)
143
132
  @name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations = vars
144
133
  @scoped_name = nil
145
134
  @scoped_lm_name = nil
146
- end
147
-
148
- def repo_scopes
149
- @repo_scopes ||= (@enclosure.nil? ? [] : (@enclosure.repo_scopes.dup << self))
135
+ @lm_scopes = nil
150
136
  end
151
137
 
152
138
  def is_template?
153
139
  @enclosure && @enclosure.is_template?
154
140
  end
155
141
 
156
- def instantiate(_context, _enclosure, _params = {})
157
- (_context[self] = self.class.new(self.name, _enclosure, _params)).copy_from(self, _context)
142
+ def instantiate(instantiation_context, _enclosure, _params = {})
143
+ (instantiation_context[self] = self.class.new(self.name, _enclosure, _params)).copy_from(self, instantiation_context)
158
144
  end
159
145
 
160
146
  def set_repo_id(id)
161
147
  if @repo_id
162
148
  if id != @repo_id
163
- raise RuntimeError,
164
- "#{self.scoped_name} already has a different repository ID assigned: #{@repo_id}"
149
+ raise "#{self.scoped_name} already has a different repository ID assigned: #{@repo_id}"
165
150
  end
166
151
  end
167
152
  id_arr = id.split(':')
168
153
  if @repo_ver
169
154
  if id_arr.first != 'IDL' or id_arr.last != @repo_ver
170
- raise RuntimeError,
171
- "supplied repository ID (#{id}) does not match previously assigned repository version for #{self.scoped_name} = #{@repo_ver}"
155
+ raise "supplied repository ID (#{id}) does not match previously assigned repository version for #{self.scoped_name} = #{@repo_ver}"
172
156
  end
173
157
  end
174
158
  # check validity of IDL format repo IDs
175
159
  if id_arr.first == 'IDL'
176
160
  id_arr.shift
177
161
  id_str = id_arr.shift.to_s
178
- raise RuntimeError, 'ID identifiers should not start or end with \'/\'' if id_str[0,1]=='/' or id_str[-1, 1]=='/'
179
- raise RuntimeError, "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0,1])
180
- raise RuntimeError, 'Invalid ID! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed for identifiers' unless REPO_ID_RE =~ id_str
162
+ raise 'ID identifiers should not start or end with \'/\'' if id_str[0, 1] == '/' or id_str[-1, 1] == '/'
163
+ raise "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0, 1])
164
+ raise 'Invalid ID! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed for identifiers' unless REPO_ID_RE =~ id_str
181
165
  end
182
166
  @repo_id = id
183
167
  end
@@ -186,15 +170,13 @@ module IDL::AST
186
170
  ver = "#{ma}.#{mi}"
187
171
  if @repo_ver
188
172
  if ver != @repo_ver
189
- raise RuntimeError,
190
- "#{self.scoped_name} already has a repository version assigned: #{@repo_ver}"
173
+ raise "#{self.scoped_name} already has a repository version assigned: #{@repo_ver}"
191
174
  end
192
175
  end
193
176
  if @repo_id
194
177
  l = @repo_id.split(':')
195
178
  if l.last != ver
196
- raise RuntimeError,
197
- "supplied repository version (#{ver}) does not match previously assigned repository ID for #{self.scoped_name}: #{@repo_id}"
179
+ raise "supplied repository version (#{ver}) does not match previously assigned repository ID for #{self.scoped_name}: #{@repo_id}"
198
180
  end
199
181
  end
200
182
  @repo_ver = ver
@@ -202,34 +184,30 @@ module IDL::AST
202
184
 
203
185
  def prefix=(pfx)
204
186
  unless pfx.to_s.empty?
205
- raise RuntimeError, 'ID prefix should not start or end with \'/\'' if pfx[0,1]=='/' or pfx[-1, 1]=='/'
206
- raise RuntimeError, "ID prefix should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(pfx[0,1])
207
- raise RuntimeError, 'Invalid ID prefix! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed' unless REPO_ID_RE =~ pfx
187
+ raise 'ID prefix should not start or end with \'/\'' if pfx[0, 1] == '/' or pfx[-1, 1] == '/'
188
+ raise "ID prefix should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(pfx[0, 1])
189
+ raise 'Invalid ID prefix! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed' unless REPO_ID_RE =~ pfx
208
190
  end
209
- self._set_prefix(pfx)
191
+ self.set_prefix(pfx)
210
192
  end
211
193
 
212
194
  def replace_prefix(pfx)
213
195
  self.prefix = pfx
214
196
  end
215
197
 
216
- def _set_prefix(pfx)
217
- @prefix = pfx.to_s
218
- end
219
-
220
198
  def repository_id
221
199
  if @repo_id.nil?
222
200
  @repo_ver = "1.0" unless @repo_ver
223
201
  format("IDL:%s%s:%s",
224
- if @prefix.empty? then "" else @prefix+"/" end,
225
- self.repo_scopes.collect{|s| s.name}.join("/"),
202
+ if @prefix.empty? then "" else @prefix + "/" end,
203
+ self.scopes.collect{|s| s.name}.join("/"),
226
204
  @repo_ver)
227
205
  else
228
206
  @repo_id
229
207
  end
230
208
  end
231
209
 
232
- def has_annotations?()
210
+ def has_annotations?
233
211
  !@annotations.empty?
234
212
  end
235
213
 
@@ -242,11 +220,16 @@ module IDL::AST
242
220
  end
243
221
 
244
222
  protected
245
- def copy_from(_template, _context)
246
- @prefix = _template.instance_variable_get(:@prefix)
247
- @repo_id = _template.instance_variable_get(:@repo_id)
248
- @repo_ver = _template.instance_variable_get(:@repo_ver)
249
- @annotations = _template.instance_variable_get(:@annotations)
223
+
224
+ def set_prefix(pfx)
225
+ @prefix = pfx.to_s
226
+ end
227
+
228
+ def copy_from(template, _)
229
+ @prefix = template.instance_variable_get(:@prefix)
230
+ @repo_id = template.instance_variable_get(:@repo_id)
231
+ @repo_ver = template.instance_variable_get(:@repo_ver)
232
+ @annotations = template.instance_variable_get(:@annotations)
250
233
  self
251
234
  end
252
235
  end # Leaf
@@ -271,8 +254,7 @@ module IDL::AST
271
254
 
272
255
  def introduce(node)
273
256
  n = (@introduced[node.intern] ||= node)
274
- raise RuntimeError,
275
- "#{node.name} is already introduced as a #{n.scoped_name} of #{n.typename}." if n != node
257
+ raise "#{node.name} is already introduced as a #{n.scoped_name} of #{n.typename}." if n != node
276
258
  end
277
259
 
278
260
  def undo_introduction(node)
@@ -280,7 +262,7 @@ module IDL::AST
280
262
  end
281
263
 
282
264
  def redefine(node, params)
283
- raise RuntimeError, "\"#{node.name}\" is already defined."
265
+ raise "\"#{node.name}\" is already defined."
284
266
  end
285
267
 
286
268
  def is_definable?(_type)
@@ -291,8 +273,7 @@ module IDL::AST
291
273
 
292
274
  def define(_type, _name, params = Hash.new)
293
275
  if not is_definable?(_type)
294
- raise RuntimeError,
295
- "#{_type.to_s} is not definable in #{self.typename}."
276
+ raise "#{_type.to_s} is not definable in #{self.typename}."
296
277
  end
297
278
  node = search_self(_name)
298
279
  if node.nil?
@@ -303,8 +284,7 @@ module IDL::AST
303
284
  @children << node
304
285
  else
305
286
  if _type != node.class
306
- raise RuntimeError,
307
- "#{_name} is already defined as a type of #{node.typename}"
287
+ raise "#{_name} is already defined as a type of #{node.typename}"
308
288
  end
309
289
  node = redefine(node, params)
310
290
  end
@@ -343,7 +323,7 @@ module IDL::AST
343
323
  key = _name.downcase.intern
344
324
  node = @introduced[key]
345
325
  if not node.nil? and node.name != _name
346
- raise RuntimeError, "\"#{_name}\" clashed with \"#{node.name}\"."
326
+ raise "\"#{_name}\" clashed with \"#{node.name}\"."
347
327
  end
348
328
  node
349
329
  end
@@ -360,10 +340,10 @@ module IDL::AST
360
340
  self.walk_members(&block)
361
341
  end
362
342
 
363
- def copy_from(_template, _context)
343
+ def copy_from(_template, instantiation_context)
364
344
  super
365
345
  _template.__send__(:walk_members_for_copy) do |child|
366
- _child_copy = child.instantiate(_context, self)
346
+ _child_copy = child.instantiate(instantiation_context, self)
367
347
  @children << _child_copy
368
348
  # introduce unless already introduced (happens with module chains)
369
349
  @introduced[_child_copy.intern] = _child_copy unless @introduced.has_key?(_child_copy.intern)
@@ -405,7 +385,6 @@ module IDL::AST
405
385
  class Enumerator < Leaf; end
406
386
 
407
387
  class Module < Node
408
- NAMETYPE = :class
409
388
  DEFINABLE = [
410
389
  IDL::AST::Module, IDL::AST::Interface, IDL::AST::Valuebox, IDL::AST::Valuetype, IDL::AST::Const, IDL::AST::Struct,
411
390
  IDL::AST::Union, IDL::AST::Enum, IDL::AST::Enumerator, IDL::AST::Typedef, IDL::AST::Include,
@@ -416,7 +395,6 @@ module IDL::AST
416
395
  super(_name, _enclosure)
417
396
  @anchor = params[:anchor]
418
397
  @prefix = params[:prefix] || @prefix
419
- @not_in_repo_id = params[:not_in_repo_id]
420
398
  @template = params[:template]
421
399
  @template_params = (params[:template_params] || []).dup
422
400
  @next = nil
@@ -457,12 +435,8 @@ module IDL::AST
457
435
  super(vars)
458
436
  end
459
437
 
460
- def instantiate(_context, _enclosure)
461
- super(_context, _enclosure, {})
462
- end
463
-
464
- def repo_scopes
465
- @repo_scopes ||= (@enclosure.nil? ? [] : (@not_in_repo_id ? @enclosure.repo_scopes.dup : (@enclosure.repo_scopes.dup << self)))
438
+ def instantiate(instantiation_context, _enclosure)
439
+ super(instantiation_context, _enclosure, {})
466
440
  end
467
441
 
468
442
  def redefine(node, params)
@@ -488,12 +462,16 @@ module IDL::AST
488
462
  return _next
489
463
  when IDL::AST::Interface
490
464
  node.annotations.concat(params[:annotations])
491
- return node if params[:forward]
492
- if node.is_defined?
493
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
465
+ # in case of a forward declaration in the same module ignore it since a previous declaration already exists
466
+ if params[:forward]
467
+ return node if node.enclosure == self
468
+ # forward declaration in different scope (other module section in same file or other file)
469
+ elsif node.is_defined?
470
+ # multiple full declarations are illegal
471
+ raise "#{node.typename} \"#{node.name}\" is already defined."
494
472
  end
495
473
  if (node.is_abstract? != params[:abstract]) || (node.is_local? != params[:local]) || (node.is_pseudo? != params[:pseudo])
496
- raise RuntimeError, "\"attributes are not the same: \"#{node.name}\"."
474
+ raise "\"attributes are not the same: \"#{node.name}\"."
497
475
  end
498
476
 
499
477
  _intf = IDL::AST::Interface.new(node.name, self, params)
@@ -503,19 +481,25 @@ module IDL::AST
503
481
  _intf.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id))
504
482
 
505
483
  @children << _intf
506
- # replace forward node registration
507
- node.enclosure.undo_introduction(node)
508
- introduce(_intf)
484
+
485
+ # in case of a full declaration undo the preceding forward introduction and
486
+ # replace by full node
487
+ # (no need to introduce forward declaration since there is a preceding introduction)
488
+ unless params[:forward]
489
+ # replace forward node registration
490
+ node.enclosure.undo_introduction(node)
491
+ introduce(_intf)
492
+ end
509
493
 
510
494
  return _intf
511
495
  when IDL::AST::Valuetype
512
496
  node.annotations.concat(params[:annotations])
513
497
  return node if params[:forward]
514
498
  if node.is_defined?
515
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
499
+ raise "#{node.typename} \"#{node.name}\" is already defined."
516
500
  end
517
501
  if (node.is_abstract? != params[:abstract])
518
- raise RuntimeError, "\"attributes are not the same: \"#{node.name}\"."
502
+ raise "\"attributes are not the same: \"#{node.name}\"."
519
503
  end
520
504
 
521
505
  _new_node = node.class.new(node.name, self, params)
@@ -534,7 +518,7 @@ module IDL::AST
534
518
  node.annotations.concat(params[:annotations])
535
519
  return node if params[:forward]
536
520
  if node.is_defined?
537
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
521
+ raise "#{node.typename} \"#{node.name}\" is already defined."
538
522
  end
539
523
 
540
524
  _new_node = node.class.new(node.name, self, params)
@@ -552,8 +536,7 @@ module IDL::AST
552
536
 
553
537
  return _new_node
554
538
  end
555
- raise RuntimeError,
556
- "#{node.name} is already introduced as #{node.typename} #{node.scoped_name}."
539
+ raise "#{node.name} is already introduced as #{node.typename} #{node.scoped_name}."
557
540
  end
558
541
 
559
542
  def undo_introduction(node)
@@ -567,49 +550,52 @@ module IDL::AST
567
550
  def replace_prefix(pfx)
568
551
  self.prefix = pfx # handles validation
569
552
  if @anchor.nil?
570
- self.replace_prefix_(pfx)
553
+ self.replace_prefix_i(pfx)
571
554
  else
572
- @anchor.replace_prefix_(pfx)
555
+ @anchor.replace_prefix_i(pfx)
573
556
  end
574
557
  end
575
558
 
576
- def _set_prefix(pfx)
559
+ protected
560
+
561
+ def set_prefix(pfx)
577
562
  if @anchor.nil?
578
- self._set_prefix_(pfx)
563
+ self.set_prefix_i(pfx)
579
564
  else
580
- @anchor._set_prefix_(pfx)
565
+ @anchor.set_prefix_i(pfx)
581
566
  end
582
567
  end
583
568
 
584
- protected
585
-
586
569
  def get_annotations
587
570
  @annotations
588
571
  end
589
572
 
590
- def copy_from(_template, _context)
573
+ def copy_from(_template, instantiation_context)
591
574
  super
592
575
  if _template.has_anchor?
593
576
  # module anchor is first to be copied/instantiated and
594
- # should be registered in _context
595
- @anchor = IDL::AST::TemplateParam.concrete_param(_context, _template.anchor)
596
- # link ourself into module chain
577
+ # should be registered in instantiation_context
578
+ cp = IDL::AST::TemplateParam.concrete_param(instantiation_context, _template.anchor)
579
+ # concrete param must be a IDL::Type::NodeType and it's node a Module (should never fail)
580
+ raise "Invalid concrete anchor found" unless cp.is_a?(IDL::Type::NodeType) && cp.node.is_a?(IDL::AST::Module)
581
+ @anchor = cp.node
582
+ # link our self into module chain
597
583
  @anchor.find_last.set_next(self)
598
584
  end
599
585
  @next = nil # to be sure
600
586
  self
601
587
  end
602
588
 
603
- def replace_prefix_(pfx)
589
+ def replace_prefix_i(pfx)
604
590
  walk_members { |m| m.replace_prefix(pfx) }
605
591
  # propagate along chain using fast method
606
- @next.replace_prefix_(pfx) unless @next.nil?
592
+ @next.replace_prefix_i(pfx) unless @next.nil?
607
593
  end
608
594
 
609
- def _set_prefix_(pfx)
595
+ def set_prefix_i(pfx)
610
596
  @prefix = pfx
611
597
  # propagate along chain
612
- self.next._set_prefix_(pfx) unless self.next.nil?
598
+ self.next.set_prefix_i(pfx) unless self.next.nil?
613
599
  end
614
600
 
615
601
  def search_self(_name)
@@ -620,7 +606,7 @@ module IDL::AST
620
606
  _key = _name.downcase.intern
621
607
  node = @introduced[_key]
622
608
  if not node.nil? and node.name != _name
623
- raise RuntimeError, "\"#{_name}\" clashed with \"#{node.name}\"."
609
+ raise "\"#{_name}\" clashed with \"#{node.name}\"."
624
610
  end
625
611
  if node.nil? && @next
626
612
  node = @next.search_links(_name)
@@ -646,7 +632,6 @@ module IDL::AST
646
632
  end # Module
647
633
 
648
634
  class TemplateParam < Leaf
649
- NAMETYPE = :class
650
635
  attr_reader :idltype, :concrete
651
636
  def initialize(_name, _enclosure, params)
652
637
  super(_name, _enclosure)
@@ -671,24 +656,35 @@ module IDL::AST
671
656
  @concrete = _param
672
657
  end
673
658
 
674
- def self.concrete_param(_context, _node)
675
- if _node.is_template?
676
- _cnode = if _node.is_a?(IDL::AST::TemplateParam)
677
- _node.concrete
659
+ def concrete_matches?(idl_type)
660
+ if @concrete
661
+ concrete_type = (@concrete.is_a?(IDL::Type) ? @concrete : @concrete.idltype).resolved_type
662
+ return concrete_type.matches?(idl_type.resolved_type)
663
+ end
664
+ false
665
+ end
666
+
667
+ def self.concrete_param(instantiation_context, tpl_elem)
668
+ # is this an element from the template's scope
669
+ if tpl_elem.is_template?
670
+ celem = if tpl_elem.is_a?(IDL::AST::TemplateParam) # an actual template parameter?
671
+ tpl_elem.concrete # get the template parameter's concrete (instantiation argument) value
678
672
  else
679
- # referenced template node should have been instantiated already and available through context
680
- _context[_node]
673
+ # referenced template elements should have been instantiated already and available through context
674
+ ctxelem = instantiation_context[tpl_elem]
675
+ # all items in the context are AST elements but for a concrete parameter value only constants and type
676
+ # elements will be referenced; return accordingly
677
+ ctxelem.is_a?(IDL::AST::Const) ? ctxelem.expression : ctxelem.idltype
681
678
  end
682
- raise RuntimeError, "cannot resolve concrete node for template #{_node.typename} #{_node.scoped_lm_name}" unless _cnode
683
- _cnode
679
+ raise "cannot resolve concrete node for template #{tpl_elem.typename} #{tpl_elem.scoped_lm_name}" unless celem
680
+ celem
684
681
  else
685
- _node
682
+ tpl_elem.idltype # just return the element's idltype if not from the template scope
686
683
  end
687
684
  end
688
685
  end
689
686
 
690
687
  class TemplateModule < Module
691
- NAMETYPE = :class
692
688
  DEFINABLE = [
693
689
  IDL::AST::Include, IDL::AST::Module, IDL::AST::Interface, IDL::AST::Valuebox, IDL::AST::Valuetype,
694
690
  IDL::AST::Const, IDL::AST::Struct, IDL::AST::Union, IDL::AST::Enum, IDL::AST::Enumerator, IDL::AST::Typedef,
@@ -716,17 +712,16 @@ module IDL::AST
716
712
  @template_params
717
713
  end
718
714
 
719
- def instantiate(_module_instance, _context = {})
715
+ def instantiate(_module_instance, instantiation_context = {})
720
716
  # process concrete parameters
721
717
  @template_params.each_with_index do |_tp, _ix|
722
- raise RuntimeError,
723
- "missing template parameter for #{typename} #{scoped_lm_name}: #{_tp.name}" unless _ix < _module_instance.template_params.size
718
+ raise "missing template parameter for #{typename} #{scoped_lm_name}: #{_tp.name}" unless _ix < _module_instance.template_params.size
724
719
  _cp = _module_instance.template_params[_ix]
725
720
  if _cp.is_a?(IDL::Type)
726
- raise RuntimeError, "anonymous type definitions are not allowed!" if _cp.is_anonymous?
721
+ raise "anonymous type definitions are not allowed!" if _cp.is_anonymous?
727
722
  # parameter should be a matching IDL::Type
728
723
  unless _tp.idltype.is_a?(IDL::Type::Any) || _tp.idltype.class === _cp.resolved_type
729
- raise RuntimeError, "mismatched instantiation parameter \##{_ix} #{_cp.typename} for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
724
+ raise "mismatched instantiation parameter \##{_ix} #{_cp.typename} for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
730
725
  end
731
726
  # verify concrete parameter
732
727
  case _tp.idltype
@@ -746,27 +741,26 @@ module IDL::AST
746
741
  # check basetype
747
742
  unless _tptype.basetype.is_a?(IDL::Type::ScopedName) &&
748
743
  _tptype.basetype.is_node?(IDL::AST::TemplateParam) &&
749
- _tptype.basetype.node.concrete &&
750
- _tptype.basetype.node.concrete.idltype.resolved_type == _cp.resolved_type.basetype.resolved_type
751
- raise RuntimeError, "invalid sequence type as instantiation parameter for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
744
+ _tptype.basetype.node.concrete_matches?(_cp.resolved_type.basetype)
745
+ raise "invalid sequence type as instantiation parameter for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
752
746
  end
753
747
  end
754
748
  end
755
749
  elsif _cp.is_a?(IDL::Expression)
756
750
  # template param should be 'const <const_type>'
757
751
  unless _tp.idltype.is_a?(IDL::Type::Const)
758
- raise RuntimeError, "unexpected expression as instantiation parameter for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
752
+ raise "unexpected expression as instantiation parameter for #{typename} #{scoped_lm_name}: expected #{_tp.idltype.typename} for #{_tp.name}"
759
753
  end
760
754
  # match constant type
761
755
  _tp.idltype.narrow(_cp.value)
762
756
  else
763
- raise RuntimeError, "invalid instantiation parameter for #{typename} #{scoped_lm_name}: #{_cp.class.name}"
757
+ raise "invalid instantiation parameter for #{typename} #{scoped_lm_name}: #{_cp.class.name}"
764
758
  end
765
- # if we get here all is well -> store concrete param
766
- _tp.set_concrete_param(_cp.is_a?(IDL::Type::ScopedName) ? _cp.node : _cp)
759
+ # if we get here all is well -> store concrete param (either IDL type or expression)
760
+ _tp.set_concrete_param(_cp)
767
761
  end
768
762
  # instantiate template by copying template module state to module instance
769
- _module_instance.copy_from(self, _context)
763
+ _module_instance.copy_from(self, instantiation_context)
770
764
  end
771
765
 
772
766
  protected
@@ -777,16 +771,15 @@ module IDL::AST
777
771
  end # TemplateModule
778
772
 
779
773
  class TemplateModuleReference < Leaf
780
- NAMETYPE = :class
781
774
  def initialize(_name, _enclosure, _params)
782
775
  super(_name, _enclosure)
783
776
  unless _params[:tpl_type].is_a?(IDL::Type::ScopedName) && _params[:tpl_type].is_node?(IDL::AST::TemplateModule)
784
- raise RuntimeError, "templated module reference type required for #{typename} #{scoped_lm_name}: got #{_params[:tpl_type].typename}"
777
+ raise "templated module reference type required for #{typename} #{scoped_lm_name}: got #{_params[:tpl_type].typename}"
785
778
  end
786
779
  @template = _params[:tpl_type].resolved_type.node
787
780
  _params[:tpl_params].each do |p|
788
781
  unless (p.is_a?(IDL::Type::ScopedName) || p.is_a?(IDL::Expression::ScopedName)) && p.is_node?(IDL::AST::TemplateParam)
789
- raise RuntimeError, "invalid template module parameter for template module reference #{typename} #{scoped_lm_name}: #{p.typename}"
782
+ raise "invalid template module parameter for template module reference #{typename} #{scoped_lm_name}: #{p.typename}"
790
783
  end
791
784
  end
792
785
  @params = _params[:tpl_params].collect { |p| p.resolved_node }
@@ -802,14 +795,13 @@ module IDL::AST
802
795
  super(vars)
803
796
  end
804
797
 
805
- def instantiate(_context, _enclosure)
798
+ def instantiate(instantiation_context, _enclosure)
806
799
  inst_params = @params.collect do |tp|
807
- # concrete objects are either Expression or Node; latter needs to be repacked as IDL::Type::ScopedName
808
- # as that is what the TemplateModule#instantiate expects
809
- tp.concrete.is_a?(IDL::Expression) ? tp.concrete : IDL::Type::ScopedName.new(tp.concrete)
800
+ # concrete objects are either Expression or Type
801
+ tp.concrete
810
802
  end
811
803
  mod_inst = IDL::AST::Module.new(self.name, _enclosure, { :template => @template, :template_params => inst_params })
812
- @template.instantiate(mod_inst, _context)
804
+ @template.instantiate(mod_inst, instantiation_context)
813
805
  mod_inst
814
806
  end
815
807
 
@@ -829,7 +821,10 @@ module IDL::AST
829
821
  #overrule
830
822
  @scopes = @enclosure.scopes
831
823
  @scoped_name = @scopes.collect{|s| s.name}.join("::")
832
- @scoped_lm_name = @scopes.collect{|s| s.lm_name}.join("::")
824
+ end
825
+
826
+ def lm_scopes
827
+ @lm_scopes ||= @enclosure.lm_scopes
833
828
  end
834
829
 
835
830
  def marshal_dump
@@ -844,16 +839,11 @@ module IDL::AST
844
839
  #overrule
845
840
  @scopes = @enclosure.scopes || []
846
841
  @scoped_name = @scopes.collect{|s| s.name}.join("::")
847
- @scoped_lm_name = @scopes.collect{|s| s.lm_name}.join("::")
848
842
  end
849
843
 
850
844
  def is_defined?; @defined; end
851
845
  def is_preprocessed?; @preprocessed; end
852
846
 
853
- def repo_scopes
854
- @repo_scopes ||= (@enclosure.nil? ? [] : @enclosure.repo_scopes.dup)
855
- end
856
-
857
847
  def introduce(node)
858
848
  @enclosure.introduce(node) unless node == self
859
849
  end
@@ -867,7 +857,7 @@ module IDL::AST
867
857
  end
868
858
 
869
859
  protected
870
- def copy_from(_template, _context)
860
+ def copy_from(_template, instantiation_context)
871
861
  super
872
862
  @filename = _template.filename
873
863
  @defined = _template.is_defined?
@@ -875,7 +865,6 @@ module IDL::AST
875
865
  #overrule
876
866
  @scopes = @enclosure.scopes
877
867
  @scoped_name = @scopes.collect{|s| s.name}.join("::")
878
- @scoped_lm_name = @scopes.collect{|s| s.lm_name}.join("::")
879
868
  self
880
869
  end
881
870
 
@@ -923,8 +912,8 @@ module IDL::AST
923
912
  # check if the matched name resulted in multiple different nodes or all the same
924
913
  r_one = results.shift
925
914
  unless results.all? {|r| r_one == r || (r_one.class == r.class && r_one.scoped_name == r.scoped_name) }
926
- s = results.inject([r_one]) {|l,r| l << r unless l.include?(r); l }.collect{ |n| n.scoped_name }.join(", ")
927
- raise RuntimeError, "\"#{_name}\" is ambiguous. " + s
915
+ s = results.inject([r_one]) {|l, r| l << r unless l.include?(r); l }.collect{ |n| n.scoped_name }.join(", ")
916
+ raise "\"#{_name}\" is ambiguous. " + s
928
917
  end
929
918
  end
930
919
  results.first
@@ -954,7 +943,6 @@ module IDL::AST
954
943
  end # Derivable
955
944
 
956
945
  class Interface < Derivable
957
- NAMETYPE = :class
958
946
  DEFINABLE = [IDL::AST::Const, IDL::AST::Operation, IDL::AST::Attribute,
959
947
  IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef, IDL::AST::Enum, IDL::AST::Enumerator]
960
948
  attr_reader :bases
@@ -987,17 +975,17 @@ module IDL::AST
987
975
  super(vars)
988
976
  end
989
977
 
990
- def instantiate(_context, _enclosure)
978
+ def instantiate(instantiation_context, _enclosure)
991
979
  _params = {
992
980
  :forward => self.is_forward?,
993
981
  :abstract => self.is_abstract?,
994
982
  :pseudo => self.is_pseudo?,
995
983
  :local => self.is_local?,
996
- :inherits => self.concrete_bases(_context)
984
+ :inherits => self.concrete_bases(instantiation_context)
997
985
  }
998
986
  # instantiate concrete interface def and validate
999
987
  # concrete bases
1000
- super(_context, _enclosure, _params)
988
+ super(instantiation_context, _enclosure, _params)
1001
989
  end
1002
990
 
1003
991
  def is_abstract?; @abstract; end
@@ -1009,38 +997,30 @@ module IDL::AST
1009
997
  def add_bases(inherits_)
1010
998
  inherits_.each do |tc|
1011
999
  unless tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::TemplateParam)
1012
- unless (tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::Interface))
1013
- raise RuntimeError,
1014
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1000
+ unless (tc.is_a?(IDL::Type::NodeType) && tc.is_node?(IDL::AST::Interface))
1001
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1015
1002
  end
1016
1003
  rtc = tc.resolved_type
1017
1004
  if rtc.node.has_ancestor?(self)
1018
- raise RuntimeError,
1019
- "circular inheritance detected for #{typename} #{scoped_lm_name}: #{tc.node.scoped_lm_name} is descendant"
1005
+ raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{tc.node.scoped_lm_name} is descendant"
1020
1006
  end
1021
1007
  if not rtc.node.is_defined?
1022
- raise RuntimeError,
1023
- "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1008
+ raise "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1024
1009
  end
1025
1010
  if rtc.node.is_local? and not self.is_local?
1026
- raise RuntimeError,
1027
- "#{typename} #{scoped_lm_name} cannot inherit from 'local' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1011
+ raise "#{typename} #{scoped_lm_name} cannot inherit from 'local' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1028
1012
  end
1029
1013
  if rtc.node.is_pseudo? and not self.is_pseudo?
1030
- raise RuntimeError,
1031
- "#{typename} #{scoped_lm_name} cannot inherit from 'pseudo' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1014
+ raise "#{typename} #{scoped_lm_name} cannot inherit from 'pseudo' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1032
1015
  end
1033
1016
  if self.is_abstract? and not rtc.node.is_abstract?
1034
- raise RuntimeError,
1035
- "'abstract' #{typename} #{scoped_lm_name} cannot inherit from non-'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1017
+ raise "'abstract' #{typename} #{scoped_lm_name} cannot inherit from non-'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1036
1018
  end
1037
1019
  if self.is_local? and rtc.node.is_abstract?
1038
- raise RuntimeError,
1039
- "'local' #{typename} #{scoped_lm_name} cannot inherit from 'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1020
+ raise "'local' #{typename} #{scoped_lm_name} cannot inherit from 'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1040
1021
  end
1041
1022
  if self.has_base?(rtc.node)
1042
- raise RuntimeError,
1043
- "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1023
+ raise "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1044
1024
  end
1045
1025
  # check if we indirectly derive from this base multiple times (which is ok; no further need to check)
1046
1026
  unless @resolved_bases.any? { |b| b.has_ancestor?(rtc.node) }
@@ -1050,8 +1030,7 @@ module IDL::AST
1050
1030
  new_op_att_ << m if m.is_a?(IDL::AST::Operation) || m.is_a?(IDL::AST::Attribute)
1051
1031
  end
1052
1032
  if new_op_att_.any? {|n| n_ = self.search_self(n.name); n_.is_a?(IDL::AST::Operation) || n_.is_a?(IDL::AST::Attribute) }
1053
- raise RuntimeError,
1054
- "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} because of duplicated operations/attributes"
1033
+ raise "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} because of duplicated operations/attributes"
1055
1034
  end
1056
1035
  # no need to check for duplicate member names; this inheritance is ok
1057
1036
  end
@@ -1069,13 +1048,13 @@ module IDL::AST
1069
1048
  @resolved_bases
1070
1049
  end
1071
1050
 
1072
- def operations(include_bases=false,traversed=nil)
1051
+ def operations(include_bases=false, traversed=nil)
1073
1052
  ops = @children.find_all { |c| c.is_a?(IDL::AST::Operation) }
1074
1053
  ops.concat(base_operations(traversed || [])) if include_bases
1075
1054
  ops
1076
1055
  end
1077
1056
 
1078
- def attributes(include_bases=false,traversed=nil)
1057
+ def attributes(include_bases=false, traversed=nil)
1079
1058
  atts = @children.find_all { |c| c.is_a?(IDL::AST::Attribute) }
1080
1059
  atts.concat(base_attributes(traversed || [])) if include_bases
1081
1060
  atts
@@ -1086,7 +1065,7 @@ module IDL::AST
1086
1065
  case node
1087
1066
  when IDL::AST::Struct, IDL::AST::Union
1088
1067
  if node.is_defined?
1089
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1068
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1090
1069
  end
1091
1070
  node.annotations.concat(params[:annotations])
1092
1071
 
@@ -1105,13 +1084,13 @@ module IDL::AST
1105
1084
 
1106
1085
  return _new_node
1107
1086
  else
1108
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1087
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1109
1088
  end
1110
1089
  end
1111
1090
 
1112
1091
  case node
1113
1092
  when IDL::AST::Operation, IDL::AST::Attribute
1114
- raise RuntimeError, "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1093
+ raise "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1115
1094
  else
1116
1095
  newnode = node.class.new(node.name, self, params)
1117
1096
  newnode.annotations.concat(params[:annotations])
@@ -1123,10 +1102,10 @@ module IDL::AST
1123
1102
 
1124
1103
  protected
1125
1104
 
1126
- def concrete_bases(_context)
1105
+ def concrete_bases(instantiation_context)
1127
1106
  # collect all bases and resolve any template param types
1128
- @bases.collect do |_base|
1129
- IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, _base))
1107
+ @bases.collect do |base|
1108
+ IDL::AST::TemplateParam.concrete_param(instantiation_context, base)
1130
1109
  end
1131
1110
  end
1132
1111
 
@@ -1136,7 +1115,6 @@ module IDL::AST
1136
1115
  end # Interface
1137
1116
 
1138
1117
  class ComponentBase < Derivable
1139
- NAMETYPE = :class
1140
1118
  DEFINABLE = []
1141
1119
  attr_reader :base
1142
1120
  attr_reader :interfaces
@@ -1165,24 +1143,22 @@ module IDL::AST
1165
1143
  super(vars)
1166
1144
  end
1167
1145
 
1168
- def instantiate(_context, _enclosure, _params = {})
1146
+ def instantiate(instantiation_context, _enclosure, _params = {})
1169
1147
  _params.merge!({
1170
- :base => @base ? IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, @base)) : @base,
1171
- :supports => self.concrete_interfaces(_context)
1148
+ :base => @base ? IDL::AST::TemplateParam.concrete_param(instantiation_context, @base) : @base,
1149
+ :supports => self.concrete_interfaces(instantiation_context)
1172
1150
  })
1173
1151
  # instantiate concrete def and validate
1174
- super(_context, _enclosure, _params)
1152
+ super(instantiation_context, _enclosure, _params)
1175
1153
  end
1176
1154
 
1177
1155
  def set_base(parent)
1178
1156
  unless parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(IDL::AST::TemplateParam)
1179
- unless (parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(self.class))
1180
- raise RuntimeError,
1181
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1157
+ unless (parent.is_a?(IDL::Type::NodeType) && parent.is_node?(self.class))
1158
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1182
1159
  end
1183
1160
  if parent.resolved_type.node.has_base?(self)
1184
- raise RuntimeError,
1185
- "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1161
+ raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1186
1162
  end
1187
1163
  @resolved_base = parent.resolved_type.node
1188
1164
  end
@@ -1201,22 +1177,18 @@ module IDL::AST
1201
1177
  intfs.each do |tc|
1202
1178
  unless tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::TemplateParam)
1203
1179
  unless (tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::Interface))
1204
- raise RuntimeError,
1205
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1180
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1206
1181
  end
1207
1182
  rtc = tc.resolved_type
1208
1183
  if not rtc.node.is_defined?
1209
- raise RuntimeError,
1210
- "#{typename} #{scoped_lm_name} cannot support forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1184
+ raise "#{typename} #{scoped_lm_name} cannot support forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1211
1185
  end
1212
1186
  ## TODO : is this legal?
1213
1187
  if rtc.node.is_local?
1214
- raise RuntimeError,
1215
- "#{typename} #{scoped_lm_name} cannot support 'local' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1188
+ raise "#{typename} #{scoped_lm_name} cannot support 'local' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1216
1189
  end
1217
1190
  if rtc.node.is_pseudo?
1218
- raise RuntimeError,
1219
- "#{typename} #{scoped_lm_name} cannot support 'pseudo' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1191
+ raise "#{typename} #{scoped_lm_name} cannot support 'pseudo' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1220
1192
  end
1221
1193
  ## TODO : is this legal?
1222
1194
  #if tc.node.is_abstract?
@@ -1224,8 +1196,7 @@ module IDL::AST
1224
1196
  # "'abstract' #{typename} #{scoped_lm_name} cannot support 'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1225
1197
  #end
1226
1198
  if self.has_support?(rtc.node)
1227
- raise RuntimeError,
1228
- "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1199
+ raise "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1229
1200
  end
1230
1201
  # check if we indirectly support this base multiple times (which is ok; no further need to check)
1231
1202
  unless @resolved_interfaces.any? { |b| b.has_ancestor?(rtc.node) }
@@ -1235,8 +1206,7 @@ module IDL::AST
1235
1206
  new_op_att_ << m if m.is_a?(IDL::AST::Operation) || m.is_a?(IDL::AST::Attribute)
1236
1207
  end
1237
1208
  if new_op_att_.any? {|n| n_ = self.search_self(n.name); n_.is_a?(IDL::AST::Operation) || n_.is_a?(IDL::AST::Attribute) }
1238
- raise RuntimeError,
1239
- "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} because of duplicated operations/attributes"
1209
+ raise "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} because of duplicated operations/attributes"
1240
1210
  end
1241
1211
  # no need to check for duplicate member names; this support is ok
1242
1212
  end
@@ -1259,7 +1229,7 @@ module IDL::AST
1259
1229
  case node
1260
1230
  when IDL::AST::Struct, IDL::AST::Union
1261
1231
  if node.is_defined?
1262
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1232
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1263
1233
  end
1264
1234
  node.annotations.concat(params[:annotations])
1265
1235
 
@@ -1278,13 +1248,13 @@ module IDL::AST
1278
1248
 
1279
1249
  return _new_node
1280
1250
  else
1281
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1251
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1282
1252
  end
1283
1253
  end
1284
1254
 
1285
1255
  case node
1286
1256
  when IDL::AST::Operation, IDL::AST::Attribute
1287
- raise RuntimeError, "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1257
+ raise "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1288
1258
  else
1289
1259
  newnode = node.class.new(node.name, self, params)
1290
1260
  newnode.annotations.concat(params[:annotations])
@@ -1300,16 +1270,15 @@ module IDL::AST
1300
1270
  (@resolved_base ? [@resolved_base] : []).concat(@resolved_interfaces)
1301
1271
  end
1302
1272
 
1303
- def concrete_interfaces(_context)
1273
+ def concrete_interfaces(instantiation_context)
1304
1274
  # collect all bases and resolve any template param types
1305
1275
  @interfaces.collect do |_intf|
1306
- IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, _intf))
1276
+ IDL::AST::TemplateParam.concrete_param(instantiation_context, _intf)
1307
1277
  end
1308
1278
  end
1309
1279
  end # ComponentBase
1310
1280
 
1311
1281
  class Home < ComponentBase
1312
- NAMETYPE = :class
1313
1282
  DEFINABLE = [IDL::AST::Const, IDL::AST::Operation, IDL::AST::Attribute, IDL::AST::Initializer, IDL::AST::Finder,
1314
1283
  IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef, IDL::AST::Enum, IDL::AST::Enumerator]
1315
1284
  attr_reader :component
@@ -1337,34 +1306,31 @@ module IDL::AST
1337
1306
  super(vars)
1338
1307
  end
1339
1308
 
1340
- def instantiate(_context, _enclosure)
1309
+ def instantiate(instantiation_context, _enclosure)
1341
1310
  _params = {
1342
- :component => IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, @component)),
1343
- :primarykey => @primarykey ? IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, @primarykey)) : @primarykey
1311
+ :component => IDL::AST::TemplateParam.concrete_param(instantiation_context, @component),
1312
+ :primarykey => @primarykey ? IDL::AST::TemplateParam.concrete_param(instantiation_context, @primarykey) : @primarykey
1344
1313
  }
1345
1314
  # instantiate concrete home def and validate
1346
- super(_context, _enclosure, _params)
1315
+ super(instantiation_context, _enclosure, _params)
1347
1316
  end
1348
1317
 
1349
1318
  def set_component_and_key(comp, key)
1350
1319
  unless comp && comp.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::TemplateParam)
1351
1320
  unless comp && comp.is_a?(IDL::Type::ScopedName) && comp.is_node?(IDL::AST::Component)
1352
- raise RuntimeError,
1353
- (comp ?
1321
+ raise (comp ?
1354
1322
  "invalid managed component for #{typename} #{scoped_lm_name}: #{comp.typename}" :
1355
1323
  "missing managed component specification for #{typename} #{scoped_lm_name}")
1356
1324
  end
1357
1325
  unless comp.resolved_type.node.is_defined?
1358
- raise RuntimeError,
1359
- "#{scoped_lm_name}: #{comp.typename} cannot manage forward declared component #{comp.node.scoped_lm_name}"
1326
+ raise "#{scoped_lm_name}: #{comp.typename} cannot manage forward declared component #{comp.node.scoped_lm_name}"
1360
1327
  end
1361
1328
  @resolved_comp = comp.resolved_type.node
1362
1329
  end
1363
1330
  unless key && key.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::TemplateParam)
1364
1331
  ## TODO : add check for Components::PrimaryKeyBase base type
1365
1332
  unless key.nil? || (key.is_a?(IDL::Type::ScopedName) && key.is_node?(IDL::AST::Valuetype))
1366
- raise RuntimeError,
1367
- "invalid primary key for #{typename} #{scoped_lm_name}: #{key.typename}"
1333
+ raise "invalid primary key for #{typename} #{scoped_lm_name}: #{key.typename}"
1368
1334
  end
1369
1335
  @resolved_pk = key.resolved_type.node if key
1370
1336
  end
@@ -1372,13 +1338,13 @@ module IDL::AST
1372
1338
  @primarykey = key.node if key
1373
1339
  end
1374
1340
 
1375
- def operations(include_bases=false,traversed=nil)
1341
+ def operations(include_bases=false, traversed=nil)
1376
1342
  ops = @children.find_all { |c| c.is_a?(IDL::AST::Operation) }
1377
1343
  ops.concat(base_operations(traversed || [])) if include_bases
1378
1344
  ops
1379
1345
  end
1380
1346
 
1381
- def attributes(include_bases=false,traversed=nil)
1347
+ def attributes(include_bases=false, traversed=nil)
1382
1348
  atts = @children.find_all { |c| c.is_a?(IDL::AST::Attribute) }
1383
1349
  atts.concat(base_attributes(traversed || [])) if include_bases
1384
1350
  atts
@@ -1387,7 +1353,6 @@ module IDL::AST
1387
1353
  end # Home
1388
1354
 
1389
1355
  class Connector < ComponentBase
1390
- NAMETYPE = :class
1391
1356
  DEFINABLE = [IDL::AST::Attribute, IDL::AST::Port]
1392
1357
 
1393
1358
  def initialize(_name, _enclosure, params)
@@ -1403,34 +1368,32 @@ module IDL::AST
1403
1368
  super(vars)
1404
1369
  end
1405
1370
 
1406
- def instantiate(_context, _enclosure)
1371
+ def instantiate(instantiation_context, _enclosure)
1407
1372
  # instantiate concrete connector def and validate
1408
- super(_context, _enclosure, {})
1373
+ super(instantiation_context, _enclosure, {})
1409
1374
  end
1410
1375
 
1411
1376
  def is_defined?; true; end
1412
1377
  def is_forward?; false; end
1413
1378
 
1414
1379
  def add_interfaces(intfs)
1415
- raise RuntimeError, "interface support not allowed for #{typename} #{scoped_lm_name}" if intfs && !intfs.empty?
1380
+ raise "interface support not allowed for #{typename} #{scoped_lm_name}" if intfs && !intfs.empty?
1416
1381
  end
1417
1382
 
1418
1383
  def set_base(parent)
1419
1384
  unless parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(IDL::AST::TemplateParam)
1420
- if not (parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(self.class))
1421
- raise RuntimeError,
1422
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1385
+ unless (parent.is_a?(IDL::Type::NodeType) && parent.is_node?(self.class))
1386
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1423
1387
  end
1424
1388
  @resolved_base = parent.resolved_type.node
1425
1389
  if @resolved_base.has_base?(self)
1426
- raise RuntimeError,
1427
- "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1390
+ raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1428
1391
  end
1429
1392
  end
1430
1393
  @base = parent.node
1431
1394
  end
1432
1395
 
1433
- def ports(include_bases=false,traversed=nil)
1396
+ def ports(include_bases=false, traversed=nil)
1434
1397
  ports = @children.inject([]) do |lst, c|
1435
1398
  lst.concat(c.ports) if IDL::AST::Port === c
1436
1399
  lst
@@ -1439,7 +1402,7 @@ module IDL::AST
1439
1402
  ports
1440
1403
  end
1441
1404
 
1442
- def attributes(include_bases=false,traversed=nil)
1405
+ def attributes(include_bases=false, traversed=nil)
1443
1406
  atts = @children.inject([]) do |lst, c|
1444
1407
  if IDL::AST::Port === c
1445
1408
  lst.concat(c.attributes)
@@ -1468,7 +1431,6 @@ module IDL::AST
1468
1431
  end # Connector
1469
1432
 
1470
1433
  class Component < ComponentBase
1471
- NAMETYPE = :class
1472
1434
  DEFINABLE = [IDL::AST::Attribute, IDL::AST::Port]
1473
1435
 
1474
1436
  def initialize(_name, _enclosure, params)
@@ -1486,9 +1448,9 @@ module IDL::AST
1486
1448
  super(vars)
1487
1449
  end
1488
1450
 
1489
- def instantiate(_context, _enclosure)
1451
+ def instantiate(instantiation_context, _enclosure)
1490
1452
  # instantiate concrete component def and validate
1491
- super(_context, _enclosure, { :forward => self.is_forward? })
1453
+ super(instantiation_context, _enclosure, { :forward => self.is_forward? })
1492
1454
  end
1493
1455
 
1494
1456
  def is_defined?; @defined; end
@@ -1496,24 +1458,21 @@ module IDL::AST
1496
1458
 
1497
1459
  def set_base(parent)
1498
1460
  unless parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(IDL::AST::TemplateParam)
1499
- if not (parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(self.class))
1500
- raise RuntimeError,
1501
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1461
+ unless (parent.is_a?(IDL::Type::NodeType) && parent.is_node?(self.class))
1462
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
1502
1463
  end
1503
1464
  @resolved_base = parent.resolved_type.node
1504
1465
  if not @resolved_base.is_defined?
1505
- raise RuntimeError,
1506
- "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{parent.node.typename} #{parent.node.scoped_lm_name}"
1466
+ raise "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{parent.node.typename} #{parent.node.scoped_lm_name}"
1507
1467
  end
1508
1468
  if @resolved_base.has_base?(self)
1509
- raise RuntimeError,
1510
- "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1469
+ raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
1511
1470
  end
1512
1471
  end
1513
1472
  @base = parent.node
1514
1473
  end
1515
1474
 
1516
- def ports(include_bases=false,traversed=nil)
1475
+ def ports(include_bases=false, traversed=nil)
1517
1476
  ports = @children.inject([]) do |lst, c|
1518
1477
  lst.concat(c.ports) if IDL::AST::Port === c
1519
1478
  lst
@@ -1522,11 +1481,11 @@ module IDL::AST
1522
1481
  ports
1523
1482
  end
1524
1483
 
1525
- def operations(include_bases=false,traversed=nil)
1484
+ def operations(include_bases=false, traversed=nil)
1526
1485
  include_bases ? base_operations(traversed || []) : []
1527
1486
  end
1528
1487
 
1529
- def attributes(include_bases=false,traversed=nil)
1488
+ def attributes(include_bases=false, traversed=nil)
1530
1489
  atts = @children.inject([]) do |lst, c|
1531
1490
  if IDL::AST::Port === c
1532
1491
  lst.concat(c.attributes)
@@ -1555,7 +1514,6 @@ module IDL::AST
1555
1514
  end # Component
1556
1515
 
1557
1516
  class Porttype < Node
1558
- NAMETYPE = :class
1559
1517
  DEFINABLE = [IDL::AST::Attribute, IDL::AST::Port]
1560
1518
  attr_reader :idltype
1561
1519
  def initialize(_name, _enclosure, params)
@@ -1571,13 +1529,12 @@ module IDL::AST
1571
1529
  @children.select {|c| IDL::AST::Attribute === c}
1572
1530
  end
1573
1531
 
1574
- def instantiate(_context, _enclosure)
1575
- super(_context, _enclosure, {})
1532
+ def instantiate(instantiation_context, _enclosure)
1533
+ super(instantiation_context, _enclosure, {})
1576
1534
  end
1577
1535
  end # Porttype
1578
1536
 
1579
1537
  class Port < Leaf
1580
- NAMETYPE = :member
1581
1538
  PORTTYPES = [:facet, :receptacle, :emitter, :publisher, :consumer, :port, :mirrorport]
1582
1539
  PORT_MIRRORS = {:facet => :receptacle, :receptacle => :facet}
1583
1540
  EXTPORTDEF_ANNOTATION = 'ExtendedPortDef'
@@ -1587,32 +1544,32 @@ module IDL::AST
1587
1544
  super(_name, _enclosure)
1588
1545
  @idltype = params[:type]
1589
1546
  @porttype = params[:porttype]
1590
- raise RuntimeError, "unknown porttype for #{typename} #{scoped_lm_name}: #{@porttype}" unless PORTTYPES.include?(@porttype)
1547
+ raise "unknown porttype for #{typename} #{scoped_lm_name}: #{@porttype}" unless PORTTYPES.include?(@porttype)
1591
1548
  case @porttype
1592
1549
  when :facet, :receptacle
1593
1550
  unless @idltype.is_a?(IDL::Type::Object) ||
1594
- (@idltype.is_a?(IDL::Type::ScopedName) && (@idltype.is_node?(IDL::AST::Interface) || @idltype.is_node?(IDL::AST::TemplateParam)))
1595
- raise RuntimeError, "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1551
+ (@idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Interface) || @idltype.is_node?(IDL::AST::TemplateParam)))
1552
+ raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1596
1553
  end
1597
1554
  when :port, :mirrorport
1598
- unless @idltype.is_a?(IDL::Type::ScopedName) && (@idltype.is_node?(IDL::AST::Porttype) || @idltype.is_node?(IDL::AST::TemplateParam))
1599
- raise RuntimeError, "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1555
+ unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Porttype) || @idltype.is_node?(IDL::AST::TemplateParam))
1556
+ raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1600
1557
  end
1601
1558
  else
1602
- unless @idltype.is_a?(IDL::Type::ScopedName) && (@idltype.is_node?(IDL::AST::Eventtype) || @idltype.is_node?(IDL::AST::TemplateParam))
1603
- raise RuntimeError, "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1559
+ unless @idltype.is_a?(IDL::Type::NodeType) && (@idltype.is_node?(IDL::AST::Eventtype) || @idltype.is_node?(IDL::AST::TemplateParam))
1560
+ raise "invalid type for #{typename} #{scoped_lm_name}: #{@idltype.typename}"
1604
1561
  end
1605
1562
  end
1606
1563
  @multiple = params[:multiple] ? true : false
1607
1564
  end
1608
1565
 
1609
- def instantiate(_context, _enclosure)
1566
+ def instantiate(instantiation_context, _enclosure)
1610
1567
  _params = {
1611
- :type => @idltype.instantiate(_context),
1568
+ :type => @idltype.instantiate(instantiation_context),
1612
1569
  :porttype => @porttype,
1613
1570
  :multiple => @multiple
1614
1571
  }
1615
- super(_context, _enclosure, _params)
1572
+ super(instantiation_context, _enclosure, _params)
1616
1573
  end
1617
1574
 
1618
1575
  def multiple?
@@ -1657,7 +1614,6 @@ module IDL::AST
1657
1614
  end # Port
1658
1615
 
1659
1616
  class Valuebox < Leaf
1660
- NAMETYPE = :class
1661
1617
  attr_reader :idltype, :boxed_type
1662
1618
  def initialize(_name, _enclosure, params)
1663
1619
  super(_name, _enclosure)
@@ -1665,8 +1621,7 @@ module IDL::AST
1665
1621
  @boxed_type = params[:type]
1666
1622
  unless @boxed_type.is_a?(IDL::Type::ScopedName) && @boxed_type.is_node?(IDL::AST::TemplateParam)
1667
1623
  if @boxed_type.resolved_type.is_a?(IDL::Type::Valuetype)
1668
- raise RuntimeError,
1669
- "boxing valuetype #{@boxed_type.scoped_lm_name} in Valuebox #{scoped_lm_name} not allowed"
1624
+ raise "boxing valuetype #{@boxed_type.scoped_lm_name} in Valuebox #{scoped_lm_name} not allowed"
1670
1625
  end
1671
1626
  end
1672
1627
  end
@@ -1685,16 +1640,15 @@ module IDL::AST
1685
1640
  super(vars)
1686
1641
  end
1687
1642
 
1688
- def instantiate(_context, _enclosure)
1643
+ def instantiate(instantiation_context, _enclosure)
1689
1644
  _params = {
1690
- :type => @boxed_type.instantiate(_context)
1645
+ :type => @boxed_type.instantiate(instantiation_context)
1691
1646
  }
1692
- super(_context, _enclosure, _params)
1647
+ super(instantiation_context, _enclosure, _params)
1693
1648
  end
1694
1649
  end # Valuebox
1695
1650
 
1696
1651
  class Valuetype < Derivable
1697
- NAMETYPE = :class
1698
1652
  DEFINABLE = [IDL::AST::Include, IDL::AST::Const, IDL::AST::Operation, IDL::AST::Attribute, IDL::AST::StateMember, IDL::AST::Initializer,
1699
1653
  IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef, IDL::AST::Enum, IDL::AST::Enumerator]
1700
1654
  attr_reader :bases, :interfaces
@@ -1721,8 +1675,7 @@ module IDL::AST
1721
1675
  _base = _inherits[:base] || {}
1722
1676
  @truncatable = _base[:truncatable] || false
1723
1677
  if @custom && @truncatable
1724
- raise RuntimeError,
1725
- "'truncatable' attribute *not* allowed for 'custom' #{typename} #{scoped_lm_name}"
1678
+ raise "'truncatable' attribute *not* allowed for 'custom' #{typename} #{scoped_lm_name}"
1726
1679
  end
1727
1680
  add_bases(_base[:list] || [])
1728
1681
  add_interfaces(_inherits[:supports] || [])
@@ -1752,7 +1705,7 @@ module IDL::AST
1752
1705
  super(vars)
1753
1706
  end
1754
1707
 
1755
- def instantiate(_context, _enclosure)
1708
+ def instantiate(instantiation_context, _enclosure)
1756
1709
  _params = {
1757
1710
  :forward => self.is_forward?,
1758
1711
  :abstract => self.is_abstract?,
@@ -1760,12 +1713,12 @@ module IDL::AST
1760
1713
  :inherits => {
1761
1714
  :base => {
1762
1715
  :truncatable => self.is_truncatable?,
1763
- :list => self.concrete_bases(_context)
1716
+ :list => self.concrete_bases(instantiation_context)
1764
1717
  },
1765
- :supports => self.concrete_interfaces(_context)
1718
+ :supports => self.concrete_interfaces(instantiation_context)
1766
1719
  }
1767
1720
  }
1768
- inst = super(_context, _enclosure, _params)
1721
+ inst = super(instantiation_context, _enclosure, _params)
1769
1722
  inst.defined = true
1770
1723
  inst
1771
1724
  end
@@ -1822,33 +1775,26 @@ module IDL::AST
1822
1775
  inherits_.each do |tc|
1823
1776
  unless tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::TemplateParam)
1824
1777
  if not (tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::Valuetype))
1825
- raise RuntimeError,
1826
- "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1778
+ raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
1827
1779
  end
1828
1780
  rtc = tc.resolved_type
1829
1781
  if rtc.node.has_ancestor?(self)
1830
- raise RuntimeError,
1831
- "circular inheritance detected for #{typename} #{scoped_lm_name}: #{tc.node.scoped_lm_name} is descendant"
1782
+ raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{tc.node.scoped_lm_name} is descendant"
1832
1783
  end
1833
1784
  if not rtc.node.is_defined?
1834
- raise RuntimeError,
1835
- "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1785
+ raise "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
1836
1786
  end
1837
1787
  if self.is_abstract? and not rtc.node.is_abstract?
1838
- raise RuntimeError,
1839
- "'abstract' #{typename} #{scoped_lm_name} cannot inherit from non-'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1788
+ raise "'abstract' #{typename} #{scoped_lm_name} cannot inherit from non-'abstract' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1840
1789
  end
1841
1790
  if (not self.is_custom?) and rtc.node.is_custom?
1842
- raise RuntimeError,
1843
- "non-'custom' #{typename} #{scoped_lm_name} cannot inherit from 'custom' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1791
+ raise "non-'custom' #{typename} #{scoped_lm_name} cannot inherit from 'custom' #{tc.node.typename} #{tc.node.scoped_lm_name}"
1844
1792
  end
1845
1793
  if @resolved_bases.include?(rtc.node)
1846
- raise RuntimeError,
1847
- "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1794
+ raise "#{typename} #{scoped_lm_name} cannot inherit from #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
1848
1795
  end
1849
1796
  if (not rtc.node.is_abstract?) and @bases.size > 0
1850
- raise RuntimeError,
1851
- "concrete basevalue #{tc.node.typename} #{tc.node.scoped_lm_name} MUST "+
1797
+ raise "concrete basevalue #{tc.node.typename} #{tc.node.scoped_lm_name} MUST " +
1852
1798
  "be first and only non-abstract in inheritance list for #{typename} #{scoped_lm_name}"
1853
1799
  end
1854
1800
  @resolved_bases << rtc.node
@@ -1861,18 +1807,15 @@ module IDL::AST
1861
1807
  iflist_.each do |if_|
1862
1808
  unless if_.is_a?(IDL::Type::ScopedName) && if_.is_node?(IDL::AST::TemplateParam)
1863
1809
  if not (if_.is_a?(IDL::Type::ScopedName) && if_.is_node?(IDL::AST::Interface))
1864
- raise RuntimeError,
1865
- "invalid support identifier for #{typename} #{scoped_lm_name}: #{if_.typename}"
1810
+ raise "invalid support identifier for #{typename} #{scoped_lm_name}: #{if_.typename}"
1866
1811
  end
1867
1812
  rif_ = if_.resolved_type
1868
1813
  ### @@TODO@@ further validation
1869
1814
  if (not rif_.node.is_abstract?) and @interfaces.size > 0
1870
- raise RuntimeError,
1871
- "concrete interface '#{rif_.node.scoped_lm_name}' inheritance not allowed for #{typename} #{scoped_lm_name}. Valuetypes can only inherit (support) a single concrete interface."
1815
+ raise "concrete interface '#{rif_.node.scoped_lm_name}' inheritance not allowed for #{typename} #{scoped_lm_name}. Valuetypes can only inherit (support) a single concrete interface."
1872
1816
  end
1873
1817
  if (not rif_.node.is_abstract?) && (not is_interface_compatible?(rif_.node))
1874
- raise RuntimeError,
1875
- "#{typename} #{scoped_lm_name} cannot support concrete interface #{rif_.node.scoped_lm_name} because it does not derive from inherited concrete interfaces"
1818
+ raise "#{typename} #{scoped_lm_name} cannot support concrete interface #{rif_.node.scoped_lm_name} because it does not derive from inherited concrete interfaces"
1876
1819
  end
1877
1820
  @resolved_interfaces << rif_.node
1878
1821
  end
@@ -1894,7 +1837,7 @@ module IDL::AST
1894
1837
 
1895
1838
  def define(_type, _name, *args)
1896
1839
  if self.is_abstract? && [IDL::AST::StateMember, IDL::AST::Initializer].include?(_type)
1897
- raise RuntimeError, "cannot define statemember #{_name} on abstract #{typename} #{scoped_lm_name}"
1840
+ raise "cannot define statemember #{_name} on abstract #{typename} #{scoped_lm_name}"
1898
1841
  end
1899
1842
  super(_type, _name, *args)
1900
1843
  end
@@ -1931,7 +1874,7 @@ module IDL::AST
1931
1874
  case node
1932
1875
  when IDL::AST::Struct, IDL::AST::Union
1933
1876
  if node.is_defined?
1934
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1877
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1935
1878
  end
1936
1879
  node.annotations.concat(params[:annotations])
1937
1880
 
@@ -1950,13 +1893,13 @@ module IDL::AST
1950
1893
 
1951
1894
  return _new_node
1952
1895
  else
1953
- raise RuntimeError, "#{node.typename} \"#{node.name}\" is already defined."
1896
+ raise "#{node.typename} \"#{node.name}\" is already defined."
1954
1897
  end
1955
1898
  end
1956
1899
 
1957
1900
  case node
1958
1901
  when IDL::AST::Operation, IDL::AST::Attribute, IDL::AST::StateMember, IDL::AST::Initializer
1959
- raise RuntimeError, "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1902
+ raise "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
1960
1903
  else
1961
1904
  newnode = node.class.new(node.name, self, params)
1962
1905
  newnode.annotations.concat(params[:annotations])
@@ -1975,16 +1918,16 @@ module IDL::AST
1975
1918
  @resolved_bases
1976
1919
  end
1977
1920
 
1978
- def concrete_bases(_context)
1921
+ def concrete_bases(instantiation_context)
1979
1922
  # collect all bases and resolve any template param types
1980
1923
  @bases.collect do |_base|
1981
- IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, _base))
1924
+ IDL::AST::TemplateParam.concrete_param(instantiation_context, _base)
1982
1925
  end
1983
1926
  end
1984
1927
 
1985
- def concrete_interfaces(_context)
1928
+ def concrete_interfaces(instantiation_context)
1986
1929
  @interfaces.collect do |_intf|
1987
- IDL::Type::ScopedName.new(IDL::AST::TemplateParam.concrete_param(_context, _intf))
1930
+ IDL::AST::TemplateParam.concrete_param(instantiation_context, _intf)
1988
1931
  end
1989
1932
  end
1990
1933
  end # Valuetype
@@ -1998,16 +1941,15 @@ module IDL::AST
1998
1941
  end # Eventtype
1999
1942
 
2000
1943
  class StateMember < Leaf
2001
- NAMETYPE = :member
2002
1944
  attr_reader :idltype, :visibility
2003
1945
  def initialize(_name, _enclosure, params)
2004
1946
  @is_recursive = false
2005
1947
  @has_incomplete_type = false
2006
1948
  super(_name, _enclosure)
2007
- @idltype = params[:type]
1949
+ @idltype = params[:type]
2008
1950
  @visibility = (params[:visibility] == :public ? :public : :private)
2009
1951
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2010
- raise RuntimeError, "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
1952
+ raise "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
2011
1953
  ## check for use of incomplete types
2012
1954
  if !@idltype.is_complete?
2013
1955
  ## verify type is used in sequence
@@ -2063,7 +2005,7 @@ module IDL::AST
2063
2005
  @has_incomplete_type = true
2064
2006
  return
2065
2007
  end
2066
- raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
2008
+ raise "Incomplete type #{@idltype.typename} not allowed here!"
2067
2009
  end
2068
2010
  end
2069
2011
  end
@@ -2080,12 +2022,12 @@ module IDL::AST
2080
2022
  super(vars)
2081
2023
  end
2082
2024
 
2083
- def instantiate(_context, _enclosure)
2025
+ def instantiate(instantiation_context, _enclosure)
2084
2026
  _params = {
2085
- :type => @idltype.instantiate(_context),
2027
+ :type => @idltype.instantiate(instantiation_context),
2086
2028
  :visibility => self.visibility
2087
2029
  }
2088
- super(_context, _enclosure, _params)
2030
+ super(instantiation_context, _enclosure, _params)
2089
2031
  end
2090
2032
 
2091
2033
  def is_local?(recurstk)
@@ -2106,7 +2048,6 @@ module IDL::AST
2106
2048
  end # StateMember
2107
2049
 
2108
2050
  class Initializer < Leaf
2109
- NAMETYPE = :member
2110
2051
  attr_reader :raises, :params
2111
2052
  def initialize(_name, _enclosure, params)
2112
2053
  super(_name, _enclosure)
@@ -2121,7 +2062,7 @@ module IDL::AST
2121
2062
  exlist.each do |extype|
2122
2063
  unless extype.is_a?(IDL::Type::ScopedName) &&
2123
2064
  (extype.is_node?(IDL::AST::Exception) || extype.is_node?(IDL::AST::TemplateParam) || extype.resolved_type.is_a?(IDL::Type::Native))
2124
- raise RuntimeError, 'Only IDL Exception types allowed in raises declaration.'
2065
+ raise 'Only IDL Exception types allowed in raises declaration.'
2125
2066
  end
2126
2067
  @raises << extype
2127
2068
  end
@@ -2137,28 +2078,28 @@ module IDL::AST
2137
2078
  super(vars)
2138
2079
  end
2139
2080
 
2140
- def instantiate(_context, _enclosure)
2081
+ def instantiate(instantiation_context, _enclosure)
2141
2082
  _params = {
2142
- :raises => self.concrete_raises(_context)
2083
+ :raises => self.concrete_raises(instantiation_context)
2143
2084
  }
2144
- _init = super(_context, _enclosure, _params)
2145
- _init.set_concrete_parameters(_context, @params)
2085
+ _init = super(instantiation_context, _enclosure, _params)
2086
+ _init.set_concrete_parameters(instantiation_context, @params)
2146
2087
  _init
2147
2088
  end
2148
2089
 
2149
2090
  protected
2150
2091
 
2151
- def concrete_raises(_context)
2092
+ def concrete_raises(instantiation_context)
2152
2093
  @raises.collect do |ex|
2153
- ex.instantiate(_context)
2094
+ ex.instantiate(instantiation_context)
2154
2095
  end
2155
2096
  end
2156
2097
 
2157
- def set_concrete_parameters(_context, parms)
2098
+ def set_concrete_parameters(instantiation_context, parms)
2158
2099
  @params = parms.collect do |parm|
2159
2100
  IDL::AST::Parameter.new(parm.name, self,
2160
2101
  { :attribute => :in,
2161
- :type => parm.idltype.instantiate(_context) })
2102
+ :type => parm.idltype.instantiate(instantiation_context) })
2162
2103
  end
2163
2104
  end
2164
2105
 
@@ -2168,17 +2109,15 @@ module IDL::AST
2168
2109
  end # Finder
2169
2110
 
2170
2111
  class Const < Leaf
2171
- NAMETYPE = :class
2172
2112
  attr_reader :idltype, :expression, :value
2173
2113
  def initialize(_name, _enclosure, params)
2174
2114
  super(_name, _enclosure)
2175
- @idltype = params[:type]
2115
+ @idltype = params[:type]
2176
2116
  @expression = params[:expression]
2177
2117
  @value = nil
2178
2118
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2179
- raise RuntimeError, "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2180
- raise RuntimeError,
2181
- "Incomplete type #{@idltype.typename} not allowed here!" if !@idltype.is_complete?
2119
+ raise "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2120
+ raise "Incomplete type #{@idltype.typename} not allowed here!" if !@idltype.is_complete?
2182
2121
  unless @expression.is_a?(IDL::Expression::ScopedName) && @expression.is_node?(IDL::AST::TemplateParam)
2183
2122
  @value = @idltype.narrow(@expression.value)
2184
2123
  end
@@ -2200,17 +2139,16 @@ module IDL::AST
2200
2139
  end
2201
2140
  end
2202
2141
 
2203
- def instantiate(_context, _enclosure)
2142
+ def instantiate(instantiation_context, _enclosure)
2204
2143
  _params = {
2205
- :type => @idltype.instantiate(_context),
2206
- :expression => @expression.instantiate(_context)
2144
+ :type => @idltype.instantiate(instantiation_context),
2145
+ :expression => @expression.instantiate(instantiation_context)
2207
2146
  }
2208
- super(_context, _enclosure, _params)
2147
+ super(instantiation_context, _enclosure, _params)
2209
2148
  end
2210
2149
  end # Const
2211
2150
 
2212
2151
  class Parameter < Leaf
2213
- NAMETYPE = :member
2214
2152
  IN, OUT, INOUT = 0, 1, 2
2215
2153
  ATTRIBUTE_MAP = {
2216
2154
  :in => IN,
@@ -2220,23 +2158,22 @@ module IDL::AST
2220
2158
  attr_reader :idltype
2221
2159
  def initialize(_name, _enclosure, params)
2222
2160
  super(_name, _enclosure)
2223
- @idltype = params[:type]
2161
+ @idltype = params[:type]
2224
2162
  @attribute = params[:attribute]
2225
2163
  unless ATTRIBUTE_MAP.has_key?(@attribute)
2226
- raise RuntimeError,
2227
- "invalid attribute for parameter: #{params[:attribute]}"
2164
+ raise "invalid attribute for parameter: #{params[:attribute]}"
2228
2165
  end
2229
2166
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2230
- raise RuntimeError, "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
2167
+ raise "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
2231
2168
  if @idltype.is_local?
2232
2169
  if _enclosure.enclosure.is_a?(IDL::AST::Interface) && !_enclosure.enclosure.is_local?
2233
- raise RuntimeError, "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2170
+ raise "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2234
2171
  end
2235
2172
  ## IDL_Valuetype: no problem as valuetype operations are local
2236
2173
  end
2237
2174
  if !@idltype.is_complete?
2238
2175
  if _enclosure.enclosure.is_a?(IDL::AST::Interface)
2239
- raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
2176
+ raise "Incomplete type #{@idltype.typename} not allowed here!"
2240
2177
  end
2241
2178
  ## IDL_Valuetype: no problem as valuetype operations are local
2242
2179
  end
@@ -2257,40 +2194,39 @@ module IDL::AST
2257
2194
  super(vars)
2258
2195
  end
2259
2196
 
2260
- def instantiate(_context, _enclosure)
2197
+ def instantiate(instantiation_context, _enclosure)
2261
2198
  _params = {
2262
- :type => @idltype.instantiate(_context),
2199
+ :type => @idltype.instantiate(instantiation_context),
2263
2200
  :attribute => @attribute
2264
2201
  }
2265
- super(_context, _enclosure, _params)
2202
+ super(instantiation_context, _enclosure, _params)
2266
2203
  end
2267
2204
  end # Parameter
2268
2205
 
2269
2206
  class Operation < Node
2270
- NAMETYPE = :member
2271
2207
  DEFINABLE = [IDL::AST::Parameter]
2272
2208
  attr_reader :idltype, :oneway, :raises
2273
2209
  attr_accessor :context
2274
2210
 
2275
2211
  def initialize(_name, _enclosure, params)
2276
2212
  super(_name, _enclosure)
2277
- @idltype = params[:type]
2213
+ @idltype = params[:type]
2278
2214
  @oneway = (params[:oneway] == true)
2279
2215
  @in = []
2280
2216
  @out = []
2281
2217
  @raises = []
2282
2218
  @context = nil
2283
2219
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2284
- raise RuntimeError, "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
2220
+ raise "Anonymous type definitions are not allowed!" if params[:type].is_anonymous?
2285
2221
  if @idltype.is_local?
2286
2222
  if _enclosure.is_a?(IDL::AST::Interface) && !_enclosure.is_local?
2287
- raise RuntimeError, "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2223
+ raise "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2288
2224
  end
2289
2225
  ## IDL_Valuetype: no problem as valuetype operations are local
2290
2226
  end
2291
2227
  if !@idltype.is_complete?
2292
2228
  if _enclosure.is_a?(IDL::AST::Interface)
2293
- raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
2229
+ raise "Incomplete type #{@idltype.typename} not allowed here!"
2294
2230
  end
2295
2231
  ## IDL_Valuetype: no problem as valuetype operations are local
2296
2232
  end
@@ -2311,13 +2247,13 @@ module IDL::AST
2311
2247
  super(vars)
2312
2248
  end
2313
2249
 
2314
- def instantiate(_context, _enclosure)
2250
+ def instantiate(instantiation_context, _enclosure)
2315
2251
  _params = {
2316
- :type => @idltype.instantiate(_context),
2252
+ :type => @idltype.instantiate(instantiation_context),
2317
2253
  :oneway => @oneway,
2318
2254
  }
2319
- _op = super(_context, _enclosure, _params)
2320
- _op.raises = self.concrete_raises(_context)
2255
+ _op = super(instantiation_context, _enclosure, _params)
2256
+ _op.raises = self.concrete_raises(instantiation_context)
2321
2257
  _op.context = @context
2322
2258
  _op
2323
2259
  end
@@ -2326,7 +2262,7 @@ module IDL::AST
2326
2262
  exlist.each do |extype|
2327
2263
  unless extype.is_a?(IDL::Type::ScopedName) &&
2328
2264
  (extype.is_node?(IDL::AST::Exception) || extype.is_node?(IDL::AST::TemplateParam) || extype.resolved_type.is_a?(IDL::Type::Native))
2329
- raise RuntimeError, 'Only IDL Exception or Native types allowed in raises declaration.'
2265
+ raise 'Only IDL Exception or Native types allowed in raises declaration.'
2330
2266
  end
2331
2267
  @raises << extype
2332
2268
  end
@@ -2358,13 +2294,13 @@ module IDL::AST
2358
2294
 
2359
2295
  protected
2360
2296
 
2361
- def concrete_raises(_context)
2297
+ def concrete_raises(instantiation_context)
2362
2298
  @raises.collect do |ex|
2363
- ex.instantiate(_context)
2299
+ ex.instantiate(instantiation_context)
2364
2300
  end
2365
2301
  end
2366
2302
 
2367
- def copy_from(_template, _context)
2303
+ def copy_from(_template, instantiation_context)
2368
2304
  super
2369
2305
  self.walk_members do |param|
2370
2306
  case param.attribute
@@ -2384,23 +2320,22 @@ module IDL::AST
2384
2320
  class Attribute < Leaf
2385
2321
  attr_reader :idltype, :readonly
2386
2322
  attr_reader :get_raises, :set_raises
2387
- NAMETYPE = :member
2388
2323
  def initialize(_name, _enclosure, params)
2389
2324
  super(_name, _enclosure)
2390
- @idltype = params[:type]
2325
+ @idltype = params[:type]
2391
2326
  @get_raises = []
2392
2327
  @set_raises = []
2393
2328
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2394
- raise RuntimeError, "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2329
+ raise "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2395
2330
  if @idltype.is_local?
2396
2331
  if _enclosure.is_a?(IDL::AST::Interface) && !_enclosure.is_local?
2397
- raise RuntimeError, "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2332
+ raise "Local type #{@idltype.typename} not allowed for operation on unrestricted interface"
2398
2333
  end
2399
2334
  ## IDL_Valuetype: no problem as valuetype operations are local
2400
2335
  end
2401
2336
  if !@idltype.is_complete?
2402
2337
  if _enclosure.is_a?(IDL::AST::Interface)
2403
- raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
2338
+ raise "Incomplete type #{@idltype.typename} not allowed here!"
2404
2339
  end
2405
2340
  ## IDL_Valuetype: no problem as valuetype operations are local
2406
2341
  end
@@ -2420,14 +2355,14 @@ module IDL::AST
2420
2355
  super(vars)
2421
2356
  end
2422
2357
 
2423
- def instantiate(_context, _enclosure)
2358
+ def instantiate(instantiation_context, _enclosure)
2424
2359
  _params = {
2425
- :type => @idltype.instantiate(_context),
2360
+ :type => @idltype.instantiate(instantiation_context),
2426
2361
  :readonly => @readonly
2427
2362
  }
2428
- _att = super(_context, _enclosure, _params)
2429
- _att.get_raises = self.concrete_get_raises(_context)
2430
- _att.set_raises = self.concrete_set_raises(_context)
2363
+ _att = super(instantiation_context, _enclosure, _params)
2364
+ _att.get_raises = self.concrete_get_raises(instantiation_context)
2365
+ _att.set_raises = self.concrete_set_raises(instantiation_context)
2431
2366
  _att
2432
2367
  end
2433
2368
 
@@ -2435,7 +2370,7 @@ module IDL::AST
2435
2370
  exlist.each do |extype|
2436
2371
  unless extype.is_a?(IDL::Type::ScopedName) &&
2437
2372
  (extype.is_node?(IDL::AST::Exception) || extype.is_node?(IDL::AST::TemplateParam) || extype.resolved_type.is_a?(IDL::Type::Native))
2438
- raise RuntimeError, 'Only IDL Exception types allowed in raises declaration.' unless extype.resolved_type.node.is_a?(IDL::AST::Exception)
2373
+ raise 'Only IDL Exception types allowed in raises declaration.' unless extype.resolved_type.node.is_a?(IDL::AST::Exception)
2439
2374
  end
2440
2375
  @get_raises << extype
2441
2376
  end
@@ -2445,7 +2380,7 @@ module IDL::AST
2445
2380
  exlist.each do |extype|
2446
2381
  unless extype.is_a?(IDL::Type::ScopedName) &&
2447
2382
  (extype.is_node?(IDL::AST::Exception) || extype.is_node?(IDL::AST::TemplateParam) || extype.resolved_type.is_a?(IDL::Type::Native))
2448
- raise RuntimeError, 'Only IDL Exception types allowed in raises declaration.' unless extype.resolved_type.node.is_a?(IDL::AST::Exception)
2383
+ raise 'Only IDL Exception types allowed in raises declaration.' unless extype.resolved_type.node.is_a?(IDL::AST::Exception)
2449
2384
  end
2450
2385
  @set_raises << extype
2451
2386
  end
@@ -2460,21 +2395,20 @@ module IDL::AST
2460
2395
 
2461
2396
  protected
2462
2397
 
2463
- def concrete_get_raises(_context)
2398
+ def concrete_get_raises(instantiation_context)
2464
2399
  @get_raises.collect do |ex|
2465
- ex.instantiate(_context)
2400
+ ex.instantiate(instantiation_context)
2466
2401
  end
2467
2402
  end
2468
2403
 
2469
- def concrete_set_raises(_context)
2404
+ def concrete_set_raises(instantiation_context)
2470
2405
  @set_raises.collect do |ex|
2471
- ex.instantiate(_context)
2406
+ ex.instantiate(instantiation_context)
2472
2407
  end
2473
2408
  end
2474
2409
  end # Attribute
2475
2410
 
2476
2411
  class Struct < Node
2477
- NAMETYPE = :class
2478
2412
  DEFINABLE = [IDL::AST::Member, IDL::AST::Struct, IDL::AST::Union, IDL::AST::Enum, IDL::AST::Enumerator]
2479
2413
  attr_reader :idltype
2480
2414
  def initialize(_name, _enclosure, params)
@@ -2520,11 +2454,11 @@ module IDL::AST
2520
2454
  super(vars)
2521
2455
  end
2522
2456
 
2523
- def instantiate(_context, _enclosure)
2457
+ def instantiate(instantiation_context, _enclosure)
2524
2458
  _params = {
2525
2459
  :forward => @forward
2526
2460
  }
2527
- _s = super(_context, _enclosure, _params)
2461
+ _s = super(instantiation_context, _enclosure, _params)
2528
2462
  _s.defined = self.is_defined?
2529
2463
  _s
2530
2464
  end
@@ -2546,12 +2480,11 @@ module IDL::AST
2546
2480
 
2547
2481
  class Member < Leaf
2548
2482
  attr_reader :idltype
2549
- NAMETYPE = :member
2550
2483
  def initialize(_name, _enclosure, params)
2551
2484
  super(_name, _enclosure)
2552
2485
  @idltype = params[:type]
2553
2486
  unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam)
2554
- raise RuntimeError, "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2487
+ raise "Anonymous type definitions are not allowed!" if @idltype.is_anonymous?
2555
2488
  ## check for use of incomplete types
2556
2489
  if !@idltype.is_complete?
2557
2490
  ## verify type is used in sequence
@@ -2585,7 +2518,7 @@ module IDL::AST
2585
2518
  end
2586
2519
  end
2587
2520
  end
2588
- raise RuntimeError, "Incomplete type #{@idltype.typename} not allowed here!"
2521
+ raise "Incomplete type #{@idltype.typename} not allowed here!"
2589
2522
  end
2590
2523
  end
2591
2524
  end
@@ -2603,16 +2536,15 @@ module IDL::AST
2603
2536
  super(vars)
2604
2537
  end
2605
2538
 
2606
- def instantiate(_context, _enclosure, _params = {})
2539
+ def instantiate(instantiation_context, _enclosure, _params = {})
2607
2540
  _params.merge!({
2608
- :type => @idltype.instantiate(_context),
2541
+ :type => @idltype.instantiate(instantiation_context),
2609
2542
  })
2610
- super(_context, _enclosure, _params)
2543
+ super(instantiation_context, _enclosure, _params)
2611
2544
  end
2612
2545
  end # Member
2613
2546
 
2614
2547
  class Union < Node
2615
- NAMETYPE = :class
2616
2548
  DEFINABLE = [IDL::AST::UnionMember, IDL::AST::Struct, IDL::AST::Union, IDL::AST::Enum, IDL::AST::Enumerator]
2617
2549
  attr_reader :idltype
2618
2550
  attr_accessor :switchtype
@@ -2677,16 +2609,14 @@ module IDL::AST
2677
2609
  ## check union case labels for validity
2678
2610
  m.labels.each { |lbl|
2679
2611
  if lbl == :default
2680
- raise RuntimeError,
2681
- "duplicate case label 'default' for #{typename} #{lm_name}" if default_
2612
+ raise "duplicate case label 'default' for #{typename} #{lm_name}" if default_
2682
2613
  default_ = true
2683
2614
  else
2684
2615
  # correct type
2685
2616
  lv = @switchtype.resolved_type.narrow(lbl.value)
2686
2617
  # doubles
2687
2618
  if labelvals.include? lv
2688
- raise RuntimeError,
2689
- "duplicate case label #{lv.to_s} for #{typename} #{lm_name}"
2619
+ raise "duplicate case label #{lv.to_s} for #{typename} #{lm_name}"
2690
2620
  end
2691
2621
  labelvals << lv
2692
2622
  end
@@ -2695,8 +2625,7 @@ module IDL::AST
2695
2625
  ## check if default allowed if defined
2696
2626
  if default_
2697
2627
  if @switchtype.resolved_type.range_length == labelvals.size
2698
- raise RuntimeError,
2699
- "'default' case label superfluous for #{typename} #{lm_name}"
2628
+ raise "'default' case label superfluous for #{typename} #{lm_name}"
2700
2629
  end
2701
2630
  end
2702
2631
  end
@@ -2714,12 +2643,12 @@ module IDL::AST
2714
2643
  super(vars)
2715
2644
  end
2716
2645
 
2717
- def instantiate(_context, _enclosure)
2646
+ def instantiate(instantiation_context, _enclosure)
2718
2647
  _params = {
2719
2648
  :forward => @forward
2720
2649
  }
2721
- _u = super(_context, _enclosure, _params)
2722
- _u.set_switchtype(@switchtype.instantiate(_context))
2650
+ _u = super(instantiation_context, _enclosure, _params)
2651
+ _u.set_switchtype(@switchtype.instantiate(instantiation_context))
2723
2652
  _u.validate_labels
2724
2653
  _u.defined = self.is_defined?
2725
2654
  _u
@@ -2733,7 +2662,6 @@ module IDL::AST
2733
2662
  end # Union
2734
2663
 
2735
2664
  class UnionMember < Member
2736
- NAMETYPE = :member
2737
2665
  attr_reader :labels
2738
2666
  def initialize(_name, _enclosure, params)
2739
2667
  super(_name, _enclosure, params)
@@ -2754,16 +2682,15 @@ module IDL::AST
2754
2682
  super(vars)
2755
2683
  end
2756
2684
 
2757
- def instantiate(_context, _enclosure)
2685
+ def instantiate(instantiation_context, _enclosure)
2758
2686
  _params = {
2759
- :labels => @labels.collect { |l| l == :default ? l : l.instantiate(_context) },
2687
+ :labels => @labels.collect { |l| l == :default ? l : l.instantiate(instantiation_context) },
2760
2688
  }
2761
- super(_context, _enclosure, _params)
2689
+ super(instantiation_context, _enclosure, _params)
2762
2690
  end
2763
2691
  end # UnionMember
2764
2692
 
2765
2693
  class Enum < Leaf
2766
- NAMETYPE = :class
2767
2694
  attr_reader :idltype
2768
2695
  def initialize(_name, _enclosure, params)
2769
2696
  super(_name, _enclosure)
@@ -2789,17 +2716,17 @@ module IDL::AST
2789
2716
  @enums << n
2790
2717
  end
2791
2718
 
2792
- def instantiate(_context, _enclosure)
2793
- super(_context, _enclosure, {})
2719
+ def instantiate(instantiation_context, _enclosure)
2720
+ super(instantiation_context, _enclosure, {})
2794
2721
  end
2722
+
2795
2723
  end # Enum
2796
2724
 
2797
2725
  class Enumerator < Leaf
2798
- NAMETYPE = :class
2799
2726
  attr_reader :idltype, :enum, :value
2800
2727
  def initialize(_name, _enclosure, params)
2801
2728
  super(_name, _enclosure)
2802
- @idltype = IDL::Type::ULong.new
2729
+ @idltype = IDL::Type::ULong.new
2803
2730
  @enum = params[:enum]
2804
2731
  @value = params[:value]
2805
2732
  @enum.add_enumerator(self)
@@ -2816,14 +2743,16 @@ module IDL::AST
2816
2743
  super(vars)
2817
2744
  end
2818
2745
 
2819
- def instantiate(_context, _enclosure)
2820
- super(_context, _enclosure, { :enum => @enum, :value => @value })
2746
+ def instantiate(instantiation_context, _enclosure)
2747
+ # find already instantiated Enum parent
2748
+ _enum = _enclosure.resolve(@enum.name)
2749
+ raise "Unable to resolve instantiated Enum scope for enumerator #{@enum.name}::#{name} instantiation" unless _enum
2750
+ super(instantiation_context, _enclosure, { :enum => _enum, :value => @value })
2821
2751
  end
2822
2752
  end # Enumerator
2823
2753
 
2824
2754
  class Typedef < Leaf
2825
2755
  attr_reader :idltype
2826
- NAMETYPE = :class
2827
2756
  def initialize(_name, _enclosure, params)
2828
2757
  super(_name, _enclosure)
2829
2758
  @idltype = params[:type]
@@ -2842,8 +2771,8 @@ module IDL::AST
2842
2771
  super(vars)
2843
2772
  end
2844
2773
 
2845
- def instantiate(_context, _enclosure)
2846
- super(_context, _enclosure, { :type => @idltype.instantiate(_context) })
2774
+ def instantiate(instantiation_context, _enclosure)
2775
+ super(instantiation_context, _enclosure, { :type => @idltype.instantiate(instantiation_context) })
2847
2776
  end
2848
2777
  end # Typedef
2849
2778
  end