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)


271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/ridl/type.rb', line 271

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.



268
269
270
# File 'lib/ridl/type.rb', line 268

def basetype
  @basetype
end

#recursiveObject

Returns the value of attribute recursive.



269
270
271
# File 'lib/ridl/type.rb', line 269

def recursive
  @recursive
end

#sizeObject (readonly)

Returns the value of attribute size.



268
269
270
# File 'lib/ridl/type.rb', line 268

def size
  @size
end

Instance Method Details

#instantiate(_context) ⇒ Object



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

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

#is_anonymous?Boolean

Returns:



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

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



289
290
291
# File 'lib/ridl/type.rb', line 289

def is_complete?
  @basetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



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

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

#is_recursive?Boolean

Returns:



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

def is_recursive?
  @recursive
end

#is_template?Boolean

Returns:



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

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

#lengthObject



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

def length; @size; end

#narrow(obj) ⇒ Object



286
287
288
# File 'lib/ridl/type.rb', line 286

def narrow(obj)
  typeerror(obj)
end

#typenameObject



283
284
285
# File 'lib/ridl/type.rb', line 283

def typename
  @typename
end