### Home Classes Methods

### In Files

- ext/ffi_c/ffi.c

### Parent

FFI::Type

### Methods

- ::new
- #from_native
- #native_type
- #to_native
- #type

### Files

- Makefile
- ChangeLog
- LICENSE
- README
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::AbstractMemory
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::DataConverter
- FFI::DynamicLibrary
- FFI::DynamicLibrary::Symbol
- FFI::Enum
- FFI::Enums
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::LastError
- FFI::Library
- FFI::ManagedStruct
- FFI::MemoryPointer
- FFI::NativeType
- FFI::NotFoundError
- FFI::NullPointerError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::InlineArray
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Enum
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayoutBuilder
- FFI::Type
- FFI::Type::Builtin
- FFI::Type::Mapped
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# 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.