Class: Yadriggy::C::CType::CArray

Inherits:
IvarObj
  • Object
show all
Defined in:
lib/yadriggy/c/ctype.rb

Overview

Array type available only in C code. See also IntArray and FloatArray in ‘ffi.rb`.

Direct Known Subclasses

FloatCArray, IntCArray

Constant Summary

Constants included from Yadriggy::C::CType

Float32Array, Float32Type, FloatArray, Int, IntArray, Void

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Yadriggy::C::CType

#arrayof

Constructor Details

#initialize(*sizes) ⇒ CArray

Returns a new instance of CArray.

Parameters:

  • sizes (Array<Integer>)

    size of each dimension.



50
51
52
53
54
# File 'lib/yadriggy/c/ctype.rb', line 50

def initialize(*sizes)
  raise 'unknown array size' unless sizes.size > 0
  @sizes = sizes
  @debug = false
end

Instance Attribute Details

#debugObject

debug mode.



44
45
46
# File 'lib/yadriggy/c/ctype.rb', line 44

def debug
  @debug
end

#sizesArray<Integer> (readonly)

Returns sizes array size.

Returns:

  • (Array<Integer>)

    sizes array size.



47
48
49
# File 'lib/yadriggy/c/ctype.rb', line 47

def sizes
  @sizes
end

Instance Method Details

#check_range(indexes) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/yadriggy/c/ctype.rb', line 64

def check_range(indexes)
  raise 'wrong number of indexes' unless indexes.size == @sizes.size
  indexes.each_index do |i|
    if indexes[i] >= @sizes[i]
      raise "out of range: #{self.to_s}[#{indexes[i]}]"
    end
  end
end

#typeType

This method is abstract.

Returns the element type.

Returns:

  • (Type)

    the element type.



59
60
61
# File 'lib/yadriggy/c/ctype.rb', line 59

def type()
  Undef
end

#typedecl(arg) ⇒ Object



41
# File 'lib/yadriggy/c/ctype.rb', line 41

def typedecl(arg) end