Sha256: 27b592ee1f9b1fe06dac7e83751e10289e1ae045268d451f882110bfb006b341

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

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
      unless defined? @klass
        instantiate_class
      end
      @klass
    end

    attr_reader :info

    private

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

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

    def setup_constants
      klass.const_set :GIR_INFO, info
      klass.const_set :GIR_FFI_BUILDER, self
    end

    def already_set_up
      const_defined_for klass, :GIR_FFI_BUILDER
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.7.2 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.1 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.0 lib/gir_ffi/builders/base_type_builder.rb