virtualbox 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. data/Rakefile +11 -5
  2. data/TODO.md +7 -0
  3. data/lib/virtualbox.rb +34 -8
  4. data/lib/virtualbox/abstract_model.rb +7 -8
  5. data/lib/virtualbox/abstract_model/attributable.rb +16 -2
  6. data/lib/virtualbox/abstract_model/interface_attributes.rb +10 -1
  7. data/lib/virtualbox/abstract_model/relatable.rb +11 -0
  8. data/lib/virtualbox/appliance.rb +1 -1
  9. data/lib/virtualbox/com.rb +13 -12
  10. data/lib/virtualbox/com/abstract_enum.rb +21 -5
  11. data/lib/virtualbox/com/abstract_interface.rb +11 -0
  12. data/lib/virtualbox/com/base_interface.rb +1 -32
  13. data/lib/virtualbox/com/{ffi/vboxxpcomc.rb → ffi.rb} +7 -0
  14. data/lib/virtualbox/com/ffi/interface.rb +10 -27
  15. data/lib/virtualbox/com/ffi/util.rb +32 -2
  16. data/lib/virtualbox/com/ffi_interface.rb +8 -2
  17. data/lib/virtualbox/com/implementer.rb +10 -0
  18. data/lib/virtualbox/com/implementer/base.rb +10 -3
  19. data/lib/virtualbox/com/implementer/ffi.rb +40 -13
  20. data/lib/virtualbox/com/implementer/mscom.rb +18 -1
  21. data/lib/virtualbox/com/interface/4.0.x/{access_mode.rb → AccessMode.rb} +1 -1
  22. data/lib/virtualbox/com/interface/4.0.x/{appliance.rb → Appliance.rb} +0 -0
  23. data/lib/virtualbox/com/interface/4.0.x/{audio_adapter.rb → AudioAdapter.rb} +1 -1
  24. data/lib/virtualbox/com/interface/4.0.x/{audio_controller_type.rb → AudioControllerType.rb} +0 -0
  25. data/lib/virtualbox/com/interface/4.0.x/{audio_driver_type.rb → AudioDriverType.rb} +0 -0
  26. data/lib/virtualbox/com/interface/4.0.x/{auth_type.rb → AuthType.rb} +0 -0
  27. data/lib/virtualbox/com/interface/4.0.x/{bios_boot_menu_mode.rb → BIOSBootMenuMode.rb} +0 -0
  28. data/lib/virtualbox/com/interface/4.0.x/{bios_settings.rb → BIOSSettings.rb} +1 -1
  29. data/lib/virtualbox/com/interface/4.0.x/{bandwidth_control.rb → BandwidthControl.rb} +0 -0
  30. data/lib/virtualbox/com/interface/4.0.x/{bandwidth_group.rb → BandwidthGroup.rb} +0 -0
  31. data/lib/virtualbox/com/interface/4.0.x/{bandwidth_group_type.rb → BandwidthGroupType.rb} +0 -0
  32. data/lib/virtualbox/com/interface/4.0.x/{chipset_type.rb → ChipsetType.rb} +0 -0
  33. data/lib/virtualbox/com/interface/4.0.x/{cleanup_mode.rb → CleanupMode.rb} +0 -0
  34. data/lib/virtualbox/com/interface/4.0.x/{clipboard_mode.rb → ClipboardMode.rb} +0 -0
  35. data/lib/virtualbox/com/interface/4.0.x/{console.rb → Console.rb} +0 -0
  36. data/lib/virtualbox/com/interface/4.0.x/{cpu_property_type.rb → CpuPropertyType.rb} +0 -0
  37. data/lib/virtualbox/com/interface/4.0.x/{dhcp_server.rb → DHCPServer.rb} +0 -0
  38. data/lib/virtualbox/com/interface/4.0.x/{data_type.rb → DataType.rb} +0 -0
  39. data/lib/virtualbox/com/interface/4.0.x/{device_type.rb → DeviceType.rb} +0 -0
  40. data/lib/virtualbox/com/interface/4.0.x/{event_source.rb → EventSource.rb} +0 -0
  41. data/lib/virtualbox/com/interface/4.0.x/{fault_tolerance_state.rb → FaultToleranceState.rb} +0 -0
  42. data/lib/virtualbox/com/interface/4.0.x/{firmware_type.rb → FirmwareType.rb} +0 -0
  43. data/lib/virtualbox/com/interface/4.0.x/{guest.rb → Guest.rb} +0 -0
  44. data/lib/virtualbox/com/interface/4.0.x/{guest_os_type.rb → GuestOSType.rb} +0 -0
  45. data/lib/virtualbox/com/interface/4.0.x/{hw_virt_ex_property_type.rb → HWVirtExPropertyType.rb} +0 -0
  46. data/lib/virtualbox/com/interface/4.0.x/{host.rb → Host.rb} +6 -6
  47. data/lib/virtualbox/com/interface/4.0.x/{host_network_interface.rb → HostNetworkInterface.rb} +0 -0
  48. data/lib/virtualbox/com/interface/4.0.x/{host_network_interface_medium_type.rb → HostNetworkInterfaceMediumType.rb} +0 -0
  49. data/lib/virtualbox/com/interface/4.0.x/{host_network_interface_status.rb → HostNetworkInterfaceStatus.rb} +0 -0
  50. data/lib/virtualbox/com/interface/4.0.x/{host_network_interface_type.rb → HostNetworkInterfaceType.rb} +0 -0
  51. data/lib/virtualbox/com/interface/4.0.x/{host_usb_device.rb → HostUSBDevice.rb} +3 -1
  52. data/lib/virtualbox/com/interface/4.0.x/{host_usb_device_filter.rb → HostUSBDeviceFilter.rb} +3 -1
  53. data/lib/virtualbox/com/interface/4.0.x/{keyboard_hid_type.rb → KeyboardHidType.rb} +0 -0
  54. data/lib/virtualbox/com/interface/4.0.x/{lock_type.rb → LockType.rb} +0 -0
  55. data/lib/virtualbox/com/interface/4.0.x/{machine.rb → Machine.rb} +0 -0
  56. data/lib/virtualbox/com/interface/4.0.x/{machine_state.rb → MachineState.rb} +0 -0
  57. data/lib/virtualbox/com/interface/4.0.x/{medium.rb → Medium.rb} +0 -0
  58. data/lib/virtualbox/com/interface/4.0.x/{medium_attachment.rb → MediumAttachment.rb} +0 -0
  59. data/lib/virtualbox/com/interface/4.0.x/{medium_format.rb → MediumFormat.rb} +0 -0
  60. data/lib/virtualbox/com/interface/4.0.x/{medium_state.rb → MediumState.rb} +0 -0
  61. data/lib/virtualbox/com/interface/4.0.x/{medium_type.rb → MediumType.rb} +0 -0
  62. data/lib/virtualbox/com/interface/4.0.x/{medium_variant.rb → MediumVariant.rb} +0 -0
  63. data/lib/virtualbox/com/interface/4.0.x/{nat_alias_mode.rb → NATAliasMode.rb} +0 -0
  64. data/lib/virtualbox/com/interface/4.0.x/{nat_engine.rb → NATEngine.rb} +0 -0
  65. data/lib/virtualbox/com/interface/4.0.x/{nat_protocol.rb → NATProtocol.rb} +0 -0
  66. data/lib/virtualbox/com/interface/4.0.x/{nsiexception.rb → NSIException.rb} +0 -0
  67. data/lib/virtualbox/com/interface/4.0.x/{nsisupports.rb → NSISupports.rb} +3 -0
  68. data/lib/virtualbox/com/interface/4.0.x/{network_adapter.rb → NetworkAdapter.rb} +0 -0
  69. data/lib/virtualbox/com/interface/4.0.x/{network_adapter_type.rb → NetworkAdapterType.rb} +0 -0
  70. data/lib/virtualbox/com/interface/4.0.x/{network_attachment_type.rb → NetworkAttachmentType.rb} +0 -0
  71. data/lib/virtualbox/com/interface/4.0.x/{parallel_port.rb → ParallelPort.rb} +0 -0
  72. data/lib/virtualbox/com/interface/4.0.x/{pci_device_attachment.rb → PciDeviceAttachment.rb} +0 -0
  73. data/lib/virtualbox/com/interface/4.0.x/{pointing_hid_type.rb → PointingHidType.rb} +0 -0
  74. data/lib/virtualbox/com/interface/4.0.x/{port_mode.rb → PortMode.rb} +0 -0
  75. data/lib/virtualbox/com/interface/4.0.x/{progress.rb → Progress.rb} +0 -0
  76. data/lib/virtualbox/com/interface/4.0.x/{serial_port.rb → SerialPort.rb} +0 -0
  77. data/lib/virtualbox/com/interface/4.0.x/{session.rb → Session.rb} +0 -0
  78. data/lib/virtualbox/com/interface/4.0.x/{session_state.rb → SessionState.rb} +0 -0
  79. data/lib/virtualbox/com/interface/4.0.x/{session_type.rb → SessionType.rb} +0 -0
  80. data/lib/virtualbox/com/interface/4.0.x/{shared_folder.rb → SharedFolder.rb} +0 -0
  81. data/lib/virtualbox/com/interface/4.0.x/{snapshot.rb → Snapshot.rb} +0 -0
  82. data/lib/virtualbox/com/interface/4.0.x/{storage_bus.rb → StorageBus.rb} +0 -0
  83. data/lib/virtualbox/com/interface/4.0.x/{storage_controller.rb → StorageController.rb} +0 -0
  84. data/lib/virtualbox/com/interface/4.0.x/{storage_controller_type.rb → StorageControllerType.rb} +0 -0
  85. data/lib/virtualbox/com/interface/4.0.x/{system_properties.rb → SystemProperties.rb} +0 -0
  86. data/lib/virtualbox/com/interface/4.0.x/{usb_controller.rb → USBController.rb} +0 -0
  87. data/lib/virtualbox/com/interface/4.0.x/{usb_device.rb → USBDevice.rb} +0 -0
  88. data/lib/virtualbox/com/interface/4.0.x/{usb_device_filter.rb → USBDeviceFilter.rb} +0 -0
  89. data/lib/virtualbox/com/interface/4.0.x/{usb_device_filter_action.rb → USBDeviceFilterAction.rb} +0 -0
  90. data/lib/virtualbox/com/interface/4.0.x/{usb_device_state.rb → USBDeviceState.rb} +0 -0
  91. data/lib/virtualbox/com/interface/4.0.x/{vrde_server.rb → VRDEServer.rb} +0 -0
  92. data/lib/virtualbox/com/interface/4.0.x/{virtualbox.rb → VirtualBox.rb} +1 -1
  93. data/lib/virtualbox/com/interface/4.0.x/{virtual_box_error_info.rb → VirtualBoxErrorInfo.rb} +3 -1
  94. data/lib/virtualbox/com/interface/4.0.x/{virtual_system_description.rb → VirtualSystemDescription.rb} +0 -0
  95. data/lib/virtualbox/com/interface/4.0.x/{virtual_system_description_type.rb → VirtualSystemDescriptionType.rb} +0 -0
  96. data/lib/virtualbox/com/interface/4.0.x/{virtual_system_description_value_type.rb → VirtualSystemDescriptionValueType.rb} +0 -0
  97. data/lib/virtualbox/com/interface/{3.2.x/access_mode.rb → 4.1.x/AccessMode.rb} +2 -2
  98. data/lib/virtualbox/com/interface/4.1.x/AdditionsFacility.rb +17 -0
  99. data/lib/virtualbox/com/interface/4.1.x/AdditionsFacilityClass.rb +17 -0
  100. data/lib/virtualbox/com/interface/4.1.x/AdditionsFacilityStatus.rb +19 -0
  101. data/lib/virtualbox/com/interface/4.1.x/AdditionsFacilityType.rb +17 -0
  102. data/lib/virtualbox/com/interface/4.1.x/AdditionsRunLevelType.rb +14 -0
  103. data/lib/virtualbox/com/interface/{3.2.x/appliance.rb → 4.1.x/Appliance.rb} +5 -4
  104. data/lib/virtualbox/com/interface/{3.1.x/audio_adapter.rb → 4.1.x/AudioAdapter.rb} +2 -2
  105. data/lib/virtualbox/com/interface/{3.1.x/audio_controller_type.rb → 4.1.x/AudioControllerType.rb} +2 -2
  106. data/lib/virtualbox/com/interface/{3.2.x/audio_driver_type.rb → 4.1.x/AudioDriverType.rb} +2 -2
  107. data/lib/virtualbox/com/interface/{3.1.x/vrdp_auth_type.rb → 4.1.x/AuthType.rb} +3 -3
  108. data/lib/virtualbox/com/interface/{3.1.x/bios_boot_menu_mode.rb → 4.1.x/BIOSBootMenuMode.rb} +2 -2
  109. data/lib/virtualbox/com/interface/{3.2.x/bios_settings.rb → 4.1.x/BIOSSettings.rb} +2 -2
  110. data/lib/virtualbox/com/interface/4.1.x/BandwidthControl.rb +18 -0
  111. data/lib/virtualbox/com/interface/4.1.x/BandwidthGroup.rb +16 -0
  112. data/lib/virtualbox/com/interface/4.1.x/BandwidthGroupType.rb +11 -0
  113. data/lib/virtualbox/com/interface/4.1.x/ChipsetType.rb +11 -0
  114. data/lib/virtualbox/com/interface/4.1.x/CleanupMode.rb +12 -0
  115. data/lib/virtualbox/com/interface/{3.2.x/clipboard_mode.rb → 4.1.x/ClipboardMode.rb} +2 -2
  116. data/lib/virtualbox/com/interface/4.1.x/CloneMode.rb +13 -0
  117. data/lib/virtualbox/com/interface/4.1.x/CloneOptions.rb +14 -0
  118. data/lib/virtualbox/com/interface/{3.1.x/console.rb → 4.1.x/Console.rb} +10 -7
  119. data/lib/virtualbox/com/interface/{3.2.x/cpu_property_type.rb → 4.1.x/CpuPropertyType.rb} +2 -2
  120. data/lib/virtualbox/com/interface/{3.1.x/dhcp_server.rb → 4.1.x/DHCPServer.rb} +2 -2
  121. data/lib/virtualbox/com/interface/4.1.x/DataType.rb +11 -0
  122. data/lib/virtualbox/com/interface/{3.1.x/device_type.rb → 4.1.x/DeviceType.rb} +2 -2
  123. data/lib/virtualbox/com/interface/4.1.x/DirectoryCreateFlag.rb +12 -0
  124. data/lib/virtualbox/com/interface/4.1.x/DirectoryOpenFlag.rb +11 -0
  125. data/lib/virtualbox/com/interface/{3.2.x/guest.rb → 4.1.x/EventSource.rb} +4 -4
  126. data/lib/virtualbox/com/interface/4.1.x/ExecuteProcessFlag.rb +15 -0
  127. data/lib/virtualbox/com/interface/4.1.x/ExecuteProcessStatus.rb +19 -0
  128. data/lib/virtualbox/com/interface/4.1.x/FaultToleranceState.rb +11 -0
  129. data/lib/virtualbox/com/interface/{3.1.x/firmware_type.rb → 4.1.x/FirmwareType.rb} +2 -2
  130. data/lib/virtualbox/com/interface/4.1.x/Guest.rb +36 -0
  131. data/lib/virtualbox/com/interface/4.1.x/GuestDirEntry.rb +15 -0
  132. data/lib/virtualbox/com/interface/4.1.x/GuestDirEntryType.rb +14 -0
  133. data/lib/virtualbox/com/interface/{3.2.x/guest_os_type.rb → 4.1.x/GuestOSType.rb} +2 -2
  134. data/lib/virtualbox/com/interface/{3.1.x/hw_virt_ex_property_type.rb → 4.1.x/HWVirtExPropertyType.rb} +4 -3
  135. data/lib/virtualbox/com/interface/{3.1.x/host.rb → 4.1.x/Host.rb} +8 -6
  136. data/lib/virtualbox/com/interface/{3.1.x/host_network_interface.rb → 4.1.x/HostNetworkInterface.rb} +2 -2
  137. data/lib/virtualbox/com/interface/{3.1.x/host_network_interface_medium_type.rb → 4.1.x/HostNetworkInterfaceMediumType.rb} +2 -2
  138. data/lib/virtualbox/com/interface/{3.2.x/host_network_interface_status.rb → 4.1.x/HostNetworkInterfaceStatus.rb} +2 -2
  139. data/lib/virtualbox/com/interface/{3.1.x/host_network_interface_type.rb → 4.1.x/HostNetworkInterfaceType.rb} +2 -2
  140. data/lib/virtualbox/com/interface/{3.1.x/host_usb_device.rb → 4.1.x/HostUSBDevice.rb} +4 -2
  141. data/lib/virtualbox/com/interface/{3.2.x/host_usb_device_filter.rb → 4.1.x/HostUSBDeviceFilter.rb} +4 -2
  142. data/lib/virtualbox/com/interface/4.1.x/ImportOptions.rb +12 -0
  143. data/lib/virtualbox/com/interface/{3.2.x/keyboard_hid_type.rb → 4.1.x/KeyboardHidType.rb} +2 -2
  144. data/lib/virtualbox/com/interface/4.1.x/LockType.rb +11 -0
  145. data/lib/virtualbox/com/interface/{3.2.x/machine.rb → 4.1.x/Machine.rb} +34 -15
  146. data/lib/virtualbox/com/interface/{3.1.x/machine_state.rb → 4.1.x/MachineState.rb} +1 -1
  147. data/lib/virtualbox/com/interface/{3.2.x/medium.rb → 4.1.x/Medium.rb} +5 -2
  148. data/lib/virtualbox/com/interface/{3.1.x/medium_attachment.rb → 4.1.x/MediumAttachment.rb} +6 -2
  149. data/lib/virtualbox/com/interface/{3.1.x/medium_format.rb → 4.1.x/MediumFormat.rb} +2 -2
  150. data/lib/virtualbox/com/interface/{3.1.x/medium_state.rb → 4.1.x/MediumState.rb} +2 -2
  151. data/lib/virtualbox/com/interface/{3.2.x/medium_type.rb → 4.1.x/MediumType.rb} +2 -2
  152. data/lib/virtualbox/com/interface/{3.1.x/medium_variant.rb → 4.1.x/MediumVariant.rb} +2 -2
  153. data/lib/virtualbox/com/interface/{3.2.x/nat_alias_mode.rb → 4.1.x/NATAliasMode.rb} +2 -2
  154. data/lib/virtualbox/com/interface/{3.2.x/nat_engine.rb → 4.1.x/NATEngine.rb} +2 -2
  155. data/lib/virtualbox/com/interface/{3.2.x/nat_protocol.rb → 4.1.x/NATProtocol.rb} +2 -2
  156. data/lib/virtualbox/com/interface/{3.1.x/nsiexception.rb → 4.1.x/NSIException.rb} +2 -2
  157. data/lib/virtualbox/com/interface/{3.1.x/nsisupports.rb → 4.1.x/NSISupports.rb} +4 -1
  158. data/lib/virtualbox/com/interface/{3.2.x/network_adapter.rb → 4.1.x/NetworkAdapter.rb} +11 -11
  159. data/lib/virtualbox/com/interface/4.1.x/NetworkAdapterPromiscModePolicy.rb +13 -0
  160. data/lib/virtualbox/com/interface/{3.1.x/network_adapter_type.rb → 4.1.x/NetworkAdapterType.rb} +2 -2
  161. data/lib/virtualbox/com/interface/{3.1.x/network_attachment_type.rb → 4.1.x/NetworkAttachmentType.rb} +3 -3
  162. data/lib/virtualbox/com/interface/{3.2.x/parallel_port.rb → 4.1.x/ParallelPort.rb} +2 -2
  163. data/lib/virtualbox/com/interface/4.1.x/PciDeviceAttachment.rb +16 -0
  164. data/lib/virtualbox/com/interface/{3.2.x/pointing_hid_type.rb → 4.1.x/PointingHidType.rb} +2 -2
  165. data/lib/virtualbox/com/interface/{3.1.x/port_mode.rb → 4.1.x/PortMode.rb} +1 -1
  166. data/lib/virtualbox/com/interface/4.1.x/ProcessOutputFlag.rb +12 -0
  167. data/lib/virtualbox/com/interface/{3.2.x/progress.rb → 4.1.x/Progress.rb} +3 -1
  168. data/lib/virtualbox/com/interface/{3.1.x/serial_port.rb → 4.1.x/SerialPort.rb} +2 -2
  169. data/lib/virtualbox/com/interface/{3.2.x/session.rb → 4.1.x/Session.rb} +2 -2
  170. data/lib/virtualbox/com/interface/{3.1.x/session_state.rb → 4.1.x/SessionState.rb} +2 -2
  171. data/lib/virtualbox/com/interface/{3.1.x/session_type.rb → 4.1.x/SessionType.rb} +3 -3
  172. data/lib/virtualbox/com/interface/4.1.x/SettingsVersion.rb +25 -0
  173. data/lib/virtualbox/com/interface/{3.1.x/shared_folder.rb → 4.1.x/SharedFolder.rb} +2 -2
  174. data/lib/virtualbox/com/interface/{3.1.x/snapshot.rb → 4.1.x/Snapshot.rb} +3 -2
  175. data/lib/virtualbox/com/interface/{3.2.x/storage_bus.rb → 4.1.x/StorageBus.rb} +2 -2
  176. data/lib/virtualbox/com/interface/{3.2.x/storage_controller.rb → 4.1.x/StorageController.rb} +3 -2
  177. data/lib/virtualbox/com/interface/{3.2.x/storage_controller_type.rb → 4.1.x/StorageControllerType.rb} +2 -2
  178. data/lib/virtualbox/com/interface/4.1.x/StorageDeviceChangedEvent.rb +14 -0
  179. data/lib/virtualbox/com/interface/{3.2.x/system_properties.rb → 4.1.x/SystemProperties.rb} +8 -6
  180. data/lib/virtualbox/com/interface/{3.2.x/usb_controller.rb → 4.1.x/USBController.rb} +2 -2
  181. data/lib/virtualbox/com/interface/{3.1.x/usb_device.rb → 4.1.x/USBDevice.rb} +2 -2
  182. data/lib/virtualbox/com/interface/{3.1.x/usb_device_filter.rb → 4.1.x/USBDeviceFilter.rb} +2 -2
  183. data/lib/virtualbox/com/interface/{3.2.x/usb_device_filter_action.rb → 4.1.x/USBDeviceFilterAction.rb} +2 -2
  184. data/lib/virtualbox/com/interface/{3.2.x/usb_device_state.rb → 4.1.x/USBDeviceState.rb} +2 -2
  185. data/lib/virtualbox/com/interface/4.1.x/VRDEServer.rb +23 -0
  186. data/lib/virtualbox/com/interface/{3.2.x/virtualbox.rb → 4.1.x/VirtualBox.rb} +13 -27
  187. data/lib/virtualbox/com/interface/{3.2.x/virtual_box_error_info.rb → 4.1.x/VirtualBoxErrorInfo.rb} +4 -2
  188. data/lib/virtualbox/com/interface/{3.2.x/virtual_system_description.rb → 4.1.x/VirtualSystemDescription.rb} +2 -2
  189. data/lib/virtualbox/com/interface/4.1.x/VirtualSystemDescriptionType.rb +34 -0
  190. data/lib/virtualbox/com/interface/{3.2.x/virtual_system_description_value_type.rb → 4.1.x/VirtualSystemDescriptionValueType.rb} +1 -1
  191. data/lib/virtualbox/com/util.rb +30 -8
  192. data/lib/virtualbox/exceptions.rb +14 -13
  193. data/lib/virtualbox/extra_data.rb +2 -0
  194. data/lib/virtualbox/hard_drive.rb +1 -1
  195. data/lib/virtualbox/host_network_interface.rb +1 -1
  196. data/lib/virtualbox/lib.rb +2 -0
  197. data/lib/virtualbox/medium.rb +2 -0
  198. data/lib/virtualbox/network_adapter.rb +6 -22
  199. data/lib/virtualbox/proxies.rb +6 -0
  200. data/lib/virtualbox/system_properties.rb +0 -1
  201. data/lib/virtualbox/version.rb +28 -30
  202. data/lib/virtualbox/vm.rb +75 -55
  203. data/test/test_helper.rb +2 -5
  204. data/test/virtualbox/abstract_model/attributable_test.rb +22 -0
  205. data/test/virtualbox/abstract_model/relatable_test.rb +21 -0
  206. data/test/virtualbox/abstract_model_test.rb +1 -8
  207. data/test/virtualbox/com/abstract_enum_test.rb +1 -1
  208. data/test/virtualbox/com/ffi/interface_test.rb +9 -6
  209. data/test/virtualbox/com/ffi/util_test.rb +0 -11
  210. data/test/virtualbox/com/implementer/ffi_test.rb +7 -21
  211. data/test/virtualbox/com/util_test.rb +0 -10
  212. data/test/virtualbox/host_network_interface_test.rb +1 -1
  213. data/test/virtualbox/network_adapter_test.rb +6 -32
  214. data/test/virtualbox/version_test.rb +1 -5
  215. data/test/virtualbox/vm_test.rb +11 -17
  216. data/virtualbox.gemspec +4 -2
  217. metadata +224 -250
  218. data/lib/virtualbox/com/ffi/interfaces.rb +0 -64
  219. data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +0 -11
  220. data/lib/virtualbox/com/interface/3.1.x/appliance.rb +0 -22
  221. data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +0 -11
  222. data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +0 -21
  223. data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +0 -11
  224. data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +0 -11
  225. data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +0 -23
  226. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +0 -11
  227. data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +0 -13
  228. data/lib/virtualbox/com/interface/3.1.x/machine.rb +0 -105
  229. data/lib/virtualbox/com/interface/3.1.x/medium.rb +0 -50
  230. data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +0 -11
  231. data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +0 -30
  232. data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +0 -17
  233. data/lib/virtualbox/com/interface/3.1.x/progress.rb +0 -63
  234. data/lib/virtualbox/com/interface/3.1.x/session.rb +0 -18
  235. data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +0 -11
  236. data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +0 -23
  237. data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +0 -11
  238. data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +0 -37
  239. data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +0 -20
  240. data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +0 -11
  241. data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +0 -11
  242. data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +0 -17
  243. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +0 -19
  244. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +0 -14
  245. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +0 -11
  246. data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +0 -67
  247. data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +0 -19
  248. data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +0 -15
  249. data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +0 -11
  250. data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +0 -11
  251. data/lib/virtualbox/com/interface/3.2.x/console.rb +0 -50
  252. data/lib/virtualbox/com/interface/3.2.x/device_type.rb +0 -11
  253. data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +0 -22
  254. data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +0 -11
  255. data/lib/virtualbox/com/interface/3.2.x/host.rb +0 -43
  256. data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +0 -30
  257. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +0 -11
  258. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +0 -11
  259. data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +0 -13
  260. data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +0 -11
  261. data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +0 -14
  262. data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +0 -18
  263. data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +0 -18
  264. data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +0 -11
  265. data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +0 -11
  266. data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +0 -11
  267. data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +0 -11
  268. data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +0 -23
  269. data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +0 -15
  270. data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +0 -11
  271. data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +0 -19
  272. data/lib/virtualbox/com/interface/3.2.x/session_state.rb +0 -11
  273. data/lib/virtualbox/com/interface/3.2.x/session_type.rb +0 -11
  274. data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +0 -17
  275. data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +0 -20
  276. data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +0 -24
  277. data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +0 -23
  278. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +0 -14
  279. data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +0 -11
  280. data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +0 -21
  281. data/lib/virtualbox/ext/glob_loader.rb +0 -35
