@@ -107,8 +107,6 @@ module _ctypes
107
107
#include "../_complex.h" // complex
108
108
#endif
109
109
110
- #include "clinic/callproc.c.h"
111
-
112
110
#define CTYPES_CAPSULE_NAME_PYMEM "_ctypes pymem"
113
111
114
112
@@ -1971,103 +1969,6 @@ unpickle(PyObject *self, PyObject *args)
1971
1969
return NULL ;
1972
1970
}
1973
1971
1974
- /*[clinic input]
1975
- _ctypes.POINTER as create_pointer_type
1976
-
1977
- type as cls: object
1978
- A ctypes type.
1979
- /
1980
-
1981
- Create and return a new ctypes pointer type.
1982
-
1983
- Pointer types are cached and reused internally,
1984
- so calling this function repeatedly is cheap.
1985
- [clinic start generated code]*/
1986
-
1987
- static PyObject *
1988
- create_pointer_type (PyObject * module , PyObject * cls )
1989
- /*[clinic end generated code: output=98c3547ab6f4f40b input=3b81cff5ff9b9d5b]*/
1990
- {
1991
- PyObject * result ;
1992
- PyTypeObject * typ ;
1993
-
1994
- assert (module );
1995
- ctypes_state * st = get_module_state (module );
1996
- StgInfo * info = NULL ;
1997
- if (PyType_Check (cls )) {
1998
- if (PyStgInfo_FromType (st , cls , & info ) < 0 ) {
1999
- return NULL ;
2000
- }
2001
- if (info && info -> pointer_type ) {
2002
- return Py_NewRef (info -> pointer_type );
2003
- }
2004
- }
2005
-
2006
- if (PyDict_GetItemRef (st -> _ctypes_ptrtype_cache , cls , & result ) != 0 ) {
2007
- // found or error
2008
- return result ;
2009
- }
2010
-
2011
- // not found
2012
- if (PyUnicode_CheckExact (cls )) {
2013
- PyObject * name = PyUnicode_FromFormat ("LP_%U" , cls );
2014
- result = PyObject_CallFunction ((PyObject * )Py_TYPE (st -> PyCPointer_Type ),
2015
- "N(O){}" ,
2016
- name ,
2017
- st -> PyCPointer_Type );
2018
- if (result == NULL )
2019
- return result ;
2020
- } else if (PyType_Check (cls )) {
2021
- typ = (PyTypeObject * )cls ;
2022
- PyObject * name = PyUnicode_FromFormat ("LP_%s" , typ -> tp_name );
2023
- result = PyObject_CallFunction ((PyObject * )Py_TYPE (st -> PyCPointer_Type ),
2024
- "N(O){sO}" ,
2025
- name ,
2026
- st -> PyCPointer_Type ,
2027
- "_type_" , cls );
2028
- if (result == NULL )
2029
- return result ;
2030
- } else {
2031
- PyErr_SetString (PyExc_TypeError , "must be a ctypes type" );
2032
- return NULL ;
2033
- }
2034
-
2035
- if (info ) {
2036
- // info->pointer_type = Py_NewRef(result);
2037
- }
2038
-
2039
- return result ;
2040
- }
2041
-
2042
- /*[clinic input]
2043
- _ctypes.pointer as create_pointer_inst
2044
-
2045
- obj as arg: object
2046
- /
2047
-
2048
- Create a new pointer instance, pointing to 'obj'.
2049
-
2050
- The returned object is of the type POINTER(type(obj)). Note that if you
2051
- just want to pass a pointer to an object to a foreign function call, you
2052
- should use byref(obj) which is much faster.
2053
- [clinic start generated code]*/
2054
-
2055
- static PyObject *
2056
- create_pointer_inst (PyObject * module , PyObject * arg )
2057
- /*[clinic end generated code: output=3b543bc9f0de2180 input=713685fdb4d9bc27]*/
2058
- {
2059
- PyObject * result ;
2060
- PyObject * typ ;
2061
-
2062
- typ = create_pointer_type (module , (PyObject * )Py_TYPE (arg ));
2063
- if (typ == NULL )
2064
- return NULL ;
2065
-
2066
- result = PyObject_CallOneArg (typ , arg );
2067
- Py_DECREF (typ );
2068
- return result ;
2069
- }
2070
-
2071
1972
static PyObject *
2072
1973
buffer_info (PyObject * self , PyObject * arg )
2073
1974
{
@@ -2102,8 +2003,6 @@ buffer_info(PyObject *self, PyObject *arg)
2102
2003
PyMethodDef _ctypes_module_methods [] = {
2103
2004
{"get_errno" , get_errno , METH_NOARGS },
2104
2005
{"set_errno" , set_errno , METH_VARARGS },
2105
- CREATE_POINTER_TYPE_METHODDEF
2106
- CREATE_POINTER_INST_METHODDEF
2107
2006
{"_unpickle" , unpickle , METH_VARARGS },
2108
2007
{"buffer_info" , buffer_info , METH_O , "Return buffer interface information" },
2109
2008
{"resize" , resize , METH_VARARGS , "Resize the memory buffer of a ctypes instance" },
0 commit comments