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

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

Overview

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

Class Method Summary collapse

Class Method Details

.[](*args) ⇒ Object



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