### Home Classes Methods

### In Files

- ext/ffi_c/ffi.c

### Parent

FFI::StructLayout::Field

### Methods

- #get
- #put

### 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::ArrayType
- 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::Function
- FFI::FunctionType
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- 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::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Array
- FFI::StructLayout::CharArray
- FFI::StructLayout::Enum
- FFI::StructLayout::Field
- FFI::StructLayout::Function
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayout::Number
- FFI::StructLayout::Pointer
- FFI::StructLayout::String
- FFI::StructLayoutBuilder
- FFI::Type
- FFI::Type::Builtin
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::StructLayout::Function

A function pointer {Field} in a {StructLayout}.

### Public Instance Methods

get(pointer) click to toggle source
@param [AbstractMemory] pointer pointer on a {Struct}
@return [Function]
Get a {Function} from memory pointed by +pointer+.

    static VALUE
    function_field_get(VALUE self, VALUE pointer)
    {
        StructField* f;

        Data_Get_Struct(self, StructField, f);

        return rbffi_Function_NewInstance(f->rbType, (*rbffi_AbstractMemoryOps.pointer->get)(MEMORY(pointer), f->offset));
    }

put(pointer, proc) click to toggle source
@param [AbstractMemory] pointer pointer to a {Struct}
@param [Function, Proc] proc
@return [Function]
Set a {Function} to memory pointed by +pointer+ as a function.

If a Proc is submitted as `proc`, it is automatically transformed to a {Function}.

    static VALUE
    function_field_put(VALUE self, VALUE pointer, VALUE proc)
    {
        StructField* f;
        VALUE value = Qnil;

        Data_Get_Struct(self, StructField, f);

        if (NIL_P(proc) || rb_obj_is_kind_of(proc, rbffi_FunctionClass)) {
            value = proc;
        } else if (rb_obj_is_kind_of(proc, rb_cProc) || rb_respond_to(proc, rb_intern("call"))) {
            value = rbffi_Function_ForProc(f->rbType, proc);
        } else {
            rb_raise(rb_eTypeError, "wrong type (expected Proc or Function)");
        }

        (*rbffi_AbstractMemoryOps.pointer->put)(MEMORY(pointer), f->offset, value);

        return self;
    }

[Validate]

Generated with the Darkfish Rdoc Generator 2.