Module: VirtualBox::COM::FFI

Extended by:
FFI::Library
Defined in:
lib/virtualbox/com/ffi/util.rb,
lib/virtualbox/com/ffi/interface.rb,
lib/virtualbox/com/ffi/interfaces.rb,
lib/virtualbox/com/ffi/vboxxpcomc.rb

Defined Under Namespace

Classes: Interface, Util, VBOXXPCOMC

Constant Summary collapse

NSRESULT_TYPE =

FFI specific types

:uint

Class Method Summary collapse

Class Method Details

.create_interface(interface, parent = nil) ⇒ Object

Returns a Class which creates an FFI interface to the specified com interface and potentially a parent class as well.



22
23
24
25
26
27
# File 'lib/virtualbox/com/ffi/interface.rb', line 22

def self.create_interface(interface, parent=nil)
  klass = Class.new(Interface)
  @__module.const_set(interface, klass)
  klass.com_interface(interface, parent)
  klass
end

.for_version(version, &block) ⇒ Object

Creates all the FFI classes for a given version.



12
13
14
15
16
17
18
# File 'lib/virtualbox/com/ffi/interface.rb', line 12

def self.for_version(version, &block)
  @__module = Module.new
  ::VirtualBox::COM::Util.set_interface_version(version)
  const_set(::VirtualBox::COM::Util.version_const, @__module)
  instance_eval(&block)
  @__module = Kernel
end

.setup(version) ⇒ Object

Creates all the interfaces for the FFI implementation. Eventually this file should be conditionally loaded based on OS, so that Windows users don’t have to wait for all this translation to occur.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/virtualbox/com/ffi/interfaces.rb', line 7

def self.setup(version)
  # TODO: This is so hacky and hard to maintain. Can we
  # programatically get the modules in a namespace and
  # instantiate them somehow?
  for_version version do
    create_interface(:NSISupports)
    create_interface(:NSIException, :NSISupports)
    create_interface(:Session, :NSISupports)
    create_interface(:VirtualBox, :NSISupports)
    create_interface(:Appliance, :NSISupports)
    create_interface(:AudioAdapter, :NSISupports)
    create_interface(:BIOSSettings, :NSISupports)
    create_interface(:Console, :NSISupports)
    create_interface(:DHCPServer, :NSISupports)
    create_interface(:GuestOSType, :NSISupports)
    create_interface(:Host, :NSISupports)
    create_interface(:HostNetworkInterface, :NSISupports)
    create_interface(:Machine, :NSISupports)
    create_interface(:Medium, :NSISupports)
    create_interface(:MediumAttachment, :NSISupports)
    create_interface(:MediumFormat, :NSISupports)
    create_interface(:NetworkAdapter, :NSISupports)
    create_interface(:ParallelPort, :NSISupports)
    create_interface(:Progress, :NSISupports)
    create_interface(:SerialPort, :NSISupports)
    create_interface(:SharedFolder, :NSISupports)
    create_interface(:Snapshot, :NSISupports)
    create_interface(:StorageController, :NSISupports)
    create_interface(:SystemProperties, :NSISupports)
    create_interface(:USBController, :NSISupports)
    create_interface(:USBDevice, :NSISupports)
    create_interface(:USBDeviceFilter, :NSISupports)
    create_interface(:VirtualBoxErrorInfo, :NSIException)
    create_interface(:VirtualSystemDescription, :NSISupports)

    create_interface(:HostUSBDevice, :USBDevice)
    create_interface(:HostUSBDeviceFilter, :USBDeviceFilter)

    # 3.1.x, 3.2.x
    if ["3.1.x", "3.2.x"].include?(version)
      create_interface(:VRDPServer, :NSISupports)
    end

    # 3.2.x, 4.0.x
    if ["3.2.x", "4.0.x"].include?(version)
      create_interface(:NATEngine, :NSISupports)
    end

    # 4.0.x interfaces
    if version == "4.0.x"
      create_interface(:VRDEServer, :NSISupports)
    end
  end
end