Sha256: ddf949df61ef1991a830929f4506e82092eff573fd1f85a841ea59eb86c46d1b

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'gir_ffi/builders/base_type_builder'
require 'gir_ffi/class_base'

module GirFFI
  module Builders
    # Base class for type builders building types specified by subtypes
    # of IRegisteredTypeInfo. These are types whose C representation is
    # complex, i.e., a struct or a union.
    class RegisteredTypeBuilder < BaseTypeBuilder
      private

      def target_gtype
        info.g_type
      end

      # TODO: Rename the created method, or use a constant.
      # FIXME: Only used in some of the subclases. Make mixin?
      def setup_gtype_getter
        gtype = target_gtype
        return if gtype.nil?
        klass.instance_eval "
          def self.get_gtype
            #{gtype}
          end
        "
      end

      # FIXME: Only used in some of the subclases. Make mixin?
      def provide_constructor
        return if info.find_method 'new'

        (class << klass; self; end).class_eval {
          alias_method :new, :_allocate
        }
      end

      def parent
        nil
      end

      def fields
        info.fields
      end

      def superclass
        ClassBase
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-0.7.1 lib/gir_ffi/builders/registered_type_builder.rb
gir_ffi-0.7.0 lib/gir_ffi/builders/registered_type_builder.rb