Module: FFI_Yajl

Extended by:
FFI::Library, Platform
Defined in:
lib/ffi_yajl/ext.rb,
lib/ffi_yajl/ffi.rb,
lib/ffi_yajl/ffi.rb,
lib/ffi_yajl/parser.rb,
lib/ffi_yajl/encoder.rb,
lib/ffi_yajl/version.rb,
lib/ffi_yajl/platform.rb,
lib/ffi_yajl/ffi/parser.rb,
lib/ffi_yajl/ffi/encoder.rb,
lib/ffi_yajl/benchmark/encode.rb,
lib/ffi_yajl/benchmark/parse_profile.rb,
lib/ffi_yajl/benchmark/encode_profile.rb,
lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb,
ext/ffi_yajl/ext/parser/parser.c,
ext/ffi_yajl/ext/encoder/encoder.c

Defined Under Namespace

Modules: Ext, FFI, Platform Classes: Benchmark, EncodeError, Encoder, ParseError, Parser, YajlCallbacks

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Methods included from Platform

windows?

Class Method Details

.try_dl_dlopen(libpath) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ffi_yajl/ext.rb', line 38

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

.try_ffi_dlopen(libpath) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ffi_yajl/ext.rb', line 50

def self.try_ffi_dlopen(libpath)
  require 'ffi'
  require 'rbconfig'
  extend ::FFI::Library
  ffi_lib 'dl'
  attach_function 'dlopen', :dlopen, [:string, :int], :void
  if  RbConfig::CONFIG['host_os'] =~ /linux/i
    dlopen libpath, 0x102  # linux: RTLD_GLOBAL | RTLD_NOW
  else
    dlopen libpath, 0
  end
  true
rescue LoadError
  return false
end

.try_fiddle_dlopen(libpath) ⇒ Object

FFS, what exactly was so wrong with DL.dlopen that ruby had to get rid of it???



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ffi_yajl/ext.rb', line 26

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