Class: FFI::ArrayType
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Type
|
|
Instance Chain:
self,
Type
|
|
Inherits: | FFI::Type |
Defined in: | ext/ffi_c/ArrayType.c |
Overview
This is a typed array. The type is a native type.
Constant Summary
Class Method Summary
Instance Method Summary
Constructor Details
.new(component_type, length)
.new(instance)
# File 'ext/ffi_c/ArrayType.c', line 117
static VALUE array_type_initialize(VALUE self, VALUE rbComponentType, VALUE rbLength) { ArrayType* array; int i; TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array); array->length = NUM2UINT(rbLength); RB_OBJ_WRITE(self, &array->rbComponentType, rbComponentType); TypedData_Get_Struct(rbComponentType, Type, &rbffi_type_data_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
#element(type)
# File 'ext/ffi_c/ArrayType.c', line 161
static VALUE array_type_element_type(VALUE self) { ArrayType* array; TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array); return array->rbComponentType; }
#length
Get(array's length)
# File 'ext/ffi_c/ArrayType.c', line 146
static VALUE array_type_length(VALUE self) { ArrayType* array; TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array); return UINT2NUM(array->length); }