Class: FFI::ArrayType
- Inherits:
-
Type
- Object
- Type
- 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
Constant Summary
Constants inherited from Type
Type::Array, Type::Function, Type::Struct
Instance Method Summary (collapse)
-
- (Type) element_type
Get element type.
-
- (self) initialize(component_type, length)
constructor
A new instance of ArrayType.
-
- (Numeric) length
Get array's length.
Methods inherited from Type
Constructor Details
- (self) initialize(component_type, length)
A new instance of ArrayType.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'ext/ffi_c/ArrayType.c', line 72
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
- (Type) element_type
Get element type.
116 117 118 119 120 121 122 123 124 |
# File 'ext/ffi_c/ArrayType.c', line 116
static VALUE
array_type_element_type(VALUE self)
{
ArrayType* array;
Data_Get_Struct(self, ArrayType, array);
return array->rbComponentType;
}
|
- (Numeric) length
Get array's length
101 102 103 104 105 106 107 108 109 |
# File 'ext/ffi_c/ArrayType.c', line 101
static VALUE
array_type_length(VALUE self)
{
ArrayType* array;
Data_Get_Struct(self, ArrayType, array);
return UINT2NUM(array->length);
}
|