Module: Puppet::Util::Windows::COM::Interface Private

Defined in:
lib/puppet/util/windows/com.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

code modified from Unknownr project github.com/rpeev/Unknownr licensed under MIT

API:

  • private

Class Method Summary collapse

Class Method Details

.[](*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/puppet/util/windows/com.rb', line 67

def self.[](*args)
  spec, iid, *ifaces = args.reverse

  spec.each { |name, signature| signature[0].unshift(:pointer) }

  Class.new(FFI::Struct) do
    const_set(:IID, iid)

    vtable = Class.new(FFI::Struct) do
      vtable_hash = Hash[(ifaces.map { |iface| iface::VTBL::SPEC.to_a } << spec.to_a).flatten(1)]
      const_set(:SPEC, vtable_hash)

      layout(
        *self::SPEC.map { |name, signature| [name, callback(*signature)] }.flatten
      )
    end

    const_set(:VTBL, vtable)

    layout \
      :lpVtbl, :pointer
  end
end