123456789_123456789_123456789_123456789_123456789_

Class: FFI::Type::Mapped

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::FFI::Type
Instance Chain:
self, ::FFI::Type
Inherits: FFI::Type
Defined in: ext/ffi_c/MappedType.c

Constant Summary

::FFI::Type - Inherited

Struct

Class Method Summary

::FFI::Type - Inherited

Instance Method Summary

Constructor Details

.new(converter) .these(methods)

[ GitHub ]

  
# File 'ext/ffi_c/MappedType.c', line 86

static VALUE
mapped_initialize(VALUE self, VALUE rbConverter)
{
    MappedType* m = NULL;

    if (!rb_respond_to(rbConverter, id_native_type)) {
        rb_raise(rb_eNoMethodError, "native_type method not implemented");
    }

    if (!rb_respond_to(rbConverter, id_to_native)) {
        rb_raise(rb_eNoMethodError, "to_native method not implemented");
    }

    if (!rb_respond_to(rbConverter, id_from_native)) {
        rb_raise(rb_eNoMethodError, "from_native method not implemented");
    }

    TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);
    RB_OBJ_WRITE(self, &m->rbType, rb_funcall2(rbConverter, id_native_type, 0, NULL));
    if (!(rb_obj_is_kind_of(m->rbType, rbffi_TypeClass))) {
        rb_raise(rb_eTypeError, "native_type did not return instance of FFI::Type");
    }

    RB_OBJ_WRITE(self, &m->rbConverter, rbConverter);
    TypedData_Get_Struct(m->rbType, Type, &rbffi_type_data_type, m->type);
    m->base.ffiType = m->type->ffiType;

    rb_obj_freeze(self);

    return self;
}

Instance Method Details

#converter

[ GitHub ]

  
# File 'ext/ffi_c/MappedType.c', line 180

static VALUE
mapped_converter(VALUE self)
{
    MappedType*m = NULL;
    TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);

    return m->rbConverter;
}

#from_native(*args)

[ GitHub ]

  
# File 'ext/ffi_c/MappedType.c', line 171

static VALUE
mapped_from_native(int argc, VALUE* argv, VALUE self)
{
    MappedType*m = NULL;
    TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);

    return rb_funcall2(m->rbConverter, id_from_native, argc, argv);
}

#native_type #native(type)

Alias for #type.

#to_native(*args) ⇒ ?

[ GitHub ]

  
# File 'ext/ffi_c/MappedType.c', line 158

static VALUE
mapped_to_native(int argc, VALUE* argv, VALUE self)
{
    MappedType*m = NULL;
    TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);

    return rb_funcall2(m->rbConverter, id_to_native, argc, argv);
}

#native_type #native(type)
Also known as: #native_type

[ GitHub ]

  
# File 'ext/ffi_c/MappedType.c', line 145

static VALUE
mapped_native_type(VALUE self)
{
    MappedType*m = NULL;
    TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);

    return m->rbType;
}