Class: IDL::Type::Map

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(key, value, size) ⇒ Map

Returns a new instance of Map.



409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/ridl/type.rb', line 409

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

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

Instance Attribute Details

#keytypeObject (readonly)

Returns the value of attribute keytype.



402
403
404
# File 'lib/ridl/type.rb', line 402

def keytype
  @keytype
end

#recursiveObject

Returns the value of attribute recursive.



403
404
405
# File 'lib/ridl/type.rb', line 403

def recursive
  @recursive
end

#sizeObject (readonly)

Returns the value of attribute size.



402
403
404
# File 'lib/ridl/type.rb', line 402

def size
  @size
end

#valuetypeObject (readonly)

Returns the value of attribute valuetype.



402
403
404
# File 'lib/ridl/type.rb', line 402

def valuetype
  @valuetype
end

Instance Method Details

#instantiate(instantiation_context) ⇒ Object



456
457
458
459
460
461
462
# File 'lib/ridl/type.rb', line 456

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

#is_anonymous?Boolean

Returns:



444
445
446
# File 'lib/ridl/type.rb', line 444

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



432
433
434
# File 'lib/ridl/type.rb', line 432

def is_complete?
  @keytype.resolved_type.is_complete? && @valuetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



436
437
438
# File 'lib/ridl/type.rb', line 436

def is_local?(recurstk = [])
  @keytype.resolved_type.is_local?(recurstk) && @valuetype.resolved_type.is_local?(recurstk)
end

#is_recursive?Boolean

Returns:



440
441
442
# File 'lib/ridl/type.rb', line 440

def is_recursive?
  @recursive
end

#is_template?Boolean

Returns:



448
449
450
# File 'lib/ridl/type.rb', line 448

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

#lengthObject



405
406
407
# File 'lib/ridl/type.rb', line 405

def length
  @size
end

#matches?(idltype) ⇒ Boolean

Returns:



452
453
454
# File 'lib/ridl/type.rb', line 452

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

#narrow(obj) ⇒ Object



428
429
430
# File 'lib/ridl/type.rb', line 428

def narrow(obj)
  typeerror(obj)
end

#typenameObject



424
425
426
# File 'lib/ridl/type.rb', line 424

def typename
  @typename
end