class GObjectIntrospection::CallableInfo

Public Instance Methods

description() click to toggle source
# File lib/gobject-introspection/callable-info.rb, line 68
def description
  signature
end
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
inspect() click to toggle source
Calls superclass method
# File lib/gobject-introspection/callable-info.rb, line 77
def inspect
  super.gsub(/>\z/) do
    " signature=<#{signature}>" +
      " name=#{name.inspect}" +
      " arguments=#{args.inspect}" +
      " return_type=#{return_type.inspect}" +
      " may_return_type_null=#{may_return_null?.inspect}>"
  end
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
signature() click to toggle source
# File lib/gobject-introspection/callable-info.rb, line 72
def signature
  argument_signatures = args.collect(&:signature).join(", ")
  "#{name}(#{argument_signatures}): #{return_type.description}"
end

Private Instance Methods

compute_in_args() click to toggle source
# File lib/gobject-introspection/callable-info.rb, line 88
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
      arg.output_buffer?
    end
  end
end
compute_require_callback() click to toggle source
# File lib/gobject-introspection/callable-info.rb, line 128
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