virtualbox-com 0.9.6

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.
@@ -0,0 +1,54 @@
1
+ module VirtualBox
2
+ module COM
3
+
4
+ module XPCOMC
5
+ extend ::FFI::Library
6
+
7
+ # Constant used to initialize the XPCOM C interface
8
+ VERSION = 0x00020000
9
+
10
+
11
+ # Callback types for VBOX XPCOMC
12
+ callback :pfnGetVersion, [], :uint
13
+ callback :pfnComInitialize, [:string,:pointer,:string,:pointer], :void
14
+ callback :pfnComUninitialize, [], :void
15
+ callback :pfnComUnallocMem, [:pointer], :void
16
+ callback :pfnUtf16Free, [:pointer], :void
17
+ callback :pfnUtf8Free, [:string ], :void
18
+ callback :pfnUtf16ToUtf8, [:pointer, :pointer], :int
19
+ callback :pfnUtf8ToUtf16, [:string, :pointer], :int
20
+ callback :pfnGetEventQueue, [:pointer], :void
21
+
22
+ class VBox < ::FFI::Struct
23
+ layout :cb, :uint,
24
+ :uVersion, :uint,
25
+ :pfnGetVersion, :pfnGetVersion,
26
+ :pfnComInitialize, :pfnComInitialize,
27
+ :pfnComUninitialize, :pfnComUninitialize,
28
+ :pfnComUnallocMem, :pfnComUnallocMem,
29
+ :pfnUtf16Free, :pfnUtf16Free,
30
+ :pfnUtf8Free, :pfnUtf8Free,
31
+ :pfnUtf16ToUtf8, :pfnUtf16ToUtf8,
32
+ :pfnUtf8ToUtf16, :pfnUtf8ToUtf16,
33
+ :pfnGetEventQueue, :pfnGetEventQueue,
34
+ :uEndVersion, :uint
35
+
36
+ def string_to_utf16(string)
37
+ return nil if string.nil?
38
+ ptr = ::FFI::MemoryPointer.new(:pointer)
39
+ self[:pfnUtf8ToUtf16].call(string.dup, ptr)
40
+ ptr.read_pointer()
41
+ end
42
+
43
+ def utf16_to_string(pointer)
44
+ return nil if pointer.null?
45
+ result_pointer = ::FFI::MemoryPointer.new(:pointer)
46
+ self[:pfnUtf16ToUtf8].call(pointer, result_pointer)
47
+ self[:pfnUtf16Free].call(pointer)
48
+ result_pointer.read_pointer().read_string()
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,124 @@
1
+ require 'bundler/setup'
2
+ require 'nokogiri'
3
+ require 'virtualbox/com/util'
4
+
5
+ XIDL = Nokogiri::XML(File.new("../VirtualBox.xidl"))
6
+ LIB = XIDL.root.xpath('library')
7
+
8
+
9
+
10
+ io = $stdout
11
+
12
+ io << <<-EOT
13
+ #
14
+ # This file has been automatically generated from the VirtualBox.xidl
15
+ #
16
+
17
+ EOT
18
+
19
+ io << "module VirtualBox\n"
20
+ io << "module COM\n"
21
+ io << "module Model\n"
22
+ io << "\n"
23
+
24
+ io << "VERSION = \"4.2\"\n"
25
+ io << "\n"
26
+
27
+ io << <<-EOT
28
+ class NSISupports < AbstractInterface
29
+ iid "00000000-0000-0000-c000-000000000046"
30
+ function :QueryInterface, :pointer, [ :pointer ], :hide => true
31
+ function :AddRef, nil, [], :hide => true
32
+ function :Release, nil, [], :hide => true
33
+ end
34
+
35
+ EOT
36
+
37
+
38
+ def uncamelize(string)
39
+ VirtualBox::COM::Util.uncamelize(string)
40
+ end
41
+
42
+ def cnv_type(name, array=nil, ptr=nil)
43
+ return ':pointer' if ptr
44
+ t = case name
45
+ when 'boolean' then 'BOOL'
46
+ when 'octet' then 'UINT8'
47
+ when 'short' then 'INT16'
48
+ when 'unsigned short' then 'UINT16'
49
+ when 'long' then 'INT32'
50
+ when 'long long' then 'INT64'
51
+ when 'unsigned long' then 'UINT32'
52
+ when 'unsigned long long' then 'UINT64'
53
+ when 'uuid' then 'WSTRING'
54
+ when 'wstring' then 'WSTRING'
55
+ when '$unknown' then ':NSISupports'
56
+ else ':'+ name.gsub(/^I/, '')
57
+ end
58
+ t = '[' + t + ']' if array
59
+ t
60
+ end
61
+
62
+
63
+ # Enumeration
64
+ for enum in LIB.xpath('enum')
65
+ io << "class #{enum[:name]} < AbstractEnum\n"
66
+ io << " iid \"#{enum[:uuid]}\"\n"
67
+ io << " map({\n"
68
+ enum.xpath('const').each {|c|
69
+ io << " :%-40s => %s,\n" % [ uncamelize(c[:name]), c[:value] ] }
70
+ io << " })\n"
71
+ io << " setup\n"
72
+ io << "end\n"
73
+ io << "\n"
74
+ end
75
+
76
+ # Interface
77
+ for interface in LIB.xpath('interface')
78
+ io << "class #{interface[:name][1..-1]} < AbstractInterface\n"
79
+ io << " iid \"#{interface[:uuid]}\"\n"
80
+
81
+ case e=interface[:extends]
82
+ when nil
83
+ when '$errorinfo'
84
+ when '$unknown' then io << " extends :NSISupports\n"
85
+ when /^I/ then io << " extends :#{e[1..-1]}\n"
86
+ else raise "Unkown extension"
87
+ end
88
+
89
+
90
+ interface.xpath('attribute').each {|a|
91
+ name = ':' + uncamelize(a[:name])
92
+ type = cnv_type(a[:type], a[:safearray])
93
+ opts = [ ':readonly => true' ] if a[:readonly]
94
+ args = [ name, type ]
95
+ args << opts if opts && !opts.empty?
96
+
97
+ io << " property " << args.join(', ') << "\n"
98
+ }
99
+ interface.xpath('method').each {|m|
100
+ name = ':' + uncamelize(m[:name])
101
+ ret = if ret = m.xpath("param[@dir = 'return']")[0]
102
+ cnv_type(ret[:type], ret[:safearray], ret[:mod] == 'ptr')
103
+ else 'nil'
104
+ end
105
+ param = '[' + m.xpath("param[@dir = 'in' or @dir = 'out']").map {|p|
106
+ t = cnv_type(p[:type], p[:safearray], p[:mod] == 'ptr')
107
+ t = '[:out, ' + t + ']' if p[:dir] == 'out'
108
+ t
109
+ }.join(', ') + ']'
110
+
111
+ io << " function " << [name, ret, param].join(', ') << "\n"
112
+ }
113
+
114
+ io << " setup\n"
115
+ io << "end\n"
116
+ io << "\n"
117
+ end
118
+
119
+
120
+ io << "end\n"
121
+ io << "end\n"
122
+ io << "end\n"
123
+
124
+ io.flush
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+ require "virtualbox/com/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "virtualbox-com"
7
+ s.version = VirtualBox::COM::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Mitchell Hashimoto"]
10
+ s.email = ["mitchell.hashimoto@gmail.com"]
11
+ s.homepage = "http://github.com/sdalu/virtualbox-com"
12
+ s.summary = "Low level VirtualBox interraction using pure ruby"
13
+ s.description = "Low level VirtualBox interraction using pure ruby"
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+ s.rubyforge_project = "virtualbox-com"
17
+
18
+ s.add_dependency "ffi"
19
+ s.add_development_dependency "rake"
20
+ s.add_development_dependency "nokogiri"
21
+
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
25
+ s.require_path = 'lib'
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virtualbox-com
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mitchell Hashimoto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: nokogiri
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Low level VirtualBox interraction using pure ruby
63
+ email:
64
+ - mitchell.hashimoto@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE
72
+ - Rakefile
73
+ - Readme.md
74
+ - examples/simple.rb
75
+ - lib/virtualbox-com.rb
76
+ - lib/virtualbox/com.rb
77
+ - lib/virtualbox/com/abstract_enum.rb
78
+ - lib/virtualbox/com/abstract_interface.rb
79
+ - lib/virtualbox/com/abstract_model.rb
80
+ - lib/virtualbox/com/exceptions.rb
81
+ - lib/virtualbox/com/iid.rb
82
+ - lib/virtualbox/com/model/4.2-gen.rb
83
+ - lib/virtualbox/com/model/4.2.rb
84
+ - lib/virtualbox/com/util.rb
85
+ - lib/virtualbox/com/version.rb
86
+ - lib/virtualbox/com/xpcomc-ffi.rb
87
+ - lib/virtualbox/com/xpcomc-ffi/binding.rb
88
+ - lib/virtualbox/com/xpcomc-ffi/implementer.rb
89
+ - lib/virtualbox/com/xpcomc-ffi/lib.rb
90
+ - lib/virtualbox/com/xpcomc-ffi/model-types.rb
91
+ - lib/virtualbox/com/xpcomc-ffi/sig.rb
92
+ - lib/virtualbox/com/xpcomc-ffi/spec.rb
93
+ - lib/virtualbox/com/xpcomc-ffi/xpcomc-vbox.rb
94
+ - scripts/xidl-conv.rb
95
+ - virtualbox-com.gemspec
96
+ homepage: http://github.com/sdalu/virtualbox-com
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
109
+ - 0
110
+ hash: 435323636523311339
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.6
117
+ requirements: []
118
+ rubyforge_project: virtualbox-com
119
+ rubygems_version: 1.8.25
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Low level VirtualBox interraction using pure ruby
123
+ test_files: []