velir_virtualbox 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. data/.gitignore +8 -0
  2. data/.yardopts +3 -0
  3. data/Gemfile +16 -0
  4. data/LICENSE +19 -0
  5. data/Rakefile +37 -0
  6. data/Readme.md +70 -0
  7. data/docs/GettingStarted.md +196 -0
  8. data/docs/WhatsNew.md +12 -0
  9. data/features/README.md +33 -0
  10. data/features/global.feature +19 -0
  11. data/features/global_extra_data.feature +27 -0
  12. data/features/step_definitions/abstract_model_steps.rb +39 -0
  13. data/features/step_definitions/extra_data_steps.rb +36 -0
  14. data/features/step_definitions/global_steps.rb +29 -0
  15. data/features/step_definitions/nat_engine_steps.rb +76 -0
  16. data/features/step_definitions/network_adapter_steps.rb +38 -0
  17. data/features/step_definitions/shared_folder_steps.rb +76 -0
  18. data/features/step_definitions/snapshot_steps.rb +74 -0
  19. data/features/step_definitions/storage_controller_steps.rb +16 -0
  20. data/features/step_definitions/virtualbox_steps.rb +17 -0
  21. data/features/step_definitions/vm_steps.rb +50 -0
  22. data/features/support/env.rb +61 -0
  23. data/features/support/helpers.rb +38 -0
  24. data/features/support/hooks.rb +30 -0
  25. data/features/support/ordered_hash.rb +49 -0
  26. data/features/support/vboxmanage.rb +191 -0
  27. data/features/version.feature +16 -0
  28. data/features/vm.feature +13 -0
  29. data/features/vm_bios.feature +29 -0
  30. data/features/vm_cpu.feature +29 -0
  31. data/features/vm_extra_data.feature +35 -0
  32. data/features/vm_hw_virt.feature +29 -0
  33. data/features/vm_nat_engine.feature +57 -0
  34. data/features/vm_network_adapters.feature +27 -0
  35. data/features/vm_shared_folders.feature +42 -0
  36. data/features/vm_snapshots.feature +29 -0
  37. data/features/vm_storage_controllers.feature +11 -0
  38. data/lib/virtualbox.rb +11 -0
  39. data/lib/virtualbox/abstract_model.rb +281 -0
  40. data/lib/virtualbox/abstract_model/attributable.rb +290 -0
  41. data/lib/virtualbox/abstract_model/dirty.rb +177 -0
  42. data/lib/virtualbox/abstract_model/interface_attributes.rb +98 -0
  43. data/lib/virtualbox/abstract_model/relatable.rb +332 -0
  44. data/lib/virtualbox/abstract_model/validatable.rb +167 -0
  45. data/lib/virtualbox/abstract_model/version_matcher.rb +35 -0
  46. data/lib/virtualbox/appliance.rb +62 -0
  47. data/lib/virtualbox/audio_adapter.rb +52 -0
  48. data/lib/virtualbox/bios.rb +50 -0
  49. data/lib/virtualbox/com.rb +23 -0
  50. data/lib/virtualbox/com/abstract_enum.rb +43 -0
  51. data/lib/virtualbox/com/abstract_implementer.rb +45 -0
  52. data/lib/virtualbox/com/abstract_interface.rb +167 -0
  53. data/lib/virtualbox/com/base_interface.rb +38 -0
  54. data/lib/virtualbox/com/ffi/interface.rb +150 -0
  55. data/lib/virtualbox/com/ffi/interfaces.rb +63 -0
  56. data/lib/virtualbox/com/ffi/util.rb +121 -0
  57. data/lib/virtualbox/com/ffi/vboxxpcomc.rb +31 -0
  58. data/lib/virtualbox/com/ffi_interface.rb +96 -0
  59. data/lib/virtualbox/com/implementer/base.rb +59 -0
  60. data/lib/virtualbox/com/implementer/ffi.rb +381 -0
  61. data/lib/virtualbox/com/implementer/mscom.rb +189 -0
  62. data/lib/virtualbox/com/implementer/nil.rb +10 -0
  63. data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +11 -0
  64. data/lib/virtualbox/com/interface/3.1.x/appliance.rb +22 -0
  65. data/lib/virtualbox/com/interface/3.1.x/audio_adapter.rb +15 -0
  66. data/lib/virtualbox/com/interface/3.1.x/audio_controller_type.rb +11 -0
  67. data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +11 -0
  68. data/lib/virtualbox/com/interface/3.1.x/bios_boot_menu_mode.rb +11 -0
  69. data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +21 -0
  70. data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +11 -0
  71. data/lib/virtualbox/com/interface/3.1.x/console.rb +50 -0
  72. data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +11 -0
  73. data/lib/virtualbox/com/interface/3.1.x/device_type.rb +11 -0
  74. data/lib/virtualbox/com/interface/3.1.x/dhcp_server.rb +22 -0
  75. data/lib/virtualbox/com/interface/3.1.x/firmware_type.rb +11 -0
  76. data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +23 -0
  77. data/lib/virtualbox/com/interface/3.1.x/host.rb +42 -0
  78. data/lib/virtualbox/com/interface/3.1.x/host_network_interface.rb +30 -0
  79. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_medium_type.rb +11 -0
  80. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +11 -0
  81. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_type.rb +11 -0
  82. data/lib/virtualbox/com/interface/3.1.x/host_usb_device.rb +13 -0
  83. data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +13 -0
  84. data/lib/virtualbox/com/interface/3.1.x/hw_virt_ex_property_type.rb +11 -0
  85. data/lib/virtualbox/com/interface/3.1.x/machine.rb +105 -0
  86. data/lib/virtualbox/com/interface/3.1.x/machine_state.rb +14 -0
  87. data/lib/virtualbox/com/interface/3.1.x/medium.rb +50 -0
  88. data/lib/virtualbox/com/interface/3.1.x/medium_attachment.rb +18 -0
  89. data/lib/virtualbox/com/interface/3.1.x/medium_format.rb +18 -0
  90. data/lib/virtualbox/com/interface/3.1.x/medium_state.rb +11 -0
  91. data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +11 -0
  92. data/lib/virtualbox/com/interface/3.1.x/medium_variant.rb +11 -0
  93. data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +30 -0
  94. data/lib/virtualbox/com/interface/3.1.x/network_adapter_type.rb +11 -0
  95. data/lib/virtualbox/com/interface/3.1.x/network_attachment_type.rb +11 -0
  96. data/lib/virtualbox/com/interface/3.1.x/nsiexception.rb +23 -0
  97. data/lib/virtualbox/com/interface/3.1.x/nsisupports.rb +15 -0
  98. data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +17 -0
  99. data/lib/virtualbox/com/interface/3.1.x/port_mode.rb +11 -0
  100. data/lib/virtualbox/com/interface/3.1.x/progress.rb +63 -0
  101. data/lib/virtualbox/com/interface/3.1.x/serial_port.rb +19 -0
  102. data/lib/virtualbox/com/interface/3.1.x/session.rb +18 -0
  103. data/lib/virtualbox/com/interface/3.1.x/session_state.rb +11 -0
  104. data/lib/virtualbox/com/interface/3.1.x/session_type.rb +11 -0
  105. data/lib/virtualbox/com/interface/3.1.x/shared_folder.rb +17 -0
  106. data/lib/virtualbox/com/interface/3.1.x/snapshot.rb +20 -0
  107. data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +11 -0
  108. data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +23 -0
  109. data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +11 -0
  110. data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +37 -0
  111. data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +20 -0
  112. data/lib/virtualbox/com/interface/3.1.x/usb_device.rb +24 -0
  113. data/lib/virtualbox/com/interface/3.1.x/usb_device_filter.rb +23 -0
  114. data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +11 -0
  115. data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +11 -0
  116. data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +17 -0
  117. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +19 -0
  118. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +14 -0
  119. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +11 -0
  120. data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +67 -0
  121. data/lib/virtualbox/com/interface/3.1.x/vrdp_auth_type.rb +11 -0
  122. data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +19 -0
  123. data/lib/virtualbox/com/interface/3.2.x/access_mode.rb +11 -0
  124. data/lib/virtualbox/com/interface/3.2.x/appliance.rb +22 -0
  125. data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +15 -0
  126. data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +11 -0
  127. data/lib/virtualbox/com/interface/3.2.x/audio_driver_type.rb +11 -0
  128. data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +11 -0
  129. data/lib/virtualbox/com/interface/3.2.x/bios_settings.rb +21 -0
  130. data/lib/virtualbox/com/interface/3.2.x/clipboard_mode.rb +11 -0
  131. data/lib/virtualbox/com/interface/3.2.x/console.rb +50 -0
  132. data/lib/virtualbox/com/interface/3.2.x/cpu_property_type.rb +11 -0
  133. data/lib/virtualbox/com/interface/3.2.x/device_type.rb +11 -0
  134. data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +22 -0
  135. data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +11 -0
  136. data/lib/virtualbox/com/interface/3.2.x/guest.rb +13 -0
  137. data/lib/virtualbox/com/interface/3.2.x/guest_os_type.rb +33 -0
  138. data/lib/virtualbox/com/interface/3.2.x/host.rb +43 -0
  139. data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +30 -0
  140. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +11 -0
  141. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_status.rb +11 -0
  142. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +11 -0
  143. data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +13 -0
  144. data/lib/virtualbox/com/interface/3.2.x/host_usb_device_filter.rb +13 -0
  145. data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +11 -0
  146. data/lib/virtualbox/com/interface/3.2.x/keyboard_hid_type.rb +11 -0
  147. data/lib/virtualbox/com/interface/3.2.x/machine.rb +118 -0
  148. data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +14 -0
  149. data/lib/virtualbox/com/interface/3.2.x/medium.rb +51 -0
  150. data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +18 -0
  151. data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +18 -0
  152. data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +11 -0
  153. data/lib/virtualbox/com/interface/3.2.x/medium_type.rb +11 -0
  154. data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +11 -0
  155. data/lib/virtualbox/com/interface/3.2.x/nat_alias_mode.rb +11 -0
  156. data/lib/virtualbox/com/interface/3.2.x/nat_engine.rb +27 -0
  157. data/lib/virtualbox/com/interface/3.2.x/nat_protocol.rb +11 -0
  158. data/lib/virtualbox/com/interface/3.2.x/network_adapter.rb +34 -0
  159. data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +11 -0
  160. data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +11 -0
  161. data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +23 -0
  162. data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +15 -0
  163. data/lib/virtualbox/com/interface/3.2.x/parallel_port.rb +17 -0
  164. data/lib/virtualbox/com/interface/3.2.x/pointing_hid_type.rb +11 -0
  165. data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +11 -0
  166. data/lib/virtualbox/com/interface/3.2.x/progress.rb +63 -0
  167. data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +19 -0
  168. data/lib/virtualbox/com/interface/3.2.x/session.rb +18 -0
  169. data/lib/virtualbox/com/interface/3.2.x/session_state.rb +11 -0
  170. data/lib/virtualbox/com/interface/3.2.x/session_type.rb +11 -0
  171. data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +17 -0
  172. data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +20 -0
  173. data/lib/virtualbox/com/interface/3.2.x/storage_bus.rb +11 -0
  174. data/lib/virtualbox/com/interface/3.2.x/storage_controller.rb +24 -0
  175. data/lib/virtualbox/com/interface/3.2.x/storage_controller_type.rb +11 -0
  176. data/lib/virtualbox/com/interface/3.2.x/system_properties.rb +42 -0
  177. data/lib/virtualbox/com/interface/3.2.x/usb_controller.rb +21 -0
  178. data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +24 -0
  179. data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +23 -0
  180. data/lib/virtualbox/com/interface/3.2.x/usb_device_filter_action.rb +11 -0
  181. data/lib/virtualbox/com/interface/3.2.x/usb_device_state.rb +11 -0
  182. data/lib/virtualbox/com/interface/3.2.x/virtual_box_error_info.rb +17 -0
  183. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description.rb +19 -0
  184. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +14 -0
  185. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_value_type.rb +11 -0
  186. data/lib/virtualbox/com/interface/3.2.x/virtualbox.rb +67 -0
  187. data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +11 -0
  188. data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +21 -0
  189. data/lib/virtualbox/com/interface/4.0.x/access_mode.rb +11 -0
  190. data/lib/virtualbox/com/interface/4.0.x/appliance.rb +23 -0
  191. data/lib/virtualbox/com/interface/4.0.x/audio_adapter.rb +15 -0
  192. data/lib/virtualbox/com/interface/4.0.x/audio_controller_type.rb +11 -0
  193. data/lib/virtualbox/com/interface/4.0.x/audio_driver_type.rb +11 -0
  194. data/lib/virtualbox/com/interface/4.0.x/auth_type.rb +11 -0
  195. data/lib/virtualbox/com/interface/4.0.x/bios_boot_menu_mode.rb +11 -0
  196. data/lib/virtualbox/com/interface/4.0.x/bios_settings.rb +21 -0
  197. data/lib/virtualbox/com/interface/4.0.x/cleanup_mode.rb +12 -0
  198. data/lib/virtualbox/com/interface/4.0.x/clipboard_mode.rb +11 -0
  199. data/lib/virtualbox/com/interface/4.0.x/console.rb +50 -0
  200. data/lib/virtualbox/com/interface/4.0.x/cpu_property_type.rb +11 -0
  201. data/lib/virtualbox/com/interface/4.0.x/device_type.rb +11 -0
  202. data/lib/virtualbox/com/interface/4.0.x/dhcp_server.rb +22 -0
  203. data/lib/virtualbox/com/interface/4.0.x/event_source.rb +13 -0
  204. data/lib/virtualbox/com/interface/4.0.x/fault_tolerance_state.rb +11 -0
  205. data/lib/virtualbox/com/interface/4.0.x/firmware_type.rb +11 -0
  206. data/lib/virtualbox/com/interface/4.0.x/guest.rb +13 -0
  207. data/lib/virtualbox/com/interface/4.0.x/guest_os_type.rb +33 -0
  208. data/lib/virtualbox/com/interface/4.0.x/host.rb +43 -0
  209. data/lib/virtualbox/com/interface/4.0.x/host_network_interface.rb +30 -0
  210. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_medium_type.rb +11 -0
  211. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_status.rb +11 -0
  212. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_type.rb +11 -0
  213. data/lib/virtualbox/com/interface/4.0.x/host_usb_device.rb +13 -0
  214. data/lib/virtualbox/com/interface/4.0.x/host_usb_device_filter.rb +13 -0
  215. data/lib/virtualbox/com/interface/4.0.x/hw_virt_ex_property_type.rb +12 -0
  216. data/lib/virtualbox/com/interface/4.0.x/keyboard_hid_type.rb +11 -0
  217. data/lib/virtualbox/com/interface/4.0.x/lock_type.rb +11 -0
  218. data/lib/virtualbox/com/interface/4.0.x/machine.rb +132 -0
  219. data/lib/virtualbox/com/interface/4.0.x/machine_state.rb +14 -0
  220. data/lib/virtualbox/com/interface/4.0.x/medium.rb +53 -0
  221. data/lib/virtualbox/com/interface/4.0.x/medium_attachment.rb +18 -0
  222. data/lib/virtualbox/com/interface/4.0.x/medium_format.rb +18 -0
  223. data/lib/virtualbox/com/interface/4.0.x/medium_state.rb +11 -0
  224. data/lib/virtualbox/com/interface/4.0.x/medium_type.rb +11 -0
  225. data/lib/virtualbox/com/interface/4.0.x/medium_variant.rb +11 -0
  226. data/lib/virtualbox/com/interface/4.0.x/nat_alias_mode.rb +11 -0
  227. data/lib/virtualbox/com/interface/4.0.x/nat_engine.rb +27 -0
  228. data/lib/virtualbox/com/interface/4.0.x/nat_protocol.rb +11 -0
  229. data/lib/virtualbox/com/interface/4.0.x/network_adapter.rb +35 -0
  230. data/lib/virtualbox/com/interface/4.0.x/network_adapter_type.rb +11 -0
  231. data/lib/virtualbox/com/interface/4.0.x/network_attachment_type.rb +11 -0
  232. data/lib/virtualbox/com/interface/4.0.x/nsiexception.rb +23 -0
  233. data/lib/virtualbox/com/interface/4.0.x/nsisupports.rb +15 -0
  234. data/lib/virtualbox/com/interface/4.0.x/parallel_port.rb +17 -0
  235. data/lib/virtualbox/com/interface/4.0.x/pointing_hid_type.rb +11 -0
  236. data/lib/virtualbox/com/interface/4.0.x/port_mode.rb +11 -0
  237. data/lib/virtualbox/com/interface/4.0.x/progress.rb +64 -0
  238. data/lib/virtualbox/com/interface/4.0.x/serial_port.rb +19 -0
  239. data/lib/virtualbox/com/interface/4.0.x/session.rb +18 -0
  240. data/lib/virtualbox/com/interface/4.0.x/session_state.rb +11 -0
  241. data/lib/virtualbox/com/interface/4.0.x/session_type.rb +11 -0
  242. data/lib/virtualbox/com/interface/4.0.x/shared_folder.rb +17 -0
  243. data/lib/virtualbox/com/interface/4.0.x/snapshot.rb +20 -0
  244. data/lib/virtualbox/com/interface/4.0.x/storage_bus.rb +11 -0
  245. data/lib/virtualbox/com/interface/4.0.x/storage_controller.rb +24 -0
  246. data/lib/virtualbox/com/interface/4.0.x/storage_controller_type.rb +11 -0
  247. data/lib/virtualbox/com/interface/4.0.x/system_properties.rb +42 -0
  248. data/lib/virtualbox/com/interface/4.0.x/usb_controller.rb +21 -0
  249. data/lib/virtualbox/com/interface/4.0.x/usb_device.rb +24 -0
  250. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter.rb +23 -0
  251. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter_action.rb +11 -0
  252. data/lib/virtualbox/com/interface/4.0.x/usb_device_state.rb +11 -0
  253. data/lib/virtualbox/com/interface/4.0.x/virtual_box_error_info.rb +17 -0
  254. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description.rb +19 -0
  255. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_type.rb +14 -0
  256. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_value_type.rb +11 -0
  257. data/lib/virtualbox/com/interface/4.0.x/virtualbox.rb +50 -0
  258. data/lib/virtualbox/com/interface/4.0.x/vrde_server.rb +23 -0
  259. data/lib/virtualbox/com/mscom_interface.rb +44 -0
  260. data/lib/virtualbox/com/nil_interface.rb +7 -0
  261. data/lib/virtualbox/com/util.rb +32 -0
  262. data/lib/virtualbox/cpu.rb +61 -0
  263. data/lib/virtualbox/dhcp_server.rb +89 -0
  264. data/lib/virtualbox/dvd.rb +27 -0
  265. data/lib/virtualbox/exceptions.rb +39 -0
  266. data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
  267. data/lib/virtualbox/ext/glob_loader.rb +35 -0
  268. data/lib/virtualbox/ext/logger.rb +38 -0
  269. data/lib/virtualbox/ext/platform.rb +31 -0
  270. data/lib/virtualbox/ext/subclass_listing.rb +24 -0
  271. data/lib/virtualbox/extra_data.rb +127 -0
  272. data/lib/virtualbox/forwarded_port.rb +222 -0
  273. data/lib/virtualbox/global.rb +96 -0
  274. data/lib/virtualbox/hard_drive.rb +246 -0
  275. data/lib/virtualbox/host.rb +71 -0
  276. data/lib/virtualbox/host_network_interface.rb +137 -0
  277. data/lib/virtualbox/hw_virtualization.rb +64 -0
  278. data/lib/virtualbox/lib.rb +84 -0
  279. data/lib/virtualbox/media.rb +20 -0
  280. data/lib/virtualbox/medium.rb +145 -0
  281. data/lib/virtualbox/medium_attachment.rb +61 -0
  282. data/lib/virtualbox/nat_engine.rb +71 -0
  283. data/lib/virtualbox/nat_forwarded_port.rb +171 -0
  284. data/lib/virtualbox/network_adapter.rb +166 -0
  285. data/lib/virtualbox/proxies/collection.rb +57 -0
  286. data/lib/virtualbox/shared_folder.rb +220 -0
  287. data/lib/virtualbox/snapshot.rb +185 -0
  288. data/lib/virtualbox/storage_controller.rb +160 -0
  289. data/lib/virtualbox/system_properties.rb +73 -0
  290. data/lib/virtualbox/usb_controller.rb +59 -0
  291. data/lib/virtualbox/usb_device_filter.rb +74 -0
  292. data/lib/virtualbox/version.rb +36 -0
  293. data/lib/virtualbox/virtual_system_description.rb +47 -0
  294. data/lib/virtualbox/vm.rb +649 -0
  295. data/lib/virtualbox/vrde_server.rb +57 -0
  296. data/test/test_helper.rb +18 -0
  297. data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
  298. data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
  299. data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
  300. data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
  301. data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
  302. data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
  303. data/test/virtualbox/abstract_model_test.rb +462 -0
  304. data/test/virtualbox/appliance_test.rb +159 -0
  305. data/test/virtualbox/audio_adapter_test.rb +83 -0
  306. data/test/virtualbox/bios_test.rb +83 -0
  307. data/test/virtualbox/com/abstract_enum_test.rb +49 -0
  308. data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
  309. data/test/virtualbox/com/abstract_interface_test.rb +140 -0
  310. data/test/virtualbox/com/ffi/interface_test.rb +249 -0
  311. data/test/virtualbox/com/ffi/util_test.rb +108 -0
  312. data/test/virtualbox/com/ffi_interface_test.rb +42 -0
  313. data/test/virtualbox/com/implementer/base_test.rb +38 -0
  314. data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
  315. data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
  316. data/test/virtualbox/com/mscom_interface_test.rb +17 -0
  317. data/test/virtualbox/com/util_test.rb +17 -0
  318. data/test/virtualbox/cpu_test.rb +103 -0
  319. data/test/virtualbox/dhcp_server_test.rb +165 -0
  320. data/test/virtualbox/dvd_test.rb +28 -0
  321. data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
  322. data/test/virtualbox/ext/platform_test.rb +50 -0
  323. data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
  324. data/test/virtualbox/extra_data_test.rb +155 -0
  325. data/test/virtualbox/forwarded_port_test.rb +286 -0
  326. data/test/virtualbox/global_test.rb +46 -0
  327. data/test/virtualbox/hard_drive_test.rb +141 -0
  328. data/test/virtualbox/host_network_interface_test.rb +255 -0
  329. data/test/virtualbox/host_test.rb +94 -0
  330. data/test/virtualbox/hw_virtualization_test.rb +103 -0
  331. data/test/virtualbox/lib_test.rb +93 -0
  332. data/test/virtualbox/medium_attachment_test.rb +147 -0
  333. data/test/virtualbox/medium_test.rb +192 -0
  334. data/test/virtualbox/nat_engine_test.rb +106 -0
  335. data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
  336. data/test/virtualbox/network_adapter_test.rb +191 -0
  337. data/test/virtualbox/proxies/collection_test.rb +102 -0
  338. data/test/virtualbox/shared_folder_test.rb +219 -0
  339. data/test/virtualbox/snapshot_test.rb +231 -0
  340. data/test/virtualbox/storage_controller_test.rb +197 -0
  341. data/test/virtualbox/system_properties_test.rb +87 -0
  342. data/test/virtualbox/usb_controller_test.rb +112 -0
  343. data/test/virtualbox/usb_device_filter_test.rb +93 -0
  344. data/test/virtualbox/version_test.rb +59 -0
  345. data/test/virtualbox/virtual_system_description_test.rb +61 -0
  346. data/test/virtualbox/vm_test.rb +633 -0
  347. data/test/virtualbox/vrde_server_test.rb +83 -0
  348. data/test/virtualbox_test.rb +11 -0
  349. data/virtualbox.gemspec +24 -0
  350. metadata +464 -0