data/Rakefile CHANGED
@@ -1,12 +1,14 @@
1
+ require "rbconfig"
1
2
  require "rubygems"
2
3
  require "bundler/setup"
3
4
  require "rake/testtask"
4
5
 
5
6
  require "cucumber"
6
7
  require "cucumber/rake/task"
7
- require "yard"
8
8
  Bundler::GemHelper.install_tasks
9
9
 
10
+ include Rake::DSL
11
+
10
12
  task :default => "test:units"
11
13
 
12
14
  namespace :test do
@@ -31,7 +33,11 @@ namespace :test do
31
33
  rescue LoadError; end
32
34
  end
33
35
 
34
- YARD::Rake::YardocTask.new do |t|
35
- t.options = ['--main', 'Readme.md', '--markup', 'markdown']
36
- t.options += ['--title', 'VirtualBox Ruby Library Documentation']
37
- end
36
+ if RbConfig::CONFIG["host_os"] !~ /^darwin11/
37
+ # YARD is broken on Lion
38
+ require "yard"
39
+ YARD::Rake::YardocTask.new do |t|
40
+ t.options = ['--main', 'Readme.md', '--markup', 'markdown']
41
+ t.options += ['--title', 'VirtualBox Ruby Library Documentation']
42
+ end
43
+ end
data/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ # VirtualBox 4.1 TODOs:
2
+
3
+ * NetworkAdapter uses `network_adapter_counter` which is no longer supported.
4
+ It needs to use `get_max_network_adapters` instead.
5
+ * NetworkAdapter `attach_to_*` methods are gone. Use `attachment_type` property
6
+ instead.
7
+ * Appliance import must supply import options
@@ -1,11 +1,37 @@
1
- # Load the glob loader, which will handle the loading of all the other files
2
- libdir = File.join(File.dirname(__FILE__), "virtualbox")
3
- require File.expand_path("ext/glob_loader", libdir)
1
+ require 'virtualbox/version'
4
2
 
