Sha256: ea34a791da47ccdfb04871ced740dd889158b25b066bba528cff2abaec20e898

Contents?: true

Size: 998 Bytes

Versions: 12

Compression:

Stored size: 998 Bytes

Contents

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_ref_count_increase]
        else
          super
        end
      end

      private

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

      def pre_ref_count_increase
        "#{pre_converted_name}.ref"
      end

      # SMELL: Override private method
      def post_convertor_argument
        if outgoing_ref_needed
          "#{super}.ref"
        else
          super
        end
      end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gir_ffi-0.9.2 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.9.1 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.9.0 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.6 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.5 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.4 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.3 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.2 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.1 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.8.0 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.7.10 lib/gir_ffi/builders/vfunc_argument_builder.rb
gir_ffi-0.7.9 lib/gir_ffi/builders/vfunc_argument_builder.rb