Sha256: 0c735e7d9a7545907fad6c47ae6aa73995fe48b52a9f0a6b9061db649a6b88f1

Contents?: true

Size: 893 Bytes

Versions: 5

Compression:

Stored size: 893 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
      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
      klass.const_set :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

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-0.7.10 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.9 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.8 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.7 lib/gir_ffi/builders/base_type_builder.rb
gir_ffi-0.7.6 lib/gir_ffi/builders/base_type_builder.rb