5
- # Load them up
6
- VirtualBox::GlobLoader.glob_require(libdir, %w{ext/logger ext/platform ext/subclass_listing ext/byte_normalizer com abstract_model medium})
7
-
8
- # Setup the top-level module methods
9
3
  module VirtualBox
10
- extend Version
4
+ autoload :AbstractModel, 'virtualbox/abstract_model'
5
+ autoload :Appliance, 'virtualbox/appliance'
6
+ autoload :AudioAdapter, 'virtualbox/audio_adapter'
7
+ autoload :BIOS, 'virtualbox/bios'
8
+ autoload :COM, 'virtualbox/com'
9
+ autoload :CPU, 'virtualbox/cpu'
10
+ autoload :DHCPServer, 'virtualbox/dhcp_server'
11
+ autoload :DVD, 'virtualbox/dvd'
12
+ autoload :ExtraData, 'virtualbox/extra_data'
13
+ autoload :Exceptions, 'virtualbox/exceptions'
14
+ autoload :ForwardedPort, 'virtualbox/forwarded_port'
15
+ autoload :Global, 'virtualbox/global'
16
+ autoload :HardDrive, 'virtualbox/hard_drive'
17
+ autoload :Host, 'virtualbox/host'
18
+ autoload :HostNetworkInterface, 'virtualbox/host_network_interface'
19
+ autoload :HWVirtualization, 'virtualbox/hw_virtualization'
20
+ autoload :Lib, 'virtualbox/lib'
21
+ autoload :Media, 'virtualbox/media'
22
+ autoload :Medium, 'virtualbox/medium'
23
+ autoload :MediumAttachment, 'virtualbox/medium_attachment'
24
+ autoload :NATEngine, 'virtualbox/nat_engine'
25
+ autoload :NATForwardedPort, 'virtualbox/nat_forwarded_port'
26
+ autoload :NetworkAdapter, 'virtualbox/network_adapter'
27
+ autoload :Proxies, 'virtualbox/proxies'
28
+ autoload :SharedFolder, 'virtualbox/shared_folder'
29
+ autoload :Snapshot, 'virtualbox/snapshot'
30
+ autoload :StorageController, 'virtualbox/storage_controller'
31
+ autoload :SystemProperties, 'virtualbox/system_properties'
32
+ autoload :USBController, 'virtualbox/usb_controller'
33
+ autoload :USBDeviceFilter, 'virtualbox/usb_device_filter'
34
+ autoload :VirtualSystemDescription, 'virtualbox/virtual_system_description'
35
+ autoload :VM, 'virtualbox/vm'
36
+ autoload :VRDEServer, 'virtualbox/vrde_server'
11
37
  end
