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, 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, size) ⇒ Sequence

Returns a new instance of Sequence.

Raises:

  • (RuntimeError)


279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/ridl/type.rb', line 279

def initialize(t, size)
  raise RuntimeError, "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.



276
277
278
# File 'lib/ridl/type.rb', line 276

def basetype
  @basetype
end

#recursiveObject

Returns the value of attribute recursive.



277
278
279
# File 'lib/ridl/type.rb', line 277

def recursive
  @recursive
end

#sizeObject (readonly)

Returns the value of attribute size.



276
277
278
# File 'lib/ridl/type.rb', line 276

def size
  @size
end

Instance Method Details

#instantiate(_context) ⇒ Object



315
316
317
# File 'lib/ridl/type.rb', line 315

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

#is_anonymous?Boolean

Returns:



306
307
308
# File 'lib/ridl/type.rb', line 306

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



297
298
299
# File 'lib/ridl/type.rb', line 297

def is_complete?
  @basetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



300
301
302
# File 'lib/ridl/type.rb', line 300

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

#is_recursive?Boolean

Returns:



303
304
305
# File 'lib/ridl/type.rb', line 303

def is_recursive?
  @recursive
end

#is_template?Boolean

Returns:



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

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

#lengthObject



278
# File 'lib/ridl/type.rb', line 278

def length; @size; end

#matches?(idltype) ⇒ Boolean

Returns:



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

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

#narrow(obj) ⇒ Object



294
295
296
# File 'lib/ridl/type.rb', line 294

def narrow(obj)
  typeerror(obj)
end

#typenameObject



291
292
293
# File 'lib/ridl/type.rb', line 291

def typename
  @typename
end