Method: FFI::Library#function_names

Defined in:
lib/ffi/library.rb

#function_names(name, arg_types) ⇒ Array<String>

Note:

Function names on windows may be decorated if they are using stdcall. See

Note that decorated names can be overridden via def files. Also note that the windows api, although using, doesn’t have decorated names.

This function returns a list of possible names to lookup.

Parameters:

  • name (#to_s)

    function name

  • arg_types (Array)

    function’s argument types

Returns:

  • (Array<String>)


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/ffi/library.rb', line 232

def function_names(name, arg_types)
  result = [name.to_s]
  if ffi_convention == :stdcall
    # Get the size of each parameter
    size = arg_types.inject(0) do |mem, arg|
      size = arg.size
      # The size must be a multiple of 4
      size += (4 - size) % 4
      mem + size
    end

    result << "_#{name.to_s}@#{size}" # win32
    result << "#{name.to_s}@#{size}" # win64
  end
  result
end