Class: FFI::StructByValue

Inherits:
Type
  • Object
show all
Defined in:
ext/ffi_c/StructByValue.c

Constant Summary

Constants inherited from Type

Type::Struct

Instance Method Summary collapse

Methods inherited from Type

#alignment, #inspect, #size

Constructor Details

#initialize(rbStructClass) ⇒ Object


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'ext/ffi_c/StructByValue.c', line 81

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)");
    }

    Data_Get_Struct(rbLayout, StructLayout, layout);
    Data_Get_Struct(self, StructByValue, sbv);
    sbv->rbStructClass = rbStructClass;
    sbv->rbStructLayout = rbLayout;

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

Instance Method Details

#layoutObject


119
120
121
122
123
124
125
126
# File 'ext/ffi_c/StructByValue.c', line 119

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

    Data_Get_Struct(self, StructByValue, sbv);
    return sbv->rbStructLayout;
}

#struct_classObject


128
129
130
131
132
133
134
135
136
# File 'ext/ffi_c/StructByValue.c', line 128

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

    Data_Get_Struct(self, StructByValue, sbv);

    return sbv->rbStructClass;
}