[Numpy-svn] r3444 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Nov 17 13:28:59 CST 2006


Author: oliphant
Date: 2006-11-17 13:28:56 -0600 (Fri, 17 Nov 2006)
New Revision: 3444

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Understand ctypes basic types and structures.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-11-17 18:45:17 UTC (rev 3443)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-11-17 19:28:56 UTC (rev 3444)
@@ -41,9 +41,28 @@
 	if (dtypedescr) {
 		ret = PyArray_DescrConverter(dtypedescr, &new);
 		Py_DECREF(dtypedescr);
-		if (ret) return new;
+		if (ret == PY_SUCCEED) return new;
 		PyErr_Clear();
 	}
+        /* Understand basic ctypes */
+        dtypedescr = PyObject_GetAttrString(obj, "_type_");
+        PyErr_Clear();
+        if (dtypedescr) {
+                ret = PyArray_DescrConverter(dtypedescr, &new);
+                Py_DECREF(dtypedescr);
+                if (ret == PY_SUCCEED) return new;
+                PyErr_Clear();
+        }
+        /* Understand ctypes structures --
+           bit-fields are not supported */
+        dtypedescr = PyObject_GetAttrString(obj, "_fields_");
+        PyErr_Clear();
+        if (dtypedescr) {
+                ret = PyArray_DescrConverter(dtypedescr, &new);
+                Py_DECREF(dtypedescr);
+                if (ret == PY_SUCCEED) return new;
+                PyErr_Clear();
+        }
 	return NULL;
 }
 



More information about the Numpy-svn mailing list