Skip to content

Commit

Permalink
ffi, dynamic_library: export the dlfcn.h flags from the C layer
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Oct 4, 2012
1 parent 76eb118 commit 5566191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lib/dynamic_library.js
Expand Up @@ -6,7 +6,8 @@
var ForeignFunction = require('./foreign_function')
, assert = require('assert')
, debug = require('debug')('ffi:DynamicLibrary')
, funcs = require('./bindings').StaticFunctions
, bindings = require('./bindings')
, funcs = bindings.StaticFunctions
, ref = require('ref')
, read = require('fs').readFileSync

Expand Down Expand Up @@ -76,15 +77,15 @@ function DynamicLibrary (path, mode) {
module.exports = DynamicLibrary

/**
* See "dlfcn.h"
* Set the exported flags from "dlfcn.h"
*/

DynamicLibrary.FLAGS = {
'RTLD_LAZY': 0x1
, 'RTLD_NOW': 0x2
, 'RTLD_LOCAL': 0x4
, 'RTLD_GLOBAL': 0x8
}
DynamicLibrary.FLAGS = {};
Object.keys(bindings).forEach(function (k) {
if (!/^RTLD_/.test(k)) return;
DynamicLibrary.FLAGS[k] = bindings[k];
});


/**
* Close this library, returns the result of the dlclose() system function.
Expand Down
4 changes: 3 additions & 1 deletion lib/ffi.js
Expand Up @@ -17,7 +17,9 @@ var bindings = require('./bindings')
, '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'
, 'FFI_MS_CDECL'].forEach(function (prop) {
, '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)
}
Expand Down

0 comments on commit 5566191

Please sign in to comment.