Sha256: 6298c9c5a4ce67d02f01b81d9622152a123f680fe5ba66483a3494c8a3c69b81

Contents?: true

Size: 928 Bytes

Versions: 9

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

require "gir_ffi/builders/callback_argument_builder"

module GirFFI
  module Builders
    # Convertor for arguments for vfuncs. Used when building the
    # argument mapper for vfuncs.
    class VFuncArgumentBuilder < CallbackArgumentBuilder
      def pre_conversion
        if ingoing_ref_needed?
          super + ["#{pre_converted_name}&.ref"]
        else
          super
        end
      end

      def post_conversion
        if outgoing_ref_needed?
          ["#{result_name}.ref"] + super
        else
          super
        end
      end

      private

      def ingoing_ref_needed?
        direction == :in &&
          ownership_transfer == :nothing &&
          specialized_type_tag == :object
      end

      def outgoing_ref_needed?
        direction == :out &&
          ownership_transfer == :everything &&
          specialized_type_tag == :object
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.17.0 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.16.1 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.16.0 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.9 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.8 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.7 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.6 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.5 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.15.4 lib/gir_ffi/builders/vfunc_argument_builder.rb