In Files

Parent

FFI::Type::Mapped

Public Class Methods

initialize(converter) click to toggle source
@param [#native_type, #to_native, #from_native] converter +converter+ must respond to
all these methods
@return [self]
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");
    }
    
    Data_Get_Struct(self, MappedType, m);
    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");
    }

    m->rbConverter = rbConverter;
    Data_Get_Struct(m->rbType, Type, m->type);
    m->base.ffiType = m->type->ffiType;
    
    return self;
}

Public Instance Methods

from_native(*args) click to toggle source
@param args depends on {FFI::DataConverter} used to initialize +self+
static VALUE
mapped_from_native(int argc, VALUE* argv, VALUE self)
{
    MappedType*m = NULL;
    
    Data_Get_Struct(self, MappedType, m);

    return rb_funcall2(m->rbConverter, id_from_native, argc, argv);
}
native_type click to toggle source
@return [Type]
Get native type of mapped type.
static VALUE
mapped_native_type(VALUE self)
{
    MappedType*m = NULL;
    Data_Get_Struct(self, MappedType, m);

    return m->rbType;
}
to_native(*args) click to toggle source
@param args depends on {FFI::DataConverter} used to initialize +self+
static VALUE
mapped_to_native(int argc, VALUE* argv, VALUE self)
{
    MappedType*m = NULL;
    
    Data_Get_Struct(self, MappedType, m);
    
    return rb_funcall2(m->rbConverter, id_to_native, argc, argv);
}
native_type click to toggle source
@return [Type]
Get native type of mapped type.
static VALUE
mapped_native_type(VALUE self)
{
    MappedType*m = NULL;
    Data_Get_Struct(self, MappedType, m);

    return m->rbType;
}

[Validate]

Generated with the Darkfish Rdoc Generator 2.