@@ -0,0 +1,59 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Implementer
4
+ class Base < AbstractImplementer
5
+ include Logger
6
+
7
+ # Returns the Ruby version as a float
8
+ #
9
+ # @return [Float]
10
+ def ruby_version
11
+ RUBY_VERSION.to_f
12
+ end
13
+
14
+ # Finds and returns the `COM::Interface` class associated with the type.
15
+ # If the class does not exist, a `NameError` will be raised.
16
+ #
17
+ # @return [Class]
18
+ def interface_klass(type)
19
+ ::VirtualBox::COM::FFI::Util.interface_klass(type)
20
+ end
21
+
22
+ # Gives the C type and inferred type of a parameter type. Quite confusing
23
+ # since the terminology is not consistent, but hopefully these examples
24
+ # will help:
25
+ #
26
+ # type => [pointer_type, internal_type]
27
+ # :int => [:int, :int]
28
+ # :MyStruct => [:pointer, :struct]
29
+ # :unicode_string => [:pointer, :unicode_string]
30
+ #
31
+ def infer_type(type)
32
+ c_type = type
33
+
34
+ begin
35
+ if type == WSTRING
36
+ # Handle strings as pointer types
37
+ c_type = :pointer
38
+ else
39
+ # Try to get the class from the interfaces
40
+ interface = interface_klass(type)
41
+
42
+ c_type = :pointer
43
+
44
+ # Depending on the class type, we're either dealing with an interface
45
+ # or an enum
46
+ type = :interface if interface.superclass == COM::AbstractInterface
47
+ type = :enum if interface.superclass == COM::AbstractEnum
48
+ end
49
+ rescue NameError
50
+ # Do nothing
51
+ end
52
+
53
+ [c_type, type]
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,381 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Implementer
4
+ class FFI < Base
5
+ attr_reader :ffi_interface
6
+
7
+ # Initializes the FFI implementer which takes an {VirtualBox::COM::AbstractInterface AbstractInterface}
8
+ # instant and FFI pointer and initializes everything required to
9
+ # communicate with that interface via FFI.
10
+ #
11
+ # @param [VirtualBox::COM::AbstractInteface] inteface
12
+ # @param [FFI::Pointer] pointer
13
+ def initialize(interface, lib_base, pointer)
14
+ super(interface, lib_base)
15
+
16
+ @ffi_interface = ffi_class.new(pointer)
17
+ end
18
+
19
+ # Gets the FFI struct class associated with the interface. This works
20
+ # by stripping the namespace off of the interface class and finding that
21
+ # same class within the `COM::FFI` namespace. For example:
22
+ # `VirtualBox::COM::Interface::Session` becomes `VirtualBox::COM::FFI::Session`
23
+ #
24
+ # @return [Class]
25
+ def ffi_class
26
+ # Take off the last part of the class, so `Foo::Bar::Baz` becomes
27
+ # just `Baz`
28
+ klass_name = interface.class.to_s.split("::").last
29
+
30
+ # Get the associated FFI class
31
+ COM::FFI.const_get(::VirtualBox::COM::Util.version_const).const_get(klass_name)
32
+ end
33
+
34
+ # Reads a property from the interface with the given name.
35
+ def read_property(name, opts)
36
+ call_vtbl_function("get_#{name}".to_sym, [[:out, opts[:value_type]]])
37
+ end
38
+
39
+ # Writes a property to the interface with the given name and value.
40
+ def write_property(name, value, opts)
41
+ call_vtbl_function("set_#{name}".to_sym, [opts[:value_type]], [value])
42
+ end
43
+
44
+ # Calls a function from the interface with the given name and args. This
45
+ # method is called from the {AbstractInterface}.
46
+ def call_function(name, args, opts)
47
+ spec = opts[:spec].dup
48
+ spec << [:out, opts[:value_type]] if !opts[:value_type].nil?
49
+
50
+ call_vtbl_function(name.to_sym, spec, args)
51
+ end
52
+
53
+ # Calls a function on the vtbl of the FFI struct. This function handles
54
+ # converting the spec to proper arguments and also handles reading out
55
+ # the arguments, dereferencing pointers, setting up objects, etc. so that
56
+ # the return value is filled with nicely formatted Ruby objects.
57
+ #
58
+ # If the vtbl function being called only has one out parameter, then the
59
+ # return value will be that single object. If it has multiple, then it will
60
+ # be an array of objects.
61
+ def call_vtbl_function(name, spec, args=[])
62
+ # Get the "formal argument" list. This is the list of arguments to send
63
+ # to the actual function based on the spec. This contains pointers, some
64
+ # arguments from `args`, etc.
65
+ formal_args = spec_to_args(spec, args)
66
+
67
+ # Call the function.
68
+ logger.debug("FFI call: #{name} #{args.inspect} #{formal_args.inspect}")
69
+ call_and_check(name, ffi_interface.vtbl_parent, *formal_args)
70
+
71
+ # Extract the values from the formal args array, again based on the
72
+ # spec (and the various :out parameters)
73
+ result = values_from_formal_args(spec, formal_args)
74
+ logger.debug(" = #{result.inspect}")
75
+ result
76
+ end
77
+
78
+ #############################################################
79
+ # Internal Methods, a.k.a. unless you're hacking on the code of this
80
+ # library, you should do well to leave these alone =]
81
+ #############################################################
82
+
83
+ # Checks the result of a method call for an error, and if an error
84
+ # occurs, then raises an exception.
85
+ def call_and_check(function, *args)
86
+ result = ffi_interface.vtbl[function].call(*args)
87
+
88
+ # Ignore NS_ERROR_NOT_IMPLEMENTED, since it seems to be raised for
89
+ # things which aren't really exceptional
90
+ if result != 2147500033 && (result & 0x8000_0000) != 0
91
+ # Failure, raise exception with details of the error
92
+ raise exception_map(result).new({
93
+ :function => function.to_s,
94
+ :result_code => result
95
+ })
96
+ end
97
+ end
98
+
99
+ # Maps a result code to an exception. If no mapping currently exists,
100
+ # then a regular {Exceptions::FFIException} is returned.
101
+ #
102
+ # @param [Fixnum] code Result code
103
+ # @return [Class]
104
+ def exception_map(code)
105
+ map = {
106
+ 0x80BB_0001 => Exceptions::ObjectNotFoundException,
107
+ 0x80BB_0002 => Exceptions::InvalidVMStateException,
108
+ 0x80BB_0003 => Exceptions::VMErrorException,
109
+ 0x80BB_0004 => Exceptions::FileErrorException,
110
+ 0x80BB_0005 => Exceptions::SubsystemException,
111
+ 0x80BB_0006 => Exceptions::PDMException,
112
+ 0x80BB_0007 => Exceptions::InvalidObjectStateException,
113
+ 0x80BB_0008 => Exceptions::HostErrorException,
114
+ 0x80BB_0009 => Exceptions::NotSupportedException,
115
+ 0x80BB_000A => Exceptions::XMLErrorException,
116
+ 0x80BB_000B => Exceptions::InvalidSessionStateException,
117
+ 0x80BB_000C => Exceptions::ObjectInUseException
118
+ }
119
+
120
+ map[code] || Exceptions::FFIException
121
+ end
122
+
123
+ # Converts a function spec to a proper argument list with the given
124
+ # arguments.
125
+ #
126
+ # @return [Array]
127
+ def spec_to_args(spec, args=[])
128
+ args = args.dup
129
+
130
+ results = spec.inject([]) do |results, item|
131
+ single_type_to_arg(args, item, results)
132
+ end
133
+ end
134
+
135
+ # Converts a single type and args list to the proper formal args list
136
+ def single_type_to_arg(args, item, results)
137
+ if item.is_a?(Array) && item[0] == :out
138
+ if item[1].is_a?(Array)
139
+ # For arrays we need two pointers: one for size, and one for the
140
+ # actual array
141
+ results << pointer_for_type(T_UINT32)
142
+ results << pointer_for_type(item[1][0])
143
+ else
144
+ results << pointer_for_type(item[1])
145
+ end
146
+ elsif item.is_a?(Array) && item.length == 1
147
+ # Array argument
148
+ data = args.shift
149
+
150
+ # First add the length of the array
151
+ results << data.length
152
+
153
+ # Create the array
154
+ c_type, type = infer_type(item.first)
155
+
156
+ # If its a regular type (int, bool, etc.) then just make it an
157
+ # array of that
158
+ if type != :interface
159
+ results << data.inject([]) do |converted_data, single|
160
+ single_type_to_arg([single], item[0], converted_data)
161
+ end
162
+ else
163
+ # Then convert the rest into a raw MemoryPointer
164
+ array = ::FFI::MemoryPointer.new(:pointer, data.length)
165
+ data.each_with_index do |datum, i|
166
+ converted = []
167
+ single_type_to_arg([datum], item.first, converted)
168
+ array[i].put_pointer(0, converted.first)
169
+ end
170
+
171
+ results << array
172
+ end
173
+ elsif item == WSTRING
174
+ # We have to convert the arg to a unicode string
175
+ results << string_to_utf16(args.shift)
176
+ elsif item == T_BOOL
177
+ results << (args.shift ? 1 : 0)
178
+ elsif item.to_s[0,1] == item.to_s[0,1].upcase
179
+ # Try to get the class from the interfaces
180
+ interface = interface_klass(item.to_sym)
181
+
182
+ if interface.superclass == COM::AbstractInterface
183
+ # For interfaces, get the instance, then dig deep to get the pointer
184
+ # to the VtblParent, which is what the API expects
185
+ instance = args.shift
186
+
187
+ results << if !instance.nil?
188
+ instance.implementer.ffi_interface.vtbl_parent
189
+ else
190
+ # If the argument was nil, just pass a nil pointer as the argument
191
+ nil
192
+ end
193
+ elsif interface.superclass == COM::AbstractEnum
194
+ # For enums, we need the value of the enum
195
+ results << interface.index(args.shift.to_sym)
196
+ end
197
+ else
198
+ # Simply replace spec item with next item in args
199
+ # list
200
+ results << args.shift
201
+ end
202
+ end
203
+
204
+ # Takes a spec and a formal parameter list and returns the output from
205
+ # a function, properly dereferencing any output pointers.
206
+ #
207
+ # @param [Array] specs The parameter spec for the function
208
+ # @param [Array] formal The formal parameter list
209
+ def values_from_formal_args(specs, formal)
210
+ return_values = []
211
+ i = 0
212
+ specs.each do |spec|
213
+ # Output parameters are all we care about
214
+ if spec.is_a?(Array) && spec[0] == :out
215
+ if spec[1].is_a?(Array)
216
+ # We are dealing with formal[i] and formal[i+1] here, where
217
+ # the first has the size and the second has the contents
218
+ return_values << dereference_pointer_array(formal[i+1], spec[1][0], dereference_pointer(formal[i], T_UINT32))
219
+
220
+ # Increment once more to skip the size param
221
+ i += 1
222
+ else
223
+ return_values << dereference_pointer(formal[i], spec[1])
224
+ end
225
+ end
226
+
227
+ i += 1
228
+ end
229
+
230
+ if return_values.empty?
231
+ nil
232
+ elsif return_values.length == 1
233
+ return_values.first
234
+ else
235
+ return_values
236
+ end
237
+ end
238
+
239
+ # Dereferences a pointer with a given type into a proper Ruby object.
240
+ # If the type is a standard primitive of Ruby-FFI, it simply calls the
241
+ # proper `get_*` method on the pointer. Otherwise, it calls a
242
+ # `read_*` on the Util class.
243
+ #
244
+ # @param [FFI::MemoryPointer] pointer
245
+ # @param [Symbol] type The type of the pointer
246
+ # @return [Object] The value of the dereferenced pointer
247
+ def dereference_pointer(pointer, type)
248
+ c_type, inferred_type = infer_type(type)
249
+
250
+ if pointer.respond_to?("get_#{inferred_type}".to_sym)
251
+ # This handles reading the typical times such as :uint, :int, etc.
252
+ result = pointer.send("get_#{inferred_type}".to_sym, 0)
253
+ result = !(result == 0) if type == T_BOOL
254
+ result
255
+ else
256
+ send("read_#{inferred_type}".to_sym, pointer, type)
257
+ end
258
+ end
259
+
260
+ # Dereferences an array out of a pointer into an array of proper Ruby
261
+ # objects.
262
+ #
263
+ # @param [FFI::MemoryPointer] pointer
264
+ # @param [Symbol] type The type of the pointer
265
+ # @param [Fixnum] length The length of the array
266
+ # @return [Array<Object>]
267
+ def dereference_pointer_array(pointer, type, length)
268
+ # If there are no items in the pointer, just return an empty array
269
+ return [] if length == 0
270
+
271
+ c_type, inferred_type = infer_type(type)
272
+
273
+ array_pointer = pointer.get_pointer(0)
274
+ if array_pointer.respond_to?("get_array_of_#{inferred_type}".to_sym)
275
+ # This handles reading the typical times such as :uint, :int, etc.
276
+ array_pointer.send("get_array_of_#{inferred_type}".to_sym, 0, length)
277
+ else
278
+ send("read_array_of_#{inferred_type}".to_sym, array_pointer, type, length)
279
+ end
280
+ end
281
+
282
+ # Converts a symbol type into a MemoryPointer and yield a block
283
+ # with the pointer, the C type, and the FFI type
284
+ def pointer_for_type(type)
285
+ c_type, type = infer_type(type)
286
+
287
+ # Create the pointer, yield, returning the result of the block
288
+ # if a block is given, or otherwise just returning the pointer
289
+ # and inferred type
290
+ pointer = ::FFI::MemoryPointer.new(c_type)
291
+ if block_given?
292
+ yield pointer, type
293
+ else
294
+ pointer
295
+ end
296
+ end
297
+
298
+ # Converts a ruby string to a UTF16 string
299
+ #
300
+ # @param [String] Ruby String object
301
+ # @return [::FFI::Pointer]
302
+ def string_to_utf16(string)
303
+ return nil if string.nil?
304
+
305
+ ptr = pointer_for_type(:pointer)
306
+ lib.xpcom[:pfnUtf8ToUtf16].call(string, ptr)
307
+ ptr.read_pointer()
308
+ end
309
+
310
+ # Converts a UTF16 string to UTF8
311
+ def utf16_to_string(pointer)
312
+ result_pointer = pointer_for_type(:pointer)
313
+ lib.xpcom[:pfnUtf16ToUtf8].call(pointer, result_pointer)
314
+ lib.xpcom[:pfnUtf16Free].call(pointer)
315
+ result_pointer.read_pointer().read_string().to_s
316
+ end
317
+
318
+ # Reads a unicode string value from a pointer to that value.
319
+ #
320
+ # @return [String]
321
+ def read_unicode_string(ptr, original_type=nil)
322
+ address = ptr.get_pointer(0)
323
+ return "" if address.null?
324
+ utf16_to_string(address)
325
+ end
326
+
327
+ # Reads an interface from the pointer
328
+ #
329
+ # @return [::FFI::Struct]
330
+ def read_interface(ptr, original_type)
331
+ ptr = ptr.get_pointer(0)
332
+ return nil if ptr.null?
333
+
334
+ klass = interface_klass(original_type)
335
+ klass.new(self.class, lib, ptr)
336
+ end
337
+
338
+ # Reads an enum
339
+ #
340
+ # @return [Symbol]
341
+ def read_enum(ptr, original_type)
342
+ klass = interface_klass(original_type)
343
+ klass[ptr.get_uint(0)]
344
+ end
345
+
346
+ # Reads an array of enums
347
+ #
348
+ # @return [Array<Symbol>]
349
+ def read_array_of_enum(ptr, type, length)
350
+ klass = interface_klass(type)
351
+ ptr.get_array_of_uint(0, length).collect do |value|
352
+ klass[value]
353
+ end
354
+ end
355
+
356
+ # Reads an array of structs from a pointer
357
+ #
358
+ # @return [Array<::FFI::Struct>]
359
+ def read_array_of_interface(ptr, type, length)
360
+ klass = interface_klass(type)
361
+ ptr.get_array_of_pointer(0, length).collect do |single_pointer|
362
+ klass.new(self.class, lib, single_pointer)
363
+ end
364
+ end
365
+
366
+ # Reads an array of strings from a pointer
367
+ #
368
+ # @return [Array<String>]
369
+ def read_array_of_unicode_string(ptr, type, length)
370
+ ptr.get_array_of_pointer(0, length).collect do |single_pointer|
371
+ if single_pointer.null?
372
+ nil
373
+ else
374
+ utf16_to_string(single_pointer)
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
@@ -0,0 +1,189 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Implementer
4
+ class MSCOM < Base
5
+ attr_reader :object
6
+
7
+ # Initializes the MSCOM implementer.
8
+ #
9
+ # @param [AbstractInterface] inteface
10
+ # @param [FFI::Pointer] pointer
11
+ def initialize(interface, lib_base, object)
12
+ super(interface, lib_base)
13
+
14
+ @object = object
15
+ end
16
+
17
+ # Reads a property from the interface with the given name.
18
+ def read_property(name, opts)
19
+ # First get the basic value from the COM object
20
+ method = COM::FFI::Util.camelize(name.to_s)
21
+ value = if ruby_version >= 1.9
22
+ @object.send(method)
23
+ else
24
+ @object[method]
25
+ end
26
+
27
+ # Then depending on the value type, we either return as-is or
28
+ # must wrap it up in another interface class
29
+ returnable_value(value, opts[:value_type])
30
+ end
31
+
32
+ # Writes a property from the interface with the given name and
33
+ # value.
34
+ def write_property(name, value, opts)
35
+ # Set the property with a prepared value
36
+ method = COM::FFI::Util.camelize(name.to_s)
37
+ value = spec_to_args([opts[:value_type]], [value]).first
38
+
39
+ if ruby_version >= 1.9
40
+ @object.send("#{method}=", value)
41
+ else
42
+ @object[method] = value
43
+ end
44
+ end
45
+
46
+ # Calls a function from the interface with the given name
47
+ def call_function(name, args, opts)
48
+ # Convert args to proper values to send and send em!
49
+ args = spec_to_args(opts[:spec], args)
50
+ value = @object.send(COM::FFI::Util.camelize(name.to_s), *args)
51
+
52
+ # TODO: Multiple return values
53
+ returnable_value(value, opts[:value_type])
54
+ end
55
+
56
+ #############################################################
57
+ # Internal Methods, a.k.a. unless you're hacking on the code of this
58
+ # library, you should do well to leave these alone =]
59
+ #############################################################
60
+
61
+ # Takes a function spec and an argument list. This handles properly converting
62
+ # enums to ints and {AbstractInterface}s to proper MSCOM interfaces.
63
+ def spec_to_args(spec, args)
64
+ args = args.dup
65
+
66
+ # First remove all :out parameters from the spec, since those are of no
67
+ # concern for MSCOM at this point
68
+ spec = spec.collect do |item|
69
+ if item.is_a?(Array) && item[0] == :out
70
+ nil
71
+ else
72
+ item
73
+ end
74
+ end.compact
75
+
76
+ spec = spec.inject([]) do |results, item|
77
+ single_type_to_arg(args, item, results)
78
+ end
79
+ end
80
+
81
+ # Converts a single type and args list to the proper formal args list
82
+ def single_type_to_arg(args, item, results)
83
+ if item.is_a?(Array) && item.length == 1
84
+ # Array argument
85
+ data = args.shift
86
+
87
+ # If its a regular type (int, bool, etc.) then just make it an
88
+ # array of that
89
+ results << data.inject([]) do |converted_data, single|
90
+ single_type_to_arg([single], item[0], converted_data)
91
+ end
92
+ elsif item.to_s[0,1] == item.to_s[0,1].upcase
93
+ # Try to get the class from the interfaces
94
+ interface = interface_klass(item.to_sym)
95
+
96
+ if interface.superclass == COM::AbstractInterface
97
+ # For interfaces, get the instance, then dig deep to get the pointer
98
+ # to the VtblParent, which is what the API expects
99
+ instance = args.shift
100
+
101
+ results << if !instance.nil?
102
+ # Get the actual MSCOM object, rather than the AbstractInterface
103
+ instance.implementer.object
104
+ else
105
+ # If the argument was nil, just pass a nil pointer as the argument
106
+ nil
107
+ end
108
+ elsif interface.superclass == COM::AbstractEnum
109
+ # For enums, we need the value of the enum
110
+ results << interface.index(args.shift.to_sym)
111
+ end
112
+ elsif item == T_BOOL
113
+ results << (args.shift ? 1 : 0)
114
+ else
115
+ # Simply replace spec item with next item in args
116
+ # list
117
+ results << args.shift
118
+ end
119
+ end
120
+
121
+ # Takes a value (returned from a WIN32OLE object) and a type and converts
122
+ # to a proper ruby return value type.
123
+ def returnable_value(value, type)
124
+ # Types which are void or nil just return
125
+ return nil if type.nil? || type == :void
126
+
127
+ klass = type.is_a?(Array) ? type.first : type
128
+ ignore, inferred_type = infer_type(klass)
129
+
130
+ array_of = type.is_a?(Array) ? "array_of_" : ""
131
+ send("read_#{array_of}#{inferred_type}", value, type)
132
+ end
133
+
134
+ def read_unicode_string(value, type)
135
+ # Return as-is
136
+ value
137
+ end
138
+
139
+ def read_char(value, type)
140
+ # Convert to a boolean
141
+ !(value.to_s == "0")
142
+ end
143
+
144
+ def read_ushort(value, type)
145
+ value.to_i
146
+ end
147
+
148
+ def read_uint(value, type)
149
+ value.to_i
150
+ end
151
+
152
+ def read_ulong(value, type)
153
+ value.to_i
154
+ end
155
+
156
+ def read_int(value, type)
157
+ value.to_i
158
+ end
159
+
160
+ def read_long(value, type)
161
+ value.to_i
162
+ end
163
+
164
+ def read_enum(value, type)
165
+ interface_klass(type)[value]
166
+ end
167
+
168
+ def read_interface(value, type)
169
+ return nil if value.nil?
170
+ interface_klass(type).new(self.class, lib, value)
171
+ end
172
+
173
+ def read_array_of_unicode_string(value, type)
174
+ # Return as-is, since MSCOM returns ruby strings!
175
+ value
176
+ end
177
+
178
+ def read_array_of_interface(value, type)
179
+ klass = interface_klass(type.first)
180
+ value.collect do |item|
181
+ if !item.nil?
182
+ klass.new(self.class, lib, item)
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end