Permalink
Browse files

STY: core/src - replace macros in old_defines.h with new versions.

  • Loading branch information...
1 parent 48d6edb commit 215a91a9a0e790273a3dc1203709190025ce0641 @charris charris committed Jan 28, 2012
@@ -157,7 +157,7 @@ PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)
* Special code to mimic Numeric behavior for
* character arrays.
*/
- if (PyArray_DESCR(dest)->type == PyArray_CHARLTR &&
+ if (PyArray_DESCR(dest)->type == NPY_CHARLTR &&
PyArray_NDIM(dest) > 0 &&
PyString_Check(src_object)) {
npy_intp n_new, n_old;
@@ -325,7 +325,7 @@ PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)
/*
Given a string return the type-number for
the data-type with that string as the type-object name.
- Returns PyArray_NOTYPE without setting an error if no type can be
+ Returns NPY_NOTYPE without setting an error if no type can be
found. Only works for user-defined data-types.
*/
@@ -343,7 +343,7 @@ PyArray_TypeNumFromName(char *str)
return descr->type_num;
}
}
- return PyArray_NOTYPE;
+ return NPY_NOTYPE;
}
/*********************** end C-API functions **********************/
@@ -676,7 +676,7 @@ array_str(PyArrayObject *self)
NPY_NO_EXPORT int
PyArray_CompareUCS4(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
{
- PyArray_UCS4 c1, c2;
+ npy_ucs4 c1, c2;
while(len-- > 0) {
c1 = *s1++;
c2 = *s2++;
@@ -712,21 +712,21 @@ PyArray_CompareString(char *s1, char *s2, size_t len)
If they are NULL terminated, then stop comparison.
*/
static int
-_myunincmp(PyArray_UCS4 *s1, PyArray_UCS4 *s2, int len1, int len2)
+_myunincmp(npy_ucs4 *s1, npy_ucs4 *s2, int len1, int len2)
{
- PyArray_UCS4 *sptr;
- PyArray_UCS4 *s1t=s1, *s2t=s2;
+ npy_ucs4 *sptr;
+ npy_ucs4 *s1t=s1, *s2t=s2;
int val;
npy_intp size;
int diff;
- if ((npy_intp)s1 % sizeof(PyArray_UCS4) != 0) {
- size = len1*sizeof(PyArray_UCS4);
+ if ((npy_intp)s1 % sizeof(npy_ucs4) != 0) {
+ size = len1*sizeof(npy_ucs4);
s1t = malloc(size);
memcpy(s1t, s1, size);
}
- if ((npy_intp)s2 % sizeof(PyArray_UCS4) != 0) {
- size = len2*sizeof(PyArray_UCS4);
+ if ((npy_intp)s2 % sizeof(npy_ucs4) != 0) {
+ size = len2*sizeof(npy_ucs4);
s2t = malloc(size);
memcpy(s2t, s2, size);
}
@@ -825,11 +825,11 @@ static void _rstripw(char *s, int n)
}
}
-static void _unistripw(PyArray_UCS4 *s, int n)
+static void _unistripw(npy_ucs4 *s, int n)
{
int i;
for (i = n - 1; i >= 1; i--) { /* Never strip to length 0. */
- PyArray_UCS4 c = s[i];
+ npy_ucs4 c = s[i];
if (!c || isspace(c)) {
s[i] = 0;
}
@@ -866,22 +866,22 @@ _char_release(char *ptr, int nc)
static char *
_uni_copy_n_strip(char *original, char *temp, int nc)
{
- if (nc*sizeof(PyArray_UCS4) > SMALL_STRING) {
- temp = malloc(nc*sizeof(PyArray_UCS4));
+ if (nc*sizeof(npy_ucs4) > SMALL_STRING) {
+ temp = malloc(nc*sizeof(npy_ucs4));
if (!temp) {
PyErr_NoMemory();
return NULL;
}
}
- memcpy(temp, original, nc*sizeof(PyArray_UCS4));
- _unistripw((PyArray_UCS4 *)temp, nc);
+ memcpy(temp, original, nc*sizeof(npy_ucs4));
+ _unistripw((npy_ucs4 *)temp, nc);
return temp;
}
static void
_uni_release(char *ptr, int nc)
{
- if (nc*sizeof(PyArray_UCS4) > SMALL_STRING) {
+ if (nc*sizeof(npy_ucs4) > SMALL_STRING) {
free(ptr);
}
}
@@ -1025,8 +1025,8 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
return Py_NotImplemented;
#else
PyObject *new;
- if (PyArray_TYPE(self) == PyArray_STRING &&
- PyArray_DESCR(other)->type_num == PyArray_UNICODE) {
+ if (PyArray_TYPE(self) == NPY_STRING &&
+ PyArray_DESCR(other)->type_num == NPY_UNICODE) {
PyArray_Descr* unicode = PyArray_DescrNew(PyArray_DESCR(other));
unicode->elsize = PyArray_DESCR(self)->elsize << 2;
new = PyArray_FromAny((PyObject *)self, unicode,
@@ -1037,8 +1037,8 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
Py_INCREF(other);
self = (PyArrayObject *)new;
}
- else if (PyArray_TYPE(self) == PyArray_UNICODE &&
- PyArray_DESCR(other)->type_num == PyArray_STRING) {
+ else if (PyArray_TYPE(self) == NPY_UNICODE &&
+ PyArray_DESCR(other)->type_num == NPY_STRING) {
PyArray_Descr* unicode = PyArray_DescrNew(PyArray_DESCR(self));
unicode->elsize = PyArray_DESCR(other)->elsize << 2;
new = PyArray_FromAny((PyObject *)other, unicode,
@@ -1071,7 +1071,7 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
}
result = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(PyArray_BOOL),
+ PyArray_DescrFromType(NPY_BOOL),
mit->nd,
mit->dimensions,
NULL, NULL, 0,
@@ -1166,7 +1166,7 @@ _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op)
sizeof(intp)*result_ndim);
dimensions[result_ndim] = -1;
temp2 = PyArray_Newshape((PyArrayObject *)temp,
- &newdims, PyArray_ANYORDER);
+ &newdims, NPY_ANYORDER);
if (temp2 == NULL) {
Py_DECREF(temp);
Py_XDECREF(res);
@@ -1178,7 +1178,7 @@ _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op)
/* Reduce the extra dimension of `temp` using `op` */
temp2 = PyArray_GenericReduceFunction((PyArrayObject *)temp,
op, result_ndim,
- PyArray_BOOL, NULL);
+ NPY_BOOL, NULL);
if (temp2 == NULL) {
Py_DECREF(temp);
Py_XDECREF(res);
@@ -1354,11 +1354,11 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
}
if (result == Py_NotImplemented) {
/* Try to handle string comparisons */
- if (PyArray_TYPE(self) == PyArray_OBJECT) {
+ if (PyArray_TYPE(self) == NPY_OBJECT) {
return result;
}
array_other = (PyArrayObject *)PyArray_FromObject(other,
- PyArray_NOTYPE, 0, 0);
+ NPY_NOTYPE, 0, 0);
if (PyArray_ISSTRING(self) && PyArray_ISSTRING(array_other)) {
Py_DECREF(result);
result = _strings_richcompare(self, (PyArrayObject *)
@@ -306,9 +306,9 @@ static PyObject *
UNICODE_getitem(char *ip, PyArrayObject *ap)
{
intp elsize = PyArray_DESCR(ap)->elsize;
- intp mysize = elsize/sizeof(PyArray_UCS4);
+ intp mysize = elsize/sizeof(npy_ucs4);
int alloc = 0;
- PyArray_UCS4 *buffer = NULL;
+ npy_ucs4 *buffer = NULL;
PyUnicodeObject *obj;
intp i;
@@ -321,11 +321,11 @@ UNICODE_getitem(char *ip, PyArrayObject *ap)
alloc = 1;
memcpy(buffer, ip, elsize);
if (!PyArray_ISNOTSWAPPED(ap)) {
- byte_swap_vector(buffer, mysize, sizeof(PyArray_UCS4));
+ byte_swap_vector(buffer, mysize, sizeof(npy_ucs4));
}
}
else {
- buffer = (PyArray_UCS4 *)ip;
+ buffer = (npy_ucs4 *)ip;
}
for (i = mysize; i > 0 && buffer[--i] == 0; mysize = i);
@@ -418,7 +418,7 @@ UNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap)
else {
buffer = ov;
}
- datalen = PyUCS2Buffer_AsUCS4(ptr, (PyArray_UCS4 *)buffer,
+ datalen = PyUCS2Buffer_AsUCS4(ptr, (npy_ucs4 *)buffer,
datalen >> 1, PyArray_DESCR(ap)->elsize >> 2);
datalen <<= 2;
if (!PyArray_ISALIGNED(ap)) {
@@ -804,7 +804,7 @@ VOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)
if (res == -1) {
goto fail;
}
- memcpy(ip, buffer, NPY_MIN(buflen, itemsize));
+ memcpy(ip, buffer, PyArray_MIN(buflen, itemsize));
if (itemsize > buflen) {
memset(ip + buflen, 0, itemsize - buflen);
}
@@ -2176,7 +2176,7 @@ STRING_nonzero (char *ip, PyArrayObject *ap)
#endif
static Bool
-UNICODE_nonzero (PyArray_UCS4 *ip, PyArrayObject *ap)
+UNICODE_nonzero (npy_ucs4 *ip, PyArrayObject *ap)
{
int len = PyArray_DESCR(ap)->elsize >> 2;
int i;
@@ -2192,7 +2192,7 @@ UNICODE_nonzero (PyArray_UCS4 *ip, PyArrayObject *ap)
if (!PyArray_ISNOTSWAPPED(ap)) {
byte_swap_vector(buffer, len, 4);
}
- ip = (PyArray_UCS4 *)buffer;
+ ip = (npy_ucs4 *)buffer;
}
for (i = 0; i < len; i++) {
@@ -2504,7 +2504,7 @@ STRING_compare(char *ip1, char *ip2, PyArrayObject *ap)
/* unicode type */
static int
-UNICODE_compare(PyArray_UCS4 *ip1, PyArray_UCS4 *ip2,
+UNICODE_compare(npy_ucs4 *ip1, npy_ucs4 *ip2,
PyArrayObject *ap)
{
int itemsize = PyArray_DESCR(ap)->elsize;
@@ -2513,8 +2513,8 @@ UNICODE_compare(PyArray_UCS4 *ip1, PyArray_UCS4 *ip2,
return 0;
}
while (itemsize-- > 0) {
- PyArray_UCS4 c1 = *ip1++;
- PyArray_UCS4 c2 = *ip2++;
+ npy_ucs4 c1 = *ip1++;
+ npy_ucs4 c2 = *ip2++;
if (c1 != c2) {
return (c1 < c2) ? -1 : 1;
}
@@ -2795,7 +2795,7 @@ OBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *NPY_UNUSED(ai
/**begin repeat
*
* #fname = STRING, UNICODE#
- * #type = char, PyArray_UCS4#
+ * #type = char, npy_ucs4#
*/
static int
@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)
@@ -2851,7 +2851,7 @@ OBJECT_argmin(PyObject **ip, intp n, intp *min_ind, PyArrayObject *NPY_UNUSED(ai
/**begin repeat
*
* #fname = STRING, UNICODE#
- * #type = char, PyArray_UCS4#
+ * #type = char, npy_ucs4#
*/
static int
@fname@_argmin(@type@ *ip, intp n, intp *min_ind, PyArrayObject *aip)
@@ -3475,7 +3475,7 @@ static int
* #from = VOID, STRING, UNICODE#
* #suff = void, string, unicode#
* #sort = 0, 1, 1#
- * #align = char, char, PyArray_UCS4#
+ * #align = char, char, npy_ucs4#
* #NAME = Void, String, Unicode#
* #endian = |, |, =#
*/
@@ -3935,55 +3935,55 @@ set_typeinfo(PyObject *dict)
PyDict_SetItemString(infodict, "OBJECT",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiO", PyArray_OBJECTLTR,
+ s = Py_BuildValue("CiiiO", NPY_OBJECTLTR,
#else
- s = Py_BuildValue("ciiiO", PyArray_OBJECTLTR,
+ s = Py_BuildValue("ciiiO", NPY_OBJECTLTR,
#endif
- PyArray_OBJECT,
+ NPY_OBJECT,
sizeof(PyObject *) * CHAR_BIT,
_ALIGN(PyObject *),
(PyObject *) &PyObjectArrType_Type));
Py_DECREF(s);
PyDict_SetItemString(infodict, "STRING",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiO", PyArray_STRINGLTR,
+ s = Py_BuildValue("CiiiO", NPY_STRINGLTR,
#else
- s = Py_BuildValue("ciiiO", PyArray_STRINGLTR,
+ s = Py_BuildValue("ciiiO", NPY_STRINGLTR,
#endif
- PyArray_STRING,
+ NPY_STRING,
0,
_ALIGN(char),
(PyObject *) &PyStringArrType_Type));
Py_DECREF(s);
PyDict_SetItemString(infodict, "UNICODE",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiO", PyArray_UNICODELTR,
+ s = Py_BuildValue("CiiiO", NPY_UNICODELTR,
#else
- s = Py_BuildValue("ciiiO", PyArray_UNICODELTR,
+ s = Py_BuildValue("ciiiO", NPY_UNICODELTR,
#endif
- PyArray_UNICODE,
+ NPY_UNICODE,
0,
- _ALIGN(PyArray_UCS4),
+ _ALIGN(npy_ucs4),
(PyObject *) &PyUnicodeArrType_Type));
Py_DECREF(s);
PyDict_SetItemString(infodict, "VOID",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiO", PyArray_VOIDLTR,
+ s = Py_BuildValue("CiiiO", NPY_VOIDLTR,
#else
- s = Py_BuildValue("ciiiO", PyArray_VOIDLTR,
+ s = Py_BuildValue("ciiiO", NPY_VOIDLTR,
#endif
- PyArray_VOID,
+ NPY_VOID,
0,
_ALIGN(char),
(PyObject *) &PyVoidArrType_Type));
Py_DECREF(s);
PyDict_SetItemString(infodict, "DATETIME",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiNNO", PyArray_DATETIMELTR,
+ s = Py_BuildValue("CiiiNNO", NPY_DATETIMELTR,
#else
- s = Py_BuildValue("ciiiNNO", PyArray_DATETIMELTR,
+ s = Py_BuildValue("ciiiNNO", NPY_DATETIMELTR,
#endif
- PyArray_DATETIME,
+ NPY_DATETIME,
sizeof(npy_datetime) * CHAR_BIT,
_ALIGN(npy_datetime),
MyPyLong_FromInt64(MAX_DATETIME),
@@ -3992,11 +3992,11 @@ set_typeinfo(PyObject *dict)
Py_DECREF(s);
PyDict_SetItemString(infodict, "TIMEDELTA",
#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiNNO", PyArray_TIMEDELTALTR,
+ s = Py_BuildValue("CiiiNNO", NPY_TIMEDELTALTR,
#else
- s = Py_BuildValue("ciiiNNO",PyArray_TIMEDELTALTR,
+ s = Py_BuildValue("ciiiNNO",NPY_TIMEDELTALTR,
#endif
- PyArray_TIMEDELTA,
+ NPY_TIMEDELTA,
sizeof(npy_timedelta) * CHAR_BIT,
_ALIGN(npy_timedelta),
MyPyLong_FromInt64(MAX_TIMEDELTA),
@@ -762,7 +762,7 @@ _descriptor_from_pep3118_format(char *s)
PyObject *_numpy_internal;
if (s == NULL) {
- return PyArray_DescrNewFromType(PyArray_BYTE);
+ return PyArray_DescrNewFromType(NPY_BYTE);
}
/* Strip whitespace, except from field names */
Oops, something went wrong.

0 comments on commit 215a91a

Please sign in to comment.