[Python-checkins] r71854 - in python/branches/py3k: Misc/NEWS Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/ctypes.h Modules/_ctypes/malloc_closure.c Modules/_ctypes/stgdict.c

thomas.heller python-checkins at python.org
Fri Apr 24 22:50:01 CEST 2009


Author: thomas.heller
Date: Fri Apr 24 22:50:00 2009
New Revision: 71854

Log:
Merged revisions 71853 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71853 | thomas.heller | 2009-04-24 22:31:47 +0200 (Fr, 24 Apr 2009) | 3 lines
  
  Issue #3102: All global symbols that the _ctypes extension defines are
  now prefixed with 'Py' or '_ctypes'.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/_ctypes/_ctypes.c
   python/branches/py3k/Modules/_ctypes/callbacks.c
   python/branches/py3k/Modules/_ctypes/callproc.c
   python/branches/py3k/Modules/_ctypes/cfield.c
   python/branches/py3k/Modules/_ctypes/ctypes.h
   python/branches/py3k/Modules/_ctypes/malloc_closure.c
   python/branches/py3k/Modules/_ctypes/stgdict.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Apr 24 22:50:00 2009
@@ -77,6 +77,11 @@
 Library
 -------
 
+- Issue #3102:  All global symbols that the _ctypes extension defines
+  are now prefixed with 'Py' or '_ctypes'.
+
+- Issue #5041: ctypes does now allow pickling wide character.
+
 - Issue #5812: For the two-argument form of the Fraction constructor,
   Fraction(m, n), m and n are permitted to be arbitrary Rational
   instances.
@@ -430,8 +435,6 @@
 Library
 -------
 
-- Issue #5041: ctypes does now allow pickling wide character.
-
 - Issue #5795: Fixed test_distutils failure on Debian ppc.
 
 - Issue #5607: fixed Distutils test_get_platform for Mac OS X fat binaries.

Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/py3k/Modules/_ctypes/_ctypes.c	Fri Apr 24 22:50:00 2009
@@ -1,7 +1,7 @@
 /*
   ToDo:
 
-  Get rid of the checker (and also the converters) field in CFuncPtrObject and
+  Get rid of the checker (and also the converters) field in PyCFuncPtrObject and
   StgDictObject, and replace them by slot functions in StgDictObject.
 
   think about a buffer-like object (memory? bytes?)
@@ -23,20 +23,20 @@
 Name			methods, members, getsets
 ==============================================================================
 
-StructType_Type		__new__(), from_address(), __mul__(), from_param()
+PyCStructType_Type		__new__(), from_address(), __mul__(), from_param()
 UnionType_Type		__new__(), from_address(), __mul__(), from_param()
-PointerType_Type	__new__(), from_address(), __mul__(), from_param(), set_type()
-ArrayType_Type		__new__(), from_address(), __mul__(), from_param()
-SimpleType_Type		__new__(), from_address(), __mul__(), from_param()
+PyCPointerType_Type	__new__(), from_address(), __mul__(), from_param(), set_type()
+PyCArrayType_Type		__new__(), from_address(), __mul__(), from_param()
+PyCSimpleType_Type		__new__(), from_address(), __mul__(), from_param()
 
-CData_Type
+PyCData_Type
   Struct_Type		__new__(), __init__()
-  Pointer_Type		__new__(), __init__(), _as_parameter_, contents
-  Array_Type		__new__(), __init__(), _as_parameter_, __get/setitem__(), __len__()
+  PyCPointer_Type		__new__(), __init__(), _as_parameter_, contents
+  PyCArray_Type		__new__(), __init__(), _as_parameter_, __get/setitem__(), __len__()
   Simple_Type		__new__(), __init__(), _as_parameter_
 
-CField_Type
-StgDict_Type
+PyCField_Type
+PyCStgDict_Type
 
 ==============================================================================
 
@@ -82,20 +82,20 @@
 */
 
 /*
- * StgDict_Type
- * StructType_Type
+ * PyCStgDict_Type
+ * PyCStructType_Type
  * UnionType_Type
- * PointerType_Type
- * ArrayType_Type
- * SimpleType_Type
+ * PyCPointerType_Type
+ * PyCArrayType_Type
+ * PyCSimpleType_Type
  *
- * CData_Type
+ * PyCData_Type
  * Struct_Type
  * Union_Type
- * Array_Type
+ * PyCArray_Type
  * Simple_Type
- * Pointer_Type
- * CField_Type
+ * PyCPointer_Type
+ * PyCField_Type
  *
  */
 
@@ -125,15 +125,15 @@
 PyObject *PyExc_ArgError;
 
 /* This dict maps ctypes types to POINTER types */
-PyObject *_pointer_type_cache;
+PyObject *_ctypes_ptrtype_cache;
 
 static PyTypeObject Simple_Type;
 
 /* a callable object used for unpickling */
 static PyObject *_unpickle;
 
-char *conversion_mode_encoding = NULL;
-char *conversion_mode_errors = NULL;
+char *_ctypes_conversion_encoding = NULL;
+char *_ctypes_conversion_errors = NULL;
 
 
 /****************************************************************/
@@ -267,7 +267,7 @@
   already be set.
  */
 char *
-alloc_format_string(const char *prefix, const char *suffix)
+_ctypes_alloc_format_string(const char *prefix, const char *suffix)
 {
 	size_t len;
 	char *result;
@@ -291,7 +291,7 @@
 }
 
 /*
-  StructType_Type - a meta type/class.  Creating a new class using this one as
+  PyCStructType_Type - a meta type/class.  Creating a new class using this one as
   __metaclass__ will call the contructor StructUnionType_new.  It replaces the
   tp_dict member with a new instance of StgDict, and initializes the C
   accessible fields somehow.
@@ -303,7 +303,7 @@
 	PyCArgObject *parg;
 	StgDictObject *stgdict;
 	
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 
@@ -339,7 +339,7 @@
 	if (PyDict_GetItemString(result->tp_dict, "_abstract_"))
 		return (PyObject *)result;
 
-	dict = (StgDictObject *)PyObject_CallObject((PyObject *)&StgDict_Type, NULL);
+	dict = (StgDictObject *)PyObject_CallObject((PyObject *)&PyCStgDict_Type, NULL);
 	if (!dict) {
 		Py_DECREF(result);
 		return NULL;
@@ -353,7 +353,7 @@
 	}
 	Py_DECREF(result->tp_dict);
 	result->tp_dict = (PyObject *)dict;
-	dict->format = alloc_format_string(NULL, "B");
+	dict->format = _ctypes_alloc_format_string(NULL, "B");
 	if (dict->format == NULL) {
 		Py_DECREF(result);
 		return NULL;
@@ -368,7 +368,7 @@
 		if (basedict == NULL)
 			return (PyObject *)result;
 		/* copy base dict */
-		if (-1 == StgDict_clone(dict, basedict)) {
+		if (-1 == PyCStgDict_clone(dict, basedict)) {
 			Py_DECREF(result);
 			return NULL;
 		}
@@ -385,7 +385,7 @@
 }
 
 static PyObject *
-StructType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCStructType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	return StructUnionType_new(type, args, kwds, 1);
 }
@@ -411,7 +411,7 @@
 	buf = (void *)PyLong_AsVoidPtr(value);
 	if (PyErr_Occurred())
 		return NULL;
-	return CData_AtAddress(type, buf);
+	return PyCData_AtAddress(type, buf);
 }
 
 static char from_buffer_doc[] =
@@ -458,7 +458,7 @@
 		return NULL;
 	}
 
-	result = CData_AtAddress(type, (char *)buffer + offset);
+	result = PyCData_AtAddress(type, (char *)buffer + offset);
 	if (result == NULL)
 		return NULL;
 
@@ -474,7 +474,7 @@
 "C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
 
 static PyObject *
-GenericCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+GenericPyCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 
 static PyObject *
 CDataType_from_buffer_copy(PyObject *type, PyObject *args)
@@ -515,7 +515,7 @@
 		return NULL;
 	}
 
-	result = GenericCData_new((PyTypeObject *)type, NULL, NULL);
+	result = GenericPyCData_new((PyTypeObject *)type, NULL, NULL);
 	if (result == NULL)
 		return NULL;
 	memcpy(((CDataObject *)result)->b_ptr,
@@ -577,7 +577,7 @@
 		return NULL;
 	}
 #endif
-	return CData_AtAddress(type, address);
+	return PyCData_AtAddress(type, address);
 }
 
 static char from_param_doc[] =
@@ -641,7 +641,7 @@
 		return PyErr_Format(PyExc_ValueError,
 				    "Array length must be >= 0, not %zd",
 				    length);
-	return CreateArrayType(self, length);
+	return PyCArrayType_from_ctype(self, length);
 }
 
 static PySequenceMethods CDataType_as_sequence = {
@@ -677,7 +677,7 @@
 }
 
 static int
-StructType_setattro(PyObject *self, PyObject *key, PyObject *value)
+PyCStructType_setattro(PyObject *self, PyObject *key, PyObject *value)
 {
 	/* XXX Should we disallow deleting _fields_? */
 	if (-1 == PyType_Type.tp_setattro(self, key, value))
@@ -686,7 +686,7 @@
 	if (value && PyUnicode_Check(key) &&
 	    /* XXX struni _PyUnicode_AsString can fail (also in other places)! */
 	    0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
-		return StructUnionType_update_stgdict(self, value, 1);
+		return PyCStructUnionType_update_stgdict(self, value, 1);
 	return 0;
 }
 
@@ -700,14 +700,14 @@
 	
 	if (PyUnicode_Check(key) &&
 	    0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
-		return StructUnionType_update_stgdict(self, value, 0);
+		return PyCStructUnionType_update_stgdict(self, value, 0);
 	return 0;
 }
 
 
-PyTypeObject StructType_Type = {
+PyTypeObject PyCStructType_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.StructType",			/* tp_name */
+	"_ctypes.PyCStructType",			/* tp_name */
 	0,					/* tp_basicsize */
 	0,					/* tp_itemsize */
 	0,					/* tp_dealloc */
@@ -723,7 +723,7 @@
 	0,					/* tp_call */
 	0,					/* tp_str */
 	0,					/* tp_getattro */
-	StructType_setattro,			/* tp_setattro */
+	PyCStructType_setattro,			/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
 	"metatype for the CData Objects",	/* tp_doc */
@@ -743,7 +743,7 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	StructType_new,				/* tp_new */
+	PyCStructType_new,				/* tp_new */
 	0,					/* tp_free */
 };
 
@@ -794,20 +794,20 @@
 
 /*
 
-The PointerType_Type metaclass must ensure that the subclass of Pointer can be
+The PyCPointerType_Type metaclass must ensure that the subclass of Pointer can be
 created. It must check for a _type_ attribute in the class. Since are no
 runtime created properties, a CField is probably *not* needed ?
 
 class IntPointer(Pointer):
     _type_ = "i"
 
-The Pointer_Type provides the functionality: a contents method/property, a
+The PyCPointer_Type provides the functionality: a contents method/property, a
 size property/method, and the sequence protocol.
 
 */
 
 static int
-PointerType_SetProto(StgDictObject *stgdict, PyObject *proto)
+PyCPointerType_SetProto(StgDictObject *stgdict, PyObject *proto)
 {
 	if (!proto || !PyType_Check(proto)) {
 		PyErr_SetString(PyExc_TypeError,
@@ -826,11 +826,11 @@
 }
 
 static PyCArgObject *
-PointerType_paramfunc(CDataObject *self)
+PyCPointerType_paramfunc(CDataObject *self)
 {
 	PyCArgObject *parg;
 
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 
@@ -843,7 +843,7 @@
 }
 
 static PyObject *
-PointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	PyTypeObject *result;
 	StgDictObject *stgdict;
@@ -858,18 +858,18 @@
   stgdict->proto has info about the pointed to type!
 */
 	stgdict = (StgDictObject *)PyObject_CallObject(
-		(PyObject *)&StgDict_Type, NULL);
+		(PyObject *)&PyCStgDict_Type, NULL);
 	if (!stgdict)
 		return NULL;
 	stgdict->size = sizeof(void *);
-	stgdict->align = getentry("P")->pffi_type->alignment;
+	stgdict->align = _ctypes_get_fielddesc("P")->pffi_type->alignment;
 	stgdict->length = 1;
 	stgdict->ffi_type_pointer = ffi_type_pointer;
-	stgdict->paramfunc = PointerType_paramfunc;
+	stgdict->paramfunc = PyCPointerType_paramfunc;
 	stgdict->flags |= TYPEFLAG_ISPOINTER;
 
 	proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */
-	if (proto && -1 == PointerType_SetProto(stgdict, proto)) {
+	if (proto && -1 == PyCPointerType_SetProto(stgdict, proto)) {
 		Py_DECREF((PyObject *)stgdict);
 		return NULL;
 	}
@@ -882,7 +882,7 @@
 		   'pointer to bytes' in this case.  XXX Better would be to
 		   fix the format string later...
 		*/
-		stgdict->format = alloc_format_string("&",
+		stgdict->format = _ctypes_alloc_format_string("&",
 			      itemdict->format ? itemdict->format : "B");
 		if (stgdict->format == NULL) {
 			Py_DECREF((PyObject *)stgdict);
@@ -912,14 +912,14 @@
 
 
 static PyObject *
-PointerType_set_type(PyTypeObject *self, PyObject *type)
+PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
 {
 	StgDictObject *dict;
 
 	dict = PyType_stgdict((PyObject *)self);
 	assert(dict);
 
-	if (-1 == PointerType_SetProto(dict, type))
+	if (-1 == PyCPointerType_SetProto(dict, type))
 		return NULL;
 
 	if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type))
@@ -932,7 +932,7 @@
 static PyObject *_byref(PyObject *);
 
 static PyObject *
-PointerType_from_param(PyObject *type, PyObject *value)
+PyCPointerType_from_param(PyObject *type, PyObject *value)
 {
 	StgDictObject *typedict;
 
@@ -970,19 +970,19 @@
      	return CDataType_from_param(type, value);
 }
 
-static PyMethodDef PointerType_methods[] = {
+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)PointerType_from_param, METH_O, from_param_doc},
-	{ "set_type", (PyCFunction)PointerType_set_type, METH_O },
+	{ "from_param", (PyCFunction)PyCPointerType_from_param, METH_O, from_param_doc},
+	{ "set_type", (PyCFunction)PyCPointerType_set_type, METH_O },
 	{ NULL, NULL },
 };
 
-PyTypeObject PointerType_Type = {
+PyTypeObject PyCPointerType_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.PointerType",				/* tp_name */
+	"_ctypes.PyCPointerType",				/* tp_name */
 	0,					/* tp_basicsize */
 	0,					/* tp_itemsize */
 	0,					/* tp_dealloc */
@@ -1008,7 +1008,7 @@
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
-	PointerType_methods,			/* tp_methods */
+	PyCPointerType_methods,			/* tp_methods */
 	0,					/* tp_members */
 	0,					/* tp_getset */
 	0,					/* tp_base */
@@ -1018,17 +1018,17 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	PointerType_new,			/* tp_new */
+	PyCPointerType_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
 
 /******************************************************************/
 /*
-  ArrayType_Type
+  PyCArrayType_Type
 */
 /*
-  ArrayType_new ensures that the new Array subclass created has a _length_
+  PyCArrayType_new ensures that the new Array subclass created has a _length_
   attribute, and a _type_ attribute.
 */
 
@@ -1089,8 +1089,8 @@
 
 	if (PyUnicode_Check(value)) {
 		value = PyUnicode_AsEncodedString(value,
-						  conversion_mode_encoding,
-						  conversion_mode_errors);
+						  _ctypes_conversion_encoding,
+						  _ctypes_conversion_errors);
 		if (!value)
 			return -1;
 	} else if (!PyBytes_Check(value)) {
@@ -1149,8 +1149,8 @@
 	}
 	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
-						    conversion_mode_encoding,
-						    conversion_mode_errors);
+						    _ctypes_conversion_encoding,
+						    _ctypes_conversion_errors);
 		if (!value)
 			return -1;
 	} else if (!PyUnicode_Check(value)) {
@@ -1242,9 +1242,9 @@
 }
 
 static PyCArgObject *
