2022-04-18 23:56:53 -03:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2023-10-17 09:30:31 -03:00
|
|
|
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
|
|
|
|
2022-04-18 23:56:53 -03:00
|
|
|
PyDoc_STRVAR(method___reduce____doc__,
|
|
|
|
"__reduce__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define METHOD___REDUCE___METHODDEF \
|
|
|
|
{"__reduce__", (PyCFunction)method___reduce__, METH_NOARGS, method___reduce____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method___reduce___impl(PyMethodObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method___reduce__(PyMethodObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return method___reduce___impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(method_new__doc__,
|
|
|
|
"method(function, instance, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Create a bound instance method object.");
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2023-01-31 16:42:03 -04:00
|
|
|
PyTypeObject *base_tp = &PyMethod_Type;
|
2022-04-18 23:56:53 -03:00
|
|
|
PyObject *function;
|
|
|
|
PyObject *instance;
|
|
|
|
|
2023-01-31 16:42:03 -04:00
|
|
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
2022-04-18 23:56:53 -03:00
|
|
|
!_PyArg_NoKeywords("method", kwargs)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!_PyArg_CheckPositional("method", PyTuple_GET_SIZE(args), 2, 2)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
function = PyTuple_GET_ITEM(args, 0);
|
|
|
|
instance = PyTuple_GET_ITEM(args, 1);
|
|
|
|
return_value = method_new_impl(type, function, instance);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(instancemethod_new__doc__,
|
|
|
|
"instancemethod(function, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Bind a function to a class.");
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
instancemethod_new_impl(PyTypeObject *type, PyObject *function);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2023-01-31 16:42:03 -04:00
|
|
|
PyTypeObject *base_tp = &PyInstanceMethod_Type;
|
2022-04-18 23:56:53 -03:00
|
|
|
PyObject *function;
|
|
|
|
|
2023-01-31 16:42:03 -04:00
|
|
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
2022-04-18 23:56:53 -03:00
|
|
|
!_PyArg_NoKeywords("instancemethod", kwargs)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!_PyArg_CheckPositional("instancemethod", PyTuple_GET_SIZE(args), 1, 1)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
function = PyTuple_GET_ITEM(args, 0);
|
|
|
|
return_value = instancemethod_new_impl(type, function);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2023-10-17 09:30:31 -03:00
|
|
|
/*[clinic end generated code: output=5a5e3f2d0726f189 input=a9049054013a1b77]*/
|