class RLTK::CG::ConstantStruct
A constant struct value.
Public Class Methods
new(size_or_values, packed = false, context = nil, &block)
click to toggle source
Create a new constant struct value.
@example Using array of values:
ConstantStruct.new([Int32.new(0), Int64.new(1), Int32.new(2), Int64.new(3)])
@example Using size:
ConstantStruct.new(4) { |i| if i % 2 == 0 then Int32.new(i) else Int64.new(i) end }
@yieldparam index [Integer] Index of the value in the struct.
@param [Array<Value>, Integer] size_or_values Number of values or array of values. @param [Boolean] packed Are the types packed already, or should they be re-arranged to save space? @param [Context, nil] context Context
in which to create the value. @param [Proc] block Block evaluated if size is specified.
# File lib/rltk/cg/value.rb, line 463 def initialize(size_or_values, packed = false, context = nil, &block) vals_ptr = make_ptr_to_elements(size_or_values, &block) @ptr = if context Bindings.const_struct_in_context(check_type(context, Context, 'context'), vals_ptr, vals_ptr.size / vals_ptr.type_size, packed.to_i) else Bindings.const_struct(vals_ptr, vals_ptr.size / vals_ptr.type_size, packed.to_i) end end