Author: mattip <[email protected]>
Branch: cleanup-includes
Changeset: r83604:a03329def3ec
Date: 2016-04-11 21:47 +0300
http://bitbucket.org/pypy/pypy/changeset/a03329def3ec/
Log: add parts of headers removed in 4518b83c9ee2, fixes for testing
diff --git a/pypy/module/cpyext/include/numpy/arrayobject.h
b/pypy/module/cpyext/include/numpy/arrayobject.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/include/numpy/arrayobject.h
@@ -0,0 +1,38 @@
+
+/* NDArray object interface - S. H. Muller, 2013/07/26 */
+/* For testing ndarrayobject only */
+
+#ifndef Py_NDARRAYOBJECT_H
+#define Py_NDARRAYOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "npy_common.h"
+#include "ndarraytypes.h"
+
+/* fake PyArrayObject so that code that doesn't do direct field access works */
+#define PyArrayObject PyObject
+#define PyArray_Descr PyObject
+
+PyAPI_DATA(PyTypeObject) PyArray_Type;
+
+#define PyArray_SimpleNew _PyArray_SimpleNew
+#define PyArray_ZEROS _PyArray_ZEROS
+#define PyArray_CopyInto _PyArray_CopyInto
+#define PyArray_FILLWBYTE _PyArray_FILLWBYTE
+
+#define NPY_MAXDIMS 32
+
+/* functions defined in ndarrayobject.c*/
+
+PyAPI_FUNC(void) _PyArray_FILLWBYTE(PyObject* obj, int val);
+PyAPI_FUNC(PyObject *) _PyArray_ZEROS(int nd, npy_intp* dims, int type_num,
int fortran);
+PyAPI_FUNC(int) _PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_NDARRAYOBJECT_H */
diff --git a/pypy/module/cpyext/include/numpy/ndarraytypes.h
b/pypy/module/cpyext/include/numpy/ndarraytypes.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/include/numpy/ndarraytypes.h
@@ -0,0 +1,123 @@
+#ifndef NDARRAYTYPES_H
+#define NDARRAYTYPES_H
+
+/* For testing ndarrayobject only */
+
+#include "numpy/npy_common.h"
+
+enum NPY_TYPES { NPY_BOOL=0,
+ NPY_BYTE, NPY_UBYTE,
+ NPY_SHORT, NPY_USHORT,
+ NPY_INT, NPY_UINT,
+ NPY_LONG, NPY_ULONG,
+ NPY_LONGLONG, NPY_ULONGLONG,
+ NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE,
+ NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE,
+ NPY_OBJECT=17,
+ NPY_STRING, NPY_UNICODE,
+ NPY_VOID,
+ /*
+ * New 1.6 types appended, may be integrated
+ * into the above in 2.0.
+ */
+ NPY_DATETIME, NPY_TIMEDELTA, NPY_HALF,
+
+ NPY_NTYPES,
+ NPY_NOTYPE,
+ NPY_CHAR, /* special flag */
+ NPY_USERDEF=256, /* leave room for characters */
+
+ /* The number of types not including the new 1.6 types */
+ NPY_NTYPES_ABI_COMPATIBLE=21
+};
+
+/*
+ * These characters correspond to the array type and the struct
+ * module
+ */
+
+enum NPY_TYPECHAR {
+ NPY_BOOLLTR = '?',
+ NPY_BYTELTR = 'b',
+ NPY_UBYTELTR = 'B',
+ NPY_SHORTLTR = 'h',
+ NPY_USHORTLTR = 'H',
+ NPY_INTLTR = 'i',
+ NPY_UINTLTR = 'I',
+ NPY_LONGLTR = 'l',
+ NPY_ULONGLTR = 'L',
+ NPY_LONGLONGLTR = 'q',
+ NPY_ULONGLONGLTR = 'Q',
+ NPY_HALFLTR = 'e',
+ NPY_FLOATLTR = 'f',
+ NPY_DOUBLELTR = 'd',
+ NPY_LONGDOUBLELTR = 'g',
+ NPY_CFLOATLTR = 'F',
+ NPY_CDOUBLELTR = 'D',
+ NPY_CLONGDOUBLELTR = 'G',
+ NPY_OBJECTLTR = 'O',
+ NPY_STRINGLTR = 'S',
+ NPY_STRINGLTR2 = 'a',
+ NPY_UNICODELTR = 'U',
+ NPY_VOIDLTR = 'V',
+ NPY_DATETIMELTR = 'M',
+ NPY_TIMEDELTALTR = 'm',
+ NPY_CHARLTR = 'c',
+
+ /*
+ * No Descriptor, just a define -- this let's
+ * Python users specify an array of integers
+ * large enough to hold a pointer on the
+ * platform
+ */
+ NPY_INTPLTR = 'p',
+ NPY_UINTPLTR = 'P',
+
+ /*
+ * These are for dtype 'kinds', not dtype 'typecodes'
+ * as the above are for.
+ */
+ NPY_GENBOOLLTR ='b',
+ NPY_SIGNEDLTR = 'i',
+ NPY_UNSIGNEDLTR = 'u',
+ NPY_FLOATINGLTR = 'f',
+ NPY_COMPLEXLTR = 'c'
+};
+
+typedef enum {
+ NPY_NOSCALAR=-1,
+ NPY_BOOL_SCALAR,
+ NPY_INTPOS_SCALAR,
+ NPY_INTNEG_SCALAR,
+ NPY_FLOAT_SCALAR,
+ NPY_COMPLEX_SCALAR,
+ NPY_OBJECT_SCALAR
+} NPY_SCALARKIND;
+
+/* For specifying array memory layout or iteration order */
+typedef enum {
+ /* Fortran order if inputs are all Fortran, C otherwise */
+ NPY_ANYORDER=-1,
+ /* C order */
+ NPY_CORDER=0,
+ /* Fortran order */
+ NPY_FORTRANORDER=1,
+ /* An order as close to the inputs as possible */
+ NPY_KEEPORDER=2
+} NPY_ORDER;
+
+
+/*
+ * C API: consists of Macros and functions. The MACROS are defined
+ * here.
+ */
+
+
+#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS)
+#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, NPY_ARRAY_WRITEABLE)
+#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, NPY_ARRAY_ALIGNED)
+
+#define PyArray_IS_C_CONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS)
+#define PyArray_IS_F_CONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS)
+
+#endif /* NPY_ARRAYTYPES_H */
diff --git a/pypy/module/cpyext/include/numpy/npy_common.h
b/pypy/module/cpyext/include/numpy/npy_common.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/include/numpy/npy_common.h
@@ -0,0 +1,36 @@
+#ifndef _NPY_COMMON_H_
+#define _NPY_COMMON_H_
+
+/* For testing ndarrayobject only */
+
+typedef Py_intptr_t npy_intp;
+typedef Py_uintptr_t npy_uintp;
+typedef PY_LONG_LONG npy_longlong;
+typedef unsigned PY_LONG_LONG npy_ulonglong;
+typedef unsigned char npy_bool;
+typedef long npy_int32;
+typedef unsigned long npy_uint32;
+typedef unsigned long npy_ucs4;
+typedef long npy_int64;
+typedef unsigned long npy_uint64;
+typedef unsigned char npy_uint8;
+
+typedef signed char npy_byte;
+typedef unsigned char npy_ubyte;
+typedef unsigned short npy_ushort;
+typedef unsigned int npy_uint;
+typedef unsigned long npy_ulong;
+
+/* These are for completeness */
+typedef char npy_char;
+typedef short npy_short;
+typedef int npy_int;
+typedef long npy_long;
+typedef float npy_float;
+typedef double npy_double;
+
+typedef struct { float real, imag; } npy_cfloat;
+typedef struct { double real, imag; } npy_cdouble;
+typedef npy_cdouble npy_complex128;
+#endif //_NPY_COMMON_H_
+
diff --git a/pypy/module/cpyext/src/ndarrayobject.c
b/pypy/module/cpyext/src/ndarrayobject.c
--- a/pypy/module/cpyext/src/ndarrayobject.c
+++ b/pypy/module/cpyext/src/ndarrayobject.c
@@ -5,21 +5,21 @@
void
_PyArray_FILLWBYTE(PyObject* obj, int val) {
- memset(PyArray_DATA(obj), val, PyArray_NBYTES(obj));
+ memset(_PyArray_DATA(obj), val, _PyArray_NBYTES(obj));
}
PyObject*
_PyArray_ZEROS(int nd, npy_intp* dims, int type_num, int fortran)
{
- PyObject *arr = PyArray_EMPTY(nd, dims, type_num, fortran);
- memset(PyArray_DATA(arr), 0, PyArray_NBYTES(arr));
+ PyObject *arr = _PyArray_SimpleNew(nd, dims, type_num);
+ memset(_PyArray_DATA(arr), 0, _PyArray_NBYTES(arr));
return arr;
}
int
_PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src)
{
- memcpy(PyArray_DATA(dest), PyArray_DATA(src), PyArray_NBYTES(dest));
+ memcpy(_PyArray_DATA(dest), _PyArray_DATA(src), _PyArray_NBYTES(dest));
return 0;
}
diff --git a/pypy/module/cpyext/test/test_api.py
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -102,7 +102,7 @@
def test_copy_header_files(tmpdir):
- api.copy_header_files(tmpdir, True)
+ api.copy_header_files(tmpdir)
def check(name):
f = tmpdir.join(name)
assert f.check(file=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit