Class: Yadriggy::C::CType::CArray
- 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
Constant Summary
Constants included from Yadriggy::C::CType
Float32Array, Float32Type, FloatArray, Int, IntArray, Void
Instance Attribute Summary collapse
-
#debug ⇒ Object
debug mode.
-
#sizes ⇒ Array<Integer>
readonly
Sizes array size.
Instance Method Summary collapse
- #check_range(indexes) ⇒ Object
-
#initialize(*sizes) ⇒ CArray
constructor
A new instance of CArray.
-
#type ⇒ Type
abstract
The element type.
- #typedecl(arg) ⇒ Object
Methods included from Yadriggy::C::CType
Constructor Details
#initialize(*sizes) ⇒ CArray
Returns a new instance of CArray.
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
#debug ⇒ Object
debug mode.
44 45 46 |
# File 'lib/yadriggy/c/ctype.rb', line 44 def debug @debug end |
#sizes ⇒ Array<Integer> (readonly)
Returns 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 |
#type ⇒ Type
This method is abstract.
Returns 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 |