@@ -1,10 +1,9 @@
1
- ['abstract_model/attributable',
2
- 'abstract_model/interface_attributes',
3
- 'abstract_model/dirty',
4
- 'abstract_model/relatable',
5
- 'abstract_model/validatable'].each do |lib|
6
- require File.expand_path(lib, File.dirname(__FILE__))
7
- end
1
+ require 'virtualbox/abstract_model/attributable'
2
+ require 'virtualbox/abstract_model/interface_attributes'
3
+ require 'virtualbox/abstract_model/dirty'
4
+ require 'virtualbox/abstract_model/relatable'
5
+ require 'virtualbox/abstract_model/validatable'
6
+ require 'virtualbox/ext/logger'
8
7
 
9
8
  module VirtualBox
10
9
  # AbstractModel is the base class used for most of virtualbox's classes.
@@ -218,7 +217,7 @@ module VirtualBox
218
217
  # Overwrites {Attributable#write_attribute} to set the dirty state of
219
218
  # the written attribute. See {Dirty#set_dirty!} as well.
220
219
  def write_attribute(name, value)
221
- set_dirty!(name, read_attribute(name), value) unless lazy_attribute?(name) && !loaded_attribute?(name)
220
+ set_dirty!(name, read_attribute(name), value)
222
221
  super
