• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 #include "pycore_modsupport.h"    // _PyArg_CheckPositional()
6 
7 PyDoc_STRVAR(method___reduce____doc__,
8 "__reduce__($self, /)\n"
9 "--\n"
10 "\n");
11 
12 #define METHOD___REDUCE___METHODDEF    \
13     {"__reduce__", (PyCFunction)method___reduce__, METH_NOARGS, method___reduce____doc__},
14 
15 static PyObject *
16 method___reduce___impl(PyMethodObject *self);
17 
18 static PyObject *
method___reduce__(PyMethodObject * self,PyObject * Py_UNUSED (ignored))19 method___reduce__(PyMethodObject *self, PyObject *Py_UNUSED(ignored))
20 {
21     return method___reduce___impl(self);
22 }
23 
24 PyDoc_STRVAR(method_new__doc__,
25 "method(function, instance, /)\n"
26 "--\n"
27 "\n"
28 "Create a bound instance method object.");
29 
30 static PyObject *
31 method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance);
32 
33 static PyObject *
method_new(PyTypeObject * type,PyObject * args,PyObject * kwargs)34 method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
35 {
36     PyObject *return_value = NULL;
37     PyTypeObject *base_tp = &PyMethod_Type;
38     PyObject *function;
39     PyObject *instance;
40 
41     if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
42         !_PyArg_NoKeywords("method", kwargs)) {
43         goto exit;
44     }
45     if (!_PyArg_CheckPositional("method", PyTuple_GET_SIZE(args), 2, 2)) {
46         goto exit;
47     }
48     function = PyTuple_GET_ITEM(args, 0);
49     instance = PyTuple_GET_ITEM(args, 1);
50     return_value = method_new_impl(type, function, instance);
51 
52 exit:
53     return return_value;
54 }
55 
56 PyDoc_STRVAR(instancemethod_new__doc__,
57 "instancemethod(function, /)\n"
58 "--\n"
59 "\n"
60 "Bind a function to a class.");
61 
62 static PyObject *
63 instancemethod_new_impl(PyTypeObject *type, PyObject *function);
64 
65 static PyObject *
instancemethod_new(PyTypeObject * type,PyObject * args,PyObject * kwargs)66 instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
67 {
68     PyObject *return_value = NULL;
69     PyTypeObject *base_tp = &PyInstanceMethod_Type;
70     PyObject *function;
71 
72     if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
73         !_PyArg_NoKeywords("instancemethod", kwargs)) {
74         goto exit;
75     }
76     if (!_PyArg_CheckPositional("instancemethod", PyTuple_GET_SIZE(args), 1, 1)) {
77         goto exit;
78     }
79     function = PyTuple_GET_ITEM(args, 0);
80     return_value = instancemethod_new_impl(type, function);
81 
82 exit:
83     return return_value;
84 }
85 /*[clinic end generated code: output=5a5e3f2d0726f189 input=a9049054013a1b77]*/
86