Class: RCGTK::ConstantArray

Inherits:
ConstantAggregate show all
Defined in:
lib/rcgtk/value.rb

Overview

A constant array value.

Direct Known Subclasses

ConstantString

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Instance Method Summary collapse

Methods inherited from ConstantAggregate

#extract, #insert

Methods inherited from Constant

#addr_space_cast, #bitcast_to, #get_element_ptr, #get_element_ptr_in_bounds

Methods inherited from User

#operands

Methods inherited from Value

#==, #attributes, #bitcast, #constant?, #dump, #hash, #name, #name=, #null?, #print, #trunc, #trunc_or_bitcast, #type, #undefined?, #zextend, #zextend_or_bitcast

Methods included from BindingClass

#==

Constructor Details

#initialize(element_type, size_or_values, &block) {|index| ... } ⇒ ConstantArray

Create a new constant array value.

Examples:

Using array of values:

ConstantArray.new(Int32Type, [Int32.new(0), Int32.new(1)])

Using size:

ConstantArray.new(Int32Type, 2) { |i| Int32.new(i) }

Parameters:

  • element_type (Type)

    Type of values in this aggregate.

  • size_or_values (Array<Value>, Integer)

    Number of values or array of values.

  • block (Proc)

    Block evaluated if size is specified.

Yield Parameters:

  • index (Integer)

    Index of the value in the array.



417
418
419
420
421
# File 'lib/rcgtk/value.rb', line 417

def initialize(element_type, size_or_values, &block)
	vals_ptr     = make_ptr_to_elements(size_or_values, &block)
	element_type = check_cg_type(element_type, Type, 'element_type')
	@ptr         = Bindings.const_array(element_type, vals_ptr, vals_ptr.size / vals_ptr.type_size)
end

Instance Method Details

#sizeObject Also known as: length



423
424
425
# File 'lib/rcgtk/value.rb', line 423

def size
	self.type.size
end