Skip to content

Commit

Permalink
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the a…
Browse files Browse the repository at this point in the history
…liases in intobject.h
  • Loading branch information
tiran committed Dec 2, 2007
1 parent 1a3284e commit 217cfd1
Show file tree
Hide file tree
Showing 123 changed files with 888 additions and 885 deletions.
2 changes: 1 addition & 1 deletion Demo/embed/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ main(int argc, char **argv)
static PyObject *
xyzzy_foo(PyObject *self, PyObject* args)
{
return PyInt_FromLong(42L);
return PyLong_FromLong(42L);
}

static PyMethodDef xyzzy_methods[] = {
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/run-func.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ main(int argc, char *argv[])
if (pFunc && PyCallable_Check(pFunc)) {
pArgs = PyTuple_New(argc - 3);
for (i = 0; i < argc - 3; ++i) {
pValue = PyInt_FromLong(atoi(argv[i + 3]));
pValue = PyLong_FromLong(atoi(argv[i + 3]));
if (!pValue) {
Py_DECREF(pArgs);
Py_DECREF(pModule);
Expand All @@ -39,7 +39,7 @@ main(int argc, char *argv[])
pValue = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
if (pValue != NULL) {
printf("Result of call: %ld\n", PyInt_AsLong(pValue));
printf("Result of call: %ld\n", PyLong_AsLong(pValue));
Py_DECREF(pValue);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion Doc/includes/shoddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static PyObject *
Shoddy_increment(Shoddy *self, PyObject *unused)
{
self->state++;
return PyInt_FromLong(self->state);
return PyLong_FromLong(self->state);
}


Expand Down
25 changes: 13 additions & 12 deletions Include/intobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyInt_Type;
*/

#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op))

#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#ifdef 0
# define PyInt_Check(op) PyLong_Check(op)
# define PyInt_FromString PyLong_FromString
# define PyInt_FromUnicode PyLong_FromUnicode
# define PyInt_FromLong PyLong_FromLong
# define PyInt_FromSize_t PyLong_FromSize_t
# define PyInt_FromSsize_t PyLong_FromSsize_t
# define PyInt_AsLong PyLong_AsLong
# define PyInt_AsSsize_t PyLong_AsSsize_t
# define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
# define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
# define PyInt_AS_LONG PyLong_AS_LONG
#endif

PyAPI_FUNC(long) PyInt_GetMax(void);

#define PyInt_AS_LONG(op) PyLong_AsLong(op)

/* These aren't really part of the Int object, but they're handy; the protos
* are necessary for systems that need the magic of PyAPI_FUNC.
*/
Expand Down
4 changes: 4 additions & 0 deletions Include/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);

/* It may be useful in the future. I've added it in the PyInt -> PyLong
cleanup to keep the extra information. [CH] */
#define PyLong_AS_LONG(op) PyLong_AsLong(op)

/* Used by socketmodule.c */
#if SIZEOF_SOCKET_T <= SIZEOF_LONG
#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
Expand Down
2 changes: 1 addition & 1 deletion Include/py_curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
return PyInt_FromLong((long) X()); }
return PyLong_FromLong((long) X()); }


#define NoArgReturnStringFunction(X) \
Expand Down
2 changes: 0 additions & 2 deletions Include/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ PyAPI_FUNC(void) _PyImport_Init(void);
PyAPI_FUNC(void) _PyExc_Init(void);
PyAPI_FUNC(void) _PyImportHooks_Init(void);
PyAPI_FUNC(int) _PyFrame_Init(void);
PyAPI_FUNC(int) _PyInt_Init(void);
PyAPI_FUNC(void) _PyFloat_Init(void);
PyAPI_FUNC(int) PyBytes_Init(void);

Expand All @@ -140,7 +139,6 @@ PyAPI_FUNC(void) PyList_Fini(void);
PyAPI_FUNC(void) PySet_Fini(void);
PyAPI_FUNC(void) PyString_Fini(void);
PyAPI_FUNC(void) PyBytes_Fini(void);
PyAPI_FUNC(void) PyInt_Fini(void);
PyAPI_FUNC(void) PyFloat_Fini(void);
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);

Expand Down
2 changes: 1 addition & 1 deletion Mac/Modules/MacOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ rf_tell(rfobject *self, PyObject *args)
PyMac_Error(err);
return NULL;
}
return PyInt_FromLong(where);
return PyLong_FromLong(where);
}

