Sha256: a3ddd79bb41b7a79f04ddea272cbaade0e50cbe82f220c10d7127ce3792e2f6b
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
require 'rubygems' require 'ffi_yajl/encoder' require 'ffi_yajl/parser' require 'ffi' require 'libyajl2' module FFI_Yajl # FIXME: DRY with ffi_yajl/ffi.rb # FIXME: extract map_library_name from FFI and stop requiring it at the top level # so that the C-library can be installed without FFI libname = ::FFI.map_library_name("yajl") libpath = File.expand_path(File.join(Libyajl2.opt_path, libname)) libpath.gsub!(/dylib/, 'bundle') libpath = ::FFI.map_library_name("yajl") unless File.exist?(libpath) # # FFS, what exactly was so wrong with DL.dlopen that ruby had to get rid of it??? # def self.try_fiddle_dlopen(libpath) require 'fiddle' if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) ::Fiddle.dlopen(libpath) true else false end rescue LoadError return false end def self.try_dl_dlopen(libpath) require 'dl' if defined?(DL) && DL.respond_to?(:dlopen) ::DL.dlopen(libpath) true else false end rescue LoadError return false end def self.try_ffi_dlopen(libpath) require 'ffi' require 'rbconfig' extend ::FFI::Library ffi_lib 'dl' attach_function 'dlopen', :dlopen, [:string, :int], :void if Config::CONFIG['host_os'] =~ /linux/i dlopen libpath, 0x102 # linux: RTLD_GLOBAL | RTLD_NOW else dlopen libpath, 0 end true rescue LoadError return false end unless try_fiddle_dlopen(libpath) || try_dl_dlopen(libpath) || try_ffi_dlopen(libpath) raise "cannot find dlopen vi Fiddle, DL or FFI, what am I supposed to do?" end class Parser require 'ffi_yajl/ext/parser' include FFI_Yajl::Ext::Parser end class Encoder require 'ffi_yajl/ext/encoder' include FFI_Yajl::Ext::Encoder end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffi-yajl-1.1.0-universal-java | lib/ffi_yajl/ext.rb |
ffi-yajl-1.1.0 | lib/ffi_yajl/ext.rb |