Debian Codegraph @

Modules/clinic/_testmultiphase.c.h

raw
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 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(_testmultiphase_StateAccessType_get_defining_module__doc__,
12 "get_defining_module($self, /)\n"
13 "--\n"
14 "\n"
15 "Return the module of the defining class.\n"
16 "\n"
17 "Also tests that result of PyType_GetModuleByDef matches\n"
18 "defining_class\'s module.");
19
20 #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_DEFINING_MODULE_METHODDEF \
21 {"get_defining_module", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_defining_module), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__},
22
23 static PyObject *
24 _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self,
25 PyTypeObject *cls);
26
27 static PyObject *
28 _testmultiphase_StateAccessType_get_defining_module(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
29 {
30 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
31 PyErr_SetString(PyExc_TypeError, "get_defining_module() takes no arguments");
32 return NULL;
33 }
34 return _testmultiphase_StateAccessType_get_defining_module_impl((StateAccessTypeObject *)self, cls);
35 }
36
37 PyDoc_STRVAR(_testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__,
38 "getmodulebydef_bad_def($self, /)\n"
39 "--\n"
40 "\n"
41 "Test that result of PyType_GetModuleByDef with a bad def is NULL.");
42
43 #define _TESTMULTIPHASE_STATEACCESSTYPE_GETMODULEBYDEF_BAD_DEF_METHODDEF \
44 {"getmodulebydef_bad_def", _PyCFunction_CAST(_testmultiphase_StateAccessType_getmodulebydef_bad_def), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__},
45
46 static PyObject *
47 _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(StateAccessTypeObject *self,
48 PyTypeObject *cls);
49
50 static PyObject *
51 _testmultiphase_StateAccessType_getmodulebydef_bad_def(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
52 {
53 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
54 PyErr_SetString(PyExc_TypeError, "getmodulebydef_bad_def() takes no arguments");
55 return NULL;
56 }
57 return _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl((StateAccessTypeObject *)self, cls);
58 }
59
60 PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__,
61 "increment_count_clinic($self, /, n=1, *, twice=False)\n"
62 "--\n"
63 "\n"
64 "Add \'n\' from the module-state counter.\n"
65 "\n"
66 "Pass \'twice\' to double that amount.\n"
67 "\n"
68 "This tests Argument Clinic support for defining_class.");
69
70 #define _TESTMULTIPHASE_STATEACCESSTYPE_INCREMENT_COUNT_CLINIC_METHODDEF \
71 {"increment_count_clinic", _PyCFunction_CAST(_testmultiphase_StateAccessType_increment_count_clinic), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_increment_count_clinic__doc__},
72
73 static PyObject *
74 _testmultiphase_StateAccessType_increment_count_clinic_impl(StateAccessTypeObject *self,
75 PyTypeObject *cls,
76 int n, int twice);
77
78 static PyObject *
79 _testmultiphase_StateAccessType_increment_count_clinic(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
80 {
81 PyObject *return_value = NULL;
82 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
83
84 #define NUM_KEYWORDS 2
85 static struct {
86 PyGC_Head _this_is_not_used;
87 PyObject_VAR_HEAD
88 Py_hash_t ob_hash;
89 PyObject *ob_item[NUM_KEYWORDS];
90 } _kwtuple = {
91 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
92 .ob_hash = -1,
93 .ob_item = { _Py_LATIN1_CHR('n'), &_Py_ID(twice), },
94 };
95 #undef NUM_KEYWORDS
96 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
97
98 #else // !Py_BUILD_CORE
99 # define KWTUPLE NULL
100 #endif // !Py_BUILD_CORE
101
102 static const char * const _keywords[] = {"n", "twice", NULL};
103 static _PyArg_Parser _parser = {
104 .keywords = _keywords,
105 .fname = "increment_count_clinic",
106 .kwtuple = KWTUPLE,
107 };
108 #undef KWTUPLE
109 PyObject *argsbuf[2];
110 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
111 int n = 1;
112 int twice = 0;
113
114 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
115 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
116 if (!args) {
117 goto exit;
118 }
119 if (!noptargs) {
120 goto skip_optional_pos;
121 }
122 if (args[0]) {
123 n = PyLong_AsInt(args[0]);
124 if (n == -1 && PyErr_Occurred()) {
125 goto exit;
126 }
127 if (!--noptargs) {
128 goto skip_optional_pos;
129 }
130 }
131 skip_optional_pos:
132 if (!noptargs) {
133 goto skip_optional_kwonly;
134 }
135 twice = PyObject_IsTrue(args[1]);
136 if (twice < 0) {
137 goto exit;
138 }
139 skip_optional_kwonly:
140 return_value = _testmultiphase_StateAccessType_increment_count_clinic_impl((StateAccessTypeObject *)self, cls, n, twice);
141
142 exit:
143 return return_value;
144 }
145
146 PyDoc_STRVAR(_testmultiphase_StateAccessType_get_count__doc__,
147 "get_count($self, /)\n"
148 "--\n"
149 "\n"
150 "Return the value of the module-state counter.");
151
152 #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_COUNT_METHODDEF \
153 {"get_count", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_count), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_count__doc__},
154
155 static PyObject *
156 _testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self,
157 PyTypeObject *cls);
158
159 static PyObject *
160 _testmultiphase_StateAccessType_get_count(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
161 {
162 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
163 PyErr_SetString(PyExc_TypeError, "get_count() takes no arguments");
164 return NULL;
165 }
166 return _testmultiphase_StateAccessType_get_count_impl((StateAccessTypeObject *)self, cls);
167 }
168 /*[clinic end generated code: output=aff91f6219a7baca input=a9049054013a1b77]*/