223
222
  end
224
223
 
@@ -153,7 +153,7 @@ module VirtualBox
153
153
  # a custom populate key to use for {Attributable#populate_attributes}
154
154
  def attribute(name, options = {})
155
155
  name = name.to_sym
156
- attributes[name] = defined?(@__attribute_scope) ? @__attribute_scope : {}
156
+ attributes[name] = defined?(@__attribute_scope) ? @__attribute_scope.dup : {}
157
157
  attributes[name].merge!(options)
158
158
 
159
159
  # Create the method for reading this attribute
@@ -225,6 +225,20 @@ module VirtualBox
225
225
  end
226
226
  end
227
227
 
228
+ # Reset attributes which basically causes all lazy attributes to
229
+ # be reset. This forces them to reload when they're accessed.
230
+ def reset_attributes
231
+ # Find the lazy attributes
232
+ to_delete = []
233
+ attributes.each do |name, value|
234
+ to_delete << name if lazy_attribute?(name)
235
+ end
236
+
237
+ # Delete them!
238
+ to_delete.each { |key| attributes.delete(key) }
239
+ end
240
+
241
+
228
242
  # Writes an attribute. This method ignores the `readonly` option
229
243
  # on attribute definitions. This method is mostly meant for
230
244
  # internal use on setting attributes (including readonly
