Sha256: 63813532e04d964cb9f9da3a445f45e6b98416c908d9377da807c4fde75ab96e

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

require "gir_ffi/builders/registered_type_builder"
require "gir_ffi/builders/struct_like"
require "gir_ffi/struct_base"

module GirFFI
  module Builders
    # Implements the creation of a class representing a Struct.
    class StructBuilder < RegisteredTypeBuilder
      include StructLike

      def layout_superclass
        GirFFI::Struct
      end

      def superclass
        # HACK: Inheritance chain is not expressed in GObject's code correctly.
        return GObject::ObjectClass if info.full_type_name == "GObject::InitiallyUnownedClass"
        return parent_field_type.tag_or_class if info.gtype_struct?
        return BoxedBase if GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED

        StructBase
      end

      def parent_field_type
        fields.first.field_type
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.15.2 lib/gir_ffi/builders/struct_builder.rb
gir_ffi-0.15.1 lib/gir_ffi/builders/struct_builder.rb
gir_ffi-0.15.0 lib/gir_ffi/builders/struct_builder.rb