diff -r b700278310ee Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Tue May 05 14:31:40 2015 +0300 +++ b/Modules/_ctypes/_ctypes.c Tue May 05 21:49:36 2015 +0300 @@ -99,6 +99,26 @@ bytes(cdata) * */ +/*[clinic input] +module _ctypes +class _ctypes.DictRemover "DictRemover *" "&DictRemover_Type" +class _ctypes.PyCStructType "PyObject *" "&PyCStructType_Type" +class _ctypes.UnionType "PyObject *" "&UnionType_Type" +class _ctypes.PyCPointerType "PyObject *" "&PyCPointerType_Type" +class _ctypes.PyCArrayType "PyObject *" "&PyCArrayType_Type" +class _ctypes.PyCSimpleType "PyObject *" "&PyCSimpleType_Type" +class _ctypes.PyCFuncPtrType "PyObject *" "&PyCFuncPtrType_Type" +class _ctypes._CData "PyObject *" "&PyCData_Type" +class _ctypes.PyCFuncPtr "PyCFuncPtrObject *" "&PyCFuncPtr_Type" +class _ctypes.Structure "PyObject *" "&Struct_Type" +class _ctypes.Union "PyObject *" "&Union_Type" +class _ctypes.Array "PyObject *" "&PyCArray_Type" +class _ctypes._SimpleCData "PyObject *" "&Simple_Type" +class _ctypes._Pointer "PyObject *" "&PyCPointer_Type" +class _ctypes.COMError "PyObject *" "&PyComError_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=dad5d6750c8ecb64]*/ + #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -162,8 +182,7 @@ static PyObject * Py_CLEAR(self->key); Py_CLEAR(self->dict); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyTypeObject DictRemover_Type = { @@ -436,132 +455,142 @@ UnionType_new(PyTypeObject *type, PyObje return StructUnionType_new(type, args, kwds, 0); } -static char from_address_doc[] = -"C.from_address(integer) -> C instance\naccess a C instance at the specified address"; +/*[clinic input] +_ctypes._CData.from_address + + address: object + / + +Access a C instance at the specified address. +[clinic start generated code]*/ static PyObject * -CDataType_from_address(PyObject *type, PyObject *value) +_ctypes__CData_from_address(PyObject *self, PyObject *address) +/*[clinic end generated code: output=58deebc6048da83a input=42552a505a65e315]*/ { void *buf; - if (!PyLong_Check(value)) { + if (!PyLong_Check(address)) { PyErr_SetString(PyExc_TypeError, "integer expected"); return NULL; } - buf = (void *)PyLong_AsVoidPtr(value); + buf = (void *)PyLong_AsVoidPtr(address); if (PyErr_Occurred()) return NULL; - return PyCData_AtAddress(type, buf); + return PyCData_AtAddress(self, buf); } -static char from_buffer_doc[] = -"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer"; - static int KeepRef(CDataObject *target, Py_ssize_t index, PyObject *keep); +/*[clinic input] +_ctypes._CData.from_buffer + + buffer: Py_buffer(accept={rwbuffer}) + offset: Py_ssize_t = 0 + / + +Create an instance from a writeable buffer. +[clinic start generated code]*/ + static PyObject * -CDataType_from_buffer(PyObject *type, PyObject *args) +_ctypes__CData_from_buffer_impl(PyObject *self, Py_buffer *buffer, + Py_ssize_t offset) +/*[clinic end generated code: output=7ad284f73e015e5d input=7ceb952b8e31fa89]*/ { - Py_buffer buffer; - Py_ssize_t offset = 0; PyObject *result, *mv; - StgDictObject *dict = PyType_stgdict(type); + StgDictObject *dict = PyType_stgdict(self); assert (dict); - if (!PyArg_ParseTuple(args, "w*|n:from_buffer", &buffer, &offset)) - return NULL; - if (offset < 0) { PyErr_SetString(PyExc_ValueError, "offset cannot be negative"); - PyBuffer_Release(&buffer); return NULL; } - if (dict->size > buffer.len - offset) { + if (dict->size > buffer->len - offset) { PyErr_Format(PyExc_ValueError, "Buffer size too small (%zd instead of at least %zd bytes)", - buffer.len, dict->size + offset); - PyBuffer_Release(&buffer); + buffer->len, dict->size + offset); return NULL; } - result = PyCData_AtAddress(type, (char *)buffer.buf + offset); - if (result == NULL) { - PyBuffer_Release(&buffer); + result = PyCData_AtAddress(self, (char *)buffer->buf + offset); + if (result == NULL) return NULL; - } - - mv = PyMemoryView_FromBuffer(&buffer); - if (mv == NULL) { - PyBuffer_Release(&buffer); + + mv = PyMemoryView_FromBuffer(buffer); + if (mv == NULL) return NULL; - } /* Hack the memoryview so that it will release the buffer. */ - ((PyMemoryViewObject *)mv)->mbuf->master.obj = buffer.obj; - ((PyMemoryViewObject *)mv)->view.obj = buffer.obj; + ((PyMemoryViewObject *)mv)->mbuf->master.obj = buffer->obj; + ((PyMemoryViewObject *)mv)->view.obj = buffer->obj; + buffer->obj = NULL; if (-1 == KeepRef((CDataObject *)result, -1, mv)) result = NULL; return result; } -static char from_buffer_copy_doc[] = -"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer"; - static PyObject * GenericPyCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +/*[clinic input] +_ctypes._CData.from_buffer_copy + + buffer: Py_buffer + offset: Py_ssize_t = 0 + / + +Create an instance from a readable buffer. +[clinic start generated code]*/ + static PyObject * -CDataType_from_buffer_copy(PyObject *type, PyObject *args) +_ctypes__CData_from_buffer_copy_impl(PyObject *self, Py_buffer *buffer, + Py_ssize_t offset) +/*[clinic end generated code: output=5e9ac2220ae087e5 input=4c0a63bf6f43a372]*/ { - Py_buffer buffer; - Py_ssize_t offset = 0; PyObject *result; - StgDictObject *dict = PyType_stgdict(type); + StgDictObject *dict = PyType_stgdict(self); assert (dict); - if (!PyArg_ParseTuple(args, "y*|n:from_buffer", &buffer, &offset)) - return NULL; - if (offset < 0) { PyErr_SetString(PyExc_ValueError, "offset cannot be negative"); - PyBuffer_Release(&buffer); return NULL; } - if (dict->size > buffer.len - offset) { + if (dict->size > buffer->len - offset) { PyErr_Format(PyExc_ValueError, "Buffer size too small (%zd instead of at least %zd bytes)", - buffer.len, dict->size + offset); - PyBuffer_Release(&buffer); + buffer->len, dict->size + offset); return NULL; } - result = GenericPyCData_new((PyTypeObject *)type, NULL, NULL); + result = GenericPyCData_new((PyTypeObject *)self, NULL, NULL); if (result != NULL) { memcpy(((CDataObject *)result)->b_ptr, - (char *)buffer.buf + offset, dict->size); - } - PyBuffer_Release(&buffer); + (char *)buffer->buf + offset, dict->size); + } return result; } -static char in_dll_doc[] = -"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll"; +/*[clinic input] +_ctypes._CData.in_dll + + dll: object + name: str + / + +Access a C instance in a dll. +[clinic start generated code]*/ static PyObject * -CDataType_in_dll(PyObject *type, PyObject *args) +_ctypes__CData_in_dll_impl(PyObject *self, PyObject *dll, const char *name) +/*[clinic end generated code: output=e3c80a884027d46d input=55eac1dcf5d12539]*/ { - PyObject *dll; - char *name; PyObject *obj; void *handle; void *address; - if (!PyArg_ParseTuple(args, "Os:in_dll", &dll, &name)) - return NULL; - obj = PyObject_GetAttrString(dll, "_handle"); if (!obj) return NULL; @@ -601,17 +630,24 @@ CDataType_in_dll(PyObject *type, PyObjec return NULL; } #endif - return PyCData_AtAddress(type, address); + return PyCData_AtAddress(self, address); } -static char from_param_doc[] = -"Convert a Python object into a function call parameter."; +/*[clinic input] +_ctypes._CData.from_param + + value: object + / + +Convert a Python object into a function call parameter. +[clinic start generated code]*/ static PyObject * -CDataType_from_param(PyObject *type, PyObject *value) +_ctypes__CData_from_param(PyObject *self, PyObject *value) +/*[clinic end generated code: output=22ce0f312ffa90a7 input=c5652468512c5247]*/ { PyObject *as_parameter; - int res = PyObject_IsInstance(value, type); + int res = PyObject_IsInstance(value, self); if (res == -1) return NULL; if (res) { @@ -623,7 +659,7 @@ CDataType_from_param(PyObject *type, PyO PyObject *ob = p->obj; const char *ob_name; StgDictObject *dict; - dict = PyType_stgdict(type); + dict = PyType_stgdict(self); /* If we got a PyCArgObject, we must check if the object packed in it is an instance of the type's dict->proto */ @@ -639,29 +675,31 @@ CDataType_from_param(PyObject *type, PyO ob_name = (ob) ? Py_TYPE(ob)->tp_name : "???"; PyErr_Format(PyExc_TypeError, "expected %s instance instead of pointer to %s", - ((PyTypeObject *)type)->tp_name, ob_name); + ((PyTypeObject *)self)->tp_name, ob_name); return NULL; } as_parameter = PyObject_GetAttrString(value, "_as_parameter_"); if (as_parameter) { - value = CDataType_from_param(type, as_parameter); + value = _ctypes__CData_from_param(self, as_parameter); Py_DECREF(as_parameter); return value; } PyErr_Format(PyExc_TypeError, "expected %s instance instead of %s", - ((PyTypeObject *)type)->tp_name, + ((PyTypeObject *)self)->tp_name, Py_TYPE(value)->tp_name); return NULL; } +#include "clinic/_ctypes.c.h" + static PyMethodDef CDataType_methods[] = { - { "from_param", CDataType_from_param, METH_O, from_param_doc }, - { "from_address", CDataType_from_address, METH_O, from_address_doc }, - { "from_buffer", CDataType_from_buffer, METH_VARARGS, from_buffer_doc, }, - { "from_buffer_copy", CDataType_from_buffer_copy, METH_VARARGS, from_buffer_copy_doc, }, - { "in_dll", CDataType_in_dll, METH_VARARGS, in_dll_doc }, + _CTYPES__CDATA_FROM_PARAM_METHODDEF + _CTYPES__CDATA_FROM_ADDRESS_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_COPY_METHODDEF + _CTYPES__CDATA_IN_DLL_METHODDEF { NULL, NULL }, }; @@ -949,12 +987,21 @@ PyCPointerType_new(PyTypeObject *type, P } +/*[clinic input] +_ctypes.PyCPointerType.set_type + + type: object + / + +[clinic start generated code]*/ + static PyObject * -PyCPointerType_set_type(PyTypeObject *self, PyObject *type) +_ctypes_PyCPointerType_set_type(PyObject *self, PyObject *type) +/*[clinic end generated code: output=57037ea119692c99 input=a78b7941981f720b]*/ { StgDictObject *dict; - dict = PyType_stgdict((PyObject *)self); + dict = PyType_stgdict(self); assert(dict); if (-1 == PyCPointerType_SetProto(dict, type)) @@ -963,14 +1010,18 @@ PyCPointerType_set_type(PyTypeObject *se if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *_byref(PyObject *); +/*[clinic input] +_ctypes.PyCPointerType.from_param = _ctypes._CData.from_param +[clinic start generated code]*/ + static PyObject * -PyCPointerType_from_param(PyObject *type, PyObject *value) +_ctypes_PyCPointerType_from_param(PyObject *self, PyObject *value) +/*[clinic end generated code: output=d4b157916c3cf0e9 input=2a4d16b9d920aab1]*/ { StgDictObject *typedict; @@ -980,7 +1031,7 @@ PyCPointerType_from_param(PyObject *type return value; } - typedict = PyType_stgdict(type); + typedict = PyType_stgdict(self); assert(typedict); /* Cannot be NULL for pointer types */ /* If we expect POINTER(), but receive a instance, accept @@ -1007,16 +1058,16 @@ PyCPointerType_from_param(PyObject *type return value; } } - return CDataType_from_param(type, value); + return _ctypes__CData_from_param(self, value); } static PyMethodDef PyCPointerType_methods[] = { - { "from_address", CDataType_from_address, METH_O, from_address_doc }, - { "from_buffer", CDataType_from_buffer, METH_VARARGS, from_buffer_doc, }, - { "from_buffer_copy", CDataType_from_buffer_copy, METH_VARARGS, from_buffer_copy_doc, }, - { "in_dll", CDataType_in_dll, METH_VARARGS, in_dll_doc}, - { "from_param", (PyCFunction)PyCPointerType_from_param, METH_O, from_param_doc}, - { "set_type", (PyCFunction)PyCPointerType_set_type, METH_O }, + _CTYPES__CDATA_FROM_ADDRESS_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_COPY_METHODDEF + _CTYPES__CDATA_IN_DLL_METHODDEF + _CTYPES_PYCPOINTERTYPE_FROM_PARAM_METHODDEF + _CTYPES_PYCPOINTERTYPE_SET_TYPE_METHODDEF { NULL, NULL }, }; @@ -1472,10 +1523,8 @@ c_wchar_p_from_param(PyObject *type, PyO { PyObject *as_parameter; int res; - if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; - } + if (value == Py_None) + Py_RETURN_NONE; if (PyUnicode_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = _ctypes_get_fielddesc("Z"); @@ -1537,10 +1586,8 @@ c_char_p_from_param(PyObject *type, PyOb { PyObject *as_parameter; int res; - if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; - } + if (value == Py_None) + Py_RETURN_NONE; if (PyBytes_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = _ctypes_get_fielddesc("z"); @@ -1605,10 +1652,8 @@ c_void_p_from_param(PyObject *type, PyOb int res; /* None */ - if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; - } + if (value == Py_None) + Py_RETURN_NONE; /* Should probably allow buffer interface as well */ /* int, long */ if (PyLong_Check(value)) { @@ -1933,7 +1978,7 @@ PyCSimpleType_new(PyTypeObject *type, Py result->tp_dict = (PyObject *)stgdict; /* Install from_param class methods in ctypes base classes. - Overrides the PyCSimpleType_from_param generic method. + Overrides the _ctypes_PyCSimpleType_from_param generic method. */ if (result->tp_base == &Simple_Type) { switch (*proto_str) { @@ -2015,8 +2060,13 @@ PyCSimpleType_new(PyTypeObject *type, Py * This is a *class method*. * Convert a parameter into something that ConvParam can handle. */ +/*[clinic input] +_ctypes.PyCSimpleType.from_param = _ctypes._CData.from_param +[clinic start generated code]*/ + static PyObject * -PyCSimpleType_from_param(PyObject *type, PyObject *value) +_ctypes_PyCSimpleType_from_param(PyObject *self, PyObject *value) +/*[clinic end generated code: output=bb18b3e5a4f52a6e input=b1e4957b3ea17d3c]*/ { StgDictObject *dict; char *fmt; @@ -2027,7 +2077,7 @@ PyCSimpleType_from_param(PyObject *type, /* If the value is already an instance of the requested type, we can use it as is */ - res = PyObject_IsInstance(value, type); + res = PyObject_IsInstance(value, self); if (res == -1) return NULL; if (res) { @@ -2035,7 +2085,7 @@ PyCSimpleType_from_param(PyObject *type, return value; } - dict = PyType_stgdict(type); + dict = PyType_stgdict(self); assert(dict); /* I think we can rely on this being a one-character string */ @@ -2063,7 +2113,7 @@ PyCSimpleType_from_param(PyObject *type, Py_DECREF(as_parameter); return NULL; } - value = PyCSimpleType_from_param(type, as_parameter); + value = _ctypes_PyCSimpleType_from_param(self, as_parameter); Py_LeaveRecursiveCall(); Py_DECREF(as_parameter); return value; @@ -2074,11 +2124,11 @@ PyCSimpleType_from_param(PyObject *type, } static PyMethodDef PyCSimpleType_methods[] = { - { "from_param", PyCSimpleType_from_param, METH_O, from_param_doc }, - { "from_address", CDataType_from_address, METH_O, from_address_doc }, - { "from_buffer", CDataType_from_buffer, METH_VARARGS, from_buffer_doc, }, - { "from_buffer_copy", CDataType_from_buffer_copy, METH_VARARGS, from_buffer_copy_doc, }, - { "in_dll", CDataType_in_dll, METH_VARARGS, in_dll_doc}, + _CTYPES_PYCSIMPLETYPE_FROM_PARAM_METHODDEF + _CTYPES__CDATA_FROM_ADDRESS_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_METHODDEF + _CTYPES__CDATA_FROM_BUFFER_COPY_METHODDEF + _CTYPES__CDATA_IN_DLL_METHODDEF { NULL, NULL }, }; @@ -2558,26 +2608,32 @@ PyCData_reduce(PyObject *myself, PyObjec PyBytes_FromStringAndSize(self->b_ptr, self->b_size)); } +/*[clinic input] +_ctypes._CData.__setstate__ + + dict: object + data: str(accept={str, robuffer}, length=True) + / + +[clinic start generated code]*/ + static PyObject * -PyCData_setstate(PyObject *myself, PyObject *args) +_ctypes__CData___setstate___impl(PyObject *self, PyObject *dict, + const char *data, + Py_ssize_clean_t data_length) +/*[clinic end generated code: output=4cb25d0641fb5806 input=4dec4a33a668b0ff]*/ { - void *data; - Py_ssize_t len; int res; - PyObject *dict, *mydict; - CDataObject *self = (CDataObject *)myself; - if (!PyArg_ParseTuple(args, "Os#", &dict, &data, &len)) - return NULL; - if (len > self->b_size) - len = self->b_size; - memmove(self->b_ptr, data, len); - mydict = PyObject_GetAttrString(myself, "__dict__"); + PyObject *mydict; + if (data_length > ((CDataObject *)self)->b_size) + data_length = ((CDataObject *)self)->b_size; + memmove(((CDataObject *)self)->b_ptr, data, data_length); + mydict = PyObject_GetAttrString(self, "__dict__"); res = PyDict_Update(mydict, dict); Py_DECREF(mydict); if (res == -1) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* @@ -2593,7 +2649,7 @@ PyCData_from_outparam(PyObject *self, Py static PyMethodDef PyCData_methods[] = { { "__ctypes_from_outparam__", PyCData_from_outparam, METH_NOARGS, }, { "__reduce__", PyCData_reduce, METH_NOARGS, }, - { "__setstate__", PyCData_setstate, METH_VARARGS, }, + _CTYPES__CDATA___SETSTATE___METHODDEF { NULL, NULL }, }; @@ -2799,8 +2855,7 @@ static PyObject * return result; } else if (value == Py_None && PyCPointerTypeObject_Check(type)) { *(void **)ptr = NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_Format(PyExc_TypeError, "expected %s instance, got %s", @@ -2955,8 +3010,7 @@ PyCFuncPtr_get_errcheck(PyCFuncPtrObject Py_INCREF(self->errcheck); return self->errcheck; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static int @@ -2996,8 +3050,7 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject Py_INCREF(dict->restype); return dict->restype; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -3036,8 +3089,7 @@ PyCFuncPtr_get_argtypes(PyCFuncPtrObject Py_INCREF(dict->argtypes); return dict->argtypes; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -5115,7 +5167,6 @@ static char comerror_doc[] = "Raised whe int comerror_init(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject *hresult, *text, *details; PyBaseExceptionObject *bself; PyObject *a; int status; diff -r b700278310ee Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c Tue May 05 14:31:40 2015 +0300 +++ b/Modules/_ctypes/callproc.c Tue May 05 21:49:36 2015 +0300 @@ -82,6 +82,23 @@ #define DONT_USE_SEH #endif +/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */ +#ifndef RTLD_LOCAL +#define RTLD_LOCAL 0 +#endif + +/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as + RTLD_LOCAL. +*/ +#ifndef RTLD_GLOBAL +#define RTLD_GLOBAL RTLD_LOCAL +#endif + +/*[clinic input] +module _ctypes +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=476a19c49b31a75c]*/ + #define CTYPES_CAPSULE_NAME_PYMEM "_ctypes pymem" static void pymem_destructor(PyObject *ptr) @@ -170,7 +187,7 @@ PyObject * } static PyObject * -get_error_internal(PyObject *self, PyObject *args, int index) +get_error_internal(int index) { int *space; PyObject *errobj = _ctypes_get_errobj(&space); @@ -184,14 +201,12 @@ get_error_internal(PyObject *self, PyObj } static PyObject * -set_error_internal(PyObject *self, PyObject *args, int index) +set_error_internal(int new_errno, int index) { - int new_errno, old_errno; + int old_errno; PyObject *errobj; int *space; - if (!PyArg_ParseTuple(args, "i", &new_errno)) - return NULL; errobj = _ctypes_get_errobj(&space); if (errobj == NULL) return NULL; @@ -201,30 +216,53 @@ set_error_internal(PyObject *self, PyObj return PyLong_FromLong(old_errno); } +/*[clinic input] +_ctypes.get_errno +[clinic start generated code]*/ + static PyObject * -get_errno(PyObject *self, PyObject *args) +_ctypes_get_errno_impl(PyModuleDef *module) +/*[clinic end generated code: output=14e2d1118fdccc99 input=188d4af77e75a918]*/ { - return get_error_internal(self, args, 0); + return get_error_internal(0); } +/*[clinic input] +_ctypes.set_errno + + errno as new_errno: int + / +[clinic start generated code]*/ + static PyObject * -set_errno(PyObject *self, PyObject *args) +_ctypes_set_errno_impl(PyModuleDef *module, int new_errno) +/*[clinic end generated code: output=7d3031bb13673cc2 input=1f94ed29ee4dcd6b]*/ { - return set_error_internal(self, args, 0); + return set_error_internal(new_errno, 0); } #ifdef MS_WIN32 +/*[clinic input] +_ctypes.get_last_error = _ctypes.get_errno +[clinic start generated code]*/ + static PyObject * -get_last_error(PyObject *self, PyObject *args) +_ctypes_get_last_error_impl(PyModuleDef *module) +/*[clinic end generated code: output=924fa536edff087f input=3889a392a25a5cca]*/ { - return get_error_internal(self, args, 1); + return get_error_internal(1); } +/*[clinic input] +_ctypes.set_last_error = _ctypes.set_errno +[clinic start generated code]*/ + static PyObject * -set_last_error(PyObject *self, PyObject *args) +_ctypes_set_last_error_impl(PyModuleDef *module, int new_errno) +/*[clinic end generated code: output=ed9a9d44f36f3ddd input=a26a7777acbf08aa]*/ { - return set_error_internal(self, args, 1); + return set_error_internal(new_errno, 1); } PyObject *ComError; @@ -410,12 +448,18 @@ static DWORD HandleException(EXCEPTION_P } #endif +/*[clinic input] +_ctypes._check_HRESULT + + hr: int + / + +[clinic start generated code]*/ + static PyObject * -check_hresult(PyObject *self, PyObject *args) +_ctypes__check_HRESULT_impl(PyModuleDef *module, int hr) +/*[clinic end generated code: output=9ae69fdd3877c1ec input=3a3ab32f86bd0ad5]*/ { - HRESULT hr; - if (!PyArg_ParseTuple(args, "i", &hr)) - return NULL; if (FAILED(hr)) return PyErr_SetFromWindowsErr(hr); return PyLong_FromLong(hr); @@ -893,10 +937,8 @@ static PyObject *GetResult(PyObject *res if (restype == NULL) return PyLong_FromLong(*(int *)result); - if (restype == Py_None) { - Py_INCREF(Py_None); - return Py_None; - } + if (restype == Py_None) + Py_RETURN_NONE; dict = PyType_stgdict(restype); if (dict == NULL) @@ -1199,20 +1241,34 @@ static int return 1; } +/*[python input] +class void_p_converter(CConverter): + type = 'void *' + converter = '_parse_voidp' + +[python start generated code]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=ce3270c036c6e054]*/ + #ifdef MS_WIN32 -static char format_error_doc[] = -"FormatError([integer]) -> string\n\ -\n\ -Convert a win32 error code into a string. If the error code is not\n\ -given, the return value of a call to GetLastError() is used.\n"; -static PyObject *format_error(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.FormatError + + code: int = 0 + / + +Convert a win32 error code into a string. + +If the error code is not given, the return value of a call to +GetLastError() is used. +[clinic start generated code]*/ + +static PyObject * +_ctypes_FormatError_impl(PyModuleDef *module, int code) +/*[clinic end generated code: output=9717992546f482ed input=e0c98f1c644e5153]*/ { PyObject *result; wchar_t *lpMsgBuf; - DWORD code = 0; - if (!PyArg_ParseTuple(args, "|i:FormatError", &code)) - return NULL; if (code == 0) code = GetLastError(); lpMsgBuf = FormatError(code); @@ -1225,20 +1281,26 @@ static PyObject *format_error(PyObject * return result; } -static char load_library_doc[] = -"LoadLibrary(name) -> handle\n\ -\n\ -Load an executable (usually a DLL), and return a handle to it.\n\ -The handle may be used to locate exported functions in this\n\ -module.\n"; -static PyObject *load_library(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.LoadLibrary + + name as nameobj: object + ignored: object = NULL + / + +Load an executable (usually a DLL), and return a handle to it. + +The handle may be used to locate exported functions in this +module. +[clinic start generated code]*/ + +static PyObject * +_ctypes_LoadLibrary_impl(PyModuleDef *module, PyObject *nameobj, + PyObject *ignored) +/*[clinic end generated code: output=0b231d59445644bd input=ba27d9a7354f3603]*/ { WCHAR *name; - PyObject *nameobj; - PyObject *ignored; HMODULE hMod; - if (!PyArg_ParseTuple(args, "O|O:LoadLibrary", &nameobj, &ignored)) - return NULL; name = PyUnicode_AsUnicode(nameobj); if (!name) @@ -1254,32 +1316,40 @@ static PyObject *load_library(PyObject * #endif } -static char free_library_doc[] = -"FreeLibrary(handle) -> void\n\ -\n\ -Free the handle of an executable previously loaded by LoadLibrary.\n"; -static PyObject *free_library(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.FreeLibrary + + handle: void_p + / + +Free the handle of an executable previously loaded by LoadLibrary. +[clinic start generated code]*/ + +static PyObject * +_ctypes_FreeLibrary_impl(PyModuleDef *module, void *handle) +/*[clinic end generated code: output=f91c49f1187e455a input=40b5dbc973611e6f]*/ { - void *hMod; - if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod)) - return NULL; - if (!FreeLibrary((HMODULE)hMod)) + if (!FreeLibrary((HMODULE)handle)) return PyErr_SetFromWindowsErr(GetLastError()); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static char copy_com_pointer_doc[] = -"CopyComPointer(src, dst) -> HRESULT value\n"; +/*[clinic input] +_ctypes.CopyComPointer + + src as p1: object + dst as p2: object + / + +[clinic start generated code]*/ static PyObject * -copy_com_pointer(PyObject *self, PyObject *args) +_ctypes_CopyComPointer_impl(PyModuleDef *module, PyObject *p1, PyObject *p2) +/*[clinic end generated code: output=af1dee586a5a1557 input=7bae3fbbde914eb2]*/ { - PyObject *p1, *p2, *r = NULL; + PyObject *r = NULL; struct argument a, b; IUnknown *src, **pdst; - if (!PyArg_ParseTuple(args, "OO:CopyComPointer", &p1, &p2)) - return NULL; a.keep = b.keep = NULL; if (-1 == ConvParam(p1, 0, &a) || -1 == ConvParam(p2, 1, &b)) @@ -1302,20 +1372,24 @@ copy_com_pointer(PyObject *self, PyObjec } #else -static PyObject *py_dl_open(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.dlopen + + name: object + flag: int(c_default="RTLD_NOW | RTLD_LOCAL") = RTLD_NOW | RTLD_LOCAL + / + +Open a shared library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlopen_impl(PyModuleDef *module, PyObject *name, int flag) +/*[clinic end generated code: output=b4ec742bd163cd12 input=af7c843071f46eab]*/ { - PyObject *name, *name2; + PyObject *name2; char *name_str; void * handle; -#ifdef RTLD_LOCAL - int mode = RTLD_NOW | RTLD_LOCAL; -#else - /* cygwin doesn't define RTLD_LOCAL */ - int mode = RTLD_NOW; -#endif - if (!PyArg_ParseTuple(args, "O|i:dlopen", &name, &mode)) - return NULL; - mode |= RTLD_NOW; + flag |= RTLD_NOW; if (name != Py_None) { if (PyUnicode_FSConverter(name, &name2) == 0) return NULL; @@ -1327,7 +1401,7 @@ static PyObject *py_dl_open(PyObject *se name_str = NULL; name2 = NULL; } - handle = ctypes_dlopen(name_str, mode); + handle = ctypes_dlopen(name_str, flag); Py_XDECREF(name2); if (!handle) { char *errmsg = ctypes_dlerror(); @@ -1340,31 +1414,44 @@ static PyObject *py_dl_open(PyObject *se return PyLong_FromVoidPtr(handle); } -static PyObject *py_dl_close(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.dlclose + + handle: void_p + / + +dlclose a library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlclose_impl(PyModuleDef *module, void *handle) +/*[clinic end generated code: output=c9cea4386b72183c input=3c941ac4a0e0fc84]*/ { - void *handle; - - if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle)) - return NULL; if (dlclose(handle)) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_dl_sym(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.dlsym + + handle: void_p + name: str + / + +Find symbol in shared library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlsym_impl(PyModuleDef *module, void *handle, const char *name) +/*[clinic end generated code: output=bcddca0592fd506d input=f89bd75488200c7f]*/ { - char *name; - void *handle; void *ptr; - if (!PyArg_ParseTuple(args, "O&s:dlsym", - &_parse_voidp, &handle, &name)) - return NULL; - ptr = ctypes_dlsym((void*)handle, name); + ptr = ctypes_dlsym(handle, name); if (!ptr) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); @@ -1379,20 +1466,23 @@ static PyObject *py_dl_sym(PyObject *sel * * XXX Needs to accept more arguments: flags, argtypes, restype */ +/*[clinic input] +_ctypes.call_function + + handle: void_p + args as arguments: object(subclass_of="&PyTuple_Type") + / + +[clinic start generated code]*/ + static PyObject * -call_function(PyObject *self, PyObject *args) +_ctypes_call_function_impl(PyModuleDef *module, void *handle, + PyObject *arguments) +/*[clinic end generated code: output=967bfceb5272f092 input=f80811c2c321c3d0]*/ { - void *func; - PyObject *arguments; PyObject *result; - if (!PyArg_ParseTuple(args, - "O&O!", - &_parse_voidp, &func, - &PyTuple_Type, &arguments)) - return NULL; - - result = _ctypes_callproc((PPROC)func, + result = _ctypes_callproc((PPROC)handle, arguments, #ifdef MS_WIN32 NULL, @@ -1410,20 +1500,23 @@ call_function(PyObject *self, PyObject * * * XXX Needs to accept more arguments: flags, argtypes, restype */ +/*[clinic input] +_ctypes.call_cdeclfunction + + handle: void_p + args as arguments: object(subclass_of="&PyTuple_Type") + / + +[clinic start generated code]*/ + static PyObject * -call_cdeclfunction(PyObject *self, PyObject *args) +_ctypes_call_cdeclfunction_impl(PyModuleDef *module, void *handle, + PyObject *arguments) +/*[clinic end generated code: output=41ebf74ff533e363 input=972c1307d03fa426]*/ { - void *func; - PyObject *arguments; PyObject *result; - if (!PyArg_ParseTuple(args, - "O&O!", - &_parse_voidp, &func, - &PyTuple_Type, &arguments)) - return NULL; - - result = _ctypes_callproc((PPROC)func, + result = _ctypes_callproc((PPROC)handle, arguments, #ifdef MS_WIN32 NULL, @@ -1439,13 +1532,19 @@ call_cdeclfunction(PyObject *self, PyObj /***************************************************************** * functions */ -static char sizeof_doc[] = -"sizeof(C type) -> integer\n" -"sizeof(C instance) -> integer\n" -"Return the size in bytes of a C instance"; + +/*[clinic input] +_ctypes.sizeof + + obj: object + / + +Return the size in bytes of a C type or a C instance. +[clinic start generated code]*/ static PyObject * -sizeof_func(PyObject *self, PyObject *obj) +_ctypes_sizeof(PyModuleDef *module, PyObject *obj) +/*[clinic end generated code: output=987c03bcc351c002 input=557ca77c86f41a16]*/ { StgDictObject *dict; @@ -1460,13 +1559,18 @@ sizeof_func(PyObject *self, PyObject *ob return NULL; } -static char alignment_doc[] = -"alignment(C type) -> integer\n" -"alignment(C instance) -> integer\n" -"Return the alignment requirements of a C instance"; +/*[clinic input] +_ctypes.alignment + + obj: object + / + +Return the alignment requirements of a C type or a C instance. +[clinic start generated code]*/ static PyObject * -align_func(PyObject *self, PyObject *obj) +_ctypes_alignment(PyModuleDef *module, PyObject *obj) +/*[clinic end generated code: output=851c5e6a7fc7a5cc input=f4d07bace4e280a8]*/ { StgDictObject *dict; @@ -1483,26 +1587,29 @@ align_func(PyObject *self, PyObject *obj return NULL; } -static char byref_doc[] = -"byref(C instance[, offset=0]) -> byref-object\n" -"Return a pointer lookalike to a C instance, only usable\n" -"as function argument"; - /* * We must return something which can be converted to a parameter, * but still has a reference to self. */ +/*[clinic input] +_ctypes.byref + + obj: object + offset as pyoffset: object(c_default="NULL") = 0 + / + +Return a pointer lookalike to a C instance. + +Only usable as function argument. +[clinic start generated code]*/ + static PyObject * -byref(PyObject *self, PyObject *args) +_ctypes_byref_impl(PyModuleDef *module, PyObject *obj, PyObject *pyoffset) +/*[clinic end generated code: output=f98cce38cff1bf19 input=37d25dee49cc4331]*/ { PyCArgObject *parg; - PyObject *obj; - PyObject *pyoffset = NULL; Py_ssize_t offset = 0; - if (!PyArg_UnpackTuple(args, "byref", 1, 2, - &obj, &pyoffset)) - return NULL; if (pyoffset) { offset = PyNumber_AsSsize_t(pyoffset, NULL); if (offset == -1 && PyErr_Occurred()) @@ -1527,12 +1634,18 @@ byref(PyObject *self, PyObject *args) return (PyObject *)parg; } -static char addressof_doc[] = -"addressof(C instance) -> integer\n" -"Return the address of the C instance internal buffer"; +/*[clinic input] +_ctypes.addressof + + obj: object + / + +Return the address of the C instance internal buffer. +[clinic start generated code]*/ static PyObject * -addressof(PyObject *self, PyObject *obj) +_ctypes_addressof(PyModuleDef *module, PyObject *obj) +/*[clinic end generated code: output=f6a989608ec08e23 input=533f155d381d35d3]*/ { if (CDataObject_Check(obj)) return PyLong_FromVoidPtr(((CDataObject *)obj)->b_ptr); @@ -1541,50 +1654,71 @@ addressof(PyObject *self, PyObject *obj) return NULL; } -static int -converter(PyObject *obj, void **address) +/*[clinic input] +_ctypes.PyObj_FromPtr + + obj: object(converter="_parse_voidp") + / + +[clinic start generated code]*/ + +static PyObject * +_ctypes_PyObj_FromPtr_impl(PyModuleDef *module, PyObject *obj) +/*[clinic end generated code: output=e7c71ba33a7130e8 input=07a67147c4d55d96]*/ { - *address = PyLong_AsVoidPtr(obj); - return *address != NULL; + Py_INCREF(obj); + return obj; } -static PyObject * -My_PyObj_FromPtr(PyObject *self, PyObject *args) -{ - PyObject *ob; - if (!PyArg_ParseTuple(args, "O&:PyObj_FromPtr", converter, &ob)) - return NULL; - Py_INCREF(ob); - return ob; -} +/*[clinic input] +_ctypes.Py_INCREF + + arg: object + / + +[clinic start generated code]*/ static PyObject * -My_Py_INCREF(PyObject *self, PyObject *arg) +_ctypes_Py_INCREF(PyModuleDef *module, PyObject *arg) +/*[clinic end generated code: output=7891e2f6595cbf7e input=bf467e73b2d96805]*/ { Py_INCREF(arg); /* that's what this function is for */ Py_INCREF(arg); /* that for returning it */ return arg; } +/*[clinic input] +_ctypes.Py_DECREF + + arg: object + / + +[clinic start generated code]*/ + static PyObject * -My_Py_DECREF(PyObject *self, PyObject *arg) +_ctypes_Py_DECREF(PyModuleDef *module, PyObject *arg) +/*[clinic end generated code: output=e65ddf5919b4fa15 input=59f81debf48eddc1]*/ { Py_DECREF(arg); /* that's what this function is for */ Py_INCREF(arg); /* that's for returning it */ return arg; } +/*[clinic input] +_ctypes.resize + + obj: object(type="CDataObject *") + size: Py_ssize_t + / + +Resize the memory buffer of a ctypes instance. +[clinic start generated code]*/ + static PyObject * -resize(PyObject *self, PyObject *args) +_ctypes_resize_impl(PyModuleDef *module, CDataObject *obj, Py_ssize_t size) +/*[clinic end generated code: output=53916536836b7fb6 input=f820bc83762d9bc1]*/ { - CDataObject *obj; StgDictObject *dict; - Py_ssize_t size; - - if (!PyArg_ParseTuple(args, - "On:resize", - &obj, &size)) - return NULL; dict = PyObject_stgdict((PyObject *)obj); if (dict == NULL) { @@ -1626,23 +1760,28 @@ resize(PyObject *self, PyObject *args) obj->b_size = size; } done: - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_ctypes._unpickle + + type: object + state: object + / + +[clinic start generated code]*/ + static PyObject * -unpickle(PyObject *self, PyObject *args) +_ctypes__unpickle_impl(PyModuleDef *module, PyObject *type, PyObject *state) +/*[clinic end generated code: output=09c86088b15457c3 input=85599d357b4fb43f]*/ { - PyObject *typ; - PyObject *state; PyObject *result; PyObject *tmp; _Py_IDENTIFIER(__new__); _Py_IDENTIFIER(__setstate__); - if (!PyArg_ParseTuple(args, "OO", &typ, &state)) - return NULL; - result = _PyObject_CallMethodId(typ, &PyId___new__, "O", typ); + result = _PyObject_CallMethodId(type, &PyId___new__, "O", type); if (result == NULL) return NULL; tmp = _PyObject_CallMethodId(result, &PyId___setstate__, "O", state); @@ -1654,8 +1793,17 @@ unpickle(PyObject *self, PyObject *args) return result; } +/*[clinic input] +_ctypes.POINTER as POINTER + + cls: object + / + +[clinic start generated code]*/ + static PyObject * -POINTER(PyObject *self, PyObject *cls) +POINTER(PyModuleDef *module, PyObject *cls) +/*[clinic end generated code: output=8fc8844f53c21486 input=c157523e07ae4f6b]*/ { PyObject *result; PyTypeObject *typ; @@ -1710,8 +1858,17 @@ POINTER(PyObject *self, PyObject *cls) return result; } +/*[clinic input] +_ctypes.pointer + + arg: object + / + +[clinic start generated code]*/ + static PyObject * -pointer(PyObject *self, PyObject *arg) +_ctypes_pointer(PyModuleDef *module, PyObject *arg) +/*[clinic end generated code: output=45471494e6fdd17c input=f73eddc8dcf9fcd5]*/ { PyObject *result; PyObject *typ; @@ -1727,8 +1884,18 @@ pointer(PyObject *self, PyObject *arg) return result; } +/*[clinic input] +_ctypes.buffer_info + + arg: object + / + +Return buffer interface information. +[clinic start generated code]*/ + static PyObject * -buffer_info(PyObject *self, PyObject *arg) +_ctypes_buffer_info(PyModuleDef *module, PyObject *arg) +/*[clinic end generated code: output=cfce912fb96bb23c input=f76a7a2be3af29b3]*/ { StgDictObject *dict = PyType_stgdict(arg); PyObject *shape; @@ -1754,37 +1921,38 @@ buffer_info(PyObject *self, PyObject *ar return Py_BuildValue("siN", dict->format, dict->ndim, shape); } +#include "clinic/callproc.c.h" + PyMethodDef _ctypes_module_methods[] = { - {"get_errno", get_errno, METH_NOARGS}, - {"set_errno", set_errno, METH_VARARGS}, - {"POINTER", POINTER, METH_O }, - {"pointer", pointer, METH_O }, - {"_unpickle", unpickle, METH_VARARGS }, - {"buffer_info", buffer_info, METH_O, "Return buffer interface information"}, - {"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"}, -#ifdef MS_WIN32 - {"get_last_error", get_last_error, METH_NOARGS}, - {"set_last_error", set_last_error, METH_VARARGS}, - {"CopyComPointer", copy_com_pointer, METH_VARARGS, copy_com_pointer_doc}, - {"FormatError", format_error, METH_VARARGS, format_error_doc}, - {"LoadLibrary", load_library, METH_VARARGS, load_library_doc}, - {"FreeLibrary", free_library, METH_VARARGS, free_library_doc}, - {"_check_HRESULT", check_hresult, METH_VARARGS}, -#else - {"dlopen", py_dl_open, METH_VARARGS, - "dlopen(name, flag={RTLD_GLOBAL|RTLD_LOCAL}) open a shared library"}, - {"dlclose", py_dl_close, METH_VARARGS, "dlclose a library"}, - {"dlsym", py_dl_sym, METH_VARARGS, "find symbol in shared library"}, -#endif - {"alignment", align_func, METH_O, alignment_doc}, - {"sizeof", sizeof_func, METH_O, sizeof_doc}, - {"byref", byref, METH_VARARGS, byref_doc}, - {"addressof", addressof, METH_O, addressof_doc}, - {"call_function", call_function, METH_VARARGS }, - {"call_cdeclfunction", call_cdeclfunction, METH_VARARGS }, - {"PyObj_FromPtr", My_PyObj_FromPtr, METH_VARARGS }, - {"Py_INCREF", My_Py_INCREF, METH_O }, - {"Py_DECREF", My_Py_DECREF, METH_O }, + _CTYPES_GET_ERRNO_METHODDEF + _CTYPES_SET_ERRNO_METHODDEF + POINTER_METHODDEF + _CTYPES_POINTER_METHODDEF + _CTYPES__UNPICKLE_METHODDEF + _CTYPES_BUFFER_INFO_METHODDEF + _CTYPES_RESIZE_METHODDEF + _CTYPES_ALIGNMENT_METHODDEF + _CTYPES_SIZEOF_METHODDEF + _CTYPES_BYREF_METHODDEF + _CTYPES_ADDRESSOF_METHODDEF + _CTYPES_CALL_FUNCTION_METHODDEF + _CTYPES_CALL_CDECLFUNCTION_METHODDEF + _CTYPES_PYOBJ_FROMPTR_METHODDEF + _CTYPES_PY_INCREF_METHODDEF + _CTYPES_PY_DECREF_METHODDEF + + _CTYPES_GET_LAST_ERROR_METHODDEF + _CTYPES_SET_LAST_ERROR_METHODDEF + _CTYPES_COPYCOMPOINTER_METHODDEF + _CTYPES_FORMATERROR_METHODDEF + _CTYPES_LOADLIBRARY_METHODDEF + _CTYPES_FREELIBRARY_METHODDEF + _CTYPES__CHECK_HRESULT_METHODDEF + + _CTYPES_DLOPEN_METHODDEF + _CTYPES_DLCLOSE_METHODDEF + _CTYPES_DLSYM_METHODDEF + {NULL, NULL} /* Sentinel */ }; @@ -1793,3 +1961,4 @@ PyMethodDef _ctypes_module_methods[] = { compile-command: "cd .. && python setup.py -q build -g && python setup.py -q build install --home ~" End: */ + diff -r b700278310ee Modules/_ctypes/clinic/_ctypes.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/_ctypes/clinic/_ctypes.c.h Tue May 05 21:49:36 2015 +0300 @@ -0,0 +1,170 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_ctypes__CData_from_address__doc__, +"from_address($self, address, /)\n" +"--\n" +"\n" +"Access a C instance at the specified address."); + +#define _CTYPES__CDATA_FROM_ADDRESS_METHODDEF \ + {"from_address", (PyCFunction)_ctypes__CData_from_address, METH_O, _ctypes__CData_from_address__doc__}, + +PyDoc_STRVAR(_ctypes__CData_from_buffer__doc__, +"from_buffer($self, buffer, offset=0, /)\n" +"--\n" +"\n" +"Create an instance from a writeable buffer."); + +#define _CTYPES__CDATA_FROM_BUFFER_METHODDEF \ + {"from_buffer", (PyCFunction)_ctypes__CData_from_buffer, METH_VARARGS, _ctypes__CData_from_buffer__doc__}, + +static PyObject * +_ctypes__CData_from_buffer_impl(PyObject *self, Py_buffer *buffer, + Py_ssize_t offset); + +static PyObject * +_ctypes__CData_from_buffer(PyObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer buffer = {NULL, NULL}; + Py_ssize_t offset = 0; + + if (!PyArg_ParseTuple(args, "w*|n:from_buffer", + &buffer, &offset)) + goto exit; + return_value = _ctypes__CData_from_buffer_impl(self, &buffer, offset); + +exit: + /* Cleanup for buffer */ + if (buffer.obj) + PyBuffer_Release(&buffer); + + return return_value; +} + +PyDoc_STRVAR(_ctypes__CData_from_buffer_copy__doc__, +"from_buffer_copy($self, buffer, offset=0, /)\n" +"--\n" +"\n" +"Create an instance from a readable buffer."); + +#define _CTYPES__CDATA_FROM_BUFFER_COPY_METHODDEF \ + {"from_buffer_copy", (PyCFunction)_ctypes__CData_from_buffer_copy, METH_VARARGS, _ctypes__CData_from_buffer_copy__doc__}, + +static PyObject * +_ctypes__CData_from_buffer_copy_impl(PyObject *self, Py_buffer *buffer, + Py_ssize_t offset); + +static PyObject * +_ctypes__CData_from_buffer_copy(PyObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer buffer = {NULL, NULL}; + Py_ssize_t offset = 0; + + if (!PyArg_ParseTuple(args, "y*|n:from_buffer_copy", + &buffer, &offset)) + goto exit; + return_value = _ctypes__CData_from_buffer_copy_impl(self, &buffer, offset); + +exit: + /* Cleanup for buffer */ + if (buffer.obj) + PyBuffer_Release(&buffer); + + return return_value; +} + +PyDoc_STRVAR(_ctypes__CData_in_dll__doc__, +"in_dll($self, dll, name, /)\n" +"--\n" +"\n" +"Access a C instance in a dll."); + +#define _CTYPES__CDATA_IN_DLL_METHODDEF \ + {"in_dll", (PyCFunction)_ctypes__CData_in_dll, METH_VARARGS, _ctypes__CData_in_dll__doc__}, + +static PyObject * +_ctypes__CData_in_dll_impl(PyObject *self, PyObject *dll, const char *name); + +static PyObject * +_ctypes__CData_in_dll(PyObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *dll; + const char *name; + + if (!PyArg_ParseTuple(args, "Os:in_dll", + &dll, &name)) + goto exit; + return_value = _ctypes__CData_in_dll_impl(self, dll, name); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes__CData_from_param__doc__, +"from_param($self, value, /)\n" +"--\n" +"\n" +"Convert a Python object into a function call parameter."); + +#define _CTYPES__CDATA_FROM_PARAM_METHODDEF \ + {"from_param", (PyCFunction)_ctypes__CData_from_param, METH_O, _ctypes__CData_from_param__doc__}, + +PyDoc_STRVAR(_ctypes_PyCPointerType_set_type__doc__, +"set_type($self, type, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PYCPOINTERTYPE_SET_TYPE_METHODDEF \ + {"set_type", (PyCFunction)_ctypes_PyCPointerType_set_type, METH_O, _ctypes_PyCPointerType_set_type__doc__}, + +PyDoc_STRVAR(_ctypes_PyCPointerType_from_param__doc__, +"from_param($self, value, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PYCPOINTERTYPE_FROM_PARAM_METHODDEF \ + {"from_param", (PyCFunction)_ctypes_PyCPointerType_from_param, METH_O, _ctypes_PyCPointerType_from_param__doc__}, + +PyDoc_STRVAR(_ctypes_PyCSimpleType_from_param__doc__, +"from_param($self, value, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PYCSIMPLETYPE_FROM_PARAM_METHODDEF \ + {"from_param", (PyCFunction)_ctypes_PyCSimpleType_from_param, METH_O, _ctypes_PyCSimpleType_from_param__doc__}, + +PyDoc_STRVAR(_ctypes__CData___setstate____doc__, +"__setstate__($self, dict, data, /)\n" +"--\n" +"\n"); + +#define _CTYPES__CDATA___SETSTATE___METHODDEF \ + {"__setstate__", (PyCFunction)_ctypes__CData___setstate__, METH_VARARGS, _ctypes__CData___setstate____doc__}, + +static PyObject * +_ctypes__CData___setstate___impl(PyObject *self, PyObject *dict, + const char *data, + Py_ssize_clean_t data_length); + +static PyObject * +_ctypes__CData___setstate__(PyObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *dict; + const char *data; + Py_ssize_clean_t data_length; + + if (!PyArg_ParseTuple(args, "Os#:__setstate__", + &dict, &data, &data_length)) + goto exit; + return_value = _ctypes__CData___setstate___impl(self, dict, data, data_length); + +exit: + return return_value; +} +/*[clinic end generated code: output=e4aa726cabb87582 input=a9049054013a1b77]*/ diff -r b700278310ee Modules/_ctypes/clinic/callproc.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/_ctypes/clinic/callproc.c.h Tue May 05 21:49:36 2015 +0300 @@ -0,0 +1,628 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_ctypes_get_errno__doc__, +"get_errno($module, /)\n" +"--\n" +"\n"); + +#define _CTYPES_GET_ERRNO_METHODDEF \ + {"get_errno", (PyCFunction)_ctypes_get_errno, METH_NOARGS, _ctypes_get_errno__doc__}, + +static PyObject * +_ctypes_get_errno_impl(PyModuleDef *module); + +static PyObject * +_ctypes_get_errno(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _ctypes_get_errno_impl(module); +} + +PyDoc_STRVAR(_ctypes_set_errno__doc__, +"set_errno($module, errno, /)\n" +"--\n" +"\n"); + +#define _CTYPES_SET_ERRNO_METHODDEF \ + {"set_errno", (PyCFunction)_ctypes_set_errno, METH_O, _ctypes_set_errno__doc__}, + +static PyObject * +_ctypes_set_errno_impl(PyModuleDef *module, int new_errno); + +static PyObject * +_ctypes_set_errno(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int new_errno; + + if (!PyArg_Parse(arg, "i:set_errno", &new_errno)) + goto exit; + return_value = _ctypes_set_errno_impl(module, new_errno); + +exit: + return return_value; +} + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_get_last_error__doc__, +"get_last_error($module, /)\n" +"--\n" +"\n"); + +#define _CTYPES_GET_LAST_ERROR_METHODDEF \ + {"get_last_error", (PyCFunction)_ctypes_get_last_error, METH_NOARGS, _ctypes_get_last_error__doc__}, + +static PyObject * +_ctypes_get_last_error_impl(PyModuleDef *module); + +static PyObject * +_ctypes_get_last_error(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _ctypes_get_last_error_impl(module); +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_set_last_error__doc__, +"set_last_error($module, errno, /)\n" +"--\n" +"\n"); + +#define _CTYPES_SET_LAST_ERROR_METHODDEF \ + {"set_last_error", (PyCFunction)_ctypes_set_last_error, METH_O, _ctypes_set_last_error__doc__}, + +static PyObject * +_ctypes_set_last_error_impl(PyModuleDef *module, int new_errno); + +static PyObject * +_ctypes_set_last_error(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int new_errno; + + if (!PyArg_Parse(arg, "i:set_last_error", &new_errno)) + goto exit; + return_value = _ctypes_set_last_error_impl(module, new_errno); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes__check_HRESULT__doc__, +"_check_HRESULT($module, hr, /)\n" +"--\n" +"\n"); + +#define _CTYPES__CHECK_HRESULT_METHODDEF \ + {"_check_HRESULT", (PyCFunction)_ctypes__check_HRESULT, METH_O, _ctypes__check_HRESULT__doc__}, + +static PyObject * +_ctypes__check_HRESULT_impl(PyModuleDef *module, int hr); + +static PyObject * +_ctypes__check_HRESULT(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int hr; + + if (!PyArg_Parse(arg, "i:_check_HRESULT", &hr)) + goto exit; + return_value = _ctypes__check_HRESULT_impl(module, hr); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_FormatError__doc__, +"FormatError($module, code=0, /)\n" +"--\n" +"\n" +"Convert a win32 error code into a string.\n" +"\n" +"If the error code is not given, the return value of a call to\n" +"GetLastError() is used."); + +#define _CTYPES_FORMATERROR_METHODDEF \ + {"FormatError", (PyCFunction)_ctypes_FormatError, METH_VARARGS, _ctypes_FormatError__doc__}, + +static PyObject * +_ctypes_FormatError_impl(PyModuleDef *module, int code); + +static PyObject * +_ctypes_FormatError(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int code = 0; + + if (!PyArg_ParseTuple(args, "|i:FormatError", + &code)) + goto exit; + return_value = _ctypes_FormatError_impl(module, code); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_LoadLibrary__doc__, +"LoadLibrary($module, name, ignored=None, /)\n" +"--\n" +"\n" +"Load an executable (usually a DLL), and return a handle to it.\n" +"\n" +"The handle may be used to locate exported functions in this\n" +"module."); + +#define _CTYPES_LOADLIBRARY_METHODDEF \ + {"LoadLibrary", (PyCFunction)_ctypes_LoadLibrary, METH_VARARGS, _ctypes_LoadLibrary__doc__}, + +static PyObject * +_ctypes_LoadLibrary_impl(PyModuleDef *module, PyObject *nameobj, + PyObject *ignored); + +static PyObject * +_ctypes_LoadLibrary(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *nameobj; + PyObject *ignored = NULL; + + if (!PyArg_UnpackTuple(args, "LoadLibrary", + 1, 2, + &nameobj, &ignored)) + goto exit; + return_value = _ctypes_LoadLibrary_impl(module, nameobj, ignored); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_FreeLibrary__doc__, +"FreeLibrary($module, handle, /)\n" +"--\n" +"\n" +"Free the handle of an executable previously loaded by LoadLibrary."); + +#define _CTYPES_FREELIBRARY_METHODDEF \ + {"FreeLibrary", (PyCFunction)_ctypes_FreeLibrary, METH_O, _ctypes_FreeLibrary__doc__}, + +static PyObject * +_ctypes_FreeLibrary_impl(PyModuleDef *module, void *handle); + +static PyObject * +_ctypes_FreeLibrary(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + void *handle; + + if (!PyArg_Parse(arg, "O&:FreeLibrary", _parse_voidp, &handle)) + goto exit; + return_value = _ctypes_FreeLibrary_impl(module, handle); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_CopyComPointer__doc__, +"CopyComPointer($module, src, dst, /)\n" +"--\n" +"\n"); + +#define _CTYPES_COPYCOMPOINTER_METHODDEF \ + {"CopyComPointer", (PyCFunction)_ctypes_CopyComPointer, METH_VARARGS, _ctypes_CopyComPointer__doc__}, + +static PyObject * +_ctypes_CopyComPointer_impl(PyModuleDef *module, PyObject *p1, PyObject *p2); + +static PyObject * +_ctypes_CopyComPointer(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *p1; + PyObject *p2; + + if (!PyArg_UnpackTuple(args, "CopyComPointer", + 2, 2, + &p1, &p2)) + goto exit; + return_value = _ctypes_CopyComPointer_impl(module, p1, p2); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlopen__doc__, +"dlopen($module, name, flag=RTLD_NOW | RTLD_LOCAL, /)\n" +"--\n" +"\n" +"Open a shared library."); + +#define _CTYPES_DLOPEN_METHODDEF \ + {"dlopen", (PyCFunction)_ctypes_dlopen, METH_VARARGS, _ctypes_dlopen__doc__}, + +static PyObject * +_ctypes_dlopen_impl(PyModuleDef *module, PyObject *name, int flag); + +static PyObject * +_ctypes_dlopen(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *name; + int flag = RTLD_NOW | RTLD_LOCAL; + + if (!PyArg_ParseTuple(args, "O|i:dlopen", + &name, &flag)) + goto exit; + return_value = _ctypes_dlopen_impl(module, name, flag); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlclose__doc__, +"dlclose($module, handle, /)\n" +"--\n" +"\n" +"dlclose a library."); + +#define _CTYPES_DLCLOSE_METHODDEF \ + {"dlclose", (PyCFunction)_ctypes_dlclose, METH_O, _ctypes_dlclose__doc__}, + +static PyObject * +_ctypes_dlclose_impl(PyModuleDef *module, void *handle); + +static PyObject * +_ctypes_dlclose(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + void *handle; + + if (!PyArg_Parse(arg, "O&:dlclose", _parse_voidp, &handle)) + goto exit; + return_value = _ctypes_dlclose_impl(module, handle); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlsym__doc__, +"dlsym($module, handle, name, /)\n" +"--\n" +"\n" +"Find symbol in shared library."); + +#define _CTYPES_DLSYM_METHODDEF \ + {"dlsym", (PyCFunction)_ctypes_dlsym, METH_VARARGS, _ctypes_dlsym__doc__}, + +static PyObject * +_ctypes_dlsym_impl(PyModuleDef *module, void *handle, const char *name); + +static PyObject * +_ctypes_dlsym(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + void *handle; + const char *name; + + if (!PyArg_ParseTuple(args, "O&s:dlsym", + _parse_voidp, &handle, &name)) + goto exit; + return_value = _ctypes_dlsym_impl(module, handle, name); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +PyDoc_STRVAR(_ctypes_call_function__doc__, +"call_function($module, handle, args, /)\n" +"--\n" +"\n"); + +#define _CTYPES_CALL_FUNCTION_METHODDEF \ + {"call_function", (PyCFunction)_ctypes_call_function, METH_VARARGS, _ctypes_call_function__doc__}, + +static PyObject * +_ctypes_call_function_impl(PyModuleDef *module, void *handle, + PyObject *arguments); + +static PyObject * +_ctypes_call_function(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + void *handle; + PyObject *arguments; + + if (!PyArg_ParseTuple(args, "O&O!:call_function", + _parse_voidp, &handle, &PyTuple_Type, &arguments)) + goto exit; + return_value = _ctypes_call_function_impl(module, handle, arguments); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_call_cdeclfunction__doc__, +"call_cdeclfunction($module, handle, args, /)\n" +"--\n" +"\n"); + +#define _CTYPES_CALL_CDECLFUNCTION_METHODDEF \ + {"call_cdeclfunction", (PyCFunction)_ctypes_call_cdeclfunction, METH_VARARGS, _ctypes_call_cdeclfunction__doc__}, + +static PyObject * +_ctypes_call_cdeclfunction_impl(PyModuleDef *module, void *handle, + PyObject *arguments); + +static PyObject * +_ctypes_call_cdeclfunction(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + void *handle; + PyObject *arguments; + + if (!PyArg_ParseTuple(args, "O&O!:call_cdeclfunction", + _parse_voidp, &handle, &PyTuple_Type, &arguments)) + goto exit; + return_value = _ctypes_call_cdeclfunction_impl(module, handle, arguments); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_sizeof__doc__, +"sizeof($module, obj, /)\n" +"--\n" +"\n" +"Return the size in bytes of a C type or a C instance."); + +#define _CTYPES_SIZEOF_METHODDEF \ + {"sizeof", (PyCFunction)_ctypes_sizeof, METH_O, _ctypes_sizeof__doc__}, + +PyDoc_STRVAR(_ctypes_alignment__doc__, +"alignment($module, obj, /)\n" +"--\n" +"\n" +"Return the alignment requirements of a C type or a C instance."); + +#define _CTYPES_ALIGNMENT_METHODDEF \ + {"alignment", (PyCFunction)_ctypes_alignment, METH_O, _ctypes_alignment__doc__}, + +PyDoc_STRVAR(_ctypes_byref__doc__, +"byref($module, obj, offset=0, /)\n" +"--\n" +"\n" +"Return a pointer lookalike to a C instance.\n" +"\n" +"Only usable as function argument."); + +#define _CTYPES_BYREF_METHODDEF \ + {"byref", (PyCFunction)_ctypes_byref, METH_VARARGS, _ctypes_byref__doc__}, + +static PyObject * +_ctypes_byref_impl(PyModuleDef *module, PyObject *obj, PyObject *pyoffset); + +static PyObject * +_ctypes_byref(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *obj; + PyObject *pyoffset = NULL; + + if (!PyArg_UnpackTuple(args, "byref", + 1, 2, + &obj, &pyoffset)) + goto exit; + return_value = _ctypes_byref_impl(module, obj, pyoffset); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_addressof__doc__, +"addressof($module, obj, /)\n" +"--\n" +"\n" +"Return the address of the C instance internal buffer."); + +#define _CTYPES_ADDRESSOF_METHODDEF \ + {"addressof", (PyCFunction)_ctypes_addressof, METH_O, _ctypes_addressof__doc__}, + +PyDoc_STRVAR(_ctypes_PyObj_FromPtr__doc__, +"PyObj_FromPtr($module, obj, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PYOBJ_FROMPTR_METHODDEF \ + {"PyObj_FromPtr", (PyCFunction)_ctypes_PyObj_FromPtr, METH_O, _ctypes_PyObj_FromPtr__doc__}, + +static PyObject * +_ctypes_PyObj_FromPtr_impl(PyModuleDef *module, PyObject *obj); + +static PyObject * +_ctypes_PyObj_FromPtr(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *obj; + + if (!PyArg_Parse(arg, "O&:PyObj_FromPtr", _parse_voidp, &obj)) + goto exit; + return_value = _ctypes_PyObj_FromPtr_impl(module, obj); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_Py_INCREF__doc__, +"Py_INCREF($module, arg, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PY_INCREF_METHODDEF \ + {"Py_INCREF", (PyCFunction)_ctypes_Py_INCREF, METH_O, _ctypes_Py_INCREF__doc__}, + +PyDoc_STRVAR(_ctypes_Py_DECREF__doc__, +"Py_DECREF($module, arg, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PY_DECREF_METHODDEF \ + {"Py_DECREF", (PyCFunction)_ctypes_Py_DECREF, METH_O, _ctypes_Py_DECREF__doc__}, + +PyDoc_STRVAR(_ctypes_resize__doc__, +"resize($module, obj, size, /)\n" +"--\n" +"\n" +"Resize the memory buffer of a ctypes instance."); + +#define _CTYPES_RESIZE_METHODDEF \ + {"resize", (PyCFunction)_ctypes_resize, METH_VARARGS, _ctypes_resize__doc__}, + +static PyObject * +_ctypes_resize_impl(PyModuleDef *module, CDataObject *obj, Py_ssize_t size); + +static PyObject * +_ctypes_resize(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + CDataObject *obj; + Py_ssize_t size; + + if (!PyArg_ParseTuple(args, "On:resize", + &obj, &size)) + goto exit; + return_value = _ctypes_resize_impl(module, obj, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes__unpickle__doc__, +"_unpickle($module, type, state, /)\n" +"--\n" +"\n"); + +#define _CTYPES__UNPICKLE_METHODDEF \ + {"_unpickle", (PyCFunction)_ctypes__unpickle, METH_VARARGS, _ctypes__unpickle__doc__}, + +static PyObject * +_ctypes__unpickle_impl(PyModuleDef *module, PyObject *type, PyObject *state); + +static PyObject * +_ctypes__unpickle(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *type; + PyObject *state; + + if (!PyArg_UnpackTuple(args, "_unpickle", + 2, 2, + &type, &state)) + goto exit; + return_value = _ctypes__unpickle_impl(module, type, state); + +exit: + return return_value; +} + +PyDoc_STRVAR(POINTER__doc__, +"POINTER($module, cls, /)\n" +"--\n" +"\n"); + +#define POINTER_METHODDEF \ + {"POINTER", (PyCFunction)POINTER, METH_O, POINTER__doc__}, + +PyDoc_STRVAR(_ctypes_pointer__doc__, +"pointer($module, arg, /)\n" +"--\n" +"\n"); + +#define _CTYPES_POINTER_METHODDEF \ + {"pointer", (PyCFunction)_ctypes_pointer, METH_O, _ctypes_pointer__doc__}, + +PyDoc_STRVAR(_ctypes_buffer_info__doc__, +"buffer_info($module, arg, /)\n" +"--\n" +"\n" +"Return buffer interface information."); + +#define _CTYPES_BUFFER_INFO_METHODDEF \ + {"buffer_info", (PyCFunction)_ctypes_buffer_info, METH_O, _ctypes_buffer_info__doc__}, + +#ifndef _CTYPES_GET_LAST_ERROR_METHODDEF + #define _CTYPES_GET_LAST_ERROR_METHODDEF +#endif /* !defined(_CTYPES_GET_LAST_ERROR_METHODDEF) */ + +#ifndef _CTYPES_SET_LAST_ERROR_METHODDEF + #define _CTYPES_SET_LAST_ERROR_METHODDEF +#endif /* !defined(_CTYPES_SET_LAST_ERROR_METHODDEF) */ + +#ifndef _CTYPES__CHECK_HRESULT_METHODDEF + #define _CTYPES__CHECK_HRESULT_METHODDEF +#endif /* !defined(_CTYPES__CHECK_HRESULT_METHODDEF) */ + +#ifndef _CTYPES_FORMATERROR_METHODDEF + #define _CTYPES_FORMATERROR_METHODDEF +#endif /* !defined(_CTYPES_FORMATERROR_METHODDEF) */ + +#ifndef _CTYPES_LOADLIBRARY_METHODDEF + #define _CTYPES_LOADLIBRARY_METHODDEF +#endif /* !defined(_CTYPES_LOADLIBRARY_METHODDEF) */ + +#ifndef _CTYPES_FREELIBRARY_METHODDEF + #define _CTYPES_FREELIBRARY_METHODDEF +#endif /* !defined(_CTYPES_FREELIBRARY_METHODDEF) */ + +#ifndef _CTYPES_COPYCOMPOINTER_METHODDEF + #define _CTYPES_COPYCOMPOINTER_METHODDEF +#endif /* !defined(_CTYPES_COPYCOMPOINTER_METHODDEF) */ + +#ifndef _CTYPES_DLOPEN_METHODDEF + #define _CTYPES_DLOPEN_METHODDEF +#endif /* !defined(_CTYPES_DLOPEN_METHODDEF) */ + +#ifndef _CTYPES_DLCLOSE_METHODDEF + #define _CTYPES_DLCLOSE_METHODDEF +#endif /* !defined(_CTYPES_DLCLOSE_METHODDEF) */ + +#ifndef _CTYPES_DLSYM_METHODDEF + #define _CTYPES_DLSYM_METHODDEF +#endif /* !defined(_CTYPES_DLSYM_METHODDEF) */ +/*[clinic end generated code: output=70bdec5cc9b1ca3b input=a9049054013a1b77]*/