Class: GObjectIntrospection::Loader::Invoker
- Inherits:
-
Object
- Object
- GObjectIntrospection::Loader::Invoker
- Defined in:
- lib/gobject-introspection/loader.rb
Instance Method Summary collapse
-
#initialize(info, method_name, full_method_name) ⇒ Invoker
constructor
A new instance of Invoker.
- #invoke(receiver, arguments, block, abort_tag: nil, implementor_gtype: nil) ⇒ Object
- #match?(receiver, arguments, block) ⇒ Boolean
- #signature ⇒ Object
Constructor Details
#initialize(info, method_name, full_method_name) ⇒ Invoker
Returns a new instance of Invoker.
694 695 696 697 698 699 700 |
# File 'lib/gobject-introspection/loader.rb', line 694 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
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 731 732 733 734 735 736 737 738 739 740 741 742 |
# File 'lib/gobject-introspection/loader.rb', line 702 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, (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 |
#match?(receiver, arguments, block) ⇒ Boolean
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
# File 'lib/gobject-introspection/loader.rb', line 744 def match?(receiver, arguments, block) ensure_prepared arguments = arguments.dup if receiver and @info.class == FunctionInfo arguments.unshift(receiver) end arguments, _block = build(receiver, arguments, block) return false if wrong_number_of_arguments?(arguments) arguments.each_with_index.all? do |argument, i| if argument.nil? @in_arg_nils[i] else @in_arg_types[i].match?(argument) end end end |
#signature ⇒ Object
763 764 765 766 767 |
# File 'lib/gobject-introspection/loader.rb', line 763 def signature ensure_prepared argument_signatures = @in_args.collect(&:signature) "(" + argument_signatures.join(", ") + ")" end |