{"name":"node-ffi","version":"0.5.7","author":{"name":"Rick Branson"},"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net","url":"http://tootallnate.net"}],"description":"A foreign function interface (FFI) for Node.js","homepage":"http://github.com/rbranson/node-ffi","engines":{"node":">=0.6.0"},"main":"./lib/ffi","dependencies":{"bindings":"*"},"devDependencies":{"expect.js":"*","mocha":">= 0.10.x"},"scripts":{"test":"mocha -gc --reporter spec","install":"node-gyp rebuild"},"repository":{"type":"git","url":"http://github.com/rbranson/node-ffi.git"},"bugs":{"url":"http://github.com/rbranson/node-ffi/issues"},"gypfile":true,"_id":"node-ffi@0.5.7","dist":{"shasum":"c80f7c4bc7912f4f4c601a7a340c3c09b6834ece","tarball":"http://registry-npm.ywwl.com/node-ffi/download/node-ffi-0.5.7.tgz","integrity":"sha512-UapnsnhaFyBA9AsGWbNhmQQDhauV2YTOysTfivJJmYK14jeygqO/V8gWg3bpVrenQ9tLxqrBCJ6hHWIIxCteEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDtmz4apnUiKJf9BSEOryYlniHVfmYAc6zgpZWBJU273AiBlwGVCjr8uch37ZZtgWfUHEczQd4L/v+rqvbu00GEFag=="}],"size":1467221,"noattachment":false,"key":"/node-ffi/-/node-ffi-0.5.7.tgz"},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"maintainers":[{"name":"rbranson","email":"rick@diodeware.com"},{"name":"TooTallNate","email":"nathan@tootallnate.net"},{"name":"tootallnate","email":"nathan@tootallnate.net"}],"deprecated":"Use the 'ffi' package instead. See https://github.com/rbranson/node-ffi/wiki/API-changes-from-v0.x-to-v1.x","directories":{},"readme":"node-ffi\n========\n### Node.js Foreign Function Interface [![Build Status](https://secure.travis-ci.org/rbranson/node-ffi.png)](http://travis-ci.org/rbranson/node-ffi)\n\n`node-ffi` is a Node.js addon for loading and calling dynamic libraries using pure JavaScript. It can be used to create bindings to native libraries without writing any C++ code.\n\nIt also simplifies the augmentation of node.js with C code as it takes care of handling the translation of types across JavaScript and C, which can add reams of boilerplate code to your otherwise simple C. See the `example/factorial` for an example of this use case.\n\n**WARNING**: node-ffi assumes you know what you're doing. You can pretty easily create situations where you will segfault the interpreter and unless you've got C debugger skills, you probably won't know what's going on.\n\n# EXAMPLE\n\n``` js\nvar ffi = require(\"node-ffi\");\n\nvar libm = new ffi.Library(\"libm\", { \"ceil\": [ \"double\", [ \"double\" ] ] });\nlibm.ceil(1.5); // 2\n\n// You can also access just functions in the current process by passing a null\nvar current = new ffi.Library(null, { \"atoi\": [ \"int32\", [ \"string\" ] ] });\ncurrent.atoi(\"1234\"); // 1234\n```\n\n# REQUIREMENTS\n\n * Linux, OS X, Windows, or Solaris.\n * `libffi` comes bundled with node-ffi, it does not need to be installed on your system.\n * The current version is tested to run on node 0.6.x.\n * If you need node 0.4.x support, use the `0.4` branch of node-ffi.\n\n# NPM INSTALL\n\n``` bash\n$ npm install node-ffi\n```\n\nMost popular operating systems have a pre-compiled binary that comes along with node-ffi, so most of the time you will not need to compile anything! (Unless of course you want to, then see below).\n\n# SOURCE INSTALL / MANUAL COMPILATION\n\nTo compile from source it's easiest to use\n[`node-gyp`](https://github.com/TooTallNate/node-gyp):\n\n``` bash\n$ npm install -g node-gyp\n```\n\nNow you can compile `node-ffi`:\n\n``` bash\n$ git clone git://github.com/rbranson/node-ffi.git\n$ cd node-ffi\n$ node-gyp configure build\n```\n\n# TYPES\n\n    int8        Signed 8-bit Integer\n    uint8       Unsigned 8-bit Integer\n    int16       Signed 16-bit Integer\n    uint16      Unsigned 16-bit Integer\n    int32       Signed 32-bit Integer\n    uint32      Unsigned 32-bit Integer\n    int64       Signed 64-bit Integer\n    uint64      Unsigned 64-bit Integer\n    float       Single Precision Floating Point Number (float)\n    double      Double Precision Floating Point Number (double)\n    pointer     Pointer Type\n    string      Null-Terminated String (char *)\n\nIn addition to the basic types, there are type aliases for common C types.\n\n    byte        unsigned char\n    char        char\n    uchar       unsigned char\n    short       short\n    ushort      unsigned short\n    int         int\n    uint        unsigned int\n    long        long\n    ulong       unsigned long\n    longlong    long\n    ulonglong   unsigned long long\n    size_t      platform-dependent, usually pointer size\n\n# V8 and 64-bit Types\n\nInternally, V8 stores integers that will fit into a 32-bit space in a 32-bit integer, and those that fall outside of this get put into double-precision floating point numbers. This is problematic because FP numbers are imprecise. To get around this, the methods in node-ffi that deal with 64-bit integers return strings and can accept strings as parameters.\n\n# Call Overhead\n\nThere is non-trivial overhead associated with FFI calls. Comparing a hard-coded binding version of `strtoul()` to an FFI version of `strtoul()` shows that the native hard-coded binding is 5x faster. So don't just use the C version of a function just because it's faster. There's a significant cost in FFI calls, so make them worth it.\n\n# LICENSE\n\nMIT License. See the `LICENSE` file.\n\n","publish_time":1364766881172,"_cnpm_publish_time":1364766881172,"dist-tags":{"latest":"0.5.7"}}