Class: FFI::StructLayout::Array

Inherits:
Field
  • Object
show all
Defined in:
ext/ffi_c/StructLayout.c

Instance Method Summary collapse

Methods inherited from Field

#alignment, #ffi_type, #initialize, #name, #offset, #put, #size

Constructor Details

This class inherits a constructor from FFI::StructLayout::Field

Instance Method Details

#get(pointer) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'ext/ffi_c/StructLayout.c', line 233

static VALUE
array_field_get(VALUE self, VALUE pointer)
{
    StructField* f;
    ArrayType* array;
    MemoryOp* op;
    AbstractMemory* memory = MEMORY(pointer);
    VALUE argv[2];

    Data_Get_Struct(self, StructField, f);
    Data_Get_Struct(f->rbType, ArrayType, array);

    op = memory_get_op(memory, array->componentType);
    if (op == NULL) {
        rb_raise(rb_eArgError, "get not supported for %s", rb_obj_classname(array->rbComponentType));
        return Qnil;
    }

    argv[0] = pointer;
    argv[1] = self;

    return rb_class_new_instance(2, argv, rbffi_StructInlineArrayClass);
}