Module: GRCommons::TryExtern

Included in:
GR3::FFI, GR::FFI, GRM::FFI
Defined in:
lib/gr_commons/try_extern.rb

Overview

This module records the names of the methods defined by Fiddle::Importer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ffi_methodsObject (readonly)

Returns the value of attribute ffi_methods.



6
7
8
# File 'lib/gr_commons/try_extern.rb', line 6

def ffi_methods
  @ffi_methods
end

Instance Method Details

#try_extern(signature, *opts) ⇒ Object

Improved extern method.

  1. Ignore functions that cannot be attached.

  2. Available function (names) are stored in @ffi_methods.

For compatibility with older versions of GR.



12
13
14
15
16
17
18
19
20
21
# File 'lib/gr_commons/try_extern.rb', line 12

def try_extern(signature, *opts)
  @ffi_methods ||= []
  begin
    func = extern(signature, *opts)
    @ffi_methods << func.name
    func
  rescue Fiddle::DLError => e
    warn "#{e.class.name}: #{e.message}" if $VERBOSE
  end
end