Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
/** * Module dependencies. */
var ref = require('ref')var assert = require('assert')var debug = require('debug')('ffi:ffi')var Struct = require('ref-struct')var bindings = require('./bindings')
/** * Export some of the properties from the "bindings" file. */
;['HAS_OBJC', 'FFI_TYPES',, 'FFI_OK', 'FFI_BAD_TYPEDEF', 'FFI_BAD_ABI', 'FFI_DEFAULT_ABI', 'FFI_FIRST_ABI', 'FFI_LAST_ABI', 'FFI_SYSV', 'FFI_UNIX64', 'FFI_WIN64', 'FFI_VFP', 'FFI_STDCALL', 'FFI_THISCALL', 'FFI_FASTCALL', 'RTLD_LAZY', 'RTLD_NOW', 'RTLD_LOCAL', 'RTLD_GLOBAL', 'RTLD_NOLOAD', 'RTLD_NODELETE', 'RTLD_FIRST', 'RTLD_NEXT', 'RTLD_DEFAULT', 'RTLD_SELF', 'RTLD_MAIN_ONLY', 'FFI_MS_CDECL'].forEach(function (prop) { if (!bindings.hasOwnProperty(prop)) { return debug('skipping exporting of non-existant property', prop) } var desc = Object.getOwnPropertyDescriptor(bindings, prop) Object.defineProperty(exports, prop, desc)})
/** * Set the `ffi_type` property on the built-in types. */
Object.keys(bindings.FFI_TYPES).forEach(function (name) { var type = bindings.FFI_TYPES[name] type.name = name if (name === 'pointer') return // there is no "pointer" type... ref.types[name].ffi_type = type})
// make `size_t` use the "ffi_type_pointer"ref.types.size_t.ffi_type = bindings.FFI_TYPES.pointer
// make `Utf8String` use "ffi_type_pointer"var CString = ref.types.CString || ref.types.Utf8StringCString.ffi_type = bindings.FFI_TYPES.pointer
// make `Object` use the "ffi_type_pointer"ref.types.Object.ffi_type = bindings.FFI_TYPES.pointer
// libffi is weird when it comes to long data types (defaults to 64-bit),// so we emulate here, since some platforms have 32-bit longs and some// platforms have 64-bit longs.switch (ref.sizeof.long) { case 4: ref.types.ulong.ffi_type = bindings.FFI_TYPES.uint32 ref.types.long.ffi_type = bindings.FFI_TYPES.int32 break; case 8: ref.types.ulong.ffi_type = bindings.FFI_TYPES.uint64 ref.types.long.ffi_type = bindings.FFI_TYPES.int64 break; default: throw new Error('unsupported "long" size: ' + ref.sizeof.long)}
/** * Alias the "ref" types onto ffi's exports, for convenience... */
exports.types = ref.types
// Include our other modulesexports.version = bindings.versionexports.CIF = require('./cif')exports.CIF_var = require('./cif_var')exports.Function = require('./function')exports.ForeignFunction = require('./foreign_function')exports.VariadicForeignFunction = require('./foreign_function_var')exports.DynamicLibrary = require('./dynamic_library')exports.Library = require('./library')exports.Callback = require('./callback')exports.errno = require('./errno')exports.ffiType = require('./type')
// the shared library extension for this platformexports.LIB_EXT = exports.Library.EXT
// the FFI_TYPE struct definitionexports.FFI_TYPE = exports.ffiType.FFI_TYPE