Class: FFI::ArrayType
- Defined in:
- ext/ffi_c/ArrayType.c,
ext/ffi_c/ArrayType.c
Overview
This is a typed array. The type is a native type.
Constant Summary
Constants inherited from Type
Instance Method Summary collapse
-
#element_type ⇒ Type
Get element type.
-
#initialize(component_type, length) ⇒ self
constructor
A new instance of ArrayType.
-
#length ⇒ Numeric
Get array’s length.
Methods inherited from Type
Constructor Details
#initialize(component_type, length) ⇒ self
A new instance of ArrayType.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'ext/ffi_c/ArrayType.c', line 81 static VALUE array_type_initialize(VALUE self, VALUE rbComponentType, VALUE rbLength) { ArrayType* array; int i; Data_Get_Struct(self, ArrayType, array); array->length = NUM2UINT(rbLength); array->rbComponentType = rbComponentType; Data_Get_Struct(rbComponentType, Type, array->componentType); array->ffiTypes = xcalloc(array->length + 1, sizeof(*array->ffiTypes)); array->base.ffiType->elements = array->ffiTypes; array->base.ffiType->size = array->componentType->ffiType->size * array->length; array->base.ffiType->alignment = array->componentType->ffiType->alignment; for (i = 0; i < array->length; ++i) { array->ffiTypes[i] = array->componentType->ffiType; } return self; } |
Instance Method Details
#element_type ⇒ Type
Get element type.
125 126 127 128 129 130 131 132 133 |
# File 'ext/ffi_c/ArrayType.c', line 125 static VALUE array_type_element_type(VALUE self) { ArrayType* array; Data_Get_Struct(self, ArrayType, array); return array->rbComponentType; } |
#length ⇒ Numeric
Get array’s length
110 111 112 113 114 115 116 117 118 |
# File 'ext/ffi_c/ArrayType.c', line 110 static VALUE array_type_length(VALUE self) { ArrayType* array; Data_Get_Struct(self, ArrayType, array); return UINT2NUM(array->length); } |