Sha256: 88e1eb0d0f5bf65a58838a33994ecf07ddca697089f39c5c3e97ed488aac1a88

Contents?: true

Size: 947 Bytes

Versions: 9

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

require "gir_ffi/builder_helper"

module GirFFI
  # Base class for type builders.
  class BaseTypeBuilder
    include BuilderHelper

    def initialize(info)
      @info = info
      @namespace = @info.namespace
      @classname = @info.safe_name
    end

    def build_class
      instantiate_class unless defined? @klass
      @klass
    end

    def instantiate_class
      setup_class unless already_set_up
    end

    attr_reader :info

    private

    def namespace_module
      @namespace_module ||= Builder.build_module @namespace
    end

    def lib
      @lib ||= namespace_module::Lib
    end

    def setup_constants
      optionally_define_constant(klass, :GIR_INFO) { info }
      klass.const_set :GIR_FFI_BUILDER, self
    end

    def already_set_up
      klass.const_defined? :GIR_FFI_BUILDER, false
    end

    def gir
      @gir ||= GObjectIntrospection::IRepository.default
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.17.0 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.16.1 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.16.0 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.9 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.8 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.7 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.6 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.5 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.15.4 lib/gir_ffi/builders/base_type_builder.rb