Sha256: 582b774f136baf2de3498e6ba1224bcce1f466a8803730e3f910d015448ee2dd

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

#include <sys/types.h>
#include <stdio.h>
#include <dlfcn.h>
#include <ruby.h>

#include <ffi.h>

#include "rbffi.h"
#include "AbstractMemory.h"
#include "MemoryPointer.h"
#include "Platform.h"
#include "Types.h"


void Init_ffi();

static VALUE moduleFFI = Qnil;
static VALUE moduleNativeType = Qnil;

void
Init_ffi_c() {
    moduleFFI = rb_define_module("FFI");
    moduleNativeType = rb_define_module_under(moduleFFI, "NativeType");
    
    rb_define_const(moduleNativeType, "VOID", INT2FIX(VOID));
    rb_define_const(moduleNativeType, "INT8", INT2FIX(INT8));
    rb_define_const(moduleNativeType, "UINT8", INT2FIX(UINT8));
    rb_define_const(moduleNativeType, "INT16", INT2FIX(INT16));
    rb_define_const(moduleNativeType, "UINT16", INT2FIX(UINT16));
    rb_define_const(moduleNativeType, "INT32", INT2FIX(INT32));
    rb_define_const(moduleNativeType, "UINT32", INT2FIX(UINT32));
    rb_define_const(moduleNativeType, "INT64", INT2FIX(INT64));
    rb_define_const(moduleNativeType, "UINT64", INT2FIX(UINT64));
    rb_define_const(moduleNativeType, "FLOAT32", INT2FIX(FLOAT32));
    rb_define_const(moduleNativeType, "FLOAT64", INT2FIX(FLOAT64));
    rb_define_const(moduleNativeType, "POINTER", INT2FIX(POINTER));
    rb_define_const(moduleNativeType, "STRING", INT2FIX(STRING));
    rb_define_const(moduleNativeType, "RBXSTRING", INT2FIX(RBXSTRING));
    rb_define_const(moduleNativeType, "CHAR_ARRAY", INT2FIX(CHAR_ARRAY));
    if (sizeof(long) == 4) {
        rb_define_const(moduleNativeType, "LONG", INT2FIX(INT32));
        rb_define_const(moduleNativeType, "ULONG", INT2FIX(UINT32));
    } else {
        rb_define_const(moduleNativeType, "LONG", INT2FIX(INT64));
        rb_define_const(moduleNativeType, "ULONG", INT2FIX(UINT64));
    }
    rb_FFI_Platform_Init();
    rb_FFI_AbstractMemory_Init();
    rb_FFI_MemoryPointer_Init();
    rb_FFI_Buffer_Init();
    rb_FFI_Callback_Init();
    rb_FFI_Invoker_Init();    
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-0.1.1 ext/ffi.c
ffi-0.1.0 ext/ffi.c