Module: FFI::Library

Overview

Redefining #attach_function so we can avoid bombing out if a called method is not defined.

Instance Method Summary collapse

Instance Method Details

#attach_function(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ext/ffi_library_function_checks.rb', line 12

def attach_function(*args)
  old_attach_function(*args)
rescue FFI::NotFoundError
  @unsupported_gdal_functions ||= []

  if $VERBOSE || ENV.fetch("VERBOSE", nil)
    warn "ffi-gdal warning: function '#{args.first}' is not available in this " \
         "build of GDAL/OGR (v#{FFI::GDAL.GDALVersionInfo('RELEASE_NAME')})"
  end

  @unsupported_gdal_functions << args.first
end

#old_attach_functionObject



10
# File 'lib/ext/ffi_library_function_checks.rb', line 10

alias old_attach_function attach_function

#unsupported_gdal_functionsObject



25
26
27
# File 'lib/ext/ffi_library_function_checks.rb', line 25

def unsupported_gdal_functions
  @unsupported_gdal_functions ||= []
end