summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-02 14:31:20 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-02 14:31:20 (GMT)
commit217cfd1c86c59ed8a55ce6d6b88bbe37309e7ba2 (patch)
tree4737b4a91359c94953623ab9ee297e9a90f319e4 /Modules/_ctypes
parent1a3284ed69d545e4ef59869998cb8c29233a45fa (diff)
downloadcpython-217cfd1c86c59ed8a55ce6d6b88bbe37309e7ba2.zip
cpython-217cfd1c86c59ed8a55ce6d6b88bbe37309e7ba2.tar.gz
cpython-217cfd1c86c59ed8a55ce6d6b88bbe37309e7ba2.tar.bz2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c40
-rw-r--r--Modules/_ctypes/callbacks.c4
-rw-r--r--Modules/_ctypes/callproc.c20
-rw-r--r--Modules/_ctypes/cfield.c62
-rw-r--r--Modules/_ctypes/stgdict.c2
5 files changed, 64 insertions, 64 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 1c11853..00643ac 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -236,7 +236,7 @@ static PyObject *
CDataType_from_address(PyObject *type, PyObject *value)
{
void *buf;
- if (!PyInt_Check(value)) {
+ if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"integer expected");
return NULL;
@@ -265,7 +265,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)
obj = PyObject_GetAttrString(dll, "_handle");
if (!obj)
return NULL;
- if (!PyInt_Check(obj)) {
+ if (!PyLong_Check(obj)) {
PyErr_SetString(PyExc_TypeError,
"the _handle attribute of the second argument must be an integer");
Py_DECREF(obj);
@@ -641,7 +641,7 @@ PointerType_from_param(PyObject *type, PyObject *value)
StgDictObject *typedict;
if (value == Py_None)
- return PyInt_FromLong(0); /* NULL pointer */
+ return PyLong_FromLong(0); /* NULL pointer */
typedict = PyType_stgdict(type);
assert(typedict); /* Cannot be NULL for pointer types */
@@ -969,7 +969,7 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
"which must be a positive integer");
return NULL;
}
- length = PyInt_AS_LONG(proto);
+ length = PyLong_AS_LONG(proto);
proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */
if (!proto) {
@@ -1233,7 +1233,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
}
/* Should probably allow buffer interface as well */
/* int, long */
- if (PyInt_Check(value)) {
+ if (PyLong_Check(value)) {
PyCArgObject *parg;
struct fielddesc *fd = getentry("P");
@@ -1784,12 +1784,12 @@ make_funcptrtype_dict(StgDictObject *stgdict)
stgdict->ffi_type_pointer = ffi_type_pointer;
ob = PyDict_GetItemString((PyObject *)stgdict, "_flags_");
- if (!ob || !PyInt_Check(ob)) {
+ if (!ob || !PyLong_Check(ob)) {
PyErr_SetString(PyExc_TypeError,
"class must define _flags_ which must be an integer");
return -1;
}
- stgdict->flags = PyInt_AS_LONG(ob);
+ stgdict->flags = PyLong_AS_LONG(ob);
/* _argtypes_ is optional... */
ob = PyDict_GetItemString((PyObject *)stgdict, "_argtypes_");
@@ -2697,11 +2697,11 @@ static int
_get_name(PyObject *obj, char **pname)
{
#ifdef MS_WIN32
- if (PyInt_Check(obj)) {
+ if (PyLong_Check(obj)) {
/* We have to use MAKEINTRESOURCEA for Windows CE.
Works on Windows as well, of course.
*/
- *pname = MAKEINTRESOURCEA(PyInt_AsUnsignedLongMask(obj) & 0xFFFF);
+ *pname = MAKEINTRESOURCEA(PyLong_AsUnsignedLongMask(obj) & 0xFFFF);
return 1;
}
#endif
@@ -2738,7 +2738,7 @@ CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
obj = PyObject_GetAttrString(dll, "_handle");
if (!obj)
return NULL;
- if (!PyInt_Check(obj)) {
+ if (!PyLong_Check(obj)) {
PyErr_SetString(PyExc_TypeError,
"the _handle attribute of the second argument must be an integer");
Py_DECREF(obj);
@@ -2858,12 +2858,12 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return CFuncPtr_FromDll(type, args, kwds);
#ifdef MS_WIN32
- if (2 <= PyTuple_GET_SIZE(args) && PyInt_Check(PyTuple_GET_ITEM(args, 0)))
+ if (2 <= PyTuple_GET_SIZE(args) && PyLong_Check(PyTuple_GET_ITEM(args, 0)))
return CFuncPtr_FromVtblIndex(type, args, kwds);
#endif
if (1 == PyTuple_GET_SIZE(args)
- && (PyInt_Check(PyTuple_GET_ITEM(args, 0)))) {
+ && (PyLong_Check(PyTuple_GET_ITEM(args, 0)))) {
CDataObject *ob;
void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0));
if (ptr == NULL)
@@ -3068,7 +3068,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
calls below. */
/* We HAVE already checked that the tuple can be parsed with "i|ZO", so... */
Py_ssize_t tsize = PyTuple_GET_SIZE(item);
- flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0));
+ flag = PyLong_AS_LONG(PyTuple_GET_ITEM(item, 0));
name = tsize > 1 ? PyTuple_GET_ITEM(item, 1) : NULL;
defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL;
@@ -3077,7 +3077,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
/* ['in', 'lcid'] parameter. Always taken from defval,
if given, else the integer 0. */
if (defval == NULL) {
- defval = PyInt_FromLong(0);
+ defval = PyLong_FromLong(0);
if (defval == NULL)
goto error;
} else
@@ -4864,11 +4864,11 @@ init_ctypes(void)
return;
PyModule_AddObject(m, "COMError", ComError);
- PyModule_AddObject(m, "FUNCFLAG_HRESULT", PyInt_FromLong(FUNCFLAG_HRESULT));
- PyModule_AddObject(m, "FUNCFLAG_STDCALL", PyInt_FromLong(FUNCFLAG_STDCALL));
+ PyModule_AddObject(m, "FUNCFLAG_HRESULT", PyLong_FromLong(FUNCFLAG_HRESULT));
+ PyModule_AddObject(m, "FUNCFLAG_STDCALL", PyLong_FromLong(FUNCFLAG_STDCALL));
#endif
- PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL));
- PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI));
+ PyModule_AddObject(m, "FUNCFLAG_CDECL", PyLong_FromLong(FUNCFLAG_CDECL));
+ PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyLong_FromLong(FUNCFLAG_PYTHONAPI));
PyModule_AddStringConstant(m, "__version__", "1.1.0");
PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove));
@@ -4891,8 +4891,8 @@ init_ctypes(void)
#define RTLD_GLOBAL RTLD_LOCAL
#endif
- PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL));
- PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL));
+ PyModule_AddObject(m, "RTLD_LOCAL", PyLong_FromLong(RTLD_LOCAL));
+ PyModule_AddObject(m, "RTLD_GLOBAL", PyLong_FromLong(RTLD_GLOBAL));
PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL);
if (PyExc_ArgError) {
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 9e1aa4f..5e61938 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -408,7 +408,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
return E_FAIL;
}
- retval = PyInt_AsLong(result);
+ retval = PyLong_AsLong(result);
if (PyErr_Occurred()) {
PyErr_WriteUnraisable(context ? context : Py_None);
retval = E_FAIL;
@@ -469,7 +469,7 @@ long Call_CanUnloadNow(void)
return E_FAIL;
}
- retval = PyInt_AsLong(result);
+ retval = PyLong_AsLong(result);
if (PyErr_Occurred()) {
PyErr_WriteUnraisable(context ? context : Py_None);
retval = E_FAIL;
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 1ab1d27..befb31b 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -269,7 +269,7 @@ check_hresult(PyObject *self, PyObject *args)
return NULL;
if (FAILED(hr))
return PyErr_SetFromWindowsErr(hr);
- return PyInt_FromLong(hr);
+ return PyLong_FromLong(hr);
}
#endif
@@ -727,7 +727,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
PyObject *retval, *v;
if (restype == NULL)
- return PyInt_FromLong(*(int *)result);
+ return PyLong_FromLong(*(int *)result);
if (restype == Py_None) {
Py_INCREF(Py_None);
@@ -1020,12 +1020,12 @@ PyObject *_CallProc(PPROC pProc,
if (*(int *)resbuf & 0x80000000)
retval = GetComError(*(HRESULT *)resbuf, iid, pIunk);
else
- retval = PyInt_FromLong(*(int *)resbuf);
+ retval = PyLong_FromLong(*(int *)resbuf);
} else if (flags & FUNCFLAG_HRESULT) {
if (*(int *)resbuf & 0x80000000)
retval = PyErr_SetFromWindowsErr(*(int *)resbuf);
else
- retval = PyInt_FromLong(*(int *)resbuf);
+ retval = PyLong_FromLong(*(int *)resbuf);
} else
#endif
retval = GetResult(restype, resbuf, checker);
@@ -1198,12 +1198,12 @@ copy_com_pointer(PyObject *self, PyObject *args)
pdst = (IUnknown **)b.value.p;
if (pdst == NULL)
- r = PyInt_FromLong(E_POINTER);
+ r = PyLong_FromLong(E_POINTER);
else {
if (src)
src->lpVtbl->AddRef(src);
*pdst = src;
- r = PyInt_FromLong(S_OK);
+ r = PyLong_FromLong(S_OK);
}
done:
Py_XDECREF(a.keep);
@@ -1345,10 +1345,10 @@ sizeof_func(PyObject *self, PyObject *obj)
dict = PyType_stgdict(obj);
if (dict)
- return PyInt_FromSsize_t(dict->size);
+ return PyLong_FromSsize_t(dict->size);
if (CDataObject_Check(obj))
- return PyInt_FromSsize_t(((CDataObject *)obj)->b_size);
+ return PyLong_FromSsize_t(((CDataObject *)obj)->b_size);
PyErr_SetString(PyExc_TypeError,
"this type has no size");
return NULL;
@@ -1366,11 +1366,11 @@ align_func(PyObject *self, PyObject *obj)
dict = PyType_stgdict(obj);
if (dict)
- return PyInt_FromSsize_t(dict->align);
+ return PyLong_FromSsize_t(dict->align);
dict = PyObject_stgdict(obj);
if (dict)
- return PyInt_FromSsize_t(dict->align);
+ return PyLong_FromSsize_t(dict->align);
PyErr_SetString(PyExc_TypeError,
"no alignment info");
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 2ec7b3a..f29fc666 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -216,13 +216,13 @@ CField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
static PyObject *
CField_get_offset(PyObject *self, void *data)
{
- return PyInt_FromSsize_t(((CFieldObject *)self)->offset);
+ return PyLong_FromSsize_t(((CFieldObject *)self)->offset);
}
static PyObject *
CField_get_size(PyObject *self, void *data)
{
- return PyInt_FromSsize_t(((CFieldObject *)self)->size);
+ return PyLong_FromSsize_t(((CFieldObject *)self)->size);
}
static PyGetSetDef CField_getset[] = {
@@ -329,13 +329,13 @@ static int
get_long(PyObject *v, long *p)
{
long x;
- if (!PyInt_Check(v)) {
+ if (!PyLong_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
return -1;
}
- x = PyInt_AsUnsignedLongMask(v);
+ x = PyLong_AsUnsignedLongMask(v);
if (x == -1 && PyErr_Occurred())
return -1;
*p = x;
@@ -348,13 +348,13 @@ static int
get_ulong(PyObject *v, unsigned long *p)
{
unsigned long x;
- if (!PyInt_Check(v)) {
+ if (!PyLong_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
return -1;
}
- x = PyInt_AsUnsignedLongMask(v);
+ x = PyLong_AsUnsignedLongMask(v);
if (x == -1 && PyErr_Occurred())
return -1;
*p = x;
@@ -369,13 +369,13 @@ static int
get_longlong(PyObject *v, PY_LONG_LONG *p)
{
PY_LONG_LONG x;
- if (!PyInt_Check(v)) {
+ if (!PyLong_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
return -1;
}
- x = PyInt_AsUnsignedLongLongMask(v);
+ x = PyLong_AsUnsignedLongLongMask(v);
if (x == -1 && PyErr_Occurred())
return -1;
*p = x;
@@ -388,13 +388,13 @@ static int
get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
{
unsigned PY_LONG_LONG x;
- if (!PyInt_Check(v)) {
+ if (!PyLong_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
return -1;
}
- x = PyInt_AsUnsignedLongLongMask(v);
+ x = PyLong_AsUnsignedLongLongMask(v);
if (x == -1 && PyErr_Occurred())
return -1;
*p = x;
@@ -513,7 +513,7 @@ b_get(void *ptr, Py_ssize_t size)
{
signed char val = *(signed char *)ptr;
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -533,7 +533,7 @@ B_get(void *ptr, Py_ssize_t size)
{
unsigned char val = *(unsigned char *)ptr;
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -571,7 +571,7 @@ h_get(void *ptr, Py_ssize_t size)
short val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
- return PyInt_FromLong((long)val);
+ return PyLong_FromLong((long)val);
}
static PyObject *
@@ -581,7 +581,7 @@ h_get_sw(void *ptr, Py_ssize_t size)
memcpy(&val, ptr, sizeof(val));
val = SWAP_2(val);
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -619,7 +619,7 @@ H_get(void *ptr, Py_ssize_t size)
unsigned short val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -629,7 +629,7 @@ H_get_sw(void *ptr, Py_ssize_t size)
memcpy(&val, ptr, sizeof(val));
val = SWAP_2(val);
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -667,7 +667,7 @@ i_get(void *ptr, Py_ssize_t size)
int val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -677,7 +677,7 @@ i_get_sw(void *ptr, Py_ssize_t size)
memcpy(&val, ptr, sizeof(val));
val = SWAP_INT(val);
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
#ifdef MS_WIN32
@@ -815,7 +815,7 @@ l_get(void *ptr, Py_ssize_t size)
long val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -825,7 +825,7 @@ l_get_sw(void *ptr, Py_ssize_t size)
memcpy(&val, ptr, sizeof(val));
val = SWAP_LONG(val);
GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
+ return PyLong_FromLong(val);
}
static PyObject *
@@ -1173,9 +1173,9 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size)
*(char *)ptr = PyBytes_AS_STRING(value)[0];
_RET(value);
}
- if (PyInt_Check(value))
+ if (PyLong_Check(value))
{
- long longval = PyInt_AS_LONG(value);
+ long longval = PyLong_AS_LONG(value);
if (longval < 0 || longval >= 256)
goto error;
*(char *)ptr = (char)longval;
@@ -1384,11 +1384,11 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size)
return NULL;
*(char **)ptr = PyString_AS_STRING(str);
return str;
- } else if (PyInt_Check(value)) {
+ } else if (PyLong_Check(value)) {
#if SIZEOF_VOID_P == SIZEOF_LONG_LONG
- *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value);
+ *(char **)ptr = (char *)PyLong_AsUnsignedLongLongMask(value);
#else
- *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value);
+ *(char **)ptr = (char *)PyLong_AsUnsignedLongMask(value);
#endif
_RET(value);
}
@@ -1427,11 +1427,11 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
Py_INCREF(value);
return value;
}
- if (PyInt_Check(value) || PyLong_Check(value)) {
+ if (PyLong_Check(value) || PyLong_Check(value)) {
#if SIZEOF_VOID_P == SIZEOF_LONG_LONG
- *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value);
+ *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongLongMask(value);
#else
- *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value);
+ *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value);
#endif
Py_INCREF(Py_None);
return Py_None;
@@ -1585,21 +1585,21 @@ P_set(void *ptr, PyObject *value, Py_ssize_t size)
_RET(value);
}
- if (!PyInt_Check(value) && !PyLong_Check(value)) {
+ if (!PyLong_Check(value) && !PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"cannot be converted to pointer");
return NULL;
}
#if SIZEOF_VOID_P <= SIZEOF_LONG
- v = (void *)PyInt_AsUnsignedLongMask(value);
+ v = (void *)PyLong_AsUnsignedLongMask(value);
#else
#ifndef HAVE_LONG_LONG
# error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long"
#elif SIZEOF_LONG_LONG < SIZEOF_VOID_P
# error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
#endif
- v = (void *)PyInt_AsUnsignedLongLongMask(value);
+ v = (void *)PyLong_AsUnsignedLongLongMask(value);
#endif
if (PyErr_Occurred())
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 3f330f0..d38380b 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -311,7 +311,7 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
isPacked = PyObject_GetAttrString(type, "_pack_");
if (isPacked) {
- pack = PyInt_AsLong(isPacked);
+ pack = PyLong_AsLong(isPacked);
if (pack < 0 || PyErr_Occurred()) {
Py_XDECREF(isPacked);
PyErr_SetString(PyExc_ValueError,