/* $Id: numarray.h,v 1.2 2002/03/01 22:36:15 jaytmiller Exp $ */ #define PY_BOOL_CHAR "b" #define PY_INT8_CHAR "b" #define PY_INT16_CHAR "h" #define PY_INT32_CHAR "i" #define PY_FLOAT32_CHAR "f" #define PY_FLOAT64_CHAR "d" #define PY_UINT8_CHAR "h" #define PY_UINT16_CHAR "i" #define PY_UINT32_CHAR "i" /* Unless longer int available */ #define pyFPE_DIVIDE_BY_ZERO 1 #define pyFPE_OVERFLOW 2 #define pyFPE_UNDERFLOW 4 #define pyFPE_INVALID 8 #define MAXARGS 20 #define isNonZERO(x) (x != 0) /* to convert values to boolean 1's or 0's */ typedef char Bool; typedef char Int8; typedef short int Int16; typedef int Int32; typedef unsigned char UInt8; typedef unsigned short int UInt16; /* typedef long int Int64; */ typedef float Float32; typedef double Float64; typedef PyObject *(*CFUNCasPyValue)(void *); typedef int (*UFUNC)(long, long, long, void **, long*); /* typedef void (*CFUNC_2ARG)(long, void *, void *); */ /* typedef void (*CFUNC_3ARG)(long, void *, void *, void *); */ typedef int (*CFUNCfromPyValue)(PyObject *, void *); typedef int (*CFUNC_STRIDE_CONV_FUNC)(long, long, long *, void *, long, long*, void *, long, long *); typedef enum { CFUNC_UFUNC, CFUNC_STRIDING, CFUNC_AS_PY_VALUE, CFUNC_FROM_PY_VALUE } eCfuncType; typedef struct { char *name; void *fptr; /* Pointer to "un-wrapped" c function */ eCfuncType type; /* UFUNC, STRIDING, AsPyValue, FromPyValue */ Bool chkself; /* CFUNC does own alignment/bounds checking */ Bool align; /* CFUNC requires aligned buffer pointers */ Int8 wantIn, wantOut; /* required input/output arg counts. */ Int8 sizes[3]; /* array of align/itemsizes. */ Int8 iters[3]; /* array of element counts. 0 --> niter. */ } CfuncDescriptor; typedef struct { PyObject_HEAD CfuncDescriptor descr; } CfuncObject; #define SELF_CHECKED_CFUNC_DESCR(name, type) \ static CfuncDescriptor name##_descr = { #name, (void *) name, type, 1 } #define CHECK_ALIGN 1 #define CFUNC_DESCR(name, type, align, iargs, oargs, s1, s2, s3, i1, i2, i3) \ static CfuncDescriptor name##_descr = \ { #name, (void *)name, type, 0, align, iargs, oargs, \ {s1, s2, s3}, {i1, i2, i3}} #define UFUNC_DESCR1(name, s1) \ CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 0, 1, s1, 0, 0, 0, 0, 0) #define UFUNC_DESCR2(name, s1, s2) \ CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 1, 1, s1, s2, 0, 0, 0, 0) #define UFUNC_DESCR3(name, s1, s2, s3) \ CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 0, 0, 0) #define UFUNC_DESCR3sv(name, s1, s2, s3) \ CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 1, 0, 0) #define UFUNC_DESCR3vs(name, s1, s2, s3) \ CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 0, 1, 0) #define STRIDING_DESCR2(name, align, s1, s2) \ CFUNC_DESCR(name, CFUNC_STRIDING, align, 1, 1, s1, s2, 0, 0, 0, 0)