@@ -245,7 +259,7 @@ module VirtualBox
245
259
  assert_version_match(options[:version], VirtualBox.version) if options[:version]
246
260
  if lazy_attribute?(name) && !loaded_attribute?(name)
247
261
  # Load the lazy attribute
248
- load_attribute(name.to_sym)
262
+ attributes[name] = load_attribute(name.to_sym)
249
263
  end
250
264
 
251
265
  if attributes[name].nil?
@@ -19,6 +19,15 @@ module VirtualBox
19
19
  # @param [Symbol] key The attribute to load
20
20
  # @param [VirtualBox::COM::Interface] interface The interface
21
21
  def load_interface_attribute(key, interface)
22
+ value = read_interface_attribute(key, interface)
23
+ return if !value
24
+
25
+ write_attribute(key, value)
26
+ end
27
+
28
+ # Reads a single interface attribute without loading it into the
29
+ # given key.
30
+ def read_interface_attribute(key, interface)
22
31
  # Return unless we have a valid interface attribute with a getter
23
32
  return unless has_attribute?(key)
24
33
  options = self.class.attributes[key.to_sym]
@@ -29,7 +38,7 @@ module VirtualBox
29
38
 
30
39
  # Convert the getter to a proc and call it
31
40
  getter = spec_to_proc(getter)
