### Home Classes Methods

### In Files

- ext/ffi_c/ffi.c

### Parent

Object

### Namespace

- CLASS FFI::Type::Builtin

### Methods

- ::new
- #alignment
- #inspect
- #size

### 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::Function
- FFI::FunctionType
- 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::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::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::Type

This class manages C types.

It embbed {FFI::Type::Builtin} objects as constants (for names, see {FFI::NativeType}).

### Public Class Methods

initialize(value) click to toggle source
@param [Fixnum,Type] value
@return [self]

    static VALUE
    type_initialize(VALUE self, VALUE value)
    {
        Type* type;
        Type* other;

        Data_Get_Struct(self, Type, type);

        if (FIXNUM_P(value)) {
            type->nativeType = FIX2INT(value);
        } else if (rb_obj_is_kind_of(value, rbffi_TypeClass)) {
            Data_Get_Struct(value, Type, other);
            type->nativeType = other->nativeType;
            type->ffiType = other->ffiType;
        } else {
            rb_raise(rb_eArgError, "wrong type");
        }

        return self;
    }

### Public Instance Methods

alignment click to toggle source
@return [Fixnum]
Get Type alignment.

    static VALUE
    type_alignment(VALUE self)
    {
        Type *type;

        Data_Get_Struct(self, Type, type);

        return INT2FIX(type->ffiType->alignment);
    }

inspect click to toggle source
@return [String]
Inspect {Type} object.

    static VALUE
    type_inspect(VALUE self)
    {
        char buf[100];
        Type *type;

        Data_Get_Struct(self, Type, type);

        snprintf(buf, sizeof(buf), "#<%s:%p size=%d alignment=%d>",
                rb_obj_classname(self), type, (int) type->ffiType->size, (int) type->ffiType->alignment);

        return rb_str_new2(buf);
    }

size click to toggle source
@return [Fixnum]
Return type's size, in bytes.

    static VALUE
    type_size(VALUE self)
    {
        Type *type;

        Data_Get_Struct(self, Type, type);

        return INT2FIX(type->ffiType->size);
    }

[Validate]

Generated with the Darkfish Rdoc Generator 2.