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