Method: OpenC3::Win32API#call

Defined in:
lib/openc3/win32/win32_main.rb

#call(*args) ⇒ Object Also known as: Call



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/openc3/win32/win32_main.rb', line 51

def call(*args)
  # Break up prototype into characters
  import = @function_prototype.split('')

  args.each_with_index do |arg, index|
    case import[index]
    when 'S'
      # Handle NULL specified with 0 value
      arg = nil if arg == 0

      # Convert argument into array of longs
      args[index], = [arg].pack("p").unpack(POINTER_TYPE)
    when 'I'
      # Handle intergers larger than 2^31 - 1
      args[index], = [arg].pack("I").unpack("i")
    end
  end

  # Call the function and return its return value
  return_value = @function.call(*args)
  return_value ||= 0
  return_value
end