32
- write_attribute(key, getter.call(self, interface, key))
41
+ getter.call(self, interface, key)
33
42
  end
34
43
 
35
44
  # Saves all the attributes which have an interface setter.
@@ -182,6 +182,17 @@ module VirtualBox
182
182
  end
183
183
  end
184
184
 
185
+ # Resets a relationship. This resets all lazy relationships.
186
+ def reset_relationships
187
+ to_delete = []
188
+ relationship_data.each do |key, value|
189
+ to_delete << key if lazy_relationship?(key)
190
+ end
191
+
192
+ # Delete them!
193
+ to_delete.each { |key| relationship_data.delete(key) }
194
+ end
195
+
185
196
  # Reads a relationship. This is equivalent to {Attributable#read_attribute},
186
197
  # but for relationships.
187
198
  def read_relationship(name)
@@ -41,7 +41,7 @@ module VirtualBox
41
41
  # it will be yielded every percent that the operation progresses. This can be
42
42
  # done to check the progress of the import.
43
43
  def import(&block)
44
- interface.import_machines.wait(&block)
44
+ interface.import_machines([:keep_all_macs, :keep_all_nats]).wait(&block)
45
45
  end
46
46
 
47
47
  # Exports the machines to the given path. If a block is given, it will be yielded
@@ -1,23 +1,24 @@
1
1
  module VirtualBox
2
2
  module COM
3
3
  WSTRING = :unicode_string
4
+ T_INT8 = :int8
5
+ T_UINT8 = :uint8
4
6
  T_INT32 = :int
5
7
  T_INT64 = :long
6
- T_ULONG = :ulong
7
- T_UINT8 = :uchar
8
8
  T_UINT16 = :ushort
9
9
  T_UINT32 = :uint
10
10
  T_UINT64 = :ulong
11
11
  T_BOOL = :char
12
+
13
+ autoload :AbstractEnum, 'virtualbox/com/abstract_enum'
14
+ autoload :AbstractImplementer, 'virtualbox/com/abstract_implementer'
15
+ autoload :AbstractInterface, 'virtualbox/com/abstract_interface'
16
+ autoload :BaseInterface, 'virtualbox/com/base_interface'
17
+ autoload :FFI, 'virtualbox/com/ffi'
18
+ autoload :FFIInterface, 'virtualbox/com/ffi_interface'
19
+ autoload :Implementer, 'virtualbox/com/implementer'
20
+ autoload :MSCOMInterface, 'virtualbox/com/mscom_interface'
21
+ autoload :NilInterface, 'virtualbox/com/nil_interface'
22
+ autoload :Util, 'virtualbox/com/util'
12
23
  end
13
24
  end
14
-
15
- # The com directory of the gem
16
- comdir = File.join(File.dirname(__FILE__), 'com')
17
-
18
- # Require the abstract interface first then glob load all
19
- # of the interfaces
20
- require File.expand_path("abstract_interface", comdir)
21
- require File.expand_path("abstract_enum", comdir)
22
- VirtualBox::GlobLoader.glob_require(File.join(comdir, "interface"))
23
- VirtualBox::GlobLoader.glob_require(comdir, %w{base_interface abstract_interface abstract_implementer util ffi/interface ffi/util implementer/base})
@@ -11,23 +11,39 @@ module VirtualBox
11
11
  # can be indexed with `[]` and an integer and returns a value of
12
12
  # some sort. If value is left nil, it will return the current mapping
13
13
  def map(value = nil)
14
- @map = value if value
14
+ if value
15
+ # Convert the array to a hash of equal structure
16
+ if value.is_a?(Array)
17
+ result = {}
18
+ value.each_index do |i|
19
+ result[value[i]] = i
20
+ end
21
+
22
+ value = result
23
+ end
24
+
25
+ # Store both the map and the reverse map since both lookups
26
+ # are frequently used.
27
+ @map = value
28
+ @reverse_map = @map.invert
29
+ end
30
+
15
31
  @map
16
32
  end
17
33
 
18
34
  # Returns the symbol associatd with the given key
19
- def [](key)
20
- @map[key]
35
+ def [](index)
36
+ @reverse_map[index]
21
37
  end
22
38
 
23
39
  # Returns the index associated with a value
24
40
  def index(key)
25
- @map.index(key)
41
+ @map[key]
26
42
  end
27
43
 
28
44
  # Iterate over the enum, yielding each item to a block.
29
45
  def each
30
- @map.each do |key|
46
+ @map.each do |key, value|
31
47
  yield key
32
48
  end
33
49
  end
@@ -36,6 +36,17 @@ module VirtualBox
36
36
  attr_reader :lib
37
37
 
38
38
  class << self
39
+ # This sets the parent class type. This defaults to NSISupports, but
40
+ # can be explicitly set to nil (no parent) if necessary.
41
+ def parent(type=nil)
42
+ @parent = type
43
+ end
44
+
45
+ # Returns the parent.
46
+ def get_parent
47
+ defined?(@parent) ? @parent : :NSISupports
48
+ end
49
+
39
50
  # Adds a function to the interface with the given name and function
40
51
  # spec. The spec determines the arguments required, the order they
41
52
  # are required in, and any out-arguments.
@@ -1,38 +1,7 @@
1
- require 'thread'
2
-
3
1
  module VirtualBox
4
2
  module COM
5
3
  class BaseInterface
6
- def initialize
7
- @task_queue = Queue.new
8
-
9
- @lib_thread = Thread.new(@task_queue) do |queue|
10
- while true
11
- task, result = queue.pop
12
-
13
- # Run the task, set the return value, and run the waiter
14
- # which will simply finish that thread
15
- result << task.call
16
- end
17
- end
18
- end
19
-
20
- # This function takes a block and runs it on a thread which is
21
- # guaranteed to be the same since the first time this is
22
- # called. This is required by the MSCOM implementation and is a
23
- # good idea in general so that multiple API calls aren't firing
24
- # at once.
25
- def on_lib_thread(&task)
26
- # If we're already on the lib thread, then just run it!
27
- return task.call if Thread.current == @lib_thread
28
-
29
- # Add the task to the queue
30
- result = Queue.new
31
- @task_queue << [task, result]
32
-
33
- # Pop the result off of the result queue
34
- result.pop
35
- end
4
+ # Nothing for now
36
5
  end
