Object
This class includes {FFI::DataConverter} module.
static VALUE
sbr_initialize(VALUE self, VALUE rbStructClass)
{
StructByReference* sbr = NULL;
if (!rb_class_inherited_p(rbStructClass, rbffi_StructClass)) {
rb_raise(rb_eTypeError, "wrong type (expected subclass of FFI::Struct)");
}
Data_Get_Struct(self, StructByReference, sbr);
sbr->rbStructClass = rbStructClass;
return self;
}
static VALUE
sbr_from_native(VALUE self, VALUE value, VALUE ctx)
{
StructByReference* sbr;
Data_Get_Struct(self, StructByReference, sbr);
return rb_class_new_instance(1, &value, sbr->rbStructClass);
}
static VALUE
sbr_native_type(VALUE self)
{
return rb_const_get(rbffi_TypeClass, rb_intern("POINTER"));
}
static VALUE
sbr_struct_class(VALUE self)
{
StructByReference* sbr;
Data_Get_Struct(self, StructByReference, sbr);
return sbr->rbStructClass;
}
static VALUE
sbr_to_native(VALUE self, VALUE value, VALUE ctx)
{
StructByReference* sbr;
Struct* s;
if (unlikely(value == Qnil)) {
return rbffi_NullPointerSingleton;
}
Data_Get_Struct(self, StructByReference, sbr);
if (!rb_obj_is_kind_of(value, sbr->rbStructClass)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
rb_obj_classname(value),
RSTRING_PTR(rb_class_name(sbr->rbStructClass)));
}
Data_Get_Struct(value, Struct, s);
return s->rbPointer;
}
Generated with the Darkfish Rdoc Generator 2.