| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
PyDoc_STRVAR(test_empty_function__doc__, |
| 6 |
"test_empty_function($module, /)\n" |
| 7 |
"--\n" |
| 8 |
"\n"); |
| 9 |
|
| 10 |
#define TEST_EMPTY_FUNCTION_METHODDEF \ |
| 11 |
{"test_empty_function", (PyCFunction)test_empty_function, METH_NOARGS, test_empty_function__doc__}, |
| 12 |
|
| 13 |
static PyObject * |
| 14 |
test_empty_function_impl(PyObject *module); |
| 15 |
|
| 16 |
static PyObject * |
| 17 |
test_empty_function(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 18 |
{ |
| 19 |
return test_empty_function_impl(module); |
| 20 |
} |
| 21 |
|
| 22 |
PyDoc_STRVAR(my_int_func__doc__, |
| 23 |
"my_int_func($module, arg, /)\n" |
| 24 |
"--\n" |
| 25 |
"\n"); |
| 26 |
|
| 27 |
#define MY_INT_FUNC_METHODDEF \ |
| 28 |
{"my_int_func", (PyCFunction)my_int_func, METH_O, my_int_func__doc__}, |
| 29 |
|
| 30 |
static int |
| 31 |
my_int_func_impl(PyObject *module, int arg); |
| 32 |
|
| 33 |
static PyObject * |
| 34 |
my_int_func(PyObject *module, PyObject *arg_) |
| 35 |
{ |
| 36 |
PyObject *return_value = NULL; |
| 37 |
int arg; |
| 38 |
int _return_value; |
| 39 |
|
| 40 |
arg = PyLong_AsInt(arg_); |
| 41 |
if (arg == -1 && PyErr_Occurred()) { |
| 42 |
goto exit; |
| 43 |
} |
| 44 |
_return_value = my_int_func_impl(module, arg); |
| 45 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 46 |
goto exit; |
| 47 |
} |
| 48 |
return_value = PyLong_FromLong((long)_return_value); |
| 49 |
|
| 50 |
exit: |
| 51 |
return return_value; |
| 52 |
} |
| 53 |
|
| 54 |
PyDoc_STRVAR(my_int_sum__doc__, |
| 55 |
"my_int_sum($module, x, y, /)\n" |
| 56 |
"--\n" |
| 57 |
"\n"); |
| 58 |
|
| 59 |
#define MY_INT_SUM_METHODDEF \ |
| 60 |
{"my_int_sum", (PyCFunction)(void(*)(void))my_int_sum, METH_FASTCALL, my_int_sum__doc__}, |
| 61 |
|
| 62 |
static int |
| 63 |
my_int_sum_impl(PyObject *module, int x, int y); |
| 64 |
|
| 65 |
static PyObject * |
| 66 |
my_int_sum(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 67 |
{ |
| 68 |
PyObject *return_value = NULL; |
| 69 |
int x; |
| 70 |
int y; |
| 71 |
int _return_value; |
| 72 |
|
| 73 |
if (nargs != 2) { |
| 74 |
PyErr_Format(PyExc_TypeError, "my_int_sum expected 2 arguments, got %zd", nargs); |
| 75 |
goto exit; |
| 76 |
} |
| 77 |
x = PyLong_AsInt(args[0]); |
| 78 |
if (x == -1 && PyErr_Occurred()) { |
| 79 |
goto exit; |
| 80 |
} |
| 81 |
y = PyLong_AsInt(args[1]); |
| 82 |
if (y == -1 && PyErr_Occurred()) { |
| 83 |
goto exit; |
| 84 |
} |
| 85 |
_return_value = my_int_sum_impl(module, x, y); |
| 86 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 87 |
goto exit; |
| 88 |
} |
| 89 |
return_value = PyLong_FromLong((long)_return_value); |
| 90 |
|
| 91 |
exit: |
| 92 |
return return_value; |
| 93 |
} |
| 94 |
|
| 95 |
PyDoc_STRVAR(my_float_sum__doc__, |
| 96 |
"my_float_sum($module, x, y, /)\n" |
| 97 |
"--\n" |
| 98 |
"\n"); |
| 99 |
|
| 100 |
#define MY_FLOAT_SUM_METHODDEF \ |
| 101 |
{"my_float_sum", (PyCFunction)(void(*)(void))my_float_sum, METH_FASTCALL, my_float_sum__doc__}, |
| 102 |
|
| 103 |
static float |
| 104 |
my_float_sum_impl(PyObject *module, float x, float y); |
| 105 |
|
| 106 |
static PyObject * |
| 107 |
my_float_sum(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 108 |
{ |
| 109 |
PyObject *return_value = NULL; |
| 110 |
float x; |
| 111 |
float y; |
| 112 |
float _return_value; |
| 113 |
|
| 114 |
if (nargs != 2) { |
| 115 |
PyErr_Format(PyExc_TypeError, "my_float_sum expected 2 arguments, got %zd", nargs); |
| 116 |
goto exit; |
| 117 |
} |
| 118 |
x = (float) PyFloat_AsDouble(args[0]); |
| 119 |
if (x == -1.0 && PyErr_Occurred()) { |
| 120 |
goto exit; |
| 121 |
} |
| 122 |
y = (float) PyFloat_AsDouble(args[1]); |
| 123 |
if (y == -1.0 && PyErr_Occurred()) { |
| 124 |
goto exit; |
| 125 |
} |
| 126 |
_return_value = my_float_sum_impl(module, x, y); |
| 127 |
if ((_return_value == -1.0) && PyErr_Occurred()) { |
| 128 |
goto exit; |
| 129 |
} |
| 130 |
return_value = PyFloat_FromDouble((double)_return_value); |
| 131 |
|
| 132 |
exit: |
| 133 |
return return_value; |
| 134 |
} |
| 135 |
|
| 136 |
PyDoc_STRVAR(my_double_sum__doc__, |
| 137 |
"my_double_sum($module, x, y, /)\n" |
| 138 |
"--\n" |
| 139 |
"\n"); |
| 140 |
|
| 141 |
#define MY_DOUBLE_SUM_METHODDEF \ |
| 142 |
{"my_double_sum", (PyCFunction)(void(*)(void))my_double_sum, METH_FASTCALL, my_double_sum__doc__}, |
| 143 |
|
| 144 |
static double |
| 145 |
my_double_sum_impl(PyObject *module, double x, double y); |
| 146 |
|
| 147 |
static PyObject * |
| 148 |
my_double_sum(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 149 |
{ |
| 150 |
PyObject *return_value = NULL; |
| 151 |
double x; |
| 152 |
double y; |
| 153 |
double _return_value; |
| 154 |
|
| 155 |
if (nargs != 2) { |
| 156 |
PyErr_Format(PyExc_TypeError, "my_double_sum expected 2 arguments, got %zd", nargs); |
| 157 |
goto exit; |
| 158 |
} |
| 159 |
x = PyFloat_AsDouble(args[0]); |
| 160 |
if (x == -1.0 && PyErr_Occurred()) { |
| 161 |
goto exit; |
| 162 |
} |
| 163 |
y = PyFloat_AsDouble(args[1]); |
| 164 |
if (y == -1.0 && PyErr_Occurred()) { |
| 165 |
goto exit; |
| 166 |
} |
| 167 |
_return_value = my_double_sum_impl(module, x, y); |
| 168 |
if ((_return_value == -1.0) && PyErr_Occurred()) { |
| 169 |
goto exit; |
| 170 |
} |
| 171 |
return_value = PyFloat_FromDouble(_return_value); |
| 172 |
|
| 173 |
exit: |
| 174 |
return return_value; |
| 175 |
} |
| 176 |
|
| 177 |
PyDoc_STRVAR(get_file_descriptor__doc__, |
| 178 |
"get_file_descriptor($module, file, /)\n" |
| 179 |
"--\n" |
| 180 |
"\n" |
| 181 |
"Get a file descriptor."); |
| 182 |
|
| 183 |
#define GET_FILE_DESCRIPTOR_METHODDEF \ |
| 184 |
{"get_file_descriptor", (PyCFunction)get_file_descriptor, METH_O, get_file_descriptor__doc__}, |
| 185 |
|
| 186 |
static int |
| 187 |
get_file_descriptor_impl(PyObject *module, int fd); |
| 188 |
|
| 189 |
static PyObject * |
| 190 |
get_file_descriptor(PyObject *module, PyObject *arg) |
| 191 |
{ |
| 192 |
PyObject *return_value = NULL; |
| 193 |
int fd; |
| 194 |
int _return_value; |
| 195 |
|
| 196 |
fd = PyObject_AsFileDescriptor(arg); |
| 197 |
if (fd < 0) { |
| 198 |
goto exit; |
| 199 |
} |
| 200 |
_return_value = get_file_descriptor_impl(module, fd); |
| 201 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 202 |
goto exit; |
| 203 |
} |
| 204 |
return_value = PyLong_FromLong((long)_return_value); |
| 205 |
|
| 206 |
exit: |
| 207 |
return return_value; |
| 208 |
} |
| 209 |
/*[clinic end generated code: output=03fd7811c056dc74 input=a9049054013a1b77]*/ |