Class: RLTK::CG::VectorType

Inherits:
Type show all
Defined in:
lib/rltk/cg/type.rb

Overview

A type used to represent vector operations (SIMD). This is NOT an aggregate type.

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Instance Method Summary collapse

Methods inherited from Type

#allignment, #context, from_ptr, #hash, #kind

Methods included from AbstractClass

included

Methods included from BindingClass

#==

Constructor Details

#initialize(overloaded, size = 0) ⇒ VectorType

Create a new vector type from a pointer or a type.

Parameters:

  • overloaded (FFI::Pointer, Type)

    Pointer to existing vector type or Type of object stored in the vector.

  • size (Integer) (defaults to: 0)

    Number of objects in this vector type.



282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/rltk/cg/type.rb', line 282

def initialize(overloaded, size = 0)
	@ptr =
	case overloaded
	when FFI::Pointer
		overloaded
	else
		@element_type	= check_cg_type(overloaded, Type, 'overloaded')
		bname		= Bindings.get_bname(self.class.short_name)
		
		Bindings.send(bname, @element_type, size)
	end
end

Instance Method Details

#element_typeType

Returns Type of object stored inside this vector.

Returns:

  • (Type)

    Type of object stored inside this vector.



296
297
298
# File 'lib/rltk/cg/type.rb', line 296

def element_type
	@element_type ||= Type.from_ptr(Bindings.get_element_type(@ptr))
end

#sizeInteger Also known as: length

Returns Number of objects in this vector type.

Returns:

  • (Integer)

    Number of objects in this vector type.



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

def size
	Bindings.get_vector_size(@ptr)
end