37
6
  end
38
7
  end
@@ -1,6 +1,13 @@
1
+ require 'ffi'
2
+
1
3
  module VirtualBox
2
4
  module COM
3
5
  module FFI
6
+ autoload :Interface, 'virtualbox/com/ffi/interface'
7
+ autoload :Util, 'virtualbox/com/ffi/util'
8
+
9
+ extend ::FFI::Library
10
+
4
11
  # Callback types for VBOXXPCOMC
5
12
  callback :pfnGetVersion, [], :uint
6
13
  callback :pfnComInitialize, [:string, :pointer, :string, :pointer], :void
@@ -3,29 +3,6 @@ require 'ffi'
3
3
  module VirtualBox
4
4
  module COM
5
5
  module FFI
6
- extend ::FFI::Library
7
-
8
- # FFI specific types
9
- NSRESULT_TYPE = :uint
10
-
11
- # Creates all the FFI classes for a given version.
12
- def self.for_version(version, &block)
13
- @__module = Module.new
14
- ::VirtualBox::COM::Util.set_interface_version(version)
15
- const_set(::VirtualBox::COM::Util.version_const, @__module)
16
- instance_eval(&block)
17
- @__module = Kernel
18
- end
19
-
20
- # Returns a Class which creates an FFI interface to the specified
21
- # com interface and potentially a parent class as well.
22
- def self.create_interface(interface, parent=nil)
23
- klass = Class.new(Interface)
24
- @__module.const_set(interface, klass)
25
- klass.com_interface(interface, parent)
26
- klass
27
- end
28
-
29
6
  # Represents a VirtualBox XPCOM C interface, which is a C struct
30
7
  # which emulates an object (a struct with function pointers
31
8
  # and getters/setters). This class does **a lot** of magic which pretty
@@ -36,6 +13,9 @@ module VirtualBox
36
13
  class Interface
37
14
  extend ::FFI::Library
38
15
 
16
+ # FFI specific types
17
+ NSRESULT_TYPE = :uint
18
+
39
19
  attr_reader :vtbl_parent
40
20
  attr_reader :vtbl
41
21
 
@@ -46,11 +26,11 @@ module VirtualBox
46
26
  # XPCOM C structs are setup, the properties are first, in
47
27
  # `GetFoo` and `SetFoo` format. And the functions are next. They are
48
28
  # put into the struct in the order defined in the {AbstractInterface}.
49
- def com_interface(interface, parent=nil)
29
+ def com_interface(interface)
50
30
  # Create the parent class and vtbl class
51
31
  interface = ::VirtualBox::COM::Util.versioned_interface(interface)
52
32
  define_vtbl_parent_for_interface(interface)
53
- define_vtbl_for_interface(interface, parent)
33
+ define_vtbl_for_interface(interface)
54
34
  end
55
35
 
56
36
  # Creates the parent of the vtbl class associated with a given
@@ -64,7 +44,10 @@ module VirtualBox
64
44
  end
65
45
 
66
46
  # Creates the vtbl class associated with a given interface.
67
- def define_vtbl_for_interface(interface, parent=nil)
47
+ def define_vtbl_for_interface(interface)
48
+ # Get the parent for the interface
49
+ parent = interface.get_parent
50
+
68
51
  # Define the properties, then the functions, since thats the order
69
52
  # the FFI structs are in
70
53
  layout_args.clear
@@ -88,7 +71,7 @@ module VirtualBox
88
71
  def define_interface_parent(parent)
89
72
  return if parent.nil?
90
73
 
91
- parent_klass = Object.module_eval("::VirtualBox::COM::FFI::#{::VirtualBox::COM::Util.version_const}::#{parent}::Vtbl")
74
+ parent_klass = Util.versioned_interface(parent).const_get("Vtbl")
92
75
  layout_args << [:superklass, parent_klass]
93
76
  end
94
77
 
@@ -18,7 +18,36 @@ module VirtualBox
18
18
  #
19
19
  # @return [Class]
20
20
  def versioned_interface(interface)
21
- ::VirtualBox::COM::FFI.const_get(::VirtualBox::COM::Util.version_const).const_get(interface)
21
+ version = ::VirtualBox::COM::Util.version
22
+ loaded_interfaces[version] ||= {}
23
+ loaded_interfaces[version][interface] ||= load_interface(interface)
24
+ end
25
+
26
+ # This keeps a hash of all the loaded interface classes by both
27
+ # version and name. Example:
28
+ #
29
+ # loaded_interfaces["4.0.x"][:VirtualBox]
30
+ #
31
+ def loaded_interfaces
32
+ @loaded_interfaces ||= {}
33
+ end
34
+
35
+ # Loads an interface with the current version.
36
+ def load_interface(interface)
37
+ @current_constant ||= 1
38
+
39
+ # Create a new class that is an interface
40
+ klass = Class.new(Interface)
41
+
42
+ # Note that the klass must exist in a real constant path
43
+ # because FFI gem exists by climbing up the full path of the
44
+ # class. Dumb.
45
+ const_set("FFIClass#{@current_constant}", klass)
46
+ @current_constant += 1
47
+
48
+ # Create the actual interface on this empty class and return!
49
+ klass.com_interface(interface)
50
+ klass
22
51
  end
23
52
 
24
53
  # Converts a function spec from {AbstractInterface} to an FFI
@@ -55,7 +84,7 @@ module VirtualBox
55
84
  elsif interface.superclass == COM::AbstractEnum
56
85
  T_UINT32
57
86
  end
58
- rescue NameError
87
+ rescue NameError,LoadError
59
88
  # Default to a pointer, since not all interfaces are implemented
60
89
  :pointer
61
90
  end
@@ -79,6 +108,7 @@ module VirtualBox
79
108
  # @return [String]
80
109
  def camelize(string)
81
110
  special_cases = {
111
+ "api" => "API",
82
112
  "os" => "OS",
83
113
  "dhcp" => "DHCP",
84
114
  "dvd" => "DVD",