(root)/
Python-3.12.0/
Objects/
clinic/
typeobject.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(type___instancecheck____doc__,
      12  "__instancecheck__($self, instance, /)\n"
      13  "--\n"
      14  "\n"
      15  "Check if an object is an instance.");
      16  
      17  #define TYPE___INSTANCECHECK___METHODDEF    \
      18      {"__instancecheck__", (PyCFunction)type___instancecheck__, METH_O, type___instancecheck____doc__},
      19  
      20  static int
      21  type___instancecheck___impl(PyTypeObject *self, PyObject *instance);
      22  
      23  static PyObject *
      24  type___instancecheck__(PyTypeObject *self, PyObject *instance)
      25  {
      26      PyObject *return_value = NULL;
      27      int _return_value;
      28  
      29      _return_value = type___instancecheck___impl(self, instance);
      30      if ((_return_value == -1) && PyErr_Occurred()) {
      31          goto exit;
      32      }
      33      return_value = PyBool_FromLong((long)_return_value);
      34  
      35  exit:
      36      return return_value;
      37  }
      38  
      39  PyDoc_STRVAR(type___subclasscheck____doc__,
      40  "__subclasscheck__($self, subclass, /)\n"
      41  "--\n"
      42  "\n"
      43  "Check if a class is a subclass.");
      44  
      45  #define TYPE___SUBCLASSCHECK___METHODDEF    \
      46      {"__subclasscheck__", (PyCFunction)type___subclasscheck__, METH_O, type___subclasscheck____doc__},
      47  
      48  static int
      49  type___subclasscheck___impl(PyTypeObject *self, PyObject *subclass);
      50  
      51  static PyObject *
      52  type___subclasscheck__(PyTypeObject *self, PyObject *subclass)
      53  {
      54      PyObject *return_value = NULL;
      55      int _return_value;
      56  
      57      _return_value = type___subclasscheck___impl(self, subclass);
      58      if ((_return_value == -1) && PyErr_Occurred()) {
      59          goto exit;
      60      }
      61      return_value = PyBool_FromLong((long)_return_value);
      62  
      63  exit:
      64      return return_value;
      65  }
      66  
      67  PyDoc_STRVAR(type_mro__doc__,
      68  "mro($self, /)\n"
      69  "--\n"
      70  "\n"
      71  "Return a type\'s method resolution order.");
      72  
      73  #define TYPE_MRO_METHODDEF    \
      74      {"mro", (PyCFunction)type_mro, METH_NOARGS, type_mro__doc__},
      75  
      76  static PyObject *
      77  type_mro_impl(PyTypeObject *self);
      78  
      79  static PyObject *
      80  type_mro(PyTypeObject *self, PyObject *Py_UNUSED(ignored))
      81  {
      82      return type_mro_impl(self);
      83  }
      84  
      85  PyDoc_STRVAR(type___subclasses____doc__,
      86  "__subclasses__($self, /)\n"
      87  "--\n"
      88  "\n"
      89  "Return a list of immediate subclasses.");
      90  
      91  #define TYPE___SUBCLASSES___METHODDEF    \
      92      {"__subclasses__", (PyCFunction)type___subclasses__, METH_NOARGS, type___subclasses____doc__},
      93  
      94  static PyObject *
      95  type___subclasses___impl(PyTypeObject *self);
      96  
      97  static PyObject *
      98  type___subclasses__(PyTypeObject *self, PyObject *Py_UNUSED(ignored))
      99  {
     100      return type___subclasses___impl(self);
     101  }
     102  
     103  PyDoc_STRVAR(type___dir____doc__,
     104  "__dir__($self, /)\n"
     105  "--\n"
     106  "\n"
     107  "Specialized __dir__ implementation for types.");
     108  
     109  #define TYPE___DIR___METHODDEF    \
     110      {"__dir__", (PyCFunction)type___dir__, METH_NOARGS, type___dir____doc__},
     111  
     112  static PyObject *
     113  type___dir___impl(PyTypeObject *self);
     114  
     115  static PyObject *
     116  type___dir__(PyTypeObject *self, PyObject *Py_UNUSED(ignored))
     117  {
     118      return type___dir___impl(self);
     119  }
     120  
     121  PyDoc_STRVAR(type___sizeof____doc__,
     122  "__sizeof__($self, /)\n"
     123  "--\n"
     124  "\n"
     125  "Return memory consumption of the type object.");
     126  
     127  #define TYPE___SIZEOF___METHODDEF    \
     128      {"__sizeof__", (PyCFunction)type___sizeof__, METH_NOARGS, type___sizeof____doc__},
     129  
     130  static PyObject *
     131  type___sizeof___impl(PyTypeObject *self);
     132  
     133  static PyObject *
     134  type___sizeof__(PyTypeObject *self, PyObject *Py_UNUSED(ignored))
     135  {
     136      return type___sizeof___impl(self);
     137  }
     138  
     139  PyDoc_STRVAR(object___getstate____doc__,
     140  "__getstate__($self, /)\n"
     141  "--\n"
     142  "\n"
     143  "Helper for pickle.");
     144  
     145  #define OBJECT___GETSTATE___METHODDEF    \
     146      {"__getstate__", (PyCFunction)object___getstate__, METH_NOARGS, object___getstate____doc__},
     147  
     148  static PyObject *
     149  object___getstate___impl(PyObject *self);
     150  
     151  static PyObject *
     152  object___getstate__(PyObject *self, PyObject *Py_UNUSED(ignored))
     153  {
     154      return object___getstate___impl(self);
     155  }
     156  
     157  PyDoc_STRVAR(object___reduce____doc__,
     158  "__reduce__($self, /)\n"
     159  "--\n"
     160  "\n"
     161  "Helper for pickle.");
     162  
     163  #define OBJECT___REDUCE___METHODDEF    \
     164      {"__reduce__", (PyCFunction)object___reduce__, METH_NOARGS, object___reduce____doc__},
     165  
     166  static PyObject *
     167  object___reduce___impl(PyObject *self);
     168  
     169  static PyObject *
     170  object___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored))
     171  {
     172      return object___reduce___impl(self);
     173  }
     174  
     175  PyDoc_STRVAR(object___reduce_ex____doc__,
     176  "__reduce_ex__($self, protocol, /)\n"
     177  "--\n"
     178  "\n"
     179  "Helper for pickle.");
     180  
     181  #define OBJECT___REDUCE_EX___METHODDEF    \
     182      {"__reduce_ex__", (PyCFunction)object___reduce_ex__, METH_O, object___reduce_ex____doc__},
     183  
     184  static PyObject *
     185  object___reduce_ex___impl(PyObject *self, int protocol);
     186  
     187  static PyObject *
     188  object___reduce_ex__(PyObject *self, PyObject *arg)
     189  {
     190      PyObject *return_value = NULL;
     191      int protocol;
     192  
     193      protocol = _PyLong_AsInt(arg);
     194      if (protocol == -1 && PyErr_Occurred()) {
     195          goto exit;
     196      }
     197      return_value = object___reduce_ex___impl(self, protocol);
     198  
     199  exit:
     200      return return_value;
     201  }
     202  
     203  PyDoc_STRVAR(object___format____doc__,
     204  "__format__($self, format_spec, /)\n"
     205  "--\n"
     206  "\n"
     207  "Default object formatter.\n"
     208  "\n"
     209  "Return str(self) if format_spec is empty. Raise TypeError otherwise.");
     210  
     211  #define OBJECT___FORMAT___METHODDEF    \
     212      {"__format__", (PyCFunction)object___format__, METH_O, object___format____doc__},
     213  
     214  static PyObject *
     215  object___format___impl(PyObject *self, PyObject *format_spec);
     216  
     217  static PyObject *
     218  object___format__(PyObject *self, PyObject *arg)
     219  {
     220      PyObject *return_value = NULL;
     221      PyObject *format_spec;
     222  
     223      if (!PyUnicode_Check(arg)) {
     224          _PyArg_BadArgument("__format__", "argument", "str", arg);
     225          goto exit;
     226      }
     227      if (PyUnicode_READY(arg) == -1) {
     228          goto exit;
     229      }
     230      format_spec = arg;
     231      return_value = object___format___impl(self, format_spec);
     232  
     233  exit:
     234      return return_value;
     235  }
     236  
     237  PyDoc_STRVAR(object___sizeof____doc__,
     238  "__sizeof__($self, /)\n"
     239  "--\n"
     240  "\n"
     241  "Size of object in memory, in bytes.");
     242  
     243  #define OBJECT___SIZEOF___METHODDEF    \
     244      {"__sizeof__", (PyCFunction)object___sizeof__, METH_NOARGS, object___sizeof____doc__},
     245  
     246  static PyObject *
     247  object___sizeof___impl(PyObject *self);
     248  
     249  static PyObject *
     250  object___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored))
     251  {
     252      return object___sizeof___impl(self);
     253  }
     254  
     255  PyDoc_STRVAR(object___dir____doc__,
     256  "__dir__($self, /)\n"
     257  "--\n"
     258  "\n"
     259  "Default dir() implementation.");
     260  
     261  #define OBJECT___DIR___METHODDEF    \
     262      {"__dir__", (PyCFunction)object___dir__, METH_NOARGS, object___dir____doc__},
     263  
     264  static PyObject *
     265  object___dir___impl(PyObject *self);
     266  
     267  static PyObject *
     268  object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
     269  {
     270      return object___dir___impl(self);
     271  }
     272  /*[clinic end generated code: output=d2fc52440a89f2fa input=a9049054013a1b77]*/