[Numpy-svn] r5626 - in trunk/numpy/core: include/numpy src

numpy-svn@scip... numpy-svn@scip...
Sun Aug 10 15:05:51 CDT 2008


Author: oliphant
Date: 2008-08-10 15:05:49 -0500 (Sun, 10 Aug 2008)
New Revision: 5626

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/multiarraymodule.c
Log:
*Full recompile needed*:  changed the name of hasobject structure member to flags in the PyArray_Descr structure and increased it's size to int

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-09 23:55:21 UTC (rev 5625)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-10 20:05:49 UTC (rev 5626)
@@ -39,7 +39,7 @@
 #define NPY_SUCCEED 1
 
         /* Helpful to distinguish what is installed */
-#define NPY_VERSION 0x01000009
+#define NPY_VERSION 0x0100000A
 
         /* Some platforms don't define bool, long long, or long double.
            Handle that here.
@@ -1176,7 +1176,7 @@
                                 NPY_NEEDS_INIT | NPY_NEEDS_PYAPI)
 
 #define PyDataType_FLAGCHK(dtype, flag)                                   \
-        (((dtype)->hasobject & (flag)) == (flag))
+        (((dtype)->flags & (flag)) == (flag))
 
 #define PyDataType_REFCHK(dtype)                                          \
         PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)
@@ -1192,7 +1192,7 @@
         char type;              /* unique-character representing this type */
         char byteorder;         /* '>' (big), '<' (little), '|'
                                    (not-applicable), or '=' (native). */
-        char hasobject;         /* non-zero if it has object arrays
+        int flags;              /* non-zero if it has object arrays
                                    in fields */
         int type_num;          /* number representing this type */
         int elsize;             /* element size for this type */

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-08-09 23:55:21 UTC (rev 5625)
+++ trunk/numpy/core/src/arrayobject.c	2008-08-10 20:05:49 UTC (rev 5626)
@@ -11155,7 +11155,7 @@
     {"byteorder", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},
     {"itemsize", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},
     {"alignment", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},
-    {"flags", T_UBYTE, offsetof(PyArray_Descr, hasobject), RO, NULL},
+    {"flags", T_UBYTE, offsetof(PyArray_Descr, flags), RO, NULL},
     {NULL},
 };
 
@@ -11553,7 +11553,7 @@
 
     PyTuple_SET_ITEM(state, 5, PyInt_FromLong(elsize));
     PyTuple_SET_ITEM(state, 6, PyInt_FromLong(alignment));
-    PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->hasobject));
+    PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->flags));
 
     PyTuple_SET_ITEM(ret, 2, state);
     return ret;
@@ -11565,7 +11565,8 @@
 static int
 _descr_find_object(PyArray_Descr *self)
 {
-    if (self->hasobject || self->type_num == PyArray_OBJECT ||
+    if (PyDataType_FLAGCHK(self, NPY_ITEM_HASOBJECT) || 
+	self->type_num == PyArray_OBJECT ||
         self->kind == 'O')
         return NPY_OBJECT_DTYPE_FLAGS;
     if (PyDescr_HASFIELDS(self)) {
@@ -11581,7 +11582,7 @@
                 return 0;
             }
             if (_descr_find_object(new)) {
-                new->hasobject = NPY_OBJECT_DTYPE_FLAGS;
+                new->flags = NPY_OBJECT_DTYPE_FLAGS;
                 return NPY_OBJECT_DTYPE_FLAGS;
             }
         }
@@ -11712,9 +11713,9 @@
         self->alignment = alignment;
     }
 
-    self->hasobject = dtypeflags;
+    self->flags = dtypeflags;
     if (version < 3) {
-        self->hasobject = _descr_find_object(self);
+        self->flags = _descr_find_object(self);
     }
     Py_INCREF(Py_None);
     return Py_None;

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2008-08-09 23:55:21 UTC (rev 5625)
+++ trunk/numpy/core/src/multiarraymodule.c	2008-08-10 20:05:49 UTC (rev 5626)
@@ -4704,7 +4704,7 @@
         new->names = conv->names;
         Py_XINCREF(new->names);
     }
-    new->hasobject = conv->hasobject;
+    new->flags = conv->flags;
     Py_DECREF(conv);
     *errflag = 0;
     return new;
@@ -4783,7 +4783,7 @@
         PyDimMem_FREE(shape.ptr);
         newdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));
         newdescr->subarray->base = type;
-        newdescr->hasobject = type->hasobject;
+        newdescr->flags = type->flags;
         Py_INCREF(val);
         newdescr->subarray->shape = val;
         Py_XDECREF(newdescr->fields);
@@ -4873,7 +4873,7 @@
                             "two fields with the same name");
             goto fail;
         }
-        dtypeflags |= (conv->hasobject & NPY_FROM_FIELDS);
+        dtypeflags |= (conv->flags & NPY_FROM_FIELDS);
         tup = PyTuple_New((title == NULL ? 2 : 3));
         PyTuple_SET_ITEM(tup, 0, (PyObject *)conv);
         if (align) {
@@ -4902,7 +4902,7 @@
     new->fields = fields;
     new->names = nameslist;
     new->elsize = totalsize;
-    new->hasobject=dtypeflags;
+    new->flags=dtypeflags;
     if (maxalign > 1) {
         totalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;
     }
@@ -4955,7 +4955,7 @@
             Py_DECREF(key);
             goto fail;
         }
-        dtypeflags |= (conv->hasobject & NPY_FROM_FIELDS);
+        dtypeflags |= (conv->flags & NPY_FROM_FIELDS);
         PyTuple_SET_ITEM(tup, 0, (PyObject *)conv);
         if (align) {
             int _align;
@@ -4973,7 +4973,7 @@
     new = PyArray_DescrNewFromType(PyArray_VOID);
     new->fields = fields;
     new->names = nameslist;
-    new->hasobject=dtypeflags;
+    new->flags=dtypeflags;
     if (maxalign > 1) {
         totalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;
     }
@@ -5199,7 +5199,7 @@
         }
         Py_DECREF(tup);
         if ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;
-        dtypeflags |= (newdescr->hasobject & NPY_FROM_FIELDS);
+        dtypeflags |= (newdescr->flags & NPY_FROM_FIELDS);
         totalsize += newdescr->elsize;
     }
 
@@ -5217,7 +5217,7 @@
     }
     new->names = names;
     new->fields = fields;
-    new->hasobject = dtypeflags;
+    new->flags = dtypeflags;
     return new;
 
  fail:



More information about the Numpy-svn mailing list