Class: FFI::StructByValue

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

Constant Summary

Constants inherited from Type

Type::Array, Type::Function, Type::Struct

Instance Method Summary collapse

Constructor Details

#initialize(rbStructClass) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'ext/ffi_c/StructByValue.c', line 72

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

    rbLayout = rb_cvar_get(rbStructClass, rb_intern("@layout"));
    if (!rb_obj_is_instance_of(rbLayout, rbffi_StructLayoutClass)) {
        rb_raise(rb_eTypeError, "wrong type in @layout cvar (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



110
111
112
113
114
115
116
117
# File 'ext/ffi_c/StructByValue.c', line 110

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

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

#struct_classObject



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

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

    Data_Get_Struct(self, StructByValue, sbv);

    return sbv->rbStructClass;
}