Sha256: ab1d1cdf3e186b33b87b4901b89104b8967617acc78630dcb1ef097cff6cce14
Contents?: true
Size: 1.12 KB
Versions: 13
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require "gir_ffi/builders/field_builder" module GirFFI module Builders # Implements the creation of classes representing types with layout, # i.e., :union, :struct, :object. # NOTE: This module depends on methods in RegisteredTypeBuilder. module WithLayout def layout_specification spec = base_layout_specification if spec.empty? dummy_layout_specification else spec end end private def setup_layout spec = layout_specification struct_class.class_eval do layout(*spec) end end def dummy_layout_specification if parent_info [:parent, superclass::Struct, 0] else [:dummy, :char, 0] end end def base_layout_specification fields.flat_map(&:layout_specification) end def klass @klass ||= get_or_define_class namespace_module, @classname, superclass end def struct_class @struct_class ||= get_or_define_class klass, :Struct, layout_superclass end end end end
Version data entries
13 entries across 13 versions & 1 rubygems