Class: GObjectIntrospection::Loader::Invoker

Inherits:
Object
  • Object
show all
Defined in:
lib/gobject-introspection/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(info, method_name, full_method_name) ⇒ Invoker

Returns a new instance of Invoker.



682
683
684
685
686
687
688
# File 'lib/gobject-introspection/loader.rb', line 682

def initialize(info, method_name, full_method_name)
  @info = info
  @method_name = method_name
  @full_method_name = full_method_name
  @prepared = false
  ensure_prepared if defined?(Ractor)
end

Instance Method Details

#invoke(receiver, arguments, block, abort_tag: nil, implementor_gtype: nil) ⇒ Object



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
# File 'lib/gobject-introspection/loader.rb', line 690

def invoke(receiver, arguments, block,
           abort_tag: nil,
           implementor_gtype: nil)
  ensure_prepared

  if receiver and @info.class == FunctionInfo
    arguments.unshift(receiver)
  end

  arguments, block = build(receiver, arguments, block)
  if wrong_number_of_arguments?(arguments)
    if abort_tag
      throw(abort_tag)
    else
      raise ArgumentError, invalid_error_message(arguments)
    end
  end
  unless normalize_arguments!(arguments, abort_tag)
    return @value_on_invalid
  end

  if block.nil? and @require_callback_p
    receiver.to_enum(@method_name, *arguments)
  else
    if @info.class == VFuncInfo
      return_value = @info.invoke(implementor_gtype,
                                  receiver,
                                  arguments,
                                  &block)
    elsif @info.class == FunctionInfo
      return_value = @info.invoke(arguments, &block)
    else
      return_value = @info.invoke(receiver, arguments, &block)
    end
    if @have_return_value_p
      return_value
    else
      receiver
    end
  end
end

#signatureObject



732
733
734
735
736
# File 'lib/gobject-introspection/loader.rb', line 732

def signature
  ensure_prepared
  argument_signatures = @in_args.collect(&:signature)
  "(" + argument_signatures.join(", ") + ")"
end