123456789_123456789_123456789_123456789_123456789_

Class: FFI::StructByValue

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/StructByValue.c

Constant Summary

Type - Inherited

Struct

Class Method Summary

Type - Inherited

Instance Method Summary

Constructor Details

.new(rbStructClass)

[ GitHub ]

  
# File 'ext/ffi_c/StructByValue.c', line 92

static VALUE
sbv_initialize(VALUE self, VALUE rbStructClass)
{
    StructByValue* sbv = NULL;
    StructLayout* layout = NULL;
    VALUE rbLayout = Qnil;

    rbLayout = rb_ivar_get(rbStructClass, rb_intern("@layout"));
    if (!rb_obj_is_instance_of(rbLayout, rbffi_StructLayoutClass)) {
        rb_raise(rb_eTypeError, "wrong type in @layout ivar (expected FFI::StructLayout)");
    }

    TypedData_Get_Struct(rbLayout, StructLayout, &rbffi_struct_layout_data_type, layout);
    TypedData_Get_Struct(self, StructByValue, &sbv_type_data_type, sbv);
    RB_OBJ_WRITE(self, &sbv->rbStructClass, rbStructClass);
    RB_OBJ_WRITE(self, &sbv->rbStructLayout, rbLayout);

    /* We can just use everything from the ffi_type directly */
    *sbv->base.ffiType = *layout->base.ffiType;

    return self;
}

Instance Method Details

#layout

[ GitHub ]

  
# File 'ext/ffi_c/StructByValue.c', line 146

static VALUE
sbv_layout(VALUE self)
{
    StructByValue* sbv;

    TypedData_Get_Struct(self, StructByValue, &sbv_type_data_type, sbv);
    return sbv->rbStructLayout;
}

#struct_class

[ GitHub ]

  
# File 'ext/ffi_c/StructByValue.c', line 155

static VALUE
sbv_struct_class(VALUE self)
{
    StructByValue* sbv;

    TypedData_Get_Struct(self, StructByValue, &sbv_type_data_type, sbv);

    return sbv->rbStructClass;
}