class GObjectIntrospection::CallableInfo - gobject-introspection-3.1.1 Documentation

# class GObjectIntrospection::CallableInfo

### Public Instance Methods

have_return_value?() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 62
    def have_return_value?
      return true if return_type.tag != TypeTag::VOID
      return true if return_type.pointer?
      not n_out_args.zero?
    end

in_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 25
    def in_args
      @in_args ||= compute_in_args
    end

n_in_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 35
    def n_in_args
      in_args.size
    end

n_out_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 58
    def n_out_args
      out_args.size
    end

n_required_in_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 39
    def n_required_in_args
      required_in_args.size
    end

out_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 47
    def out_args
      @out_args ||= args.find_all do |arg|
        case arg.direction
        when Direction::OUT, Direction::INOUT
          true
        else
          false
        end
      end
    end

require_callback?() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 43
    def require_callback?
      (@require_callback ||= compute_require_callback) == :required
    end

required_in_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 29
    def required_in_args
      @required_in_args ||= in_args.reject do |arg|
        arg.may_be_null?
      end
    end

### Private Instance Methods

compute_in_args() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 69
    def compute_in_args
      array_length_indexes = []
      callback_indexes = []
      closure_indexes = []
      destroy_indexes = []
      args.each_with_index do |arg, i|
        if arg.type.tag == TypeTag::ARRAY
          array_length = arg.type.array_length
          array_length_indexes << array_length if array_length != -1
        end

        unless arg.scope == ScopeType::INVALID
          callback_indexes << i
          closure_index = arg.closure
          closure_indexes << closure_index if closure_index != -1
          destroy_index = arg.destroy
          destroy_indexes << destroy_index if destroy_index != -1
        end
      end

      args.find_all.with_index do |arg, i|
        case arg.direction
        when Direction::IN, Direction::INOUT
          if array_length_indexes.include?(i)
            false
          elsif callback_indexes.include?(i)
            false
          elsif closure_indexes.include?(i)
            false
          elsif destroy_indexes.include?(i)
            false
          else
            true
          end
        else
          false
        end
      end
    end

compute_require_callback() click to toggle source

    # File lib/gobject-introspection/callable-info.rb, line 109
    def compute_require_callback
      args.each do |arg|
        if arg.direction == Direction::IN and
            arg.scope != ScopeType::INVALID and
            !arg.may_be_null?
          return :required
        end
      end

      :not_required
    end