(special_name, slot,
args=(),
res_type='PyObject',
res_conv=None,
res_ffi_type='*mut $crate::_detail::ffi::PyObject',
additional_slots=()
)
| 665 | |
| 666 | @special_method |
| 667 | def operator(special_name, slot, |
| 668 | args=(), |
| 669 | res_type='PyObject', |
| 670 | res_conv=None, |
| 671 | res_ffi_type='*mut $crate::_detail::ffi::PyObject', |
| 672 | additional_slots=() |
| 673 | ): |
| 674 | def optref(arg, suffix = ""): |
| 675 | if arg.allow_ref: |
| 676 | return "Option<&$%s_name%s>" % (arg.name, suffix) |
| 677 | else: |
| 678 | return "$%s_name%s" % (arg.name, suffix) |
| 679 | |
| 680 | def ref(arg, suffix = ""): |
| 681 | if arg.allow_ref: |
| 682 | return "&$%s_name%s" % (arg.name, suffix) |
| 683 | else: |
| 684 | return "$%s_name%s" % (arg.name, suffix) |
| 685 | |
| 686 | def normal(arg, suffix = ""): |
| 687 | return "$%s_name%s" % (arg.name, suffix) |
| 688 | |
| 689 | if args: |
| 690 | operator_impl(special_name, slot, args, res_type, res_conv, res_ffi_type, additional_slots, optref) |
| 691 | operator_impl(special_name, slot, args, res_type, res_conv, res_ffi_type, additional_slots, ref) |
| 692 | operator_impl(special_name, slot, args, res_type, res_conv, res_ffi_type, additional_slots, normal) |
| 693 | # Generate fall-back matcher that produces an error |
| 694 | # when using the wrong method signature |
| 695 | error('Invalid signature for operator %s' % special_name)(special_name) |
| 696 | |
| 697 | def operator_impl(special_name, slot, args, res_type, res_conv, res_ffi_type, additional_slots, typefunc): |
| 698 | if res_conv is None: |
no test coverage detected