Class: IDL::Type::Array

Inherits:
IDL::Type show all
Defined in:
lib/ridl/type.rb

Constant Summary

Constants inherited from IDL::Type

Long, LongLong, Octet, Short, ULong, ULongLong, UShort

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from IDL::Type

#is_node?, #resolved_node, #resolved_type, #typeerror

Constructor Details

#initialize(t, sizes) ⇒ Array

Returns a new instance of Array.

Raises:

  • (RuntimeError)


312
313
314
315
316
317
318
319
320
321
322
# File 'lib/ridl/type.rb', line 312

def initialize(t, sizes)
  raise RuntimeError, "Anonymous type definitions are not allowed!" if t.is_anonymous?
  @basetype = t
  if sizes.nil?
    @sizes = []
    @typename = t.typename + "[]"
  else
    @sizes = sizes
    @typename = t.typename + sizes.collect { |s| "[#{IDL::Expression::ScopedName === s ? s.node.name : s.to_s}]" }.join
  end
end

Instance Attribute Details

#basetypeObject (readonly)

Returns the value of attribute basetype.



310
311
312
# File 'lib/ridl/type.rb', line 310

def basetype
  @basetype
end

#sizesObject (readonly)

Returns the value of attribute sizes.



311
312
313
# File 'lib/ridl/type.rb', line 311

def sizes
  @sizes
end

Instance Method Details

#instantiate(_context) ⇒ Object



341
342
343
# File 'lib/ridl/type.rb', line 341

def instantiate(_context)
  self.is_template? ? Type::Array.new(@basetype.instantiate(_context), @sizes.collect { |sz| sz.instantiate(_context).value }) : self
end

#is_anonymous?Boolean

Returns:



335
336
337
# File 'lib/ridl/type.rb', line 335

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



329
330
331
# File 'lib/ridl/type.rb', line 329

def is_complete?
  @basetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



332
333
334
# File 'lib/ridl/type.rb', line 332

def is_local?(recurstk = [])
  @basetype.resolved_type.is_local?(recurstk)
end

#is_template?Boolean

Returns:



338
339
340
# File 'lib/ridl/type.rb', line 338

def is_template?
  @sizes.any? { |sz| (sz.is_a?(IDL::Expression::ScopedName) && sz.node.is_a?(IDL::AST::TemplateParam)) } || @basetype.is_template?
end

#narrow(obj) ⇒ Object



326
327
328
# File 'lib/ridl/type.rb', line 326

def narrow(obj)
  typeerror(obj)
end

#typenameObject



323
324
325
# File 'lib/ridl/type.rb', line 323

def typename
  @typename
end