1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(_testmultiphase_StateAccessType_get_defining_module__doc__,
6 "get_defining_module($self, /)\n"
7 "--\n"
8 "\n"
9 "Return the module of the defining class.\n"
10 "\n"
11 "Also tests that result of PyType_GetModuleByDef matches defining_class\'s\n"
12 "module.");
13
14 #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_DEFINING_MODULE_METHODDEF \
15 {"get_defining_module", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_defining_module), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__},
16
17 static PyObject *
18 _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self,
19 PyTypeObject *cls);
20
21 static PyObject *
_testmultiphase_StateAccessType_get_defining_module(StateAccessTypeObject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)22 _testmultiphase_StateAccessType_get_defining_module(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
23 {
24 if (nargs) {
25 PyErr_SetString(PyExc_TypeError, "get_defining_module() takes no arguments");
26 return NULL;
27 }
28 return _testmultiphase_StateAccessType_get_defining_module_impl(self, cls);
29 }
30
31 PyDoc_STRVAR(_testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__,
32 "getmodulebydef_bad_def($self, /)\n"
33 "--\n"
34 "\n"
35 "Test that result of PyType_GetModuleByDef with a bad def is NULL.");
36
37 #define _TESTMULTIPHASE_STATEACCESSTYPE_GETMODULEBYDEF_BAD_DEF_METHODDEF \
38 {"getmodulebydef_bad_def", _PyCFunction_CAST(_testmultiphase_StateAccessType_getmodulebydef_bad_def), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_getmodulebydef_bad_def__doc__},
39
40 static PyObject *
41 _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(StateAccessTypeObject *self,
42 PyTypeObject *cls);
43
44 static PyObject *
_testmultiphase_StateAccessType_getmodulebydef_bad_def(StateAccessTypeObject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)45 _testmultiphase_StateAccessType_getmodulebydef_bad_def(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
46 {
47 if (nargs) {
48 PyErr_SetString(PyExc_TypeError, "getmodulebydef_bad_def() takes no arguments");
49 return NULL;
50 }
51 return _testmultiphase_StateAccessType_getmodulebydef_bad_def_impl(self, cls);
52 }
53
54 PyDoc_STRVAR(_testmultiphase_StateAccessType_increment_count_clinic__doc__,
55 "increment_count_clinic($self, /, n=1, *, twice=False)\n"
56 "--\n"
57 "\n"
58 "Add \'n\' from the module-state counter.\n"
59 "\n"
60 "Pass \'twice\' to double that amount.\n"
61 "\n"
62 "This tests Argument Clinic support for defining_class.");
63
64 #define _TESTMULTIPHASE_STATEACCESSTYPE_INCREMENT_COUNT_CLINIC_METHODDEF \
65 {"increment_count_clinic", _PyCFunction_CAST(_testmultiphase_StateAccessType_increment_count_clinic), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_increment_count_clinic__doc__},
66
67 static PyObject *
68 _testmultiphase_StateAccessType_increment_count_clinic_impl(StateAccessTypeObject *self,
69 PyTypeObject *cls,
70 int n, int twice);
71
72 static PyObject *
_testmultiphase_StateAccessType_increment_count_clinic(StateAccessTypeObject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)73 _testmultiphase_StateAccessType_increment_count_clinic(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
74 {
75 PyObject *return_value = NULL;
76 static const char * const _keywords[] = {"n", "twice", NULL};
77 static _PyArg_Parser _parser = {NULL, _keywords, "increment_count_clinic", 0};
78 PyObject *argsbuf[2];
79 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
80 int n = 1;
81 int twice = 0;
82
83 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
84 if (!args) {
85 goto exit;
86 }
87 if (!noptargs) {
88 goto skip_optional_pos;
89 }
90 if (args[0]) {
91 n = _PyLong_AsInt(args[0]);
92 if (n == -1 && PyErr_Occurred()) {
93 goto exit;
94 }
95 if (!--noptargs) {
96 goto skip_optional_pos;
97 }
98 }
99 skip_optional_pos:
100 if (!noptargs) {
101 goto skip_optional_kwonly;
102 }
103 twice = PyObject_IsTrue(args[1]);
104 if (twice < 0) {
105 goto exit;
106 }
107 skip_optional_kwonly:
108 return_value = _testmultiphase_StateAccessType_increment_count_clinic_impl(self, cls, n, twice);
109
110 exit:
111 return return_value;
112 }
113
114 PyDoc_STRVAR(_testmultiphase_StateAccessType_get_count__doc__,
115 "get_count($self, /)\n"
116 "--\n"
117 "\n"
118 "Return the value of the module-state counter.");
119
120 #define _TESTMULTIPHASE_STATEACCESSTYPE_GET_COUNT_METHODDEF \
121 {"get_count", _PyCFunction_CAST(_testmultiphase_StateAccessType_get_count), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_count__doc__},
122
123 static PyObject *
124 _testmultiphase_StateAccessType_get_count_impl(StateAccessTypeObject *self,
125 PyTypeObject *cls);
126
127 static PyObject *
_testmultiphase_StateAccessType_get_count(StateAccessTypeObject * self,PyTypeObject * cls,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)128 _testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
129 {
130 if (nargs) {
131 PyErr_SetString(PyExc_TypeError, "get_count() takes no arguments");
132 return NULL;
133 }
134 return _testmultiphase_StateAccessType_get_count_impl(self, cls);
135 }
136 /*[clinic end generated code: output=48739d81c3834078 input=a9049054013a1b77]*/
137