module Puppet::Util::Windows::COM::Instance

Public Class Methods

[](iface) click to toggle source
# File lib/puppet/util/windows/com.rb, line 127
def self.[](iface)
  Class.new(iface) do
    send(:include, Helpers)

    def initialize(pointer)
      self.pointer = pointer

      @vtbl = self.class::VTBL.new(self[:lpVtbl])
    end

    attr_reader :vtbl

    self::VTBL.members.each do |name|
      define_method(name) do |*args|
        if Puppet::Util::Windows::COM.FAILED(result = @vtbl[name].call(self, *args))
          raise Puppet::Util::Windows::Error.new("Failed to call #{self}::#{name} with HRESULT: #{result}.", result)
        end
        result
      end
    end

    layout            :lpVtbl, :pointer
  end
end
new(pointer) click to toggle source
# File lib/puppet/util/windows/com.rb, line 131
def initialize(pointer)
  self.pointer = pointer

  @vtbl = self.class::VTBL.new(self[:lpVtbl])
end