MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / operator

Function operator

src/py_class/py_class_impl.py:667–695  ·  view source on GitHub ↗
(special_name, slot,
    args=(),
    res_type='PyObject',
    res_conv=None,
    res_ffi_type='*mut $crate::_detail::ffi::PyObject',
    additional_slots=()
)

Source from the content-addressed store, hash-verified

665
666@special_method
667def 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
697def operator_impl(special_name, slot, args, res_type, res_conv, res_ffi_type, additional_slots, typefunc):
698 if res_conv is None:

Callers 2

inplace_numeric_operatorFunction · 0.85
py_class_impl.pyFile · 0.85

Calls 2

operator_implFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected