| 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_runtime.h" // _Py_SINGLETON() |
| 7 |
#endif |
| 8 |
#include "pycore_abstract.h" // _PyNumber_Index() |
| 9 |
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
| 10 |
|
| 11 |
PyDoc_STRVAR(_ctypes_CType_Type___sizeof____doc__, |
| 12 |
"__sizeof__($self, /)\n" |
| 13 |
"--\n" |
| 14 |
"\n" |
| 15 |
"Return memory consumption of the type object."); |
| 16 |
|
| 17 |
#define _CTYPES_CTYPE_TYPE___SIZEOF___METHODDEF \ |
| 18 |
{"__sizeof__", _PyCFunction_CAST(_ctypes_CType_Type___sizeof__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _ctypes_CType_Type___sizeof____doc__}, |
| 19 |
|
| 20 |
static PyObject * |
| 21 |
_ctypes_CType_Type___sizeof___impl(PyObject *self, PyTypeObject *cls); |
| 22 |
|
| 23 |
static PyObject * |
| 24 |
_ctypes_CType_Type___sizeof__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 25 |
{ |
| 26 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 27 |
PyErr_SetString(PyExc_TypeError, "__sizeof__() takes no arguments"); |
| 28 |
return NULL; |
| 29 |
} |
| 30 |
return _ctypes_CType_Type___sizeof___impl(self, cls); |
| 31 |
} |
| 32 |
|
| 33 |
PyDoc_STRVAR(CDataType_from_address__doc__, |
| 34 |
"from_address($self, value, /)\n" |
| 35 |
"--\n" |
| 36 |
"\n" |
| 37 |
"C.from_address(integer) -> C instance\n" |
| 38 |
"\n" |
| 39 |
"Access a C instance at the specified address."); |
| 40 |
|
| 41 |
#define CDATATYPE_FROM_ADDRESS_METHODDEF \ |
| 42 |
{"from_address", _PyCFunction_CAST(CDataType_from_address), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, CDataType_from_address__doc__}, |
| 43 |
|
| 44 |
static PyObject * |
| 45 |
CDataType_from_address_impl(PyObject *type, PyTypeObject *cls, |
| 46 |
PyObject *value); |
| 47 |
|
| 48 |
static PyObject * |
| 49 |
CDataType_from_address(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 50 |
{ |
| 51 |
PyObject *return_value = NULL; |
| 52 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 53 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 54 |
#else |
| 55 |
# define KWTUPLE NULL |
| 56 |
#endif |
| 57 |
|
| 58 |
static const char * const _keywords[] = {"", NULL}; |
| 59 |
static _PyArg_Parser _parser = { |
| 60 |
.keywords = _keywords, |
| 61 |
.fname = "from_address", |
| 62 |
.kwtuple = KWTUPLE, |
| 63 |
}; |
| 64 |
#undef KWTUPLE |
| 65 |
PyObject *argsbuf[1]; |
| 66 |
PyObject *value; |
| 67 |
|
| 68 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 69 |
if (!args) { |
| 70 |
goto exit; |
| 71 |
} |
| 72 |
value = args[0]; |
| 73 |
return_value = CDataType_from_address_impl(type, cls, value); |
| 74 |
|
| 75 |
exit: |
| 76 |
return return_value; |
| 77 |
} |
| 78 |
|
| 79 |
PyDoc_STRVAR(CDataType_from_buffer__doc__, |
| 80 |
"from_buffer($self, obj, offset=0, /)\n" |
| 81 |
"--\n" |
| 82 |
"\n" |
| 83 |
"C.from_buffer(object, offset=0) -> C instance\n" |
| 84 |
"\n" |
| 85 |
"Create a C instance from a writeable buffer."); |
| 86 |
|
| 87 |
#define CDATATYPE_FROM_BUFFER_METHODDEF \ |
| 88 |
{"from_buffer", _PyCFunction_CAST(CDataType_from_buffer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, CDataType_from_buffer__doc__}, |
| 89 |
|
| 90 |
static PyObject * |
| 91 |
CDataType_from_buffer_impl(PyObject *type, PyTypeObject *cls, PyObject *obj, |
| 92 |
Py_ssize_t offset); |
| 93 |
|
| 94 |
static PyObject * |
| 95 |
CDataType_from_buffer(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 96 |
{ |
| 97 |
PyObject *return_value = NULL; |
| 98 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 99 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 100 |
#else |
| 101 |
# define KWTUPLE NULL |
| 102 |
#endif |
| 103 |
|
| 104 |
static const char * const _keywords[] = {"", "", NULL}; |
| 105 |
static _PyArg_Parser _parser = { |
| 106 |
.keywords = _keywords, |
| 107 |
.fname = "from_buffer", |
| 108 |
.kwtuple = KWTUPLE, |
| 109 |
}; |
| 110 |
#undef KWTUPLE |
| 111 |
PyObject *argsbuf[2]; |
| 112 |
PyObject *obj; |
| 113 |
Py_ssize_t offset = 0; |
| 114 |
|
| 115 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
| 116 |
if (!args) { |
| 117 |
goto exit; |
| 118 |
} |
| 119 |
obj = args[0]; |
| 120 |
if (nargs < 2) { |
| 121 |
goto skip_optional_posonly; |
| 122 |
} |
| 123 |
{ |
| 124 |
Py_ssize_t ival = -1; |
| 125 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 126 |
if (iobj != NULL) { |
| 127 |
ival = PyLong_AsSsize_t(iobj); |
| 128 |
Py_DECREF(iobj); |
| 129 |
} |
| 130 |
if (ival == -1 && PyErr_Occurred()) { |
| 131 |
goto exit; |
| 132 |
} |
| 133 |
offset = ival; |
| 134 |
} |
| 135 |
skip_optional_posonly: |
| 136 |
return_value = CDataType_from_buffer_impl(type, cls, obj, offset); |
| 137 |
|
| 138 |
exit: |
| 139 |
return return_value; |
| 140 |
} |
| 141 |
|
| 142 |
PyDoc_STRVAR(CDataType_from_buffer_copy__doc__, |
| 143 |
"from_buffer_copy($self, buffer, offset=0, /)\n" |
| 144 |
"--\n" |
| 145 |
"\n" |
| 146 |
"C.from_buffer_copy(object, offset=0) -> C instance\n" |
| 147 |
"\n" |
| 148 |
"Create a C instance from a readable buffer."); |
| 149 |
|
| 150 |
#define CDATATYPE_FROM_BUFFER_COPY_METHODDEF \ |
| 151 |
{"from_buffer_copy", _PyCFunction_CAST(CDataType_from_buffer_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, CDataType_from_buffer_copy__doc__}, |
| 152 |
|
| 153 |
static PyObject * |
| 154 |
CDataType_from_buffer_copy_impl(PyObject *type, PyTypeObject *cls, |
| 155 |
Py_buffer *buffer, Py_ssize_t offset); |
| 156 |
|
| 157 |
static PyObject * |
| 158 |
CDataType_from_buffer_copy(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 159 |
{ |
| 160 |
PyObject *return_value = NULL; |
| 161 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 162 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 163 |
#else |
| 164 |
# define KWTUPLE NULL |
| 165 |
#endif |
| 166 |
|
| 167 |
static const char * const _keywords[] = {"", "", NULL}; |
| 168 |
static _PyArg_Parser _parser = { |
| 169 |
.keywords = _keywords, |
| 170 |
.fname = "from_buffer_copy", |
| 171 |
.kwtuple = KWTUPLE, |
| 172 |
}; |
| 173 |
#undef KWTUPLE |
| 174 |
PyObject *argsbuf[2]; |
| 175 |
Py_buffer buffer = {NULL, NULL}; |
| 176 |
Py_ssize_t offset = 0; |
| 177 |
|
| 178 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
| 179 |
if (!args) { |
| 180 |
goto exit; |
| 181 |
} |
| 182 |
if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) { |
| 183 |
goto exit; |
| 184 |
} |
| 185 |
if (nargs < 2) { |
| 186 |
goto skip_optional_posonly; |
| 187 |
} |
| 188 |
{ |
| 189 |
Py_ssize_t ival = -1; |
| 190 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 191 |
if (iobj != NULL) { |
| 192 |
ival = PyLong_AsSsize_t(iobj); |
| 193 |
Py_DECREF(iobj); |
| 194 |
} |
| 195 |
if (ival == -1 && PyErr_Occurred()) { |
| 196 |
goto exit; |
| 197 |
} |
| 198 |
offset = ival; |
| 199 |
} |
| 200 |
skip_optional_posonly: |
| 201 |
return_value = CDataType_from_buffer_copy_impl(type, cls, &buffer, offset); |
| 202 |
|
| 203 |
exit: |
| 204 |
/* Cleanup for buffer */ |
| 205 |
if (buffer.obj) { |
| 206 |
PyBuffer_Release(&buffer); |
| 207 |
} |
| 208 |
|
| 209 |
return return_value; |
| 210 |
} |
| 211 |
|
| 212 |
PyDoc_STRVAR(CDataType_in_dll__doc__, |
| 213 |
"in_dll($self, dll, name, /)\n" |
| 214 |
"--\n" |
| 215 |
"\n" |
| 216 |
"C.in_dll(dll, name) -> C instance\n" |
| 217 |
"\n" |
| 218 |
"Access a C instance in a dll."); |
| 219 |
|
| 220 |
#define CDATATYPE_IN_DLL_METHODDEF \ |
| 221 |
{"in_dll", _PyCFunction_CAST(CDataType_in_dll), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, CDataType_in_dll__doc__}, |
| 222 |
|
| 223 |
static PyObject * |
| 224 |
CDataType_in_dll_impl(PyObject *type, PyTypeObject *cls, PyObject *dll, |
| 225 |
const char *name); |
| 226 |
|
| 227 |
static PyObject * |
| 228 |
CDataType_in_dll(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 229 |
{ |
| 230 |
PyObject *return_value = NULL; |
| 231 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 232 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 233 |
#else |
| 234 |
# define KWTUPLE NULL |
| 235 |
#endif |
| 236 |
|
| 237 |
static const char * const _keywords[] = {"", "", NULL}; |
| 238 |
static _PyArg_Parser _parser = { |
| 239 |
.keywords = _keywords, |
| 240 |
.fname = "in_dll", |
| 241 |
.kwtuple = KWTUPLE, |
| 242 |
}; |
| 243 |
#undef KWTUPLE |
| 244 |
PyObject *argsbuf[2]; |
| 245 |
PyObject *dll; |
| 246 |
const char *name; |
| 247 |
|
| 248 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
| 249 |
if (!args) { |
| 250 |
goto exit; |
| 251 |
} |
| 252 |
dll = args[0]; |
| 253 |
if (!PyUnicode_Check(args[1])) { |
| 254 |
_PyArg_BadArgument("in_dll", "argument 2", "str", args[1]); |
| 255 |
goto exit; |
| 256 |
} |
| 257 |
Py_ssize_t name_length; |
| 258 |
name = PyUnicode_AsUTF8AndSize(args[1], &name_length); |
| 259 |
if (name == NULL) { |
| 260 |
goto exit; |
| 261 |
} |
| 262 |
if (strlen(name) != (size_t)name_length) { |
| 263 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 264 |
goto exit; |
| 265 |
} |
| 266 |
return_value = CDataType_in_dll_impl(type, cls, dll, name); |
| 267 |
|
| 268 |
exit: |
| 269 |
return return_value; |
| 270 |
} |
| 271 |
|
| 272 |
PyDoc_STRVAR(CDataType_from_param__doc__, |
| 273 |
"from_param($self, value, /)\n" |
| 274 |
"--\n" |
| 275 |
"\n" |
| 276 |
"Convert a Python object into a function call parameter."); |
| 277 |
|
| 278 |
#define CDATATYPE_FROM_PARAM_METHODDEF \ |
| 279 |
{"from_param", _PyCFunction_CAST(CDataType_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, CDataType_from_param__doc__}, |
| 280 |
|
| 281 |
static PyObject * |
| 282 |
CDataType_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value); |
| 283 |
|
| 284 |
static PyObject * |
| 285 |
CDataType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 286 |
{ |
| 287 |
PyObject *return_value = NULL; |
| 288 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 289 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 290 |
#else |
| 291 |
# define KWTUPLE NULL |
| 292 |
#endif |
| 293 |
|
| 294 |
static const char * const _keywords[] = {"", NULL}; |
| 295 |
static _PyArg_Parser _parser = { |
| 296 |
.keywords = _keywords, |
| 297 |
.fname = "from_param", |
| 298 |
.kwtuple = KWTUPLE, |
| 299 |
}; |
| 300 |
#undef KWTUPLE |
| 301 |
PyObject *argsbuf[1]; |
| 302 |
PyObject *value; |
| 303 |
|
| 304 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 305 |
if (!args) { |
| 306 |
goto exit; |
| 307 |
} |
| 308 |
value = args[0]; |
| 309 |
return_value = CDataType_from_param_impl(type, cls, value); |
| 310 |
|
| 311 |
exit: |
| 312 |
return return_value; |
| 313 |
} |
| 314 |
|
| 315 |
PyDoc_STRVAR(PyCPointerType_set_type__doc__, |
| 316 |
"set_type($self, type, /)\n" |
| 317 |
"--\n" |
| 318 |
"\n"); |
| 319 |
|
| 320 |
#define PYCPOINTERTYPE_SET_TYPE_METHODDEF \ |
| 321 |
{"set_type", _PyCFunction_CAST(PyCPointerType_set_type), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, PyCPointerType_set_type__doc__}, |
| 322 |
|
| 323 |
static PyObject * |
| 324 |
PyCPointerType_set_type_impl(PyTypeObject *self, PyTypeObject *cls, |
| 325 |
PyObject *type); |
| 326 |
|
| 327 |
static PyObject * |
| 328 |
PyCPointerType_set_type(PyTypeObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 329 |
{ |
| 330 |
PyObject *return_value = NULL; |
| 331 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 332 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 333 |
#else |
| 334 |
# define KWTUPLE NULL |
| 335 |
#endif |
| 336 |
|
| 337 |
static const char * const _keywords[] = {"", NULL}; |
| 338 |
static _PyArg_Parser _parser = { |
| 339 |
.keywords = _keywords, |
| 340 |
.fname = "set_type", |
| 341 |
.kwtuple = KWTUPLE, |
| 342 |
}; |
| 343 |
#undef KWTUPLE |
| 344 |
PyObject *argsbuf[1]; |
| 345 |
PyObject *type; |
| 346 |
|
| 347 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 348 |
if (!args) { |
| 349 |
goto exit; |
| 350 |
} |
| 351 |
type = args[0]; |
| 352 |
return_value = PyCPointerType_set_type_impl(self, cls, type); |
| 353 |
|
| 354 |
exit: |
| 355 |
return return_value; |
| 356 |
} |
| 357 |
|
| 358 |
PyDoc_STRVAR(PyCPointerType_from_param__doc__, |
| 359 |
"from_param($self, value, /)\n" |
| 360 |
"--\n" |
| 361 |
"\n" |
| 362 |
"Convert a Python object into a function call parameter."); |
| 363 |
|
| 364 |
#define PYCPOINTERTYPE_FROM_PARAM_METHODDEF \ |
| 365 |
{"from_param", _PyCFunction_CAST(PyCPointerType_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, PyCPointerType_from_param__doc__}, |
| 366 |
|
| 367 |
static PyObject * |
| 368 |
PyCPointerType_from_param_impl(PyObject *type, PyTypeObject *cls, |
| 369 |
PyObject *value); |
| 370 |
|
| 371 |
static PyObject * |
| 372 |
PyCPointerType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 373 |
{ |
| 374 |
PyObject *return_value = NULL; |
| 375 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 376 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 377 |
#else |
| 378 |
# define KWTUPLE NULL |
| 379 |
#endif |
| 380 |
|
| 381 |
static const char * const _keywords[] = {"", NULL}; |
| 382 |
static _PyArg_Parser _parser = { |
| 383 |
.keywords = _keywords, |
| 384 |
.fname = "from_param", |
| 385 |
.kwtuple = KWTUPLE, |
| 386 |
}; |
| 387 |
#undef KWTUPLE |
| 388 |
PyObject *argsbuf[1]; |
| 389 |
PyObject *value; |
| 390 |
|
| 391 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 392 |
if (!args) { |
| 393 |
goto exit; |
| 394 |
} |
| 395 |
value = args[0]; |
| 396 |
return_value = PyCPointerType_from_param_impl(type, cls, value); |
| 397 |
|
| 398 |
exit: |
| 399 |
return return_value; |
| 400 |
} |
| 401 |
|
| 402 |
PyDoc_STRVAR(c_wchar_p_from_param__doc__, |
| 403 |
"from_param($self, value, /)\n" |
| 404 |
"--\n" |
| 405 |
"\n"); |
| 406 |
|
| 407 |
#define C_WCHAR_P_FROM_PARAM_METHODDEF \ |
| 408 |
{"from_param", _PyCFunction_CAST(c_wchar_p_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, c_wchar_p_from_param__doc__}, |
| 409 |
|
| 410 |
static PyObject * |
| 411 |
c_wchar_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value); |
| 412 |
|
| 413 |
static PyObject * |
| 414 |
c_wchar_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 415 |
{ |
| 416 |
PyObject *return_value = NULL; |
| 417 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 418 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 419 |
#else |
| 420 |
# define KWTUPLE NULL |
| 421 |
#endif |
| 422 |
|
| 423 |
static const char * const _keywords[] = {"", NULL}; |
| 424 |
static _PyArg_Parser _parser = { |
| 425 |
.keywords = _keywords, |
| 426 |
.fname = "from_param", |
| 427 |
.kwtuple = KWTUPLE, |
| 428 |
}; |
| 429 |
#undef KWTUPLE |
| 430 |
PyObject *argsbuf[1]; |
| 431 |
PyObject *value; |
| 432 |
|
| 433 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 434 |
if (!args) { |
| 435 |
goto exit; |
| 436 |
} |
| 437 |
value = args[0]; |
| 438 |
return_value = c_wchar_p_from_param_impl(type, cls, value); |
| 439 |
|
| 440 |
exit: |
| 441 |
return return_value; |
| 442 |
} |
| 443 |
|
| 444 |
PyDoc_STRVAR(c_char_p_from_param__doc__, |
| 445 |
"from_param($self, value, /)\n" |
| 446 |
"--\n" |
| 447 |
"\n"); |
| 448 |
|
| 449 |
#define C_CHAR_P_FROM_PARAM_METHODDEF \ |
| 450 |
{"from_param", _PyCFunction_CAST(c_char_p_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, c_char_p_from_param__doc__}, |
| 451 |
|
| 452 |
static PyObject * |
| 453 |
c_char_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value); |
| 454 |
|
| 455 |
static PyObject * |
| 456 |
c_char_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 457 |
{ |
| 458 |
PyObject *return_value = NULL; |
| 459 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 460 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 461 |
#else |
| 462 |
# define KWTUPLE NULL |
| 463 |
#endif |
| 464 |
|
| 465 |
static const char * const _keywords[] = {"", NULL}; |
| 466 |
static _PyArg_Parser _parser = { |
| 467 |
.keywords = _keywords, |
| 468 |
.fname = "from_param", |
| 469 |
.kwtuple = KWTUPLE, |
| 470 |
}; |
| 471 |
#undef KWTUPLE |
| 472 |
PyObject *argsbuf[1]; |
| 473 |
PyObject *value; |
| 474 |
|
| 475 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 476 |
if (!args) { |
| 477 |
goto exit; |
| 478 |
} |
| 479 |
value = args[0]; |
| 480 |
return_value = c_char_p_from_param_impl(type, cls, value); |
| 481 |
|
| 482 |
exit: |
| 483 |
return return_value; |
| 484 |
} |
| 485 |
|
| 486 |
PyDoc_STRVAR(c_void_p_from_param__doc__, |
| 487 |
"from_param($self, value, /)\n" |
| 488 |
"--\n" |
| 489 |
"\n"); |
| 490 |
|
| 491 |
#define C_VOID_P_FROM_PARAM_METHODDEF \ |
| 492 |
{"from_param", _PyCFunction_CAST(c_void_p_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, c_void_p_from_param__doc__}, |
| 493 |
|
| 494 |
static PyObject * |
| 495 |
c_void_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value); |
| 496 |
|
| 497 |
static PyObject * |
| 498 |
c_void_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 499 |
{ |
| 500 |
PyObject *return_value = NULL; |
| 501 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 502 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 503 |
#else |
| 504 |
# define KWTUPLE NULL |
| 505 |
#endif |
| 506 |
|
| 507 |
static const char * const _keywords[] = {"", NULL}; |
| 508 |
static _PyArg_Parser _parser = { |
| 509 |
.keywords = _keywords, |
| 510 |
.fname = "from_param", |
| 511 |
.kwtuple = KWTUPLE, |
| 512 |
}; |
| 513 |
#undef KWTUPLE |
| 514 |
PyObject *argsbuf[1]; |
| 515 |
PyObject *value; |
| 516 |
|
| 517 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 518 |
if (!args) { |
| 519 |
goto exit; |
| 520 |
} |
| 521 |
value = args[0]; |
| 522 |
return_value = c_void_p_from_param_impl(type, cls, value); |
| 523 |
|
| 524 |
exit: |
| 525 |
return return_value; |
| 526 |
} |
| 527 |
|
| 528 |
PyDoc_STRVAR(PyCSimpleType_from_param__doc__, |
| 529 |
"from_param($self, value, /)\n" |
| 530 |
"--\n" |
| 531 |
"\n" |
| 532 |
"Convert a Python object into a function call parameter."); |
| 533 |
|
| 534 |
#define PYCSIMPLETYPE_FROM_PARAM_METHODDEF \ |
| 535 |
{"from_param", _PyCFunction_CAST(PyCSimpleType_from_param), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, PyCSimpleType_from_param__doc__}, |
| 536 |
|
| 537 |
static PyObject * |
| 538 |
PyCSimpleType_from_param_impl(PyObject *type, PyTypeObject *cls, |
| 539 |
PyObject *value); |
| 540 |
|
| 541 |
static PyObject * |
| 542 |
PyCSimpleType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 543 |
{ |
| 544 |
PyObject *return_value = NULL; |
| 545 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 546 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 547 |
#else |
| 548 |
# define KWTUPLE NULL |
| 549 |
#endif |
| 550 |
|
| 551 |
static const char * const _keywords[] = {"", NULL}; |
| 552 |
static _PyArg_Parser _parser = { |
| 553 |
.keywords = _keywords, |
| 554 |
.fname = "from_param", |
| 555 |
.kwtuple = KWTUPLE, |
| 556 |
}; |
| 557 |
#undef KWTUPLE |
| 558 |
PyObject *argsbuf[1]; |
| 559 |
PyObject *value; |
| 560 |
|
| 561 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 562 |
if (!args) { |
| 563 |
goto exit; |
| 564 |
} |
| 565 |
value = args[0]; |
| 566 |
return_value = PyCSimpleType_from_param_impl(type, cls, value); |
| 567 |
|
| 568 |
exit: |
| 569 |
return return_value; |
| 570 |
} |
| 571 |
|
| 572 |
PyDoc_STRVAR(PyCData_reduce__doc__, |
| 573 |
"__reduce__($self, /)\n" |
| 574 |
"--\n" |
| 575 |
"\n"); |
| 576 |
|
| 577 |
#define PYCDATA_REDUCE_METHODDEF \ |
| 578 |
{"__reduce__", _PyCFunction_CAST(PyCData_reduce), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, PyCData_reduce__doc__}, |
| 579 |
|
| 580 |
static PyObject * |
| 581 |
PyCData_reduce_impl(PyObject *myself, PyTypeObject *cls); |
| 582 |
|
| 583 |
static PyObject * |
| 584 |
PyCData_reduce(PyObject *myself, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 585 |
{ |
| 586 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 587 |
PyErr_SetString(PyExc_TypeError, "__reduce__() takes no arguments"); |
| 588 |
return NULL; |
| 589 |
} |
| 590 |
return PyCData_reduce_impl(myself, cls); |
| 591 |
} |
| 592 |
|
| 593 |
PyDoc_STRVAR(Simple_from_outparm__doc__, |
| 594 |
"__ctypes_from_outparam__($self, /)\n" |
| 595 |
"--\n" |
| 596 |
"\n"); |
| 597 |
|
| 598 |
#define SIMPLE_FROM_OUTPARM_METHODDEF \ |
| 599 |
{"__ctypes_from_outparam__", _PyCFunction_CAST(Simple_from_outparm), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, Simple_from_outparm__doc__}, |
| 600 |
|
| 601 |
static PyObject * |
| 602 |
Simple_from_outparm_impl(PyObject *self, PyTypeObject *cls); |
| 603 |
|
| 604 |
static PyObject * |
| 605 |
Simple_from_outparm(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 606 |
{ |
| 607 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 608 |
PyErr_SetString(PyExc_TypeError, "__ctypes_from_outparam__() takes no arguments"); |
| 609 |
return NULL; |
| 610 |
} |
| 611 |
return Simple_from_outparm_impl(self, cls); |
| 612 |
} |
| 613 |
/*[clinic end generated code: output=a90886be2a294ee6 input=a9049054013a1b77]*/ |