Sha256: 24f52e22dd2061892330b903ea8c7cfa95687c1d484608a0cb8e1cb3c9c1083b

Contents?: true

Size: 715 Bytes

Versions: 3

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

require 'gir_ffi/registered_type_base'
require 'gir_ffi/method_setup'
require 'gir_ffi/instance_method_setup'

module GirFFI
  # Base module for modules representing GLib interfaces.
  module InterfaceBase
    include RegisteredTypeBase
    include MethodSetup
    include InstanceMethodSetup

    def setup_and_call(method, arguments, &block)
      method_name = setup_method method.to_s
      raise NoMethodError, "undefined method `#{method}' for #{self}" unless method_name

      send method_name, *arguments, &block
    end

    def wrap(ptr)
      ptr.to_object
    end

    def to_ffi_type
      :pointer
    end

    def to_callback_ffi_type
      :pointer
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.14.1 lib/gir_ffi/interface_base.rb
gir_ffi-0.14.0 lib/gir_ffi/interface_base.rb
gir_ffi-0.13.1 lib/gir_ffi/interface_base.rb