Class: IDL::Type::Sequence

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

Constant Summary

Constants inherited from IDL::Type

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from IDL::Type

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

Constructor Details

#initialize(t, size) ⇒ Sequence

Returns a new instance of Sequence.



346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/ridl/type.rb', line 346

def initialize(t, size)
  raise "Anonymous type definitions are not allowed!" if t.is_anonymous?

  @basetype = t
  @size = size
  @typename = format("sequence<%s%s>", t.typename,
                     if @size.nil? then
                        ""
                     else
                        ", #{IDL::Expression::ScopedName === size ? size.node.name : size.to_s}"
                     end)
  @recursive = false
end

Instance Attribute Details

#basetypeObject (readonly)

Returns the value of attribute basetype.



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

def basetype
  @basetype
end

#recursiveObject

Returns the value of attribute recursive.



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

def recursive
  @recursive
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#instantiate(instantiation_context) ⇒ Object



392
393
394
395
396
397
398
# File 'lib/ridl/type.rb', line 392

def instantiate(instantiation_context)
  if self.is_template?
    Type::Sequence.new(@basetype.instantiate(instantiation_context), @size ? @size.instantiate(instantiation_context).value : nil)
  else
    self
  end
end

#is_anonymous?Boolean

Returns:



380
381
382
# File 'lib/ridl/type.rb', line 380

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



368
369
370
# File 'lib/ridl/type.rb', line 368

def is_complete?
  @basetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



372
373
374
# File 'lib/ridl/type.rb', line 372

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

#is_recursive?Boolean

Returns:



376
377
378
# File 'lib/ridl/type.rb', line 376

def is_recursive?
  @recursive
end

#is_template?Boolean

Returns:



384
385
386
# File 'lib/ridl/type.rb', line 384

def is_template?
  (@size && @size.is_a?(IDL::Expression::ScopedName) && @size.node.is_a?(IDL::AST::TemplateParam)) || @basetype.is_template?
end

#lengthObject



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

def length
  @size
end

#matches?(idltype) ⇒ Boolean

Returns:



388
389
390
# File 'lib/ridl/type.rb', line 388

def matches?(idltype)
  super && self.size == idltype.size && self.basetype.resolved_type.matches?(idltype.basetype.resolved_type)
end

#narrow(obj) ⇒ Object



364
365
366
# File 'lib/ridl/type.rb', line 364

def narrow(obj)
  typeerror(obj)
end

#typenameObject



360
361
362
# File 'lib/ridl/type.rb', line 360

def typename
  @typename
end