static char rf_close__doc__[] =
Expand Down
4 changes: 2 additions & 2 deletions Mac/Modules/carbonevt/_CarbonEvtmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject
} else {
if (retValue == Py_None)
status = noErr;
else if (PyInt_Check(retValue)) {
status = PyInt_AsLong(retValue);
else if (PyLong_Check(retValue)) {
status = PyLong_AsLong(retValue);
} else
status = noErr; /* wrong object type, complain? */
Py_DECREF(retValue);
Expand Down
6 changes: 3 additions & 3 deletions Mac/Modules/cf/pycfbridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ PyCF_CF2Python_simple(CFTypeRef src) {
long l;
if (!CFNumberGetValue(src, kCFNumberLongType, &l))
/* XXXX Out of range! */;
return PyInt_FromLong(l);
return PyLong_FromLong(l);
}
}
/* XXXX Should return as CFTypeRef, really... */
Expand Down Expand Up @@ -258,8 +258,8 @@ PyCF_Python2CF_simple(PyObject *src, CFTypeRef *dst) {
*dst = kCFBooleanFalse;
return 1;
}
if (PyInt_Check(src)) {
long v = PyInt_AsLong(src);
if (PyLong_Check(src)) {
long v = PyLong_AsLong(src);
*dst = CFNumberCreate(NULL, kCFNumberLongType, &v);
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions Mac/Modules/ctl/_Ctlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,7 @@ static PyObject *CtlObj_TrackControl(ControlObject *_self, PyObject *_args)
PyMac_GetPoint, &startPoint, &callback))
return NULL;
if (callback && callback != Py_None) {
if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
if (PyLong_Check(callback) && PyLong_AS_LONG(callback) == -1)
upp = (ControlActionUPP)-1;
else {
settrackfunc(callback);
Expand Down Expand Up @@ -3283,7 +3283,7 @@ static PyObject *CtlObj_HandleControlClick(ControlObject *_self, PyObject *_args
&callback))
return NULL;
if (callback && callback != Py_None) {
if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
if (PyLong_Check(callback) && PyLong_AS_LONG(callback) == -1)
upp = (ControlActionUPP)-1;
else {
settrackfunc(callback);
Expand Down
6 changes: 3 additions & 3 deletions Mac/Modules/dlg/_Dlgmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
}
else {
Dlg_FilterProc_callback = callback;
if (PyInt_Check(res)) {
*itemHit = PyInt_AsLong(res);
if (PyLong_Check(res)) {
*itemHit = PyLong_AsLong(res);
rv = 1;
}
else
Expand Down Expand Up @@ -150,7 +150,7 @@ PyObject *DlgObj_New(DialogPtr itself)
int DlgObj_Convert(PyObject *v, DialogPtr *p_itself)
{
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);
if (PyLong_Check(v)) { *p_itself = (DialogPtr)PyLong_AsLong(v);
return 1; }
if (!DlgObj_Check(v))
{
Expand Down
2 changes: 1 addition & 1 deletion Mac/Modules/gestaltmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gestalt_gestalt(PyObject *self, PyObject *args)
iErr = Gestalt ( selector, &response );
if (iErr != 0)
return PyMac_Error(iErr);
return PyInt_FromLong(response);
return PyLong_FromLong(response);
}

static struct PyMethodDef gestalt_methods[] = {
Expand Down
4 changes: 2 additions & 2 deletions Mac/Modules/qd/_Qdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,14 +1488,14 @@ static PyMethodDef BMObj_methods[] = {

static PyObject *BMObj_get_baseAddr(BitMapObject *self, void *closure)
{
return PyInt_FromLong((long)self->ob_itself->baseAddr);
return PyLong_FromLong((long)self->ob_itself->baseAddr);
}

#define BMObj_set_baseAddr NULL

static PyObject *BMObj_get_rowBytes(BitMapObject *self, void *closure)
{
return PyInt_FromLong((long)self->ob_itself->rowBytes);
return PyLong_FromLong((long)self->ob_itself->rowBytes);
}

#define BMObj_set_rowBytes NULL
Expand Down
2 changes: 1 addition & 1 deletion Mac/Modules/res/_Resmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static int ResObj_set_data(ResourceObject *self, PyObject *v, void *closure)

static PyObject *ResObj_get_size(ResourceObject *self, void *closure)
{
return PyInt_FromLong(GetHandleSize(self->ob_itself));
return PyLong_FromLong(GetHandleSize(self->ob_itself));
}

#define ResObj_set_size NULL
Expand Down
2 changes: 1 addition & 1 deletion Mac/Modules/snd/_Sndihooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ sndih_getSampleSizeAvailable(self, args)
if( (rsizes = PyTuple_New(arg.numsizes)) == NULL)
return NULL;
for( i=0; i<arg.numsizes; i++ )
PyTuple_SetItem(rsizes, i, PyInt_FromLong((long)fsizes[i]));
PyTuple_SetItem(rsizes, i, PyLong_FromLong((long)fsizes[i]));
return rsizes;
}

Expand Down
2 changes: 1 addition & 1 deletion Mac/Modules/win/_Winmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int WinObj_Convert(PyObject *v, WindowPtr *p_itself)
{

if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
if (PyLong_Check(v)) { *p_itself = (WindowPtr)PyLong_AsLong(v); return 1; }

{
DialogRef dlg;
Expand Down
4 changes: 2 additions & 2 deletions Modules/_bisectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bisect_right(PyObject *self, PyObject *args, PyObject *kw)
index = internal_bisect_right(list, item, lo, hi);
if (index < 0)
return NULL;
return PyInt_FromLong(index);
return PyLong_FromLong(index);
}

PyDoc_STRVAR(bisect_right_doc,
Expand Down Expand Up @@ -145,7 +145,7 @@ bisect_left(PyObject *self, PyObject *args, PyObject *kw)
index = internal_bisect_left(list, item, lo, hi);
if (index < 0)
return NULL;
return PyInt_FromLong(index);
return PyLong_FromLong(index);
}

PyDoc_STRVAR(bisect_left_doc,
Expand Down
Loading

0 comments on commit 217cfd1

Please sign in to comment.