Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 50 lines (43 sloc) 2.113 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/* A simple C++ wrapper around libffi. */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dlfcn.h>

#include "vm.hpp"
#include "objectmemory.hpp"

#include "builtin/array.hpp"
#include "builtin/class.hpp"
#include "builtin/fixnum.hpp"
#include "builtin/float.hpp"
#include "builtin/memorypointer.hpp"
#include "builtin/nativefunction.hpp"
#include "builtin/string.hpp"
#include "builtin/symbol.hpp"

#include "ffi_util.hpp"
#include "arguments.hpp"

namespace rubinius {

  void VM::init_ffi() {
    Module* mod = new_module("FFI");
    mod->set_const(this, "TYPE_OBJECT", Fixnum::from(RBX_FFI_TYPE_OBJECT));
    mod->set_const(this, "TYPE_CHAR", Fixnum::from(RBX_FFI_TYPE_CHAR));
    mod->set_const(this, "TYPE_UCHAR", Fixnum::from(RBX_FFI_TYPE_UCHAR));
    mod->set_const(this, "TYPE_SHORT", Fixnum::from(RBX_FFI_TYPE_SHORT));
    mod->set_const(this, "TYPE_USHORT", Fixnum::from(RBX_FFI_TYPE_USHORT));
    mod->set_const(this, "TYPE_INT", Fixnum::from(RBX_FFI_TYPE_INT));
    mod->set_const(this, "TYPE_UINT", Fixnum::from(RBX_FFI_TYPE_UINT));
    mod->set_const(this, "TYPE_LONG", Fixnum::from(RBX_FFI_TYPE_LONG));
    mod->set_const(this, "TYPE_ULONG", Fixnum::from(RBX_FFI_TYPE_ULONG));
    mod->set_const(this, "TYPE_LL", Fixnum::from(RBX_FFI_TYPE_LONG_LONG));
    mod->set_const(this, "TYPE_ULL", Fixnum::from(RBX_FFI_TYPE_ULONG_LONG));
    mod->set_const(this, "TYPE_FLOAT", Fixnum::from(RBX_FFI_TYPE_FLOAT));
    mod->set_const(this, "TYPE_DOUBLE", Fixnum::from(RBX_FFI_TYPE_DOUBLE));
    mod->set_const(this, "TYPE_PTR", Fixnum::from(RBX_FFI_TYPE_PTR));
    mod->set_const(this, "TYPE_VOID", Fixnum::from(RBX_FFI_TYPE_VOID));
    mod->set_const(this, "TYPE_STRING", Fixnum::from(RBX_FFI_TYPE_STRING));
    mod->set_const(this, "TYPE_STATE", Fixnum::from(RBX_FFI_TYPE_STATE));
    mod->set_const(this, "TYPE_STRPTR", Fixnum::from(RBX_FFI_TYPE_STRPTR));
    mod->set_const(this, "TYPE_CHARARR", Fixnum::from(RBX_FFI_TYPE_CHARARR));
  }
};
Something went wrong with that request. Please try again.