Class: FFI::ArrayType
- Inherits:
-
Type
- Object
- Type
- FFI::ArrayType
show all
- Defined in:
- ext/ffi_c/ArrayType.c
Constant Summary
Constants inherited
from Type
Type::Array, Type::Function, Type::Struct
Instance Method Summary
collapse
Constructor Details
#initialize(rbComponentType, rbLength) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'ext/ffi_c/ArrayType.c', line 73
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
#elem_type ⇒ Object
107
108
109
110
111
112
113
114
115
|
# File 'ext/ffi_c/ArrayType.c', line 107
static VALUE
array_type_element_type(VALUE self)
{
ArrayType* array;
Data_Get_Struct(self, ArrayType, array);
return array->rbComponentType;
}
|
#length ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'ext/ffi_c/ArrayType.c', line 97
static VALUE
array_type_length(VALUE self)
{
ArrayType* array;
Data_Get_Struct(self, ArrayType, array);
return UINT2NUM(array->length);
}
|