-ArrayType_paramfunc(CDataObject *self)
+PyCArrayType_paramfunc(CDataObject *self)
 {
-	PyCArgObject *p = new_CArgObject();
+	PyCArgObject *p = PyCArgObject_new();
 	if (p == NULL)
 		return NULL;
 	p->tag = 'P';
@@ -1256,7 +1256,7 @@
 }
 
 static PyObject *
-ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	PyTypeObject *result;
 	StgDictObject *stgdict;
@@ -1294,7 +1294,7 @@
 	}
 
 	stgdict = (StgDictObject *)PyObject_CallObject(
-		(PyObject *)&StgDict_Type, NULL);
+		(PyObject *)&PyCStgDict_Type, NULL);
 	if (!stgdict)
 		return NULL;
 
@@ -1309,10 +1309,10 @@
 	assert(itemdict->format);
 	if (itemdict->format[0] == '(') {
 		sprintf(buf, "(%ld,", length);
-		stgdict->format = alloc_format_string(buf, itemdict->format+1);
+		stgdict->format = _ctypes_alloc_format_string(buf, itemdict->format+1);
 	} else {
 		sprintf(buf, "(%ld)", length);
-		stgdict->format = alloc_format_string(buf, itemdict->format);
+		stgdict->format = _ctypes_alloc_format_string(buf, itemdict->format);
 	}
 	if (stgdict->format == NULL) {
 		Py_DECREF((PyObject *)stgdict);
@@ -1346,7 +1346,7 @@
 	Py_INCREF(proto);
 	stgdict->proto = proto;
 
-	stgdict->paramfunc = &ArrayType_paramfunc;
+	stgdict->paramfunc = &PyCArrayType_paramfunc;
 
 	/* Arrays are passed as pointers to function calls. */
 	stgdict->ffi_type_pointer = ffi_type_pointer;
@@ -1369,11 +1369,11 @@
 	/* Special case for character arrays.
 	   A permanent annoyance: char arrays are also strings!
 	*/
-	if (itemdict->getfunc == getentry("c")->getfunc) {
+	if (itemdict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
 		if (-1 == add_getset(result, CharArray_getsets))
 			return NULL;
 #ifdef CTYPES_UNICODE
-	} else if (itemdict->getfunc == getentry("u")->getfunc) {
+	} else if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
 		if (-1 == add_getset(result, WCharArray_getsets))
 			return NULL;
 #endif
@@ -1382,9 +1382,9 @@
 	return (PyObject *)result;
 }
 
-PyTypeObject ArrayType_Type = {
+PyTypeObject PyCArrayType_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.ArrayType",			/* tp_name */
+	"_ctypes.PyCArrayType",			/* tp_name */
 	0,					/* tp_basicsize */
 	0,					/* tp_itemsize */
 	0,					/* tp_dealloc */
@@ -1420,18 +1420,18 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	ArrayType_new,				/* tp_new */
+	PyCArrayType_new,				/* tp_new */
 	0,					/* tp_free */
 };
 
 
 /******************************************************************/
 /*
-  SimpleType_Type
+  PyCSimpleType_Type
 */
 /*
 
-SimpleType_new ensures that the new Simple_Type subclass created has a valid
+PyCSimpleType_new ensures that the new Simple_Type subclass created has a valid
 _type_ attribute.
 
 */
@@ -1448,9 +1448,9 @@
 	}
 	if (PyUnicode_Check(value) || PyBytes_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("Z");
+		struct fielddesc *fd = _ctypes_get_fielddesc("Z");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1472,7 +1472,7 @@
 		StgDictObject *dict;
 		assert(dt); /* Cannot be NULL for pointer or array objects */
 		dict = dt && dt->proto ? PyType_stgdict(dt->proto) : NULL;
-		if (dict && (dict->setfunc == getentry("u")->setfunc)) {
+		if (dict && (dict->setfunc == _ctypes_get_fielddesc("u")->setfunc)) {
 			Py_INCREF(value);
 			return value;
 		}
@@ -1481,7 +1481,7 @@
 		/* byref(c_char(...)) */
 		PyCArgObject *a = (PyCArgObject *)value;
 		StgDictObject *dict = PyObject_stgdict(a->obj);
-		if (dict && (dict->setfunc == getentry("u")->setfunc)) {
+		if (dict && (dict->setfunc == _ctypes_get_fielddesc("u")->setfunc)) {
 			Py_INCREF(value);
 			return value;
 		}
@@ -1509,9 +1509,9 @@
 	}
 	if (PyBytes_Check(value) || PyUnicode_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("z");
+		struct fielddesc *fd = _ctypes_get_fielddesc("z");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1533,7 +1533,7 @@
 		StgDictObject *dict;
 		assert(dt); /* Cannot be NULL for pointer or array objects */
 		dict = dt && dt->proto ? PyType_stgdict(dt->proto) : NULL;
-		if (dict && (dict->setfunc == getentry("c")->setfunc)) {
+		if (dict && (dict->setfunc == _ctypes_get_fielddesc("c")->setfunc)) {
 			Py_INCREF(value);
 			return value;
 		}
@@ -1542,7 +1542,7 @@
 		/* byref(c_char(...)) */
 		PyCArgObject *a = (PyCArgObject *)value;
 		StgDictObject *dict = PyObject_stgdict(a->obj);
-		if (dict && (dict->setfunc == getentry("c")->setfunc)) {
+		if (dict && (dict->setfunc == _ctypes_get_fielddesc("c")->setfunc)) {
 			Py_INCREF(value);
 			return value;
 		}
@@ -1575,9 +1575,9 @@
 /* int, long */
 	if (PyLong_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("P");
+		struct fielddesc *fd = _ctypes_get_fielddesc("P");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1593,9 +1593,9 @@
 /* string */
 	if (PyBytes_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("z");
+		struct fielddesc *fd = _ctypes_get_fielddesc("z");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1610,9 +1610,9 @@
 /* bytes */
 	if (PyByteArray_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("z");
+		struct fielddesc *fd = _ctypes_get_fielddesc("z");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1627,9 +1627,9 @@
 /* unicode */
 	if (PyUnicode_Check(value)) {
 		PyCArgObject *parg;
-		struct fielddesc *fd = getentry("Z");
+		struct fielddesc *fd = _ctypes_get_fielddesc("Z");
 
-		parg = new_CArgObject();
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1663,11 +1663,11 @@
 		}
 	}
 /* function pointer */
-	if (CFuncPtrObject_Check(value)) {
+	if (PyCFuncPtrObject_Check(value)) {
 		PyCArgObject *parg;
-		CFuncPtrObject *func;
-		func = (CFuncPtrObject *)value;
-		parg = new_CArgObject();
+		PyCFuncPtrObject *func;
+		func = (PyCFuncPtrObject *)value;
+		parg = PyCArgObject_new();
 		if (parg == NULL)
 			return NULL;
 		parg->pffi_type = &ffi_type_pointer;
@@ -1685,7 +1685,7 @@
 		switch (_PyUnicode_AsString(stgd->proto)[0]) {
 		case 'z': /* c_char_p */
 		case 'Z': /* c_wchar_p */
-			parg = new_CArgObject();
+			parg = PyCArgObject_new();
 			if (parg == NULL)
 				return NULL;
 			parg->pffi_type = &ffi_type_pointer;
@@ -1756,7 +1756,7 @@
 		return NULL;
 
 	stgdict = (StgDictObject *)PyObject_CallObject(
-		(PyObject *)&StgDict_Type, NULL);
+		(PyObject *)&PyCStgDict_Type, NULL);
 	if (!stgdict) /* XXX leaks result! */
 		return NULL;
 
@@ -1783,7 +1783,7 @@
 }
 
 static PyCArgObject *
-SimpleType_paramfunc(CDataObject *self)
+PyCSimpleType_paramfunc(CDataObject *self)
 {
 	StgDictObject *dict;
 	char *fmt;
@@ -1795,10 +1795,10 @@
 	fmt = _PyUnicode_AsString(dict->proto);
 	assert(fmt);
 
-	fd = getentry(fmt);
+	fd = _ctypes_get_fielddesc(fmt);
 	assert(fd);
 	
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 	
@@ -1811,7 +1811,7 @@
 }
 
 static PyObject *
-SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	PyTypeObject *result;
 	StgDictObject *stgdict;
@@ -1860,7 +1860,7 @@
 			     SIMPLE_TYPE_CHARS);
 		goto error;
 	}
-	fmt = getentry(proto_str);
+	fmt = _ctypes_get_fielddesc(proto_str);
 	if (fmt == NULL) {
 		Py_DECREF((PyObject *)result);
 		PyErr_Format(PyExc_ValueError,
@@ -1869,7 +1869,7 @@
 	}
 
 	stgdict = (StgDictObject *)PyObject_CallObject(
-		(PyObject *)&StgDict_Type, NULL);
+		(PyObject *)&PyCStgDict_Type, NULL);
 	if (!stgdict)
 		return NULL;
 
@@ -1880,9 +1880,9 @@
 	stgdict->setfunc = fmt->setfunc;
 	stgdict->getfunc = fmt->getfunc;
 #ifdef WORDS_BIGENDIAN
-	stgdict->format = alloc_format_string(">", proto_str);
+	stgdict->format = _ctypes_alloc_format_string(">", proto_str);
 #else
-	stgdict->format = alloc_format_string("<", proto_str);
+	stgdict->format = _ctypes_alloc_format_string("<", proto_str);
 #endif
 	if (stgdict->format == NULL) {
 		Py_DECREF(result);
@@ -1890,7 +1890,7 @@
 		return NULL;
 	}
 
-	stgdict->paramfunc = SimpleType_paramfunc;
+	stgdict->paramfunc = PyCSimpleType_paramfunc;
 /*
 	if (result->tp_base != &Simple_Type) {
 		stgdict->setfunc = NULL;
@@ -1911,7 +1911,7 @@
 	result->tp_dict = (PyObject *)stgdict;
 
 	/* Install from_param class methods in ctypes base classes.
-	   Overrides the SimpleType_from_param generic method.
+	   Overrides the PyCSimpleType_from_param generic method.
 	 */
 	if (result->tp_base == &Simple_Type) {
 		switch (*proto_str) {
@@ -1955,7 +1955,7 @@
 		}
 	}
 
-	if (type == &SimpleType_Type && fmt->setfunc_swapped && fmt->getfunc_swapped) {
+	if (type == &PyCSimpleType_Type && fmt->setfunc_swapped && fmt->getfunc_swapped) {
 		PyObject *swapped = CreateSwappedType(type, args, kwds,
 						      proto, fmt);
 		StgDictObject *sw_dict;
@@ -1970,14 +1970,14 @@
 		PyObject_SetAttrString(swapped, "__ctype_be__", (PyObject *)result);
 		PyObject_SetAttrString(swapped, "__ctype_le__", swapped);
 		/* We are creating the type for the OTHER endian */
-		sw_dict->format = alloc_format_string("<", stgdict->format+1);
+		sw_dict->format = _ctypes_alloc_format_string("<", stgdict->format+1);
 #else
 		PyObject_SetAttrString((PyObject *)result, "__ctype_be__", swapped);
 		PyObject_SetAttrString((PyObject *)result, "__ctype_le__", (PyObject *)result);
 		PyObject_SetAttrString(swapped, "__ctype_le__", (PyObject *)result);
 		PyObject_SetAttrString(swapped, "__ctype_be__", swapped);
 		/* We are creating the type for the OTHER endian */
-		sw_dict->format = alloc_format_string(">", stgdict->format+1);
+		sw_dict->format = _ctypes_alloc_format_string(">", stgdict->format+1);
 #endif
 		Py_DECREF(swapped);
 		if (PyErr_Occurred()) {
@@ -1994,7 +1994,7 @@
  * Convert a parameter into something that ConvParam can handle.
  */
 static PyObject *
-SimpleType_from_param(PyObject *type, PyObject *value)
+PyCSimpleType_from_param(PyObject *type, PyObject *value)
 {
 	StgDictObject *dict;
 	char *fmt;
@@ -2016,10 +2016,10 @@
 	fmt = _PyUnicode_AsString(dict->proto);
 	assert(fmt);
 	
-	fd = getentry(fmt);
+	fd = _ctypes_get_fielddesc(fmt);
 	assert(fd);
 	
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 
@@ -2033,7 +2033,7 @@
 
 	as_parameter = PyObject_GetAttrString(value, "_as_parameter_");
 	if (as_parameter) {
-		value = SimpleType_from_param(type, as_parameter);
+		value = PyCSimpleType_from_param(type, as_parameter);
 		Py_DECREF(as_parameter);
 		return value;
 	}
@@ -2042,8 +2042,8 @@
 	return NULL;
 }
 
-static PyMethodDef SimpleType_methods[] = {
-	{ "from_param", SimpleType_from_param, METH_O, from_param_doc },
+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, },
@@ -2051,9 +2051,9 @@
 	{ NULL, NULL },
 };
 
-PyTypeObject SimpleType_Type = {
+PyTypeObject PyCSimpleType_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.SimpleType",				/* tp_name */
+	"_ctypes.PyCSimpleType",				/* tp_name */
 	0,					/* tp_basicsize */
 	0,					/* tp_itemsize */
 	0,					/* tp_dealloc */
@@ -2072,14 +2072,14 @@
 	0,					/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
-	"metatype for the SimpleType Objects",	/* tp_doc */
+	"metatype for the PyCSimpleType Objects",	/* tp_doc */
 	0,					/* tp_traverse */
 	0,					/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
-	SimpleType_methods,			/* tp_methods */
+	PyCSimpleType_methods,			/* tp_methods */
 	0,					/* tp_members */
 	0,					/* tp_getset */
 	0,					/* tp_base */
@@ -2089,13 +2089,13 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	SimpleType_new,				/* tp_new */
+	PyCSimpleType_new,				/* tp_new */
 	0,					/* tp_free */
 };
 
 /******************************************************************/
 /*
-  CFuncPtrType_Type
+  PyCFuncPtrType_Type
  */
 
 static PyObject *
@@ -2147,7 +2147,7 @@
 	PyObject *ob;
 	PyObject *converters = NULL;
 
-	stgdict->align = getentry("P")->pffi_type->alignment;
+	stgdict->align = _ctypes_get_fielddesc("P")->pffi_type->alignment;
 	stgdict->length = 1;
 	stgdict->size = sizeof(void *);
 	stgdict->setfunc = NULL;
@@ -2207,11 +2207,11 @@
 }
 
 static PyCArgObject *
-CFuncPtrType_paramfunc(CDataObject *self)
+PyCFuncPtrType_paramfunc(CDataObject *self)
 {
 	PyCArgObject *parg;
 	
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 	
@@ -2224,24 +2224,24 @@
 }
 
 static PyObject *
-CFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	PyTypeObject *result;
 	StgDictObject *stgdict;
 
 	stgdict = (StgDictObject *)PyObject_CallObject(
-		(PyObject *)&StgDict_Type, NULL);
+		(PyObject *)&PyCStgDict_Type, NULL);
 	if (!stgdict)
 		return NULL;
 
-	stgdict->paramfunc = CFuncPtrType_paramfunc;
+	stgdict->paramfunc = PyCFuncPtrType_paramfunc;
 	/* We do NOT expose the function signature in the format string.  It
 	   is impossible, generally, because the only requirement for the
 	   argtypes items is that they have a .from_param method - we do not
 	   know the types of the arguments (although, in practice, most
 	   argtypes would be a ctypes type).
 	*/
-	stgdict->format = alloc_format_string(NULL, "X{}");
+	stgdict->format = _ctypes_alloc_format_string(NULL, "X{}");
 	stgdict->flags |= TYPEFLAG_ISPOINTER;
 
 	/* create the new instance (which is a class,
@@ -2269,9 +2269,9 @@
 	return (PyObject *)result;
 }
 
-PyTypeObject CFuncPtrType_Type = {
+PyTypeObject PyCFuncPtrType_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.CFuncPtrType",			/* tp_name */
+	"_ctypes.PyCFuncPtrType",			/* tp_name */
 	0,					/* tp_basicsize */
 	0,					/* tp_itemsize */
 	0,					/* tp_dealloc */
@@ -2307,7 +2307,7 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	CFuncPtrType_new,			/* tp_new */
+	PyCFuncPtrType_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
@@ -2317,7 +2317,7 @@
  */
 
 static CDataObject *
-CData_GetContainer(CDataObject *self)
+PyCData_GetContainer(CDataObject *self)
 {
 	while (self->b_base)
 		self = self->b_base;
@@ -2335,7 +2335,7 @@
 static PyObject *
 GetKeepedObjects(CDataObject *target)
 {
-	return CData_GetContainer(target)->b_objects;
+	return PyCData_GetContainer(target)->b_objects;
 }
 
 static PyObject *
@@ -2391,7 +2391,7 @@
 		Py_DECREF(Py_None);
 		return 0;
 	}
-	ob = CData_GetContainer(target);
+	ob = PyCData_GetContainer(target);
 	if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) {
 		Py_XDECREF(ob->b_objects);
 		ob->b_objects = keep; /* refcount consumed */
@@ -2410,10 +2410,10 @@
 
 /******************************************************************/
 /*
-  CData_Type
+  PyCData_Type
  */
 static int
-CData_traverse(CDataObject *self, visitproc visit, void *arg)
+PyCData_traverse(CDataObject *self, visitproc visit, void *arg)
 {
 	Py_VISIT(self->b_objects);
 	Py_VISIT((PyObject *)self->b_base);
@@ -2421,7 +2421,7 @@
 }
 
 static int
-CData_clear(CDataObject *self)
+PyCData_clear(CDataObject *self)
 {
 	StgDictObject *dict = PyObject_stgdict((PyObject *)self);
 	assert(dict); /* Cannot be NULL for CDataObject instances */
@@ -2435,13 +2435,13 @@
 }
 
 static void
-CData_dealloc(PyObject *self)
+PyCData_dealloc(PyObject *self)
 {
-	CData_clear((CDataObject *)self);
+	PyCData_clear((CDataObject *)self);
 	Py_TYPE(self)->tp_free(self);
 }
 
-static PyMemberDef CData_members[] = {
+static PyMemberDef PyCData_members[] = {
 	{ "_b_base_", T_OBJECT,
 	  offsetof(CDataObject, b_base), READONLY,
 	  "the base object" },
@@ -2454,7 +2454,7 @@
 	{ NULL },
 };
 
-static int CData_GetBuffer(PyObject *_self, Py_buffer *view, int flags)
+static int PyCData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags)
 {
 	CDataObject *self = (CDataObject *)_self;
 	StgDictObject *dict = PyObject_stgdict(_self);
@@ -2481,8 +2481,8 @@
 	return 0;
 }
 
-static PyBufferProcs CData_as_buffer = {
-	CData_GetBuffer,
+static PyBufferProcs PyCData_as_buffer = {
+	PyCData_NewGetBuffer,
         NULL,
 };
 
@@ -2490,14 +2490,14 @@
  * CData objects are mutable, so they cannot be hashable!
  */
 static long
-CData_nohash(PyObject *self)
+PyCData_nohash(PyObject *self)
 {
 	PyErr_SetString(PyExc_TypeError, "unhashable type");
 	return -1;
 }
 
 static PyObject *
-CData_reduce(PyObject *_self, PyObject *args)
+PyCData_reduce(PyObject *_self, PyObject *args)
 {
 	CDataObject *self = (CDataObject *)_self;
 
@@ -2514,7 +2514,7 @@
 }
 
 static PyObject *
-CData_setstate(PyObject *_self, PyObject *args)
+PyCData_setstate(PyObject *_self, PyObject *args)
 {
 	void *data;
 	Py_ssize_t len;
@@ -2539,25 +2539,25 @@
  * default __ctypes_from_outparam__ method returns self.
  */
 static PyObject *
-CData_from_outparam(PyObject *self, PyObject *args)
+PyCData_from_outparam(PyObject *self, PyObject *args)
 {
 	Py_INCREF(self);
 	return self;
 }
 
-static PyMethodDef CData_methods[] = {
-	{ "__ctypes_from_outparam__", CData_from_outparam, METH_NOARGS, },
-	{ "__reduce__", CData_reduce, METH_NOARGS, },
-	{ "__setstate__", CData_setstate, METH_VARARGS, },
+static PyMethodDef PyCData_methods[] = {
+	{ "__ctypes_from_outparam__", PyCData_from_outparam, METH_NOARGS, },
+	{ "__reduce__", PyCData_reduce, METH_NOARGS, },
+	{ "__setstate__", PyCData_setstate, METH_VARARGS, },
 	{ NULL, NULL },
 };
 
-PyTypeObject CData_Type = {
+PyTypeObject PyCData_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"_ctypes._CData",
 	sizeof(CDataObject),			/* tp_basicsize */
 	0,					/* tp_itemsize */
-	CData_dealloc,				/* tp_dealloc */
+	PyCData_dealloc,				/* tp_dealloc */
 	0,					/* tp_print */
 	0,					/* tp_getattr */
 	0,					/* tp_setattr */
@@ -2566,22 +2566,22 @@
 	0,					/* tp_as_number */
 	0,					/* tp_as_sequence */
 	0,					/* tp_as_mapping */
-	CData_nohash,				/* tp_hash */
+	PyCData_nohash,				/* tp_hash */
 	0,					/* tp_call */
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"XXX to be provided",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
-	CData_methods,				/* tp_methods */
-	CData_members,				/* tp_members */
+	PyCData_methods,				/* tp_methods */
+	PyCData_members,				/* tp_members */
 	0,					/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */
@@ -2594,7 +2594,7 @@
 	0,					/* tp_free */
 };
 
-static int CData_MallocBuffer(CDataObject *obj, StgDictObject *dict)
+static int PyCData_MallocBuffer(CDataObject *obj, StgDictObject *dict)
 {
 	if ((size_t)dict->size <= sizeof(obj->b_value)) {
 		/* No need to call malloc, can use the default buffer */
@@ -2623,7 +2623,7 @@
 }
 
 PyObject *
-CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr)
+PyCData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr)
 {
 	CDataObject *cmem;
 	StgDictObject *dict;
@@ -2651,7 +2651,7 @@
 		cmem->b_base = (CDataObject *)base;
 		cmem->b_index = index;
 	} else { /* copy contents of adr */
-		if (-1 == CData_MallocBuffer(cmem, dict)) {
+		if (-1 == PyCData_MallocBuffer(cmem, dict)) {
 			return NULL;
 			Py_DECREF(cmem);
 		}
@@ -2665,7 +2665,7 @@
  Box a memory block into a CData instance.
 */
 PyObject *
-CData_AtAddress(PyObject *type, void *buf)
+PyCData_AtAddress(PyObject *type, void *buf)
 {
 	CDataObject *pd;
 	StgDictObject *dict;
@@ -2694,17 +2694,17 @@
   classes.  FALSE otherwise FALSE also for subclasses of c_int and
   such.
 */
-int IsSimpleSubType(PyObject *obj)
+int _ctypes_simple_instance(PyObject *obj)
 {
 	PyTypeObject *type = (PyTypeObject *)obj;
 
-	if (SimpleTypeObject_Check(type))
+	if (PyCSimpleTypeObject_Check(type))
 		return type->tp_base != &Simple_Type;
 	return 0;
 }
 
 PyObject *
-CData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
+PyCData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
 	  Py_ssize_t index, Py_ssize_t size, char *adr)
 {
 	StgDictObject *dict;
@@ -2712,16 +2712,16 @@
 		return getfunc(adr, size);
 	assert(type);
 	dict = PyType_stgdict(type);
-	if (dict && dict->getfunc && !IsSimpleSubType(type))
+	if (dict && dict->getfunc && !_ctypes_simple_instance(type))
 		return dict->getfunc(adr, size);
-	return CData_FromBaseObj(type, src, index, adr);
+	return PyCData_FromBaseObj(type, src, index, adr);
 }
 
 /*
-  Helper function for CData_set below.
+  Helper function for PyCData_set below.
 */
 static PyObject *
-_CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
+_PyCData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
 	   Py_ssize_t size, char *ptr)
 {
 	CDataObject *src;
@@ -2743,15 +2743,15 @@
 			PyObject *result;
 			ob = PyObject_CallObject(type, value);
 			if (ob == NULL) {
-				Extend_Error_Info(PyExc_RuntimeError, "(%s) ",
+				_ctypes_extend_error(PyExc_RuntimeError, "(%s) ",
 						  ((PyTypeObject *)type)->tp_name);
 				return NULL;
 			}
-			result = _CData_set(dst, type, setfunc, ob,
+			result = _PyCData_set(dst, type, setfunc, ob,
 					    size, ptr);
 			Py_DECREF(ob);
 			return result;
-		} else if (value == Py_None && PointerTypeObject_Check(type)) {
+		} else if (value == Py_None && PyCPointerTypeObject_Check(type)) {
 			*(void **)ptr = NULL;
 			Py_INCREF(Py_None);
 			return Py_None;
@@ -2770,7 +2770,7 @@
 		       src->b_ptr,
 		       size);
 
-		if (PointerTypeObject_Check(type))
+		if (PyCPointerTypeObject_Check(type))
 			/* XXX */;
 
 		value = GetKeepedObjects(src);
@@ -2778,7 +2778,7 @@
 		return value;
 	}
 
-	if (PointerTypeObject_Check(type)
+	if (PyCPointerTypeObject_Check(type)
 	    && ArrayObject_Check(value)) {
 		StgDictObject *p1, *p2;
 		PyObject *keep;
@@ -2819,7 +2819,7 @@
  * to the value 'value'.
  */
 int
-CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
+PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
 	  Py_ssize_t index, Py_ssize_t size, char *ptr)
 {
 	CDataObject *mem = (CDataObject *)dst;
@@ -2831,7 +2831,7 @@
 		return -1;
 	}
 
-	result = _CData_set(mem, type, setfunc, value,
+	result = _PyCData_set(mem, type, setfunc, value,
 			    size, ptr);
 	if (result == NULL)
 		return -1;
@@ -2845,7 +2845,7 @@
 
 /******************************************************************/
 static PyObject *
-GenericCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+GenericPyCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	CDataObject *obj;
 	StgDictObject *dict;
@@ -2867,7 +2867,7 @@
 	obj->b_objects = NULL;
 	obj->b_length = dict->length;
 			
-	if (-1 == CData_MallocBuffer(obj, dict)) {
+	if (-1 == PyCData_MallocBuffer(obj, dict)) {
 		Py_DECREF(obj);
 		return NULL;
 	}
@@ -2875,11 +2875,11 @@
 }
 /*****************************************************************/
 /*
-  CFuncPtr_Type
+  PyCFuncPtr_Type
 */
 
 static int
-CFuncPtr_set_errcheck(CFuncPtrObject *self, PyObject *ob)
+PyCFuncPtr_set_errcheck(PyCFuncPtrObject *self, PyObject *ob)
 {
 	if (ob && !PyCallable_Check(ob)) {
 		PyErr_SetString(PyExc_TypeError,
@@ -2893,7 +2893,7 @@
 }
 
 static PyObject *
-CFuncPtr_get_errcheck(CFuncPtrObject *self)
+PyCFuncPtr_get_errcheck(PyCFuncPtrObject *self)
 {
 	if (self->errcheck) {
 		Py_INCREF(self->errcheck);
@@ -2904,7 +2904,7 @@
 }
 
 static int
-CFuncPtr_set_restype(CFuncPtrObject *self, PyObject *ob)
+PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob)
 {
 	if (ob == NULL) {
 		Py_XDECREF(self->restype);
@@ -2929,7 +2929,7 @@
 }
 
 static PyObject *
-CFuncPtr_get_restype(CFuncPtrObject *self)
+PyCFuncPtr_get_restype(PyCFuncPtrObject *self)
 {
 	StgDictObject *dict;
 	if (self->restype) {
@@ -2937,7 +2937,7 @@
 		return self->restype;
 	}
 	dict = PyObject_stgdict((PyObject *)self);
-	assert(dict); /* Cannot be NULL for CFuncPtrObject instances */
+	assert(dict); /* Cannot be NULL for PyCFuncPtrObject instances */
 	if (dict->restype) {
 		Py_INCREF(dict->restype);
 		return dict->restype;
@@ -2948,7 +2948,7 @@
 }
 
 static int
-CFuncPtr_set_argtypes(CFuncPtrObject *self, PyObject *ob)
+PyCFuncPtr_set_argtypes(PyCFuncPtrObject *self, PyObject *ob)
 {
 	PyObject *converters;
 
@@ -2971,7 +2971,7 @@
 }
 
 static PyObject *
-CFuncPtr_get_argtypes(CFuncPtrObject *self)
+PyCFuncPtr_get_argtypes(PyCFuncPtrObject *self)
 {
 	StgDictObject *dict;
 	if (self->argtypes) {
@@ -2979,7 +2979,7 @@
 		return self->argtypes;
 	}
 	dict = PyObject_stgdict((PyObject *)self);
-	assert(dict); /* Cannot be NULL for CFuncPtrObject instances */
+	assert(dict); /* Cannot be NULL for PyCFuncPtrObject instances */
 	if (dict->argtypes) {
 		Py_INCREF(dict->argtypes);
 		return dict->argtypes;
@@ -2989,13 +2989,13 @@
 	}
 }
 
-static PyGetSetDef CFuncPtr_getsets[] = {
-	{ "errcheck", (getter)CFuncPtr_get_errcheck, (setter)CFuncPtr_set_errcheck,
+static PyGetSetDef PyCFuncPtr_getsets[] = {
+	{ "errcheck", (getter)PyCFuncPtr_get_errcheck, (setter)PyCFuncPtr_set_errcheck,
 	  "a function to check for errors", NULL },
-	{ "restype", (getter)CFuncPtr_get_restype, (setter)CFuncPtr_set_restype,
+	{ "restype", (getter)PyCFuncPtr_get_restype, (setter)PyCFuncPtr_set_restype,
 	  "specify the result type", NULL },
-	{ "argtypes", (getter)CFuncPtr_get_argtypes,
-	  (setter)CFuncPtr_set_argtypes,
+	{ "argtypes", (getter)PyCFuncPtr_get_argtypes,
+	  (setter)PyCFuncPtr_set_argtypes,
 	  "specify the argument types", NULL },
 	{ NULL, NULL }
 };
@@ -3050,10 +3050,10 @@
 {
 	StgDictObject *dict;
 
-	if (PointerTypeObject_Check(arg))
+	if (PyCPointerTypeObject_Check(arg))
 		return 1;
 
-	if (ArrayTypeObject_Check(arg))
+	if (PyCArrayTypeObject_Check(arg))
 		return 1;
 
 	dict = PyType_stgdict(arg);
@@ -3083,7 +3083,7 @@
 	PyObject *argtypes;
 
 	dict = PyType_stgdict((PyObject *)type);
-	assert(dict); /* Cannot be NULL. 'type' is a CFuncPtr type. */
+	assert(dict); /* Cannot be NULL. 'type' is a PyCFuncPtr type. */
 	argtypes = dict->argtypes;
 
 	if (paramflags == NULL || dict->argtypes == NULL)
@@ -3161,13 +3161,13 @@
 
 
 static PyObject *
-CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	char *name;
 	int (* address)(void);
 	PyObject *dll;
 	PyObject *obj;
-	CFuncPtrObject *self;
+	PyCFuncPtrObject *self;
 	void *handle;
 	PyObject *paramflags = NULL;
 
@@ -3223,7 +3223,7 @@
 	if (!_validate_paramflags(type, paramflags))
 		return NULL;
 
-	self = (CFuncPtrObject *)GenericCData_new(type, args, kwds);
+	self = (PyCFuncPtrObject *)GenericPyCData_new(type, args, kwds);
 	if (!self)
 		return NULL;
 
@@ -3245,9 +3245,9 @@
 
 #ifdef MS_WIN32
 static PyObject *
-CFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	CFuncPtrObject *self;
+	PyCFuncPtrObject *self;
 	int index;
 	char *name = NULL;
 	PyObject *paramflags = NULL;
@@ -3262,7 +3262,7 @@
 	if (!_validate_paramflags(type, paramflags))
 		return NULL;
 
-	self = (CFuncPtrObject *)GenericCData_new(type, args, kwds);
+	self = (PyCFuncPtrObject *)GenericPyCData_new(type, args, kwds);
 	self->index = index + 0x1000;
 	Py_XINCREF(paramflags);
 	self->paramflags = paramflags;
@@ -3273,7 +3273,7 @@
 #endif
 
 /*
-  CFuncPtr_new accepts different argument lists in addition to the standard
+  PyCFuncPtr_new accepts different argument lists in addition to the standard
   _basespec_ keyword arg:
 
   one argument form
@@ -3286,22 +3286,22 @@
   "is|..." - vtable index, method name, creates callable calling COM vtbl
 */
 static PyObject *
-CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	CFuncPtrObject *self;
+	PyCFuncPtrObject *self;
 	PyObject *callable;
 	StgDictObject *dict;
 	CThunkObject *thunk;
 
 	if (PyTuple_GET_SIZE(args) == 0)
-		return GenericCData_new(type, args, kwds);
+		return GenericPyCData_new(type, args, kwds);
 
 	if (1 <= PyTuple_GET_SIZE(args) && PyTuple_Check(PyTuple_GET_ITEM(args, 0)))
-		return CFuncPtr_FromDll(type, args, kwds);
+		return PyCFuncPtr_FromDll(type, args, kwds);
 
 #ifdef MS_WIN32
 	if (2 <= PyTuple_GET_SIZE(args) && PyLong_Check(PyTuple_GET_ITEM(args, 0)))
-		return CFuncPtr_FromVtblIndex(type, args, kwds);
+		return PyCFuncPtr_FromVtblIndex(type, args, kwds);
 #endif
 
 	if (1 == PyTuple_GET_SIZE(args)
@@ -3310,7 +3310,7 @@
 		void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0));
 		if (ptr == NULL && PyErr_Occurred())
 			return NULL;
-		ob = (CDataObject *)GenericCData_new(type, args, kwds);
+		ob = (CDataObject *)GenericPyCData_new(type, args, kwds);
 		if (ob == NULL)
 			return NULL;
 		*(void **)ob->b_ptr = ptr;
@@ -3339,7 +3339,7 @@
 */
 
 	dict = PyType_stgdict((PyObject *)type);
-	/* XXXX Fails if we do: 'CFuncPtr(lambda x: x)' */
+	/* XXXX Fails if we do: 'PyCFuncPtr(lambda x: x)' */
 	if (!dict || !dict->argtypes) {
 		PyErr_SetString(PyExc_TypeError,
 		       "cannot construct instance of this class:"
@@ -3347,14 +3347,14 @@
 		return NULL;
 	}
 
-	thunk = AllocFunctionCallback(callable,
+	thunk = _ctypes_alloc_callback(callable,
 				      dict->argtypes,
 				      dict->restype,
 				      dict->flags);
 	if (!thunk)
 		return NULL;
 
-	self = (CFuncPtrObject *)GenericCData_new(type, args, kwds);
+	self = (PyCFuncPtrObject *)GenericPyCData_new(type, args, kwds);
 	if (self == NULL) {
 		Py_DECREF(thunk);
 		return NULL;
@@ -3388,7 +3388,7 @@
 		return NULL;
 	}
 
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL) {
 		Py_DECREF(obj);
 		return NULL;
@@ -3450,7 +3450,7 @@
  function.
 */
 static PyObject *
-_build_callargs(CFuncPtrObject *self, PyObject *argtypes,
+_build_callargs(PyCFuncPtrObject *self, PyObject *argtypes,
 		PyObject *inargs, PyObject *kwds,
 		int *poutmask, int *pinoutmask, unsigned int *pnumretvals)
 {
@@ -3562,7 +3562,7 @@
 					((PyTypeObject *)ob)->tp_name);
 				goto error;
 			}
-			if (ArrayTypeObject_Check(ob))
+			if (PyCArrayTypeObject_Check(ob))
 				ob = PyObject_CallObject(ob, NULL);
 			else
 				/* Create an instance of the pointed-to type */
@@ -3678,7 +3678,7 @@
 }
 
 static PyObject *
-CFuncPtr_call(CFuncPtrObject *self, PyObject *inargs, PyObject *kwds)
+PyCFuncPtr_call(PyCFuncPtrObject *self, PyObject *inargs, PyObject *kwds)
 {
 	PyObject *restype;
 	PyObject *converters;
@@ -3697,7 +3697,7 @@
 	int outmask;
 	unsigned int numretvals;
 
-	assert(dict); /* Cannot be NULL for CFuncPtrObject instances */
+	assert(dict); /* Cannot be NULL for PyCFuncPtrObject instances */
 	restype = self->restype ? self->restype : dict->restype;
 	converters = self->converters ? self->converters : dict->converters;
 	checker = self->checker ? self->checker : dict->checker;
@@ -3774,7 +3774,7 @@
 		}
 	}
 
-	result = _CallProc(pProc,
+	result = _ctypes_callproc(pProc,
 			   callargs,
 #ifdef MS_WIN32
 			   piunk,
@@ -3810,7 +3810,7 @@
 }
 
 static int
-CFuncPtr_traverse(CFuncPtrObject *self, visitproc visit, void *arg)
+PyCFuncPtr_traverse(PyCFuncPtrObject *self, visitproc visit, void *arg)
 {
 	Py_VISIT(self->callable);
 	Py_VISIT(self->restype);
@@ -3820,11 +3820,11 @@
 	Py_VISIT(self->converters);
 	Py_VISIT(self->paramflags);
 	Py_VISIT(self->thunk);
-	return CData_traverse((CDataObject *)self, visit, arg);
+	return PyCData_traverse((CDataObject *)self, visit, arg);
 }
 
 static int
-CFuncPtr_clear(CFuncPtrObject *self)
+PyCFuncPtr_clear(PyCFuncPtrObject *self)
 {
 	Py_CLEAR(self->callable);
 	Py_CLEAR(self->restype);
@@ -3834,18 +3834,18 @@
 	Py_CLEAR(self->converters);
 	Py_CLEAR(self->paramflags);
 	Py_CLEAR(self->thunk);
-	return CData_clear((CDataObject *)self);
+	return PyCData_clear((CDataObject *)self);
 }
 
 static void
-CFuncPtr_dealloc(CFuncPtrObject *self)
+PyCFuncPtr_dealloc(PyCFuncPtrObject *self)
 {
-	CFuncPtr_clear(self);
+	PyCFuncPtr_clear(self);
 	Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static PyObject *
-CFuncPtr_repr(CFuncPtrObject *self)
+PyCFuncPtr_repr(PyCFuncPtrObject *self)
 {
 #ifdef MS_WIN32
 	if (self->index)
@@ -3860,7 +3860,7 @@
 }
 
 static int
-CFuncPtr_bool(CFuncPtrObject *self)
+PyCFuncPtr_bool(PyCFuncPtrObject *self)
 {
 	return ((*(void **)self->b_ptr != NULL)
 #ifdef MS_WIN32
@@ -3869,7 +3869,7 @@
 		);
 }
 
-static PyNumberMethods CFuncPtr_as_number = {
+static PyNumberMethods PyCFuncPtr_as_number = {
 	0, /* nb_add */
 	0, /* nb_subtract */
 	0, /* nb_multiply */
@@ -3879,40 +3879,40 @@
 	0, /* nb_negative */
 	0, /* nb_positive */
 	0, /* nb_absolute */
-	(inquiry)CFuncPtr_bool, /* nb_bool */
+	(inquiry)PyCFuncPtr_bool, /* nb_bool */
 };
 
-PyTypeObject CFuncPtr_Type = {
+PyTypeObject PyCFuncPtr_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"_ctypes.CFuncPtr",
-	sizeof(CFuncPtrObject),			/* tp_basicsize */
+	"_ctypes.PyCFuncPtr",
+	sizeof(PyCFuncPtrObject),			/* tp_basicsize */
 	0,					/* tp_itemsize */
-	(destructor)CFuncPtr_dealloc,		/* tp_dealloc */
+	(destructor)PyCFuncPtr_dealloc,		/* tp_dealloc */
 	0,					/* tp_print */
 	0,					/* tp_getattr */
 	0,					/* tp_setattr */
 	0,					/* tp_reserved */
-	(reprfunc)CFuncPtr_repr,		/* tp_repr */
-	&CFuncPtr_as_number,			/* tp_as_number */
+	(reprfunc)PyCFuncPtr_repr,		/* tp_repr */
+	&PyCFuncPtr_as_number,			/* tp_as_number */
 	0,					/* tp_as_sequence */
 	0,					/* tp_as_mapping */
 	0,					/* tp_hash */
-	(ternaryfunc)CFuncPtr_call,		/* tp_call */
+	(ternaryfunc)PyCFuncPtr_call,		/* tp_call */
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"Function Pointer",			/* tp_doc */
-	(traverseproc)CFuncPtr_traverse,	/* tp_traverse */
-	(inquiry)CFuncPtr_clear,		/* tp_clear */
+	(traverseproc)PyCFuncPtr_traverse,	/* tp_traverse */
+	(inquiry)PyCFuncPtr_clear,		/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
 	0,					/* tp_methods */
 	0,					/* tp_members */
-	CFuncPtr_getsets,			/* tp_getset */
+	PyCFuncPtr_getsets,			/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */
 	0,					/* tp_descr_get */
@@ -3920,7 +3920,7 @@
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-        CFuncPtr_new,				/* tp_new */
+        PyCFuncPtr_new,				/* tp_new */
 	0,					/* tp_free */
 };
 
@@ -4044,11 +4044,11 @@
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"Structure base class",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
@@ -4063,7 +4063,7 @@
 	0,					/* tp_dictoffset */
 	Struct_init,				/* tp_init */
 	0,					/* tp_alloc */
-	GenericCData_new,			/* tp_new */
+	GenericPyCData_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
@@ -4086,11 +4086,11 @@
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"Union base class",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
@@ -4105,14 +4105,14 @@
 	0,					/* tp_dictoffset */
 	Struct_init,				/* tp_init */
 	0,					/* tp_alloc */
-	GenericCData_new,			/* tp_new */
+	GenericPyCData_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
 
 /******************************************************************/
 /*
-  Array_Type
+  PyCArray_Type
 */
 static int
 Array_init(CDataObject *self, PyObject *args, PyObject *kw)
@@ -4157,7 +4157,7 @@
 	size = stgdict->size / stgdict->length;
 	offset = index * size;
 
-	return CData_get(stgdict->proto, stgdict->getfunc, (PyObject *)self,
+	return PyCData_get(stgdict->proto, stgdict->getfunc, (PyObject *)self,
 			 index, size, self->b_ptr + offset);
 }
 
@@ -4194,7 +4194,7 @@
 		assert(itemdict); /* proto is the item type of the array, a
 				     ctypes type, so this cannot be NULL */
 
-		if (itemdict->getfunc == getentry("c")->getfunc) {
+		if (itemdict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
 			char *ptr = (char *)self->b_ptr;
 			char *dest;
 
@@ -4219,7 +4219,7 @@
 			return np;
 		}
 #ifdef CTYPES_UNICODE
-		if (itemdict->getfunc == getentry("u")->getfunc) {
+		if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
 			wchar_t *ptr = (wchar_t *)self->b_ptr;
 			wchar_t *dest;
 			
@@ -4288,7 +4288,7 @@
 	offset = index * size;
 	ptr = self->b_ptr + offset;
 
-	return CData_set((PyObject *)self, stgdict->proto, stgdict->setfunc, value,
+	return PyCData_set((PyObject *)self, stgdict->proto, stgdict->setfunc, value,
 			 index, size, ptr);
 }
 
@@ -4376,7 +4376,7 @@
 	Array_ass_subscript,
 };
 
-PyTypeObject Array_Type = {
+PyTypeObject PyCArray_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"_ctypes.Array",
 	sizeof(CDataObject),			/* tp_basicsize */
@@ -4395,11 +4395,11 @@
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"XXX to be provided",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
@@ -4414,12 +4414,12 @@
 	0,					/* tp_dictoffset */
 	(initproc)Array_init,			/* tp_init */
 	0,					/* tp_alloc */
-        GenericCData_new,			/* tp_new */
+        GenericPyCData_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
 PyObject *
-CreateArrayType(PyObject *itemtype, Py_ssize_t length)
+PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length)
 {
 	static PyObject *cache;
 	PyObject *key;
@@ -4459,10 +4459,10 @@
 		((PyTypeObject *)itemtype)->tp_name, (long)length);
 #endif
 
-	result = PyObject_CallFunction((PyObject *)&ArrayType_Type,
+	result = PyObject_CallFunction((PyObject *)&PyCArrayType_Type,
 				       "U(O){s:n,s:O}",
 				       name,
-				       &Array_Type,
+				       &PyCArray_Type,
 				       "_length_",
 				       length,
 				       "_type_",
@@ -4538,7 +4538,7 @@
 static PyObject *
 Simple_from_outparm(PyObject *self, PyObject *args)
 {
-	if (IsSimpleSubType((PyObject *)Py_TYPE(self))) {
+	if (_ctypes_simple_instance((PyObject *)Py_TYPE(self))) {
 		Py_INCREF(self);
 		return self;
 	}
@@ -4627,11 +4627,11 @@
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"XXX to be provided",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
@@ -4646,13 +4646,13 @@
 	0,					/* tp_dictoffset */
 	(initproc)Simple_init,			/* tp_init */
 	0,					/* tp_alloc */
-        GenericCData_new,			/* tp_new */
+        GenericPyCData_new,			/* tp_new */
 	0,					/* tp_free */
 };
 
 /******************************************************************/
 /*
-  Pointer_Type
+  PyCPointer_Type
 */
 static PyObject *
 Pointer_item(PyObject *_self, Py_ssize_t index)
@@ -4681,7 +4681,7 @@
 	size = itemdict->size;
 	offset = index * itemdict->size;
 
-	return CData_get(proto, stgdict->getfunc, (PyObject *)self,
+	return PyCData_get(proto, stgdict->getfunc, (PyObject *)self,
 			 index, size, (*(char **)self->b_ptr) + offset);
 }
 
@@ -4719,7 +4719,7 @@
 	size = itemdict->size;
 	offset = index * itemdict->size;
 
-	return CData_set((PyObject *)self, proto, stgdict->setfunc, value,
+	return PyCData_set((PyObject *)self, proto, stgdict->setfunc, value,
 			 index, size, (*(char **)self->b_ptr) + offset);
 }
 
@@ -4736,7 +4736,7 @@
 
 	stgdict = PyObject_stgdict((PyObject *)self);
 	assert(stgdict); /* Cannot be NULL fr pointer instances */
-	return CData_FromBaseObj(stgdict->proto,
+	return PyCData_FromBaseObj(stgdict->proto,
 				 (PyObject *)self, 0,
 				 *(void **)self->b_ptr);
 }
@@ -4811,7 +4811,7 @@
 				"Cannot create instance: has no _type_");
 		return NULL;
 	}
-	return GenericCData_new(type, args, kw);
+	return GenericPyCData_new(type, args, kw);
 }
 
 static PyObject *
@@ -4887,7 +4887,7 @@
 		assert(proto);
 		itemdict = PyType_stgdict(proto);
 		assert(itemdict);
-		if (itemdict->getfunc == getentry("c")->getfunc) {
+		if (itemdict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
 			char *ptr = *(char **)self->b_ptr;
 			char *dest;
 			
@@ -4908,7 +4908,7 @@
 			return np;
 		}
 #ifdef CTYPES_UNICODE
-		if (itemdict->getfunc == getentry("u")->getfunc) {
+		if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
 			wchar_t *ptr = *(wchar_t **)self->b_ptr;
 			wchar_t *dest;
 			
@@ -4985,7 +4985,7 @@
 	(inquiry)Pointer_bool, /* nb_bool */
 };
 
-PyTypeObject Pointer_Type = {
+PyTypeObject PyCPointer_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"_ctypes._Pointer",
 	sizeof(CDataObject),			/* tp_basicsize */
@@ -5004,11 +5004,11 @@
 	0,					/* tp_str */
 	0,					/* tp_getattro */
 	0,					/* tp_setattro */
-	&CData_as_buffer,			/* tp_as_buffer */
+	&PyCData_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	"XXX to be provided",			/* tp_doc */
-	(traverseproc)CData_traverse,		/* tp_traverse */
-	(inquiry)CData_clear,			/* tp_clear */
+	(traverseproc)PyCData_traverse,		/* tp_traverse */
+	(inquiry)PyCData_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
@@ -5146,9 +5146,9 @@
 {
 	StgDictObject *dict;
 
-	if (PointerTypeObject_Check(arg))
+	if (PyCPointerTypeObject_Check(arg))
 		return 1;
-	if (CFuncPtrTypeObject_Check(arg))
+	if (PyCFuncPtrTypeObject_Check(arg))
 		return 1;
 	dict = PyType_stgdict(arg);
 	if (dict) {
@@ -5184,9 +5184,9 @@
 	 */
 	if (CDataObject_Check(src)) {
 		CDataObject *obj = (CDataObject *)src;
-		/* CData_GetContainer will initialize src.b_objects, we need
+		/* PyCData_GetContainer will initialize src.b_objects, we need
 		   this so it can be shared */
-		CData_GetContainer(obj);
+		PyCData_GetContainer(obj);
 		/* But we need a dictionary! */
 		if (obj->b_objects == Py_None) {
 			Py_DECREF(Py_None);
@@ -5234,7 +5234,7 @@
 	"_ctypes",
 	module_docs,
 	-1,
-	module_methods,
+	_ctypes_module_methods,
 	NULL,
 	NULL,
 	NULL,
@@ -5257,11 +5257,11 @@
 	if (!m)
 		return NULL;
 
-	_pointer_type_cache = PyDict_New();
-	if (_pointer_type_cache == NULL)
+	_ctypes_ptrtype_cache = PyDict_New();
+	if (_ctypes_ptrtype_cache == NULL)
 		return NULL;
 
-	PyModule_AddObject(m, "_pointer_type_cache", (PyObject *)_pointer_type_cache);
+	PyModule_AddObject(m, "_pointer_type_cache", (PyObject *)_ctypes_ptrtype_cache);
 
 	_unpickle = PyObject_GetAttrString(m, "_unpickle");
 	if (_unpickle == NULL)
@@ -5270,12 +5270,12 @@
 	if (PyType_Ready(&PyCArg_Type) < 0)
 		return NULL;
 
-	if (PyType_Ready(&CThunk_Type) < 0)
+	if (PyType_Ready(&PyCThunk_Type) < 0)
 		return NULL;
 
 	/* StgDict is derived from PyDict_Type */
-	StgDict_Type.tp_base = &PyDict_Type;
-	if (PyType_Ready(&StgDict_Type) < 0)
+	PyCStgDict_Type.tp_base = &PyDict_Type;
+	if (PyType_Ready(&PyCStgDict_Type) < 0)
 		return NULL;
 
 	/*************************************************
@@ -5283,28 +5283,28 @@
 	 * Metaclasses
 	 */
 
-	StructType_Type.tp_base = &PyType_Type;
-	if (PyType_Ready(&StructType_Type) < 0)
+	PyCStructType_Type.tp_base = &PyType_Type;
+	if (PyType_Ready(&PyCStructType_Type) < 0)
 		return NULL;
 
 	UnionType_Type.tp_base = &PyType_Type;
 	if (PyType_Ready(&UnionType_Type) < 0)
 		return NULL;
 
-	PointerType_Type.tp_base = &PyType_Type;
-	if (PyType_Ready(&PointerType_Type) < 0)
+	PyCPointerType_Type.tp_base = &PyType_Type;
+	if (PyType_Ready(&PyCPointerType_Type) < 0)
 		return NULL;
 
-	ArrayType_Type.tp_base = &PyType_Type;
-	if (PyType_Ready(&ArrayType_Type) < 0)
+	PyCArrayType_Type.tp_base = &PyType_Type;
+	if (PyType_Ready(&PyCArrayType_Type) < 0)
 		return NULL;
 
-	SimpleType_Type.tp_base = &PyType_Type;
-	if (PyType_Ready(&SimpleType_Type) < 0)
+	PyCSimpleType_Type.tp_base = &PyType_Type;
+	if (PyType_Ready(&PyCSimpleType_Type) < 0)
 		return NULL;
 
-	CFuncPtrType_Type.tp_base = &PyType_Type;
-	if (PyType_Ready(&CFuncPtrType_Type) < 0)
+	PyCFuncPtrType_Type.tp_base = &PyType_Type;
+	if (PyType_Ready(&PyCFuncPtrType_Type) < 0)
 		return NULL;
 
 	/*************************************************
@@ -5312,52 +5312,52 @@
 	 * Classes using a custom metaclass
 	 */
 
-	if (PyType_Ready(&CData_Type) < 0)
+	if (PyType_Ready(&PyCData_Type) < 0)
 		return NULL;
 
-	Py_TYPE(&Struct_Type) = &StructType_Type;
-	Struct_Type.tp_base = &CData_Type;
+	Py_TYPE(&Struct_Type) = &PyCStructType_Type;
+	Struct_Type.tp_base = &PyCData_Type;
 	if (PyType_Ready(&Struct_Type) < 0)
 		return NULL;
 	PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
 
 	Py_TYPE(&Union_Type) = &UnionType_Type;
-	Union_Type.tp_base = &CData_Type;
+	Union_Type.tp_base = &PyCData_Type;
 	if (PyType_Ready(&Union_Type) < 0)
 		return NULL;
 	PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
 
-	Py_TYPE(&Pointer_Type) = &PointerType_Type;
-	Pointer_Type.tp_base = &CData_Type;
-	if (PyType_Ready(&Pointer_Type) < 0)
+	Py_TYPE(&PyCPointer_Type) = &PyCPointerType_Type;
+	PyCPointer_Type.tp_base = &PyCData_Type;
+	if (PyType_Ready(&PyCPointer_Type) < 0)
 		return NULL;
-	PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type);
+	PyModule_AddObject(m, "_Pointer", (PyObject *)&PyCPointer_Type);
 
-	Py_TYPE(&Array_Type) = &ArrayType_Type;
-	Array_Type.tp_base = &CData_Type;
-	if (PyType_Ready(&Array_Type) < 0)
+	Py_TYPE(&PyCArray_Type) = &PyCArrayType_Type;
+	PyCArray_Type.tp_base = &PyCData_Type;
+	if (PyType_Ready(&PyCArray_Type) < 0)
 		return NULL;
-	PyModule_AddObject(m, "Array", (PyObject *)&Array_Type);
+	PyModule_AddObject(m, "Array", (PyObject *)&PyCArray_Type);
 
-	Py_TYPE(&Simple_Type) = &SimpleType_Type;
-	Simple_Type.tp_base = &CData_Type;
+	Py_TYPE(&Simple_Type) = &PyCSimpleType_Type;
+	Simple_Type.tp_base = &PyCData_Type;
 	if (PyType_Ready(&Simple_Type) < 0)
 		return NULL;
 	PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
 
-	Py_TYPE(&CFuncPtr_Type) = &CFuncPtrType_Type;
-	CFuncPtr_Type.tp_base = &CData_Type;
-	if (PyType_Ready(&CFuncPtr_Type) < 0)
+	Py_TYPE(&PyCFuncPtr_Type) = &PyCFuncPtrType_Type;
+	PyCFuncPtr_Type.tp_base = &PyCData_Type;
+	if (PyType_Ready(&PyCFuncPtr_Type) < 0)
 		return NULL;
-	PyModule_AddObject(m, "CFuncPtr", (PyObject *)&CFuncPtr_Type);
+	PyModule_AddObject(m, "CFuncPtr", (PyObject *)&PyCFuncPtr_Type);
 
 	/*************************************************
 	 *
 	 * Simple classes
 	 */
 
-	/* CField_Type is derived from PyBaseObject_Type */
-	if (PyType_Ready(&CField_Type) < 0)
+	/* PyCField_Type is derived from PyBaseObject_Type */
+	if (PyType_Ready(&PyCField_Type) < 0)
 		return NULL;
 
 	/*************************************************

Modified: python/branches/py3k/Modules/_ctypes/callbacks.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callbacks.c	(original)
+++ python/branches/py3k/Modules/_ctypes/callbacks.c	Fri Apr 24 22:50:00 2009
@@ -17,7 +17,7 @@
 	Py_XDECREF(self->callable);
 	Py_XDECREF(self->restype);
 	if (self->pcl)
-		FreeClosure(self->pcl);
+		_ctypes_free_closure(self->pcl);
 	PyObject_Del(self);
 }
 
@@ -41,7 +41,7 @@
 	return 0;
 }
 
-PyTypeObject CThunk_Type = {
+PyTypeObject PyCThunk_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"_ctypes.CThunkObject",
 	sizeof(CThunkObject),			/* tp_basicsize */
@@ -92,7 +92,7 @@
 
 
 /* after code that pyrex generates */
-void _AddTraceback(char *funcname, char *filename, int lineno)
+void _ctypes_add_traceback(char *funcname, char *filename, int lineno)
 {
 	PyObject *py_srcfile = 0;
 	PyObject *py_funcname = 0;
@@ -223,7 +223,7 @@
 			goto Done;
 		}
 
-		if (dict && dict->getfunc && !IsSimpleSubType(cnv)) {
+		if (dict && dict->getfunc && !_ctypes_simple_instance(cnv)) {
 			PyObject *v = dict->getfunc(*pArgs, dict->size);
 			if (!v) {
 				PrintError("create argument %d:\n", i);
@@ -237,7 +237,7 @@
 			   BTW, the same problem occurrs when they are pushed as parameters
 			*/
 		} else if (dict) {
-			/* Hm, shouldn't we use CData_AtAddress() or something like that instead? */
+			/* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */
 			CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL);
 			if (!obj) {
 				PrintError("create argument %d:\n", i);
@@ -268,10 +268,10 @@
 	}
 
 #define CHECK(what, x) \
-if (x == NULL) _AddTraceback(what, "_ctypes/callbacks.c", __LINE__ - 1), PyErr_Print()
+if (x == NULL) _ctypes_add_traceback(what, "_ctypes/callbacks.c", __LINE__ - 1), PyErr_Print()
 
 	if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
-		error_object = get_error_object(&space);
+		error_object = _ctypes_get_errobj(&space);
 		if (error_object == NULL)
 			goto Done;
 		if (flags & FUNCFLAG_USE_ERRNO) {
@@ -328,7 +328,7 @@
 			PyErr_WriteUnraisable(callable);
 		else if (keep == Py_None) /* Nothing to keep */
 			Py_DECREF(keep);
-		else if (setfunc != getentry("O")->setfunc) {
+		else if (setfunc != _ctypes_get_fielddesc("O")->setfunc) {
 			if (-1 == PyErr_WarnEx(PyExc_RuntimeWarning,
 					       "memory leak in callback function.",
 					       1))
@@ -364,7 +364,7 @@
 	CThunkObject *p;
 	int i;
 
-	p = PyObject_NewVar(CThunkObject, &CThunk_Type, nArgs);
+	p = PyObject_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
 	if (p == NULL) {
 		PyErr_NoMemory();
 		return NULL;
@@ -382,7 +382,7 @@
 	return p;
 }
 
-CThunkObject *AllocFunctionCallback(PyObject *callable,
+CThunkObject *_ctypes_alloc_callback(PyObject *callable,
 				    PyObject *converters,
 				    PyObject *restype,
 				    int flags)
@@ -399,7 +399,7 @@
 
 	assert(CThunk_CheckExact((PyObject *)p));
 
-	p->pcl = MallocClosure();
+	p->pcl = _ctypes_alloc_closure();
 	if (p->pcl == NULL) {
 		PyErr_NoMemory();
 		goto error;
@@ -410,7 +410,7 @@
 		PyObject *cnv = PySequence_GetItem(converters, i);
 		if (cnv == NULL)
 			goto error;
-		p->atypes[i] = GetType(cnv);
+		p->atypes[i] = _ctypes_get_ffi_type(cnv);
 		Py_DECREF(cnv);
 	}
 	p->atypes[i] = NULL;
@@ -438,7 +438,7 @@
 #endif
 	result = ffi_prep_cif(&p->cif, cc,
 			      Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int),
-			      GetType(restype),
+			      _ctypes_get_ffi_type(restype),
 			      &p->atypes[0]);
 	if (result != FFI_OK) {
 		PyErr_Format(PyExc_RuntimeError,

Modified: python/branches/py3k/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callproc.c	(original)
+++ python/branches/py3k/Modules/_ctypes/callproc.c	Fri Apr 24 22:50:00 2009
@@ -15,7 +15,7 @@
 /*
   How are functions called, and how are parameters converted to C ?
 
-  1. _ctypes.c::CFuncPtr_call receives an argument tuple 'inargs' and a
+  1. _ctypes.c::PyCFuncPtr_call receives an argument tuple 'inargs' and a
   keyword dictionary 'kwds'.
 
   2. After several checks, _build_callargs() is called which returns another
@@ -27,7 +27,7 @@
   the callargs tuple, specifying how to build the return value(s) of
   the function.
 
-  4. _CallProc is then called with the 'callargs' tuple.  _CallProc first
+  4. _ctypes_callproc is then called with the 'callargs' tuple.  _ctypes_callproc first
   allocates two arrays.  The first is an array of 'struct argument' items, the
   second array has 'void *' entried.
 
@@ -47,8 +47,8 @@
   libffi specific stuff, then it calls ffi_call.
 
   So, there are 4 data structures holding processed arguments:
-  - the inargs tuple (in CFuncPtr_call)
-  - the callargs tuple (in CFuncPtr_call)
+  - the inargs tuple (in PyCFuncPtr_call)
+  - the callargs tuple (in PyCFuncPtr_call)
   - the 'struct argguments' array
   - the 'void *' array
 
@@ -113,7 +113,7 @@
   kept alive in the thread state dictionary as long as the thread itself.
 */
 PyObject *
-get_error_object(int **pspace)
+_ctypes_get_errobj(int **pspace)
 {
 	PyObject *dict = PyThreadState_GetDict();
 	PyObject *errobj;
@@ -153,7 +153,7 @@
 get_error_internal(PyObject *self, PyObject *args, int index)
 {
 	int *space;
-	PyObject *errobj = get_error_object(&space);
+	PyObject *errobj = _ctypes_get_errobj(&space);
 	PyObject *result;
 
 	if (errobj == NULL)
@@ -172,7 +172,7 @@
 
 	if (!PyArg_ParseTuple(args, "i", &new_errno))
 		return NULL;
-	errobj = get_error_object(&space);
+	errobj = _ctypes_get_errobj(&space);
 	if (errobj == NULL)
 		return NULL;
 	old_errno = space[index];
@@ -405,7 +405,7 @@
 /**************************************************************/
 
 PyCArgObject *
-new_CArgObject(void)
+PyCArgObject_new(void)
 {
 	PyCArgObject *p;
 	p = PyObject_New(PyCArgObject, &PyCArg_Type);
@@ -697,7 +697,7 @@
 }
 
 
-ffi_type *GetType(PyObject *obj)
+ffi_type *_ctypes_get_ffi_type(PyObject *obj)
 {
 	StgDictObject *dict;
 	if (obj == NULL)
@@ -777,7 +777,7 @@
 	}
 
 	if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
-		error_object = get_error_object(&space);
+		error_object = _ctypes_get_errobj(&space);
 		if (error_object == NULL)
 			return -1;
 	}
@@ -895,24 +895,24 @@
 	if (dict == NULL)
 		return PyObject_CallFunction(restype, "i", *(int *)result);
 
-	if (dict->getfunc && !IsSimpleSubType(restype)) {
+	if (dict->getfunc && !_ctypes_simple_instance(restype)) {
 		retval = dict->getfunc(result, dict->size);
 		/* If restype is py_object (detected by comparing getfunc with
 		   O_get), we have to call Py_DECREF because O_get has already
 		   called Py_INCREF.
 		*/
-		if (dict->getfunc == getentry("O")->getfunc) {
+		if (dict->getfunc == _ctypes_get_fielddesc("O")->getfunc) {
 			Py_DECREF(retval);
 		}
 	} else
-		retval = CData_FromBaseObj(restype, NULL, 0, result);
+		retval = PyCData_FromBaseObj(restype, NULL, 0, result);
 
 	if (!checker || !retval)
 		return retval;
 
 	v = PyObject_CallFunctionObjArgs(checker, retval, NULL);
 	if (v == NULL)
-		_AddTraceback("GetResult", "_ctypes/callproc.c", __LINE__-2);
+		_ctypes_add_traceback("GetResult", "_ctypes/callproc.c", __LINE__-2);
 	Py_DECREF(retval);
 	return v;
 }
@@ -921,7 +921,7 @@
  * Raise a new exception 'exc_class', adding additional text to the original
  * exception string.
  */
-void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
 {
 	va_list vargs;
 	PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
@@ -1042,7 +1042,7 @@
  *
  * - XXX various requirements for restype, not yet collected
  */
-PyObject *_CallProc(PPROC pProc,
+PyObject *_ctypes_callproc(PPROC pProc,
 		    PyObject *argtuple,
 #ifdef MS_WIN32
 		    IUnknown *pIunk,
@@ -1095,7 +1095,7 @@
 		arg = PyTuple_GET_ITEM(argtuple, i);	/* borrowed ref */
 		/* For cdecl functions, we allow more actual arguments
 		   than the length of the argtypes tuple.
-		   This is checked in _ctypes::CFuncPtr_Call
+		   This is checked in _ctypes::PyCFuncPtr_Call
 		*/
 		if (argtypes && argtype_count > i) {
 			PyObject *v;
@@ -1104,26 +1104,26 @@
 							   arg,
 							   NULL);
 			if (v == NULL) {
-				Extend_Error_Info(PyExc_ArgError, "argument %d: ", i+1);
+				_ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
 				goto cleanup;
 			}
 
 			err = ConvParam(v, i+1, pa);
 			Py_DECREF(v);
 			if (-1 == err) {
-				Extend_Error_Info(PyExc_ArgError, "argument %d: ", i+1);
+				_ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
 				goto cleanup;
 			}
 		} else {
 			err = ConvParam(arg, i+1, pa);
 			if (-1 == err) {
-				Extend_Error_Info(PyExc_ArgError, "argument %d: ", i+1);
+				_ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
 				goto cleanup; /* leaking ? */
 			}
 		}
 	}
 
-	rtype = GetType(restype);
+	rtype = _ctypes_get_ffi_type(restype);
 	resbuf = alloca(max(rtype->size, sizeof(ffi_arg)));
 
 	avalues = (void **)alloca(sizeof(void *) * argcount);
@@ -1310,7 +1310,7 @@
 	pIunk = (IUnknown *)(*(void **)(pcom->b_ptr));
 	lpVtbl = (PPROC *)(pIunk->lpVtbl);
 
-	result =  _CallProc(lpVtbl[index],
+	result =  _ctypes_callproc(lpVtbl[index],
 			    arguments,
 #ifdef MS_WIN32
 			    pIunk,
@@ -1433,7 +1433,7 @@
 			      &PyTuple_Type, &arguments))
 		return NULL;
 
-	result =  _CallProc((PPROC)func,
+	result =  _ctypes_callproc((PPROC)func,
 			    arguments,
 #ifdef MS_WIN32
 			    NULL,
@@ -1464,7 +1464,7 @@
 			      &PyTuple_Type, &arguments))
 		return NULL;
 
-	result =  _CallProc((PPROC)func,
+	result =  _ctypes_callproc((PPROC)func,
 			    arguments,
 #ifdef MS_WIN32
 			    NULL,
@@ -1556,7 +1556,7 @@
 		return NULL;
 	}
 
-	parg = new_CArgObject();
+	parg = PyCArgObject_new();
 	if (parg == NULL)
 		return NULL;
 
@@ -1631,17 +1631,17 @@
 
 	if (!PyArg_ParseTuple(args, "zs:set_conversion_mode", &coding, &mode))
 		return NULL;
-	result = Py_BuildValue("(zz)", conversion_mode_encoding, conversion_mode_errors);
+	result = Py_BuildValue("(zz)", _ctypes_conversion_encoding, _ctypes_conversion_errors);
 	if (coding) {
-		PyMem_Free(conversion_mode_encoding);
-		conversion_mode_encoding = PyMem_Malloc(strlen(coding) + 1);
-		strcpy(conversion_mode_encoding, coding);
+		PyMem_Free(_ctypes_conversion_encoding);
+		_ctypes_conversion_encoding = PyMem_Malloc(strlen(coding) + 1);
+		strcpy(_ctypes_conversion_encoding, coding);
 	} else {
-		conversion_mode_encoding = NULL;
+		_ctypes_conversion_encoding = NULL;
 	}
-	PyMem_Free(conversion_mode_errors);
-	conversion_mode_errors = PyMem_Malloc(strlen(mode) + 1);
-	strcpy(conversion_mode_errors, mode);
+	PyMem_Free(_ctypes_conversion_errors);
+	_ctypes_conversion_errors = PyMem_Malloc(strlen(mode) + 1);
+	strcpy(_ctypes_conversion_errors, mode);
 	return result;
 }
 #endif
@@ -1732,7 +1732,7 @@
 	PyObject *key;
 	char *buf;
 
-	result = PyDict_GetItem(_pointer_type_cache, cls);
+	result = PyDict_GetItem(_ctypes_ptrtype_cache, cls);
 	if (result) {
 		Py_INCREF(result);
 		return result;
@@ -1741,10 +1741,10 @@
 		char *name = _PyUnicode_AsString(cls);
 		buf = alloca(strlen(name) + 3 + 1);
 		sprintf(buf, "LP_%s", name);
-		result = PyObject_CallFunction((PyObject *)Py_TYPE(&Pointer_Type),
+		result = PyObject_CallFunction((PyObject *)Py_TYPE(&PyCPointer_Type),
 					       "s(O){}",
 					       buf,
-					       &Pointer_Type);
+					       &PyCPointer_Type);
 		if (result == NULL)
 			return result;
 		key = PyLong_FromVoidPtr(result);
@@ -1752,10 +1752,10 @@
 		typ = (PyTypeObject *)cls;
 		buf = alloca(strlen(typ->tp_name) + 3 + 1);
 		sprintf(buf, "LP_%s", typ->tp_name);
-		result = PyObject_CallFunction((PyObject *)Py_TYPE(&Pointer_Type),
+		result = PyObject_CallFunction((PyObject *)Py_TYPE(&PyCPointer_Type),
 					       "s(O){sO}",
 					       buf,
-					       &Pointer_Type,
+					       &PyCPointer_Type,
 					       "_type_", cls);
 		if (result == NULL)
 			return result;
@@ -1765,7 +1765,7 @@
 		PyErr_SetString(PyExc_TypeError, "must be a ctypes type");
 		return NULL;
 	}
-	if (-1 == PyDict_SetItem(_pointer_type_cache, key, result)) {
+	if (-1 == PyDict_SetItem(_ctypes_ptrtype_cache, key, result)) {
 		Py_DECREF(result);
 		Py_DECREF(key);
 		return NULL;
@@ -1780,7 +1780,7 @@
 	PyObject *result;
 	PyObject *typ;
 
-	typ = PyDict_GetItem(_pointer_type_cache, (PyObject *)Py_TYPE(arg));
+	typ = PyDict_GetItem(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg));
 	if (typ)
 		return PyObject_CallFunctionObjArgs(typ, arg, NULL);
 	typ = POINTER(NULL, (PyObject *)Py_TYPE(arg));
@@ -1818,7 +1818,7 @@
 	return Py_BuildValue("siN", dict->format, dict->ndim, shape);
 }
 
-PyMethodDef module_methods[] = {
+PyMethodDef _ctypes_module_methods[] = {
 	{"get_errno", get_errno, METH_NOARGS},
 	{"set_errno", set_errno, METH_VARARGS},
 	{"POINTER", POINTER, METH_O },

Modified: python/branches/py3k/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/cfield.c	(original)
+++ python/branches/py3k/Modules/_ctypes/cfield.c	Fri Apr 24 22:50:00 2009
@@ -8,10 +8,10 @@
 
 /******************************************************************/
 /*
-  CField_Type
+  PyCField_Type
 */
 static PyObject *
-CField_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+PyCField_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	CFieldObject *obj;
 	obj = (CFieldObject *)type->tp_alloc(type, 0);
@@ -31,7 +31,7 @@
  * prev_desc points to the type of the previous bitfield, if any.
  */
 PyObject *
-CField_FromDesc(PyObject *desc, Py_ssize_t index,
+PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
 		Py_ssize_t *pfield_size, int bitsize, int *pbitofs,
 		Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign,
 		int pack, int big_endian)
@@ -48,7 +48,7 @@
 #define CONT_BITFIELD 2
 #define EXPAND_BITFIELD 3
 
-	self = (CFieldObject *)PyObject_CallObject((PyObject *)&CField_Type,
+	self = (CFieldObject *)PyObject_CallObject((PyObject *)&PyCField_Type,
 						   NULL);
 	if (self == NULL)
 		return NULL;
@@ -98,7 +98,7 @@
 	/*  Field descriptors for 'c_char * n' are be scpecial cased to
 	    return a Python string instead of an Array object instance...
 	*/
-	if (ArrayTypeObject_Check(proto)) {
+	if (PyCArrayTypeObject_Check(proto)) {
 		StgDictObject *adict = PyType_stgdict(proto);
 		StgDictObject *idict;
 		if (adict && adict->proto) {
@@ -109,14 +109,14 @@
 				Py_DECREF(self);
 				return NULL;
 			}
-			if (idict->getfunc == getentry("c")->getfunc) {
-				struct fielddesc *fd = getentry("s");
+			if (idict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
+				struct fielddesc *fd = _ctypes_get_fielddesc("s");
 				getfunc = fd->getfunc;
 				setfunc = fd->setfunc;
 			}
 #ifdef CTYPES_UNICODE
-			if (idict->getfunc == getentry("u")->getfunc) {
-				struct fielddesc *fd = getentry("U");
+			if (idict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
+				struct fielddesc *fd = _ctypes_get_fielddesc("U");
 				getfunc = fd->getfunc;
 				setfunc = fd->setfunc;
 			}
@@ -190,7 +190,7 @@
 }
 
 static int
-CField_set(CFieldObject *self, PyObject *inst, PyObject *value)
+PyCField_set(CFieldObject *self, PyObject *inst, PyObject *value)
 {
 	CDataObject *dst;
 	char *ptr;
@@ -202,12 +202,12 @@
 				"can't delete attribute");
 		return -1;
 	}
-	return CData_set(inst, self->proto, self->setfunc, value,
+	return PyCData_set(inst, self->proto, self->setfunc, value,
 			 self->index, self->size, ptr);
 }
 
 static PyObject *
-CField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
+PyCField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
 {
 	CDataObject *src;
 	if (inst == NULL) {
@@ -216,51 +216,51 @@
 	}
 	assert(CDataObject_Check(inst));
 	src = (CDataObject *)inst;
-	return CData_get(self->proto, self->getfunc, inst,
+	return PyCData_get(self->proto, self->getfunc, inst,
 			 self->index, self->size, src->b_ptr + self->offset);
 }
 
 static PyObject *
-CField_get_offset(PyObject *self, void *data)
+PyCField_get_offset(PyObject *self, void *data)
 {
 	return PyLong_FromSsize_t(((CFieldObject *)self)->offset);
 }
 
 static PyObject *
-CField_get_size(PyObject *self, void *data)
+PyCField_get_size(PyObject *self, void *data)
 {
 	return PyLong_FromSsize_t(((CFieldObject *)self)->size);
 }
 
-static PyGetSetDef CField_getset[] = {
-	{ "offset", CField_get_offset, NULL, "offset in bytes of this field" },
-	{ "size", CField_get_size, NULL, "size in bytes of this field" },
+static PyGetSetDef PyCField_getset[] = {
+	{ "offset", PyCField_get_offset, NULL, "offset in bytes of this field" },
+	{ "size", PyCField_get_size, NULL, "size in bytes of this field" },
 	{ NULL, NULL, NULL, NULL },
 };
 
 static int
-CField_traverse(CFieldObject *self, visitproc visit, void *arg)
+PyCField_traverse(CFieldObject *self, visitproc visit, void *arg)
 {
 	Py_VISIT(self->proto);
 	return 0;
 }
 
 static int
-CField_clear(CFieldObject *self)
+PyCField_clear(CFieldObject *self)
 {
 	Py_CLEAR(self->proto);
 	return 0;
 }
 
 static void
-CField_dealloc(PyObject *self)
+PyCField_dealloc(PyObject *self)
 {
-	CField_clear((CFieldObject *)self);
+	PyCField_clear((CFieldObject *)self);
 	self->ob_type->tp_free((PyObject *)self);
 }
 
 static PyObject *
-CField_repr(CFieldObject *self)
+PyCField_repr(CFieldObject *self)
 {
 	PyObject *result;
 	Py_ssize_t bits = self->size >> 16;
@@ -280,17 +280,17 @@
 	return result;
 }
 
-PyTypeObject CField_Type = {
+PyTypeObject PyCField_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"_ctypes.CField",				/* tp_name */
 	sizeof(CFieldObject),			/* tp_basicsize */
 	0,					/* tp_itemsize */
-	CField_dealloc,				/* tp_dealloc */
+	PyCField_dealloc,				/* tp_dealloc */
 	0,					/* tp_print */
 	0,					/* tp_getattr */
 	0,					/* tp_setattr */
 	0,					/* tp_reserved */
-	(reprfunc)CField_repr,			/* tp_repr */
+	(reprfunc)PyCField_repr,			/* tp_repr */
 	0,					/* tp_as_number */
 	0,					/* tp_as_sequence */
 	0,					/* tp_as_mapping */
@@ -302,23 +302,23 @@
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
 	"Structure/Union member",		/* tp_doc */
-	(traverseproc)CField_traverse,		/* tp_traverse */
-	(inquiry)CField_clear,			/* tp_clear */
+	(traverseproc)PyCField_traverse,		/* tp_traverse */
+	(inquiry)PyCField_clear,			/* tp_clear */
 	0,					/* tp_richcompare */
 	0,					/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */
 	0,					/* tp_methods */
 	0,					/* tp_members */
-	CField_getset,				/* tp_getset */
+	PyCField_getset,				/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */
-	(descrgetfunc)CField_get,		/* tp_descr_get */
-	(descrsetfunc)CField_set,		/* tp_descr_set */
+	(descrgetfunc)PyCField_get,		/* tp_descr_get */
+	(descrsetfunc)PyCField_set,		/* tp_descr_set */
 	0,					/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
-	CField_new,				/* tp_new */
+	PyCField_new,				/* tp_new */
 	0,					/* tp_free */
 };
 
@@ -1158,8 +1158,8 @@
 {
 	if (PyUnicode_Check(value)) {
 		value = PyUnicode_AsEncodedString(value,
-						  conversion_mode_encoding,
-						  conversion_mode_errors);
+						  _ctypes_conversion_encoding,
+						  _ctypes_conversion_errors);
 		if (value == NULL)
 			return NULL;
 		if (PyBytes_GET_SIZE(value) != 1) {
@@ -1207,8 +1207,8 @@
 	Py_ssize_t len;
 	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
-						    conversion_mode_encoding,
-						    conversion_mode_errors);
+						    _ctypes_conversion_encoding,
+						    _ctypes_conversion_errors);
 		if (!value)
 			return NULL;
 	} else if (!PyUnicode_Check(value)) {
@@ -1282,8 +1282,8 @@
 
 	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
-						    conversion_mode_encoding,
-						    conversion_mode_errors);
+						    _ctypes_conversion_encoding,
+						    _ctypes_conversion_errors);
 		if (!value)
 			return NULL;
 	} else if (!PyUnicode_Check(value)) {
@@ -1332,8 +1332,8 @@
 
 	if (PyUnicode_Check(value)) {
 		value = PyUnicode_AsEncodedString(value,
-						  conversion_mode_encoding,
-						  conversion_mode_errors);
+										  _ctypes_conversion_encoding,
+										  _ctypes_conversion_errors);
 		if (value == NULL)
 			return NULL;
 		assert(PyBytes_Check(value));
@@ -1383,8 +1383,8 @@
 		return value;
 	} else if (PyUnicode_Check(value)) {
 		PyObject *str = PyUnicode_AsEncodedString(value,
-							  conversion_mode_encoding,
-							  conversion_mode_errors);
+							  _ctypes_conversion_encoding,
+							  _ctypes_conversion_errors);
 		if (str == NULL)
 			return NULL;
 		*(char **)ptr = PyBytes_AS_STRING(str);
@@ -1443,8 +1443,8 @@
 	}
 	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
-						    conversion_mode_encoding,
-						    conversion_mode_errors);
+						    _ctypes_conversion_encoding,
+						    _ctypes_conversion_errors);
 		if (!value)
 			return NULL;
 	} else if (!PyUnicode_Check(value)) {
@@ -1529,8 +1529,8 @@
 		value = NULL;
 	} else if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
-						    conversion_mode_encoding,
-						    conversion_mode_errors);
+						    _ctypes_conversion_encoding,
+						    _ctypes_conversion_errors);
 		if (!value)
 			return NULL;
 	} else if (PyUnicode_Check(value)) {
@@ -1690,7 +1690,7 @@
 */
 
 struct fielddesc *
-getentry(const char *fmt)
+_ctypes_get_fielddesc(const char *fmt)
 {
 	static int initialized = 0;
 	struct fielddesc *table = formattable;
@@ -1699,11 +1699,11 @@
 		initialized = 1;
 #ifdef CTYPES_UNICODE
 		if (sizeof(wchar_t) == sizeof(short))
-			getentry("u")->pffi_type = &ffi_type_sshort;
+			_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort;
 		else if (sizeof(wchar_t) == sizeof(int))
-			getentry("u")->pffi_type = &ffi_type_sint;
+			_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sint;
 		else if (sizeof(wchar_t) == sizeof(long))
-			getentry("u")->pffi_type = &ffi_type_slong;
+			_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_slong;
 #endif
 	}
 

Modified: python/branches/py3k/Modules/_ctypes/ctypes.h
==============================================================================
--- python/branches/py3k/Modules/_ctypes/ctypes.h	(original)
+++ python/branches/py3k/Modules/_ctypes/ctypes.h	Fri Apr 24 22:50:00 2009
@@ -18,7 +18,7 @@
 and this one is not used.
 
 Making CDataObject a variable size object would be a better solution, but more
-difficult in the presence of CFuncPtrObject.  Maybe later.
+difficult in the presence of PyCFuncPtrObject.  Maybe later.
 */
 union value {
 		char c[16];
@@ -64,8 +64,8 @@
 	ffi_type *ffi_restype;
 	ffi_type *atypes[1];
 } CThunkObject;
-extern PyTypeObject CThunk_Type;
-#define CThunk_CheckExact(v)	    ((v)->ob_type == &CThunk_Type)
+extern PyTypeObject PyCThunk_Type;
+#define CThunk_CheckExact(v)	    ((v)->ob_type == &PyCThunk_Type)
 
 typedef struct {
 	/* First part identical to tagCDataObject */
@@ -96,61 +96,61 @@
 	GUID *iid;
 #endif
 	PyObject *paramflags;
-} CFuncPtrObject;
+} PyCFuncPtrObject;
 
-extern PyTypeObject StgDict_Type;
-#define StgDict_CheckExact(v)	    ((v)->ob_type == &StgDict_Type)
-#define StgDict_Check(v)	    PyObject_TypeCheck(v, &StgDict_Type)
+extern PyTypeObject PyCStgDict_Type;
+#define PyCStgDict_CheckExact(v)	    ((v)->ob_type == &PyCStgDict_Type)
+#define PyCStgDict_Check(v)	    PyObject_TypeCheck(v, &PyCStgDict_Type)
 
-extern int StructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
+extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
 extern int PyType_stginfo(PyTypeObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength);
 extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength);
 
 
 
-extern PyTypeObject CData_Type;
-#define CDataObject_CheckExact(v)	((v)->ob_type == &CData_Type)
-#define CDataObject_Check(v)		PyObject_TypeCheck(v, &CData_Type)
-
-extern PyTypeObject SimpleType_Type;
-#define SimpleTypeObject_CheckExact(v)	((v)->ob_type == &SimpleType_Type)
-#define SimpleTypeObject_Check(v)	PyObject_TypeCheck(v, &SimpleType_Type)
+extern PyTypeObject PyCData_Type;
+#define CDataObject_CheckExact(v)	((v)->ob_type == &PyCData_Type)
+#define CDataObject_Check(v)		PyObject_TypeCheck(v, &PyCData_Type)
+
+extern PyTypeObject PyCSimpleType_Type;
+#define PyCSimpleTypeObject_CheckExact(v)	((v)->ob_type == &PyCSimpleType_Type)
+#define PyCSimpleTypeObject_Check(v)	PyObject_TypeCheck(v, &PyCSimpleType_Type)
 
-extern PyTypeObject CField_Type;
-extern struct fielddesc *getentry(const char *fmt);
+extern PyTypeObject PyCField_Type;
+extern struct fielddesc *_ctypes_get_fielddesc(const char *fmt);
 
 
 extern PyObject *
-CField_FromDesc(PyObject *desc, Py_ssize_t index,
+PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
 		Py_ssize_t *pfield_size, int bitsize, int *pbitofs,
 		Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign,
 		int pack, int is_big_endian);
 
-extern PyObject *CData_AtAddress(PyObject *type, void *buf);
-extern PyObject *CData_FromBytes(PyObject *type, char *data, Py_ssize_t length);
+extern PyObject *PyCData_AtAddress(PyObject *type, void *buf);
+extern PyObject *PyCData_FromBytes(PyObject *type, char *data, Py_ssize_t length);
 
-extern PyTypeObject ArrayType_Type;
-extern PyTypeObject Array_Type;
-extern PyTypeObject PointerType_Type;
-extern PyTypeObject Pointer_Type;
-extern PyTypeObject CFuncPtr_Type;
-extern PyTypeObject CFuncPtrType_Type;
-extern PyTypeObject StructType_Type;
-
-#define ArrayTypeObject_Check(v)	PyObject_TypeCheck(v, &ArrayType_Type)
-#define ArrayObject_Check(v)		PyObject_TypeCheck(v, &Array_Type)
-#define PointerObject_Check(v)		PyObject_TypeCheck(v, &Pointer_Type)
-#define PointerTypeObject_Check(v)	PyObject_TypeCheck(v, &PointerType_Type)
-#define CFuncPtrObject_Check(v)		PyObject_TypeCheck(v, &CFuncPtr_Type)
-#define CFuncPtrTypeObject_Check(v)	PyObject_TypeCheck(v, &CFuncPtrType_Type)
-#define StructTypeObject_Check(v)	PyObject_TypeCheck(v, &StructType_Type)
+extern PyTypeObject PyCArrayType_Type;
+extern PyTypeObject PyCArray_Type;
+extern PyTypeObject PyCPointerType_Type;
+extern PyTypeObject PyCPointer_Type;
+extern PyTypeObject PyCFuncPtr_Type;
+extern PyTypeObject PyCFuncPtrType_Type;
+extern PyTypeObject PyCStructType_Type;
+
+#define PyCArrayTypeObject_Check(v)	PyObject_TypeCheck(v, &PyCArrayType_Type)
+#define ArrayObject_Check(v)		PyObject_TypeCheck(v, &PyCArray_Type)
+#define PointerObject_Check(v)		PyObject_TypeCheck(v, &PyCPointer_Type)
+#define PyCPointerTypeObject_Check(v)	PyObject_TypeCheck(v, &PyCPointerType_Type)
+#define PyCFuncPtrObject_Check(v)		PyObject_TypeCheck(v, &PyCFuncPtr_Type)
+#define PyCFuncPtrTypeObject_Check(v)	PyObject_TypeCheck(v, &PyCFuncPtrType_Type)
+#define PyCStructTypeObject_Check(v)	PyObject_TypeCheck(v, &PyCStructType_Type)
 
 extern PyObject *
-CreateArrayType(PyObject *itemtype, Py_ssize_t length);
+PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length);
 
-extern PyMethodDef module_methods[];
+extern PyMethodDef _ctypes_module_methods[];
 
-extern CThunkObject *AllocFunctionCallback(PyObject *callable,
+extern CThunkObject *_ctypes_alloc_callback(PyObject *callable,
 					   PyObject *converters,
 					   PyObject *restype,
 					   int flags);
@@ -182,7 +182,7 @@
 	PyDictObject dict;	/* first part identical to PyDictObject */
 /* The size and align fields are unneeded, they are in ffi_type as well.  As
    an experiment shows, it's trivial to get rid of them, the only thing to
-   remember is that in ArrayType_new the ffi_type fields must be filled in -
+   remember is that in PyCArrayType_new the ffi_type fields must be filled in -
    so far it was unneeded because libffi doesn't support arrays at all
    (because they are passed as pointers to function calls anyway).  But it's
    too much risk to change that now, and there are other fields which doen't
@@ -197,7 +197,7 @@
 	GETFUNC getfunc;	/* Only for simple objects */
 	PARAMFUNC paramfunc;
 
-	/* Following fields only used by CFuncPtrType_Type instances */
+	/* Following fields only used by PyCFuncPtrType_Type instances */
 	PyObject *argtypes;	/* tuple of CDataObjects */
 	PyObject *converters;	/* tuple([t.from_param for t in argtypes]) */
 	PyObject *restype;	/* CDataObject or NULL */
@@ -231,7 +231,7 @@
  construction time, or assigns to it later, tp_setattro should update the
  StgDictObject function to a generic one.
 
- Currently, CFuncPtr types have 'converters' and 'checker' entries in their
+ Currently, PyCFuncPtr types have 'converters' and 'checker' entries in their
  type dict.  They are only used to cache attributes from other entries, whihc
  is wrong.
 
@@ -259,11 +259,11 @@
 /* May return NULL, but does not set an exception! */
 extern StgDictObject *PyObject_stgdict(PyObject *self);
 
-extern int StgDict_clone(StgDictObject *src, StgDictObject *dst);
+extern int PyCStgDict_clone(StgDictObject *src, StgDictObject *dst);
 
 typedef int(* PPROC)(void);
 
-PyObject *_CallProc(PPROC pProc,
+PyObject *_ctypes_callproc(PPROC pProc,
 		    PyObject *arguments,
 #ifdef MS_WIN32
 		    IUnknown *pIUnk,
@@ -311,17 +311,17 @@
 
 extern PyTypeObject PyCArg_Type;
 #define PyCArg_CheckExact(v)	    ((v)->ob_type == &PyCArg_Type)
-extern PyCArgObject *new_CArgObject(void);
+extern PyCArgObject *PyCArgObject_new(void);
 
 extern PyObject *
-CData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
+PyCData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
 	  Py_ssize_t index, Py_ssize_t size, char *ptr);
 
 extern int
-CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
+PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
 	  Py_ssize_t index, Py_ssize_t size, char *ptr);
 
-extern void Extend_Error_Info(PyObject *exc_class, char *fmt, ...);
+extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...);
 
 struct basespec {
 	CDataObject *base;
@@ -331,32 +331,31 @@
 
 extern char basespec_string[];
 
-extern ffi_type *GetType(PyObject *obj);
+extern ffi_type *_ctypes_get_ffi_type(PyObject *obj);
 
 /* exception classes */
 extern PyObject *PyExc_ArgError;
 
-extern char *conversion_mode_encoding;
-extern char *conversion_mode_errors;
+extern char *_ctypes_conversion_encoding;
+extern char *_ctypes_conversion_errors;
 
 #if defined(HAVE_WCHAR_H)
 #  define CTYPES_UNICODE
 #endif
 
 
-extern void FreeClosure(void *);
-extern void *MallocClosure(void);
+extern void _ctypes_free_closure(void *);
+extern void *_ctypes_alloc_closure(void);
 
-extern void _AddTraceback(char *, char *, int);
+extern void _ctypes_add_traceback(char *, char *, int);
 
-extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr);
-extern char *alloc_format_string(const char *prefix, const char *suffix);
+extern PyObject *PyCData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr);
+extern char *_ctypes_alloc_format_string(const char *prefix, const char *suffix);
 
-/* XXX better name needed! */
-extern int IsSimpleSubType(PyObject *obj);
+extern int _ctypes_simple_instance(PyObject *obj);
 
-extern PyObject *_pointer_type_cache;
-PyObject *get_error_object(int **pspace);
+extern PyObject *_ctypes_ptrtype_cache;
+PyObject *_ctypes_get_errobj(int **pspace);
 
 #ifdef MS_WIN32
 extern PyObject *ComError;

Modified: python/branches/py3k/Modules/_ctypes/malloc_closure.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/malloc_closure.c	(original)
+++ python/branches/py3k/Modules/_ctypes/malloc_closure.c	Fri Apr 24 22:50:00 2009
@@ -89,7 +89,7 @@
 /******************************************************************/
 
 /* put the item back into the free list */
-void FreeClosure(void *p)
+void _ctypes_free_closure(void *p)
 {
 	ITEM *item = (ITEM *)p;
 	item->next = free_list;
@@ -97,7 +97,7 @@
 }
 
 /* return one item from the free list, allocating more if needed */
-void *MallocClosure(void)
+void *_ctypes_alloc_closure(void)
 {
 	ITEM *item;
 	if (!free_list)

Modified: python/branches/py3k/Modules/_ctypes/stgdict.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/stgdict.c	(original)
+++ python/branches/py3k/Modules/_ctypes/stgdict.c	Fri Apr 24 22:50:00 2009
@@ -17,7 +17,7 @@
  * PyDict_SetItem() (ma_lookup is NULL)
  */
 static int
-StgDict_init(StgDictObject *self, PyObject *args, PyObject *kwds)
+PyCStgDict_init(StgDictObject *self, PyObject *args, PyObject *kwds)
 {
 	if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0)
 		return -1;
@@ -28,7 +28,7 @@
 }
 
 static int
-StgDict_clear(StgDictObject *self)
+PyCStgDict_clear(StgDictObject *self)
 {
 	Py_CLEAR(self->proto);
 	Py_CLEAR(self->argtypes);
@@ -39,9 +39,9 @@
 }
 
 static void
-StgDict_dealloc(StgDictObject *self)
+PyCStgDict_dealloc(StgDictObject *self)
 {
-	StgDict_clear(self);
+	PyCStgDict_clear(self);
 	PyMem_Free(self->format);
 	PyMem_Free(self->shape);
 	PyMem_Free(self->ffi_type_pointer.elements);
@@ -49,12 +49,12 @@
 }
 
 int
-StgDict_clone(StgDictObject *dst, StgDictObject *src)
+PyCStgDict_clone(StgDictObject *dst, StgDictObject *src)
 {
 	char *d, *s;
 	Py_ssize_t size;
 
-	StgDict_clear(dst);
+	PyCStgDict_clear(dst);
 	PyMem_Free(dst->ffi_type_pointer.elements);
 	PyMem_Free(dst->format);
 	dst->format = NULL;
@@ -102,12 +102,12 @@
 	return 0;
 }
 
-PyTypeObject StgDict_Type = {
+PyTypeObject PyCStgDict_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"StgDict",
 	sizeof(StgDictObject),
 	0,
-	(destructor)StgDict_dealloc,		/* tp_dealloc */
+	(destructor)PyCStgDict_dealloc,		/* tp_dealloc */
 	0,					/* tp_print */
 	0,					/* tp_getattr */
 	0,					/* tp_setattr */
@@ -138,7 +138,7 @@
 	0,					/* tp_descr_get */
 	0,					/* tp_descr_set */
 	0,					/* tp_dictoffset */
-	(initproc)StgDict_init,			/* tp_init */
+	(initproc)PyCStgDict_init,			/* tp_init */
 	0,					/* tp_alloc */
 	0,					/* tp_new */
 	0,					/* tp_free */
@@ -153,7 +153,7 @@
 	if (!PyType_Check(obj))
 		return NULL;
 	type = (PyTypeObject *)obj;
-	if (!type->tp_dict || !StgDict_CheckExact(type->tp_dict))
+	if (!type->tp_dict || !PyCStgDict_CheckExact(type->tp_dict))
 		return NULL;
 	return (StgDictObject *)type->tp_dict;
 }
@@ -167,7 +167,7 @@
 PyObject_stgdict(PyObject *self)
 {
 	PyTypeObject *type = self->ob_type;
-	if (!type->tp_dict || !StgDict_CheckExact(type->tp_dict))
+	if (!type->tp_dict || !PyCStgDict_CheckExact(type->tp_dict))
 		return NULL;
 	return (StgDictObject *)type->tp_dict;
 }
@@ -207,7 +207,7 @@
 			Py_DECREF(fieldlist);
 			return -1;
 		}
-		if (Py_TYPE(fdescr) != &CField_Type) {
+		if (Py_TYPE(fdescr) != &PyCField_Type) {
 			PyErr_SetString(PyExc_TypeError, "unexpected type");
 			Py_DECREF(fdescr);
 			Py_DECREF(fieldlist);
@@ -224,13 +224,13 @@
 			}
 			continue;
 		}
- 		new_descr = (CFieldObject *)PyObject_CallObject((PyObject *)&CField_Type, NULL);
+ 		new_descr = (CFieldObject *)PyObject_CallObject((PyObject *)&PyCField_Type, NULL);
 		if (new_descr == NULL) {
 			Py_DECREF(fdescr);
 			Py_DECREF(fieldlist);
 			return -1;
 		}
-		assert(Py_TYPE(new_descr) == &CField_Type);
+		assert(Py_TYPE(new_descr) == &PyCField_Type);
  		new_descr->size = fdescr->size;
  		new_descr->offset = fdescr->offset + offset;
  		new_descr->index = fdescr->index + index;
@@ -278,7 +278,7 @@
 			Py_DECREF(anon_names);
 			return -1;
 		}
-		assert(Py_TYPE(descr) == &CField_Type);
+		assert(Py_TYPE(descr) == &PyCField_Type);
 		descr->anonymous = 1;
 
 		/* descr is in the field descriptor. */
@@ -301,7 +301,7 @@
   and create an StgDictObject.  Used for Structure and Union subclasses.
 */
 int
-StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
+PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
 {
 	StgDictObject *stgdict, *basedict;
 	Py_ssize_t len, offset, size, align, i;
@@ -410,12 +410,12 @@
 
 	assert(stgdict->format == NULL);
 	if (isStruct && !isPacked) {
-		stgdict->format = alloc_format_string(NULL, "T{");
+		stgdict->format = _ctypes_alloc_format_string(NULL, "T{");
 	} else {
 		/* PEP3118 doesn't support union, or packed structures (well,
 		   only standard packing, but we dont support the pep for
 		   that). Use 'B' for bytes. */
-		stgdict->format = alloc_format_string(NULL, "B");
+		stgdict->format = _ctypes_alloc_format_string(NULL, "B");
 	}
 
 #define realdict ((PyObject *)&stgdict->dict)
@@ -456,9 +456,9 @@
 			case FFI_TYPE_SINT8:
 			case FFI_TYPE_SINT16:
 			case FFI_TYPE_SINT32:
-				if (dict->getfunc != getentry("c")->getfunc
+				if (dict->getfunc != _ctypes_get_fielddesc("c")->getfunc
 #ifdef CTYPES_UNICODE
-				    && dict->getfunc != getentry("u")->getfunc
+				    && dict->getfunc != _ctypes_get_fielddesc("u")->getfunc
 #endif
 					)
 					break;
@@ -488,7 +488,7 @@
 			sprintf(buf, "%s:%s:", fieldfmt, fieldname);
 
 			ptr = stgdict->format;
-			stgdict->format = alloc_format_string(stgdict->format, buf);
+			stgdict->format = _ctypes_alloc_format_string(stgdict->format, buf);
 			PyMem_Free(ptr);
 
 			if (stgdict->format == NULL) {
@@ -497,7 +497,7 @@
 			}
 		}
 		if (isStruct) {
-			prop = CField_FromDesc(desc, i,
+			prop = PyCField_FromDesc(desc, i,
 					       &field_size, bitsize, &bitofs,
 					       &size, &offset, &align,
 					       pack, big_endian);
@@ -505,7 +505,7 @@
 			size = 0;
 			offset = 0;
 			align = 0;
-			prop = CField_FromDesc(desc, i,
+			prop = PyCField_FromDesc(desc, i,
 					       &field_size, bitsize, &bitofs,
 					       &size, &offset, &align,
 					       pack, big_endian);
@@ -529,7 +529,7 @@
 
 	if (isStruct && !isPacked) {
 		char *ptr = stgdict->format;
-		stgdict->format = alloc_format_string(stgdict->format, "}");
+		stgdict->format = _ctypes_alloc_format_string(stgdict->format, "}");
 		PyMem_Free(ptr);
 		if (stgdict->format == NULL)
 			return -1;


More information about the Python-checkins mailing list