Class: VirtualBox::COM::Implementer::Base

Inherits:
AbstractImplementer show all
Includes:
Logger
Defined in:
lib/virtualbox/com/implementer/base.rb

Direct Known Subclasses

FFI, MSCOM

Instance Attribute Summary

Attributes inherited from AbstractImplementer

#interface, #lib

Instance Method Summary collapse

Methods included from Logger

included, #logger, #logger_output=

Methods inherited from AbstractImplementer

#call_function, #initialize, #read_property, #write_property

Constructor Details

This class inherits a constructor from VirtualBox::COM::AbstractImplementer

Instance Method Details

#infer_type(type) ⇒ Object

Gives the C type and inferred type of a parameter type. Quite confusing since the terminology is not consistent, but hopefully these examples will help:

type => [pointer_type, internal_type]
:int => [:int, :int]
:MyStruct => [:pointer, :struct]
:unicode_string => [:pointer, :unicode_string]


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/virtualbox/com/implementer/base.rb', line 31

def infer_type(type)
  c_type = type

  begin
    if type == WSTRING
      # Handle strings as pointer types
      c_type = :pointer
    else
      # Try to get the class from the interfaces
      interface = interface_klass(type)

      c_type = :pointer

      # Depending on the class type, we're either dealing with an interface
      # or an enum
      type = :interface if interface.superclass == COM::AbstractInterface
      type = :enum if interface.superclass == COM::AbstractEnum
    end
  rescue NameError
    # Do nothing
  end

  [c_type, type]
end

#interface_klass(type) ⇒ Class

Finds and returns the ‘COM::Interface` class associated with the type. If the class does not exist, a `NameError` will be raised.

Returns:

  • (Class)


18
19
20
# File 'lib/virtualbox/com/implementer/base.rb', line 18

def interface_klass(type)
  ::VirtualBox::COM::FFI::Util.interface_klass(type)
end

#ruby_versionFloat

Returns the Ruby version as a float

Returns:

  • (Float)


10
11
12
# File 'lib/virtualbox/com/implementer/base.rb', line 10

def ruby_version
  RUBY_VERSION.to_f
end