comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/f2py/src/fortranobject.h @ 87:2a2c65a20a8b

Add Python libs and headers
author Chris Cannam
date Wed, 25 Feb 2015 14:05:22 +0000
parents
children
comparison
equal deleted inserted replaced
86:413a9d26189e 87:2a2c65a20a8b
1 #ifndef Py_FORTRANOBJECT_H
2 #define Py_FORTRANOBJECT_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #include "Python.h"
8
9 #ifdef FORTRANOBJECT_C
10 #define NO_IMPORT_ARRAY
11 #endif
12 #define PY_ARRAY_UNIQUE_SYMBOL _npy_f2py_ARRAY_API
13 #include "numpy/arrayobject.h"
14
15 /*
16 * Python 3 support macros
17 */
18 #if PY_VERSION_HEX >= 0x03000000
19 #define PyString_Check PyBytes_Check
20 #define PyString_GET_SIZE PyBytes_GET_SIZE
21 #define PyString_AS_STRING PyBytes_AS_STRING
22 #define PyString_FromString PyBytes_FromString
23 #define PyUString_FromStringAndSize PyUnicode_FromStringAndSize
24 #define PyString_ConcatAndDel PyBytes_ConcatAndDel
25 #define PyString_AsString PyBytes_AsString
26
27 #define PyInt_Check PyLong_Check
28 #define PyInt_FromLong PyLong_FromLong
29 #define PyInt_AS_LONG PyLong_AsLong
30 #define PyInt_AsLong PyLong_AsLong
31
32 #define PyNumber_Int PyNumber_Long
33
34 #else
35
36 #define PyUString_FromStringAndSize PyString_FromStringAndSize
37 #endif
38
39
40 #ifdef F2PY_REPORT_ATEXIT
41 #include <sys/timeb.h>
42 extern void f2py_start_clock(void);
43 extern void f2py_stop_clock(void);
44 extern void f2py_start_call_clock(void);
45 extern void f2py_stop_call_clock(void);
46 extern void f2py_cb_start_clock(void);
47 extern void f2py_cb_stop_clock(void);
48 extern void f2py_cb_start_call_clock(void);
49 extern void f2py_cb_stop_call_clock(void);
50 extern void f2py_report_on_exit(int,void*);
51 #endif
52
53 #ifdef DMALLOC
54 #include "dmalloc.h"
55 #endif
56
57 /* Fortran object interface */
58
59 /*
60 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
61
62 PyFortranObject represents various Fortran objects:
63 Fortran (module) routines, COMMON blocks, module data.
64
65 Author: Pearu Peterson <pearu@cens.ioc.ee>
66 */
67
68 #define F2PY_MAX_DIMS 40
69
70 typedef void (*f2py_set_data_func)(char*,npy_intp*);
71 typedef void (*f2py_void_func)(void);
72 typedef void (*f2py_init_func)(int*,npy_intp*,f2py_set_data_func,int*);
73
74 /*typedef void* (*f2py_c_func)(void*,...);*/
75
76 typedef void *(*f2pycfunc)(void);
77
78 typedef struct {
79 char *name; /* attribute (array||routine) name */
80 int rank; /* array rank, 0 for scalar, max is F2PY_MAX_DIMS,
81 || rank=-1 for Fortran routine */
82 struct {npy_intp d[F2PY_MAX_DIMS];} dims; /* dimensions of the array, || not used */
83 int type; /* PyArray_<type> || not used */
84 char *data; /* pointer to array || Fortran routine */
85 f2py_init_func func; /* initialization function for
86 allocatable arrays:
87 func(&rank,dims,set_ptr_func,name,len(name))
88 || C/API wrapper for Fortran routine */
89 char *doc; /* documentation string; only recommended
90 for routines. */
91 } FortranDataDef;
92
93 typedef struct {
94 PyObject_HEAD
95 int len; /* Number of attributes */
96 FortranDataDef *defs; /* An array of FortranDataDef's */
97 PyObject *dict; /* Fortran object attribute dictionary */
98 } PyFortranObject;
99
100 #define PyFortran_Check(op) (Py_TYPE(op) == &PyFortran_Type)
101 #define PyFortran_Check1(op) (0==strcmp(Py_TYPE(op)->tp_name,"fortran"))
102
103 extern PyTypeObject PyFortran_Type;
104 extern int F2PyDict_SetItemString(PyObject* dict, char *name, PyObject *obj);
105 extern PyObject * PyFortranObject_New(FortranDataDef* defs, f2py_void_func init);
106 extern PyObject * PyFortranObject_NewAsAttr(FortranDataDef* defs);
107
108 #if PY_VERSION_HEX >= 0x03000000
109
110 PyObject * F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(PyObject *));
111 void * F2PyCapsule_AsVoidPtr(PyObject *obj);
112 int F2PyCapsule_Check(PyObject *ptr);
113
114 #else
115
116 PyObject * F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(void *));
117 void * F2PyCapsule_AsVoidPtr(PyObject *ptr);
118 int F2PyCapsule_Check(PyObject *ptr);
119
120 #endif
121
122 #define ISCONTIGUOUS(m) ((m)->flags & NPY_CONTIGUOUS)
123 #define F2PY_INTENT_IN 1
124 #define F2PY_INTENT_INOUT 2
125 #define F2PY_INTENT_OUT 4
126 #define F2PY_INTENT_HIDE 8
127 #define F2PY_INTENT_CACHE 16
128 #define F2PY_INTENT_COPY 32
129 #define F2PY_INTENT_C 64
130 #define F2PY_OPTIONAL 128
131 #define F2PY_INTENT_INPLACE 256
132 #define F2PY_INTENT_ALIGNED4 512
133 #define F2PY_INTENT_ALIGNED8 1024
134 #define F2PY_INTENT_ALIGNED16 2048
135
136 #define ARRAY_ISALIGNED(ARR, SIZE) ((size_t)(PyArray_DATA(ARR)) % (SIZE) == 0)
137 #define F2PY_ALIGN4(intent) (intent & F2PY_INTENT_ALIGNED4)
138 #define F2PY_ALIGN8(intent) (intent & F2PY_INTENT_ALIGNED8)
139 #define F2PY_ALIGN16(intent) (intent & F2PY_INTENT_ALIGNED16)
140
141 #define F2PY_GET_ALIGNMENT(intent) \
142 (F2PY_ALIGN4(intent) ? 4 : \
143 (F2PY_ALIGN8(intent) ? 8 : \
144 (F2PY_ALIGN16(intent) ? 16 : 1) ))
145 #define F2PY_CHECK_ALIGNMENT(arr, intent) ARRAY_ISALIGNED(arr, F2PY_GET_ALIGNMENT(intent))
146
147 extern PyArrayObject* array_from_pyobj(const int type_num,
148 npy_intp *dims,
149 const int rank,
150 const int intent,
151 PyObject *obj);
152 extern int copy_ND_array(const PyArrayObject *in, PyArrayObject *out);
153
154 #ifdef DEBUG_COPY_ND_ARRAY
155 extern void dump_attrs(const PyArrayObject* arr);
156 #endif
157
158
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif /* !Py_FORTRANOBJECT_H */