Sha256: f047c099caf3481f98fff580ed98b05f85d7daeaf30fedd49cb1497cbb181e99

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
require 'gir_ffi/info_ext/full_type_name'

module GirFFI
  # Represents a type not found in the GIR, conforming, as needed, to the
  # interface of GObjectIntrospection::IObjectInfo.
  class UnintrospectableTypeInfo
    attr_reader :g_type

    def initialize(gtype,
                   gir = GObjectIntrospection::IRepository.default,
                   gobject = GObject)
      @g_type = gtype
      @gir = gir
      @gobject = gobject
    end

    def info_type
      :unintrospectable
    end

    def safe_name
      @gobject.type_name @g_type
    end

    def parent
      @gir.find_by_gtype(parent_gtype) || self.class.new(parent_gtype, @gir, @gobject)
    end

    def parent_gtype
      @parent_gtype ||= @gobject.type_parent @g_type
    end

    def namespace
      parent.namespace
    end

    def interfaces
      @gobject.type_interfaces(@g_type).map do |gtype|
        @gir.find_by_gtype gtype
      end.compact
    end

    def fields
      []
    end

    def find_signal(_any)
      nil
    end

    # TODO: Create custom class that includes the interfaces instead
    def class_struct
      parent.class_struct
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.11.1 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.11.0 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.10.2 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.10.1 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.10.0 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.10.0.pre1 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.9.5 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.9.4 lib/gir_ffi/unintrospectable_type_info.rb
gir_ffi-0.9.3 lib/gir_ffi/unintrospectable_type_info.rb