Permalink
Browse files

removed duplicate LIB_EXT definition

  • Loading branch information...
1 parent 21094ff commit acd10dd92a3de0e3ed92379a20d652eef744be98 @justinfreitag justinfreitag committed Jun 27, 2012
Showing with 29 additions and 40 deletions.
  1. +13 −34 lib/ffi.js
  2. +16 −6 lib/library.js
View
@@ -1,30 +1,8 @@
-
var ref = require('ref')
var assert = require('assert')
var debug = require('debug')('ffi:ffi')
var Struct = require('ref-struct')
var bindings = require('./bindings')
-var ffi = exports
-
-/**
- * The extension to use on libraries.
- * i.e. libm -> libm.so on linux
- */
-
-Object.defineProperty(ffi, 'LIB_EXT', {
- configurable: true
- , enumerable: true
- , writable: false
- , value: {
- 'linux': '.so'
- , 'linux2': '.so'
- , 'sunos': '.so'
- , 'solaris':'.so'
- , 'darwin': '.dylib'
- , 'mac': '.dylib'
- , 'win32': '.dll'
- }[process.platform]
-})
/**
* Export some of the properties from the "bindings" file.
@@ -38,7 +16,7 @@ Object.defineProperty(ffi, 'LIB_EXT', {
return debug('skipping exporting of non-existant property: %s', prop)
}
var desc = Object.getOwnPropertyDescriptor(bindings, prop)
- Object.defineProperty(ffi, prop, desc)
+ Object.defineProperty(exports, prop, desc)
})
/**
@@ -82,17 +60,18 @@ switch (ref.sizeof.long) {
* Alias the "ref" types onto ffi's exports, for convenience...
*/
-ffi.types = ref.types
+exports.types = ref.types
// Include our other modules
-ffi.CIF = require('./cif')
-ffi.CIF_var = require('./cif_var')
-ffi.ForeignFunction = require('./foreign_function')
-ffi.VariadicForeignFunction = require('./foreign_function_var')
-ffi.DynamicLibrary = require('./dynamic_library')
-ffi.Library = require('./library')
-ffi.Callback = require('./callback')
-ffi.errno = require('./errno')
-ffi.ffiType = require('./type').Type
-ffi.FFI_TYPE = require('./type').FFI_TYPE
+exports.CIF = require('./cif')
+exports.CIF_var = require('./cif_var')
+exports.ForeignFunction = require('./foreign_function')
+exports.VariadicForeignFunction = require('./foreign_function_var')
+exports.DynamicLibrary = require('./dynamic_library')
+exports.Library = require('./library').Library
+exports.LIB_EXT = require('./library').LIB_EXT
+exports.Callback = require('./callback')
+exports.errno = require('./errno')
+exports.ffiType = require('./type').Type
+exports.FFI_TYPE = require('./type').FFI_TYPE
View
@@ -8,7 +8,17 @@ var DynamicLibrary = require('./dynamic_library')
, VariadicForeignFunction = require('./foreign_function_var')
, debug = require('debug')('ffi:Library')
, RTLD_NOW = DynamicLibrary.FLAGS.RTLD_NOW
- , EXT = {
+
+/**
+ * The extension to use on libraries.
+ * i.e. libm -> libm.so on linux
+ */
+
+Object.defineProperty(exports, 'LIB_EXT', {
+ configurable: true
+ , enumerable: true
+ , writable: false
+ , value: {
'linux': '.so'
, 'linux2': '.so'
, 'sunos': '.so'
@@ -17,18 +27,19 @@ var DynamicLibrary = require('./dynamic_library')
, 'mac': '.dylib'
, 'win32': '.dll'
}[process.platform]
+})
/**
* Provides a friendly abstraction/API on-top of DynamicLibrary and
* ForeignFunction.
*/
-function Library (libfile, funcs) {
+exports.Library = function Library (libfile, funcs) {
debug('creating Library object for', libfile)
- if (libfile && libfile.indexOf(EXT) === -1) {
- debug('appending library extension to library name', EXT)
- libfile += EXT
+ if (libfile && libfile.indexOf(exports.LIB_EXT) === -1) {
+ debug('appending library extension to library name', exports.LIB_EXT)
+ libfile += exports.LIB_EXT
}
var lib = {}
@@ -62,4 +73,3 @@ function Library (libfile, funcs) {
return lib
}
-module.exports = Library

0 comments on commit acd10dd

Please sign in to comment.