Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
cfuncs.cpython-313.pyc1285 linesDownload Raw Back to __pycache__
1�

2z�j����R�SrSSKrSSKrSSKJr \R3rS\SS4Sjr//////////S.4r	0r5S	S60rSS0rS
S0r
SS0rSS0rSS0rSS0rSS0rSSSS.rSSS.rS \S!'S"\S#'S$\S%'S&\S''S(\S)'S*\S''S+\S,'S-\S.'S/\S0'S1\S2'S3\S4'S5\S6'S7\S8'S9\S:'S;\S<'S=\S>'S?\S@'SA\SB'SC\SD'SE\SF'SG\SH'SI\SJ'SK\SL'SM\SN'SO\SP'SQ\SR'SS\ST'SU\SV'SW\SX'SY\SZ'S4/\7S['S\\S['S]\S^'S6/\8S_'S`\S_'S:/\9Sa'Sb\Sa'Sc\Sd'Se\Sf'S</\10Sg'Sh\Sg'S@/\11Si'Sj\Si'S>/\12Sk'Sl\Sk'SB/\13Sm'Sn\Sm'SB/\14So'Sp\So'SR/\15Sq'Sr\Sq'SR/\16Ss'St\Ss'SuSR/\17Sv'Sw\Sv'Sx\Sy'Sz\S{'S#S{/\18S|'S}\S|'S~\S'S�\S�'S#/\19S�'S�\S�'S#S{/\20Su'S�\Su'S#S{/\21S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'S�\S�'/S�Q\22S�'S�\S�'/S�Q\23S�'S�\S�'S�\S�'S�/\24S�'S�\S�'S�S4/\25S�'S�\S�'S�/\26S�'S�\S�'S�\S�'S�\S�'S6/\27S�'S�\S�'S�S:/\28S�'S�\S�'S�\S�'S�/\29S�'S�\S�'/S�Q\30S�'S�\S�'S@S)/\31S�'S�\S�'S>S�/\32S�'S�\S�'S�\S�'SXSq/\33S�'S�\S�'SqS./\34S�'S�\S�'SqS4/\35S�'S�\S�'SZSq/\36S�'S�\S�'S[Sq/\37S�'S�\S�'S^Sq/\38S�'S�\S�'/S�Q\39S�'S�\S�'SfSq/\40S�'S�\S�'SdSq/\41S�'S�\S�'/S�Q\42S�'S�\S�'/S�Q\43S�'S�\S�'/S�Q\44S�'S�\S�'S�rS�S�jrS�rg)�a45C declarations, CPP macros, and C functions for f2py2e.46Only required declarations/macros/functions will be used.47 48Copyright 1999 -- 2011 Pearu Peterson all rights reserved.49Copyright 2011 -- present NumPy Developers.50Permission to use, modify, and distribute this software is given under the51terms of the NumPy License.52 53NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.54�N�)�__version__�s�returnc�f�[Rb [RRU5 gg)z~55Write an error message to stderr.56 57This indirection is needed because sys.stderr might not always be available (see #26862).58N)�sys�stderr�write)rs �WD:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/f2py/cfuncs.py�errmessrs%���z�z���59�60������)61�	includes0�includes�typedefs�typedefs_generated�userincludes�	cppmacros�cfuncs�	callbacks�f90modhooks�commonhooksrz/*need_includes0*/rz/*need_includes*/rz/*need_userincludes*/rz/*need_typedefs*/rz/*need_typedefs_generated*/rz/*need_cppmacros*/rz/*need_cfuncs*/rz/*need_callbacks*/z/*need_f90modhooks*/z/*initf90modhooksstatic*/z/*initf90modhooksdynamic*/)r�initf90modhooksstatic�initf90modhooksdynamicz/*need_commonhooks*/z/*need_initcommonhooks*/)r�initcommonhooksz#include <math.h>zmath.hz#include <string.h>zstring.hz#include <setjmp.h>zsetjmp.hzC#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API62#include "arrayobject.h"z
arrayobject.hz#include "numpy/npy_math.h"�63npy_math.hz#include "fortranobject.h"z#include <stdarg.h>zstdarg.hz$typedef unsigned char unsigned_char;�
unsigned_charz&typedef unsigned short unsigned_short;�unsigned_shortz$typedef unsigned long unsigned_long;�
unsigned_longz typedef signed char signed_char;�signed_charz�64#if defined(NPY_OS_WIN32)65typedef __int64 long_long;66#else67typedef long long long_long;68typedef unsigned long long unsigned_long_long;69#endif70�	long_longzs71#if defined(NPY_OS_WIN32)72typedef __uint64 long_long;73#else74typedef unsigned long long unsigned_long_long;75#endif76�unsigned_long_longz>77#ifndef _LONG_DOUBLE78typedef long double long_double;79#endif80�long_doublez6typedef struct {long double r,i;} complex_long_double;�complex_long_doublez*typedef struct {float r,i;} complex_float;�
complex_floatz,typedef struct {double r,i;} complex_double;�complex_doubleztypedef char * string;�stringztypedef char character;�	charactera81#ifdef DEBUGCFUNCS82#define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess);83#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \84    PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\85    fprintf(stderr,"\n");86#else87#define CFUNCSMESS(mess)88#define CFUNCSMESSPY(mess,obj)89#endif90�91CFUNCSMESSap92#if defined(PREPEND_FORTRAN)93#if defined(NO_APPEND_FORTRAN)94#if defined(UPPERCASE_FORTRAN)95#define F_FUNC(f,F) _##F96#else97#define F_FUNC(f,F) _##f98#endif99#else100#if defined(UPPERCASE_FORTRAN)101#define F_FUNC(f,F) _##F##_102#else103#define F_FUNC(f,F) _##f##_104#endif105#endif106#else107#if defined(NO_APPEND_FORTRAN)108#if defined(UPPERCASE_FORTRAN)109#define F_FUNC(f,F) F110#else111#define F_FUNC(f,F) f112#endif113#else114#if defined(UPPERCASE_FORTRAN)115#define F_FUNC(f,F) F##_116#else117#define F_FUNC(f,F) f##_118#endif119#endif120#endif121#if defined(UNDERSCORE_G77)122#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)123#else124#define F_FUNC_US(f,F) F_FUNC(f,F)125#endif126�F_FUNCa127#if defined(PREPEND_FORTRAN)128#if defined(NO_APPEND_FORTRAN)129#if defined(UPPERCASE_FORTRAN)130#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F131#else132#define F_WRAPPEDFUNC(f,F) _f2pywrap##f133#endif134#else135#if defined(UPPERCASE_FORTRAN)136#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_137#else138#define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_139#endif140#endif141#else142#if defined(NO_APPEND_FORTRAN)143#if defined(UPPERCASE_FORTRAN)144#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F145#else146#define F_WRAPPEDFUNC(f,F) f2pywrap##f147#endif148#else149#if defined(UPPERCASE_FORTRAN)150#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_151#else152#define F_WRAPPEDFUNC(f,F) f2pywrap##f##_153#endif154#endif155#endif156#if defined(UNDERSCORE_G77)157#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_)158#else159#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F)160#endif161�
F_WRAPPEDFUNCa1162#if defined(F90MOD2CCONV1) /*E.g. Compaq Fortran */163#if defined(NO_APPEND_FORTRAN)164#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f165#else166#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f ## _167#endif168#endif169 170#if defined(F90MOD2CCONV2) /*E.g. IBM XL Fortran, not tested though */171#if defined(NO_APPEND_FORTRAN)172#define F_MODFUNCNAME(m,f)  __ ## m ## _MOD_ ## f173#else174#define F_MODFUNCNAME(m,f)  __ ## m ## _MOD_ ## f ## _175#endif176#endif177 178#if defined(F90MOD2CCONV3) /*E.g. MIPSPro Compilers */179#if defined(NO_APPEND_FORTRAN)180#define F_MODFUNCNAME(m,f)  f ## .in. ## m181#else182#define F_MODFUNCNAME(m,f)  f ## .in. ## m ## _183#endif184#endif185/*186#if defined(UPPERCASE_FORTRAN)187#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(M,F)188#else189#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(m,f)190#endif191*/192 193#define F_MODFUNC(m,f) (*(f2pymodstruct##m##.##f))194�	F_MODFUNCz�195#define SWAP(a,b) (size_t)(a) = ((size_t)(a) ^ (size_t)(b));\196 (size_t)(b) = ((size_t)(a) ^ (size_t)(b));\197 (size_t)(a) = ((size_t)(a) ^ (size_t)(b))198�199SWAPUNSAFEzG200#define SWAP(a,b,t) {\201    t *c;\202    c = a;\203    a = b;\204    b = c;}205�SWAPz�206#define PRINTPYOBJERR(obj)\207    fprintf(stderr,"#modulename#.error is related to ");\208    PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\209    fprintf(stderr,"\n");210�
PRINTPYOBJERRz�211#ifndef max212#define max(a,b) ((a > b) ? (a) : (b))213#endif214#ifndef min215#define min(a,b) ((a < b) ? (a) : (b))216#endif217#ifndef MAX218#define MAX(a,b) ((a > b) ? (a) : (b))219#endif220#ifndef MIN221#define MIN(a,b) ((a < b) ? (a) : (b))222#endif223�MINMAXz�224/* See fortranobject.h for definitions. The macros here are provided for BC. */225#define rank f2py_rank226#define shape f2py_shape227#define fshape f2py_shape228#define len f2py_len229#define flen f2py_flen230#define slen f2py_slen231#define size f2py_size232zlen..z2233#define pyobj_from_char1(v) (PyLong_FromLong(v))234�pyobj_from_char1z3235#define pyobj_from_short1(v) (PyLong_FromLong(v))236�pyobj_from_short1�pyobj_from_int1z1237#define pyobj_from_int1(v) (PyLong_FromLong(v))238z2239#define pyobj_from_long1(v) (PyLong_FromLong(v))240�pyobj_from_long1�pyobj_from_long_long1z�241#ifdef HAVE_LONG_LONG242#define pyobj_from_long_long1(v) (PyLong_FromLongLong(v))243#else244#warning HAVE_LONG_LONG is not available. Redefining pyobj_from_long_long.245#define pyobj_from_long_long1(v) (PyLong_FromLong(v))246#endif247�pyobj_from_long_double1z;248#define pyobj_from_long_double1(v) (PyFloat_FromDouble(v))z6249#define pyobj_from_double1(v) (PyFloat_FromDouble(v))�pyobj_from_double1z5250#define pyobj_from_float1(v) (PyFloat_FromDouble(v))�pyobj_from_float1�pyobj_from_complex_long_double1zL251#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))�pyobj_from_complex_double1zG252#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))�pyobj_from_complex_float1zF253#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))�pyobj_from_string1z@254#define pyobj_from_string1(v) (PyUnicode_FromString((char *)v))�pyobj_from_string1sizezT255#define pyobj_from_string1size(v,len) (PyUnicode_FromStringAndSize((char *)v, len))�TRYPYARRAYTEMPLATEa�256/* New SciPy */257#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break;258#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;259#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr,PyArray_DATA(arr),pyobj_from_ ## ctype ## 1(*v)); break;260 261#define TRYPYARRAYTEMPLATE(ctype,typecode) \262        PyArrayObject *arr = NULL;\263        if (!obj) return -2;\264        if (!PyArray_Check(obj)) return -1;\265        if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,"TRYPYARRAYTEMPLATE:");PRINTPYOBJERR(obj);return 0;}\266        if (PyArray_DESCR(arr)->type==typecode)  {*(ctype *)(PyArray_DATA(arr))=*v; return 1;}\267        switch (PyArray_TYPE(arr)) {\268                case NPY_DOUBLE: *(npy_double *)(PyArray_DATA(arr))=*v; break;\269                case NPY_INT: *(npy_int *)(PyArray_DATA(arr))=*v; break;\270                case NPY_LONG: *(npy_long *)(PyArray_DATA(arr))=*v; break;\271                case NPY_FLOAT: *(npy_float *)(PyArray_DATA(arr))=*v; break;\272                case NPY_CDOUBLE: *(npy_double *)(PyArray_DATA(arr))=*v; break;\273                case NPY_CFLOAT: *(npy_float *)(PyArray_DATA(arr))=*v; break;\274                case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=(*v!=0); break;\275                case NPY_UBYTE: *(npy_ubyte *)(PyArray_DATA(arr))=*v; break;\276                case NPY_BYTE: *(npy_byte *)(PyArray_DATA(arr))=*v; break;\277                case NPY_SHORT: *(npy_short *)(PyArray_DATA(arr))=*v; break;\278                case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=*v; break;\279                case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=*v; break;\280                case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=*v; break;\281                case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=*v; break;\282                case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=*v; break;\283                case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\284                case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\285                case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_ ## ctype ## 1(*v)); break;\286        default: return -2;\287        };\288        return 1289�TRYCOMPLEXPYARRAYTEMPLATEa�290291#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_complex_ ## ctype ## 1((*v))); break;292#define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\293        PyArrayObject *arr = NULL;\294        if (!obj) return -2;\295        if (!PyArray_Check(obj)) return -1;\296        if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,"TRYCOMPLEXPYARRAYTEMPLATE:");PRINTPYOBJERR(obj);return 0;}\297        if (PyArray_DESCR(arr)->type==typecode) {\298            *(ctype *)(PyArray_DATA(arr))=(*v).r;\299            *(ctype *)(PyArray_DATA(arr)+sizeof(ctype))=(*v).i;\300            return 1;\301        }\302        switch (PyArray_TYPE(arr)) {\303                case NPY_CDOUBLE: *(npy_double *)(PyArray_DATA(arr))=(*v).r;\304                                  *(npy_double *)(PyArray_DATA(arr)+sizeof(npy_double))=(*v).i;\305                                  break;\306                case NPY_CFLOAT: *(npy_float *)(PyArray_DATA(arr))=(*v).r;\307                                 *(npy_float *)(PyArray_DATA(arr)+sizeof(npy_float))=(*v).i;\308                                 break;\309                case NPY_DOUBLE: *(npy_double *)(PyArray_DATA(arr))=(*v).r; break;\310                case NPY_LONG: *(npy_long *)(PyArray_DATA(arr))=(*v).r; break;\311                case NPY_FLOAT: *(npy_float *)(PyArray_DATA(arr))=(*v).r; break;\312                case NPY_INT: *(npy_int *)(PyArray_DATA(arr))=(*v).r; break;\313                case NPY_SHORT: *(npy_short *)(PyArray_DATA(arr))=(*v).r; break;\314                case NPY_UBYTE: *(npy_ubyte *)(PyArray_DATA(arr))=(*v).r; break;\315                case NPY_BYTE: *(npy_byte *)(PyArray_DATA(arr))=(*v).r; break;\316                case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=((*v).r!=0 && (*v).i!=0); break;\317                case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=(*v).r; break;\318                case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=(*v).r; break;\319                case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=(*v).r; break;\320                case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=(*v).r; break;\321                case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=(*v).r; break;\322                case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r; break;\323                case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r;\324                                      *(npy_longdouble *)(PyArray_DATA(arr)+sizeof(npy_longdouble))=(*v).i;\325                                      break;\326                case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_complex_ ## ctype ## 1((*v))); break;\327                default: return -2;\328        };\329        return -1;330�STRINGCOPYN�GETSTRFROMPYTUPLEa�331#define GETSTRFROMPYTUPLE(tuple,index,str,len) {\332        PyObject *rv_cb_str = PyTuple_GetItem((tuple),(index));\333        if (rv_cb_str == NULL)\334            goto capi_fail;\335        if (PyBytes_Check(rv_cb_str)) {\336            str[len-1]='\0';\337            STRINGCOPYN((str),PyBytes_AS_STRING((PyBytesObject*)rv_cb_str),(len));\338        } else {\339            PRINTPYOBJERR(rv_cb_str);\340            PyErr_SetString(#modulename#_error,"string object expected");\341            goto capi_fail;\342        }\343    }344z�345#define GETSCALARFROMPYTUPLE(tuple,index,var,ctype,mess) {\346        if ((capi_tmp = PyTuple_GetItem((tuple),(index)))==NULL) goto capi_fail;\347        if (!(ctype ## _from_pyobj((var),capi_tmp,mess)))\348            goto capi_fail;\349    }350�GETSCALARFROMPYTUPLEaj#define FAILNULL(p) do {                                            \351    if ((p) == NULL) {                                              \352        PyErr_SetString(PyExc_MemoryError, "NULL pointer found");   \353        goto capi_fail;                                             \354    }                                                               \355} while (0)356�FAILNULL�MEMCOPYzi357#define MEMCOPY(to,from,n)\358    do { FAILNULL(to); FAILNULL(from); (void)memcpy(to,from,n); } while (0)359z�360#define STRINGMALLOC(str,len)\361    if ((str = (string)malloc(len+1)) == NULL) {\362        PyErr_SetString(PyExc_MemoryError, "out of memory");\363        goto capi_fail;\364    } else {\365        (str)[len] = '\0';\366    }367�STRINGMALLOCzG368#define STRINGFREE(str) do {if (!(str == NULL)) free(str);} while (0)369�370STRINGFREE�371STRINGPADNa�372/*373STRINGPADN replaces null values with padding values from the right.374 375`to` must have size of at least N bytes.376 377If the `to[N-1]` has null value, then replace it and all the378preceding, nulls with the given padding.379 380STRINGPADN(to, N, PADDING, NULLVALUE) is an inverse operation.381*/382#define STRINGPADN(to, N, NULLVALUE, PADDING)                   \383    do {                                                        \384        int _m = (N);                                           \385        char *_to = (to);                                       \386        for (_m -= 1; _m >= 0 && _to[_m] == NULLVALUE; _m--) {  \387             _to[_m] = PADDING;                                 \388        }                                                       \389    } while (0)390a2391/*392STRINGCOPYN copies N bytes.393 394`to` and `from` buffers must have sizes of at least N bytes.395*/396#define STRINGCOPYN(to,from,N)                                  \397    do {                                                        \398        int _m = (N);                                           \399        char *_to = (to);                                       \400        char *_from = (from);                                   \401        FAILNULL(_to); FAILNULL(_from);                         \402        (void)strncpy(_to, _from, _m);             \403    } while (0)404�405STRINGCOPYzh406#define STRINGCOPY(to,from)\407    do { FAILNULL(to); FAILNULL(from); (void)strcpy(to,from); } while (0)408z�409#define CHECKGENERIC(check,tcheck,name) \410    if (!(check)) {\411        PyErr_SetString(#modulename#_error,"("tcheck") failed for "name);\412        /*goto capi_fail;*/\413    } else �CHECKGENERICz�414#define CHECKARRAY(check,tcheck,name) \415    if (!(check)) {\416        PyErr_SetString(#modulename#_error,"("tcheck") failed for "name);\417        /*goto capi_fail;*/\418    } else �419CHECKARRAYa420#define CHECKSTRING(check,tcheck,name,show,var)\421    if (!(check)) {\422        char errstring[256];\423        sprintf(errstring, "%s: "show, "("tcheck") failed for "name, slen(var), var);\424        PyErr_SetString(#modulename#_error, errstring);\425        /*goto capi_fail;*/\426    } else �CHECKSTRINGa427#define CHECKSCALAR(check,tcheck,name,show,var)\428    if (!(check)) {\429        char errstring[256];\430        sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\431        PyErr_SetString(#modulename#_error,errstring);\432        /*goto capi_fail;*/\433    } else �CHECKSCALARz>#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))�ARRSIZEzt434#ifdef OLDPYNUM435#error You need to install NumPy version 0.13 or higher. See https://scipy.org/install.html436#endif437�OLDPYNUMa�438#ifndef F2PY_THREAD_LOCAL_DECL439#if defined(_MSC_VER)440#define F2PY_THREAD_LOCAL_DECL __declspec(thread)441#elif defined(NPY_OS_MINGW)442#define F2PY_THREAD_LOCAL_DECL __thread443#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)444#define F2PY_THREAD_LOCAL_DECL _Thread_local445#elif defined(__GNUC__) \446      && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 4)))447#define F2PY_THREAD_LOCAL_DECL __thread448#endif449#endif450�F2PY_THREAD_LOCAL_DECLz�451static int calcarrindex(int *i,PyArrayObject *arr) {452    int k,ii = i[0];453    for (k=1; k < PyArray_NDIM(arr); k++)454        ii += (ii*(PyArray_DIM(arr,k) - 1)+i[k]); /* assuming contiguous arr */455    return ii;456}�calcarrindexa457static int calcarrindextr(int *i,PyArrayObject *arr) {458    int k,ii = i[PyArray_NDIM(arr)-1];459    for (k=1; k < PyArray_NDIM(arr); k++)460        ii += (ii*(PyArray_DIM(arr,PyArray_NDIM(arr)-k-1) - 1)+i[PyArray_NDIM(arr)-k-1]); /* assuming contiguous arr */461    return ii;462}�calcarrindextral463struct ForcombCache { int nd;npy_intp *d;int *i,*i_tr,tr; };464static int initforcomb(struct ForcombCache *cache, npy_intp *dims,int nd,int tr) {465  int k;466  if (dims==NULL) return 0;467  if (nd<0) return 0;468  cache->nd = nd;469  cache->d = dims;470  cache->tr = tr;471 472  cache->i = (int *)malloc(sizeof(int)*nd);473  if (cache->i==NULL) return 0;474  cache->i_tr = (int *)malloc(sizeof(int)*nd);475  if (cache->i_tr==NULL) {free(cache->i); return 0;};476 477  for (k=1;k<nd;k++) {478    cache->i[k] = cache->i_tr[nd-k-1] = 0;479  }480  cache->i[0] = cache->i_tr[nd-1] = -1;481  return 1;482}483static int *nextforcomb(struct ForcombCache *cache) {484  if (cache==NULL) return NULL;485  int j,*i,*i_tr,k;486  int nd=cache->nd;487  if ((i=cache->i) == NULL) return NULL;488  if ((i_tr=cache->i_tr) == NULL) return NULL;489  if (cache->d == NULL) return NULL;490  i[0]++;491  if (i[0]==cache->d[0]) {492    j=1;493    while ((j<nd) && (i[j]==cache->d[j]-1)) j++;494    if (j==nd) {495      free(i);496      free(i_tr);497      return NULL;498    }499    for (k=0;k<j;k++) i[k] = i_tr[nd-k-1] = 0;500    i[j]++;501    i_tr[nd-j-1]++;502  } else503    i_tr[nd-1]++;504  if (cache->tr) return i_tr;505  return i;506}�forcomb)r?r.r&�try_pyarr_from_stringa�507/*508  try_pyarr_from_string copies str[:len(obj)] to the data of an `ndarray`.509 510  If obj is an `ndarray`, it is assumed to be contiguous.511 512  If the specified len==-1, str must be null-terminated.513*/514static int try_pyarr_from_string(PyObject *obj,515                                 const string str, const int len) {516#ifdef DEBUGCFUNCS517fprintf(stderr, "try_pyarr_from_string(str='%s', len=%d, obj=%p)\n",518        (char*)str,len, obj);519#endif520    if (!obj) return -2; /* Object missing */521    if (obj == Py_None) return -1; /* None */522    if (!PyArray_Check(obj)) goto capi_fail; /* not an ndarray */523    if (PyArray_Check(obj)) {524        PyArrayObject *arr = (PyArrayObject *)obj;525        assert(ISCONTIGUOUS(arr));526        string buf = PyArray_DATA(arr);527        npy_intp n = len;528        if (n == -1) {529            /* Assuming null-terminated str. */530            n = strlen(str);531        }532        if (n > PyArray_NBYTES(arr)) {533            n = PyArray_NBYTES(arr);534        }535        STRINGCOPYN(buf, str, n);536        return 1;537    }538capi_fail:539    PRINTPYOBJERR(obj);540    PyErr_SetString(#modulename#_error, "try_pyarr_from_string failed");541    return 0;542}543)r&rDr?�string_from_pyobja�544545/*546  Create a new string buffer `str` of at most length `len` from a547  Python string-like object `obj`.548 549  The string buffer has given size (len) or the size of inistr when len==-1.550 551  The string buffer is padded with blanks: in Fortran, trailing blanks552  are insignificant contrary to C nulls.553 */554static int555string_from_pyobj(string *str, int *len, const string inistr, PyObject *obj,556                  const char *errmess)557{558    PyObject *tmp = NULL;559    string buf = NULL;560    npy_intp n = -1;561#ifdef DEBUGCFUNCS562fprintf(stderr,"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\n",563               (char*)str, *len, (char *)inistr, obj);564#endif565    if (obj == Py_None) {566        n = strlen(inistr);567        buf = inistr;568    }569    else if (PyArray_Check(obj)) {570        PyArrayObject *arr = (PyArrayObject *)obj;571        if (!ISCONTIGUOUS(arr)) {572            PyErr_SetString(PyExc_ValueError,573                            "array object is non-contiguous.");574            goto capi_fail;575        }576        n = PyArray_NBYTES(arr);577        buf = PyArray_DATA(arr);578        n = strnlen(buf, n);579    }580    else {581        if (PyBytes_Check(obj)) {582            tmp = obj;583            Py_INCREF(tmp);584        }585        else if (PyUnicode_Check(obj)) {586            tmp = PyUnicode_AsASCIIString(obj);587        }588        else {589            PyObject *tmp2;590            tmp2 = PyObject_Str(obj);591            if (tmp2) {592                tmp = PyUnicode_AsASCIIString(tmp2);593                Py_DECREF(tmp2);594            }595            else {596                tmp = NULL;597            }598        }599        if (tmp == NULL) goto capi_fail;600        n = PyBytes_GET_SIZE(tmp);601        buf = PyBytes_AS_STRING(tmp);602    }603    if (*len == -1) {604        /* TODO: change the type of `len` so that we can remove this */605        if (n > NPY_MAX_INT) {606            PyErr_SetString(PyExc_OverflowError,607                            "object too large for a 32-bit int");608            goto capi_fail;609        }610        *len = n;611    }612    else if (*len < n) {613        /* discard the last (len-n) bytes of input buf */614        n = *len;615    }616    if (n < 0 || *len < 0 || buf == NULL) {617        goto capi_fail;618    }619    STRINGMALLOC(*str, *len);  // *str is allocated with size (*len + 1)620    if (n < *len) {621        /*622          Pad fixed-width string with nulls. The caller will replace623          nulls with blanks when the corresponding argument is not624          intent(c).625        */626        memset(*str + n, '\0', *len - n);627    }628    STRINGCOPYN(*str, buf, n);629    Py_XDECREF(tmp);630    return 1;631capi_fail:632    Py_XDECREF(tmp);633    {634        PyObject* err = PyErr_Occurred();635        if (err == NULL) {636            err = #modulename#_error;637        }638        PyErr_SetString(err, errmess);639    }640    return 0;641}642a�643static int644character_from_pyobj(character* v, PyObject *obj, const char *errmess) {645    if (PyBytes_Check(obj)) {646        /* empty bytes has trailing null, so dereferencing is always safe */647        *v = PyBytes_AS_STRING(obj)[0];648        return 1;649    } else if (PyUnicode_Check(obj)) {650        PyObject* tmp = PyUnicode_AsASCIIString(obj);651        if (tmp != NULL) {652            *v = PyBytes_AS_STRING(tmp)[0];653            Py_DECREF(tmp);654            return 1;655        }656    } else if (PyArray_Check(obj)) {657        PyArrayObject* arr = (PyArrayObject*)obj;658        if (F2PY_ARRAY_IS_CHARACTER_COMPATIBLE(arr)) {659            *v = PyArray_BYTES(arr)[0];660            return 1;661        } else if (F2PY_IS_UNICODE_ARRAY(arr)) {662            // TODO: update when numpy will support 1-byte and663            // 2-byte unicode dtypes664            PyObject* tmp = PyUnicode_FromKindAndData(665                              PyUnicode_4BYTE_KIND,666                              PyArray_BYTES(arr),667                              (PyArray_NBYTES(arr)>0?1:0));668            if (tmp != NULL) {669                if (character_from_pyobj(v, tmp, errmess)) {670                    Py_DECREF(tmp);671                    return 1;672                }673                Py_DECREF(tmp);674            }675        }676    } else if (PySequence_Check(obj)) {677        PyObject* tmp = PySequence_GetItem(obj,0);678        if (tmp != NULL) {679            if (character_from_pyobj(v, tmp, errmess)) {680                Py_DECREF(tmp);681                return 1;682            }683            Py_DECREF(tmp);684        }685    }686    {687        /* TODO: This error (and most other) error handling needs cleaning. */688        char mess[F2PY_MESSAGE_BUFFER_SIZE];689        strcpy(mess, errmess);690        PyObject* err = PyErr_Occurred();691        if (err == NULL) {692            err = PyExc_TypeError;693            Py_INCREF(err);694        }695        else {696            Py_INCREF(err);697            PyErr_Clear();698        }699        sprintf(mess + strlen(mess),700                " -- expected str|bytes|sequence-of-str-or-bytes, got ");701        f2py_describe(obj, mess + strlen(mess));702        PyErr_SetString(err, mess);703        Py_DECREF(err);704    }705    return 0;706}707�character_from_pyobj�int_from_pyobj�char_from_pyobjz�708static int709char_from_pyobj(char* v, PyObject *obj, const char *errmess) {710    int i = 0;711    if (int_from_pyobj(&i, obj, errmess)) {712        *v = (char)i;713        return 1;714    }715    return 0;716}717�signed_char_from_pyobjz�718static int719signed_char_from_pyobj(signed_char* v, PyObject *obj, const char *errmess) {720    int i = 0;721    if (int_from_pyobj(&i, obj, errmess)) {722        *v = (signed_char)i;723        return 1;724    }725    return 0;726}727�short_from_pyobjz�728static int729short_from_pyobj(short* v, PyObject *obj, const char *errmess) {730    int i = 0;731    if (int_from_pyobj(&i, obj, errmess)) {732        *v = (short)i;733        return 1;734    }735    return 0;736}737a�738static int739int_from_pyobj(int* v, PyObject *obj, const char *errmess)740{741    PyObject* tmp = NULL;742 743    if (PyLong_Check(obj)) {744        *v = Npy__PyLong_AsInt(obj);745        return !(*v == -1 && PyErr_Occurred());746    }747 748    tmp = PyNumber_Long(obj);749    if (tmp) {750        *v = Npy__PyLong_AsInt(tmp);751        Py_DECREF(tmp);752        return !(*v == -1 && PyErr_Occurred());753    }754 755    if (PyComplex_Check(obj)) {756        PyErr_Clear();757        tmp = PyObject_GetAttrString(obj,"real");758    }759    else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {760        /*pass*/;761    }762    else if (PySequence_Check(obj)) {763        PyErr_Clear();764        tmp = PySequence_GetItem(obj, 0);765    }766 767    if (tmp) {768        if (int_from_pyobj(v, tmp, errmess)) {769            Py_DECREF(tmp);770            return 1;771        }772        Py_DECREF(tmp);773    }774 775    {776        PyObject* err = PyErr_Occurred();777        if (err == NULL) {778            err = #modulename#_error;779        }780        PyErr_SetString(err, errmess);781    }782    return 0;783}784a�785static int786long_from_pyobj(long* v, PyObject *obj, const char *errmess) {787    PyObject* tmp = NULL;788 789    if (PyLong_Check(obj)) {790        *v = PyLong_AsLong(obj);791        return !(*v == -1 && PyErr_Occurred());792    }793 794    tmp = PyNumber_Long(obj);795    if (tmp) {796        *v = PyLong_AsLong(tmp);797        Py_DECREF(tmp);798        return !(*v == -1 && PyErr_Occurred());799    }800 801    if (PyComplex_Check(obj)) {802        PyErr_Clear();803        tmp = PyObject_GetAttrString(obj,"real");804    }805    else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {806        /*pass*/;807    }808    else if (PySequence_Check(obj)) {809        PyErr_Clear();810        tmp = PySequence_GetItem(obj, 0);811    }812 813    if (tmp) {814        if (long_from_pyobj(v, tmp, errmess)) {815            Py_DECREF(tmp);816            return 1;817        }818        Py_DECREF(tmp);819    }820    {821        PyObject* err = PyErr_Occurred();822        if (err == NULL) {823            err = #modulename#_error;824        }825        PyErr_SetString(err, errmess);826    }827    return 0;828}829�long_from_pyobj�long_long_from_pyobja830static int831long_long_from_pyobj(long_long* v, PyObject *obj, const char *errmess)832{833    PyObject* tmp = NULL;834 835    if (PyLong_Check(obj)) {836        *v = PyLong_AsLongLong(obj);837        return !(*v == -1 && PyErr_Occurred());838    }839 840    tmp = PyNumber_Long(obj);841    if (tmp) {842        *v = PyLong_AsLongLong(tmp);843        Py_DECREF(tmp);844        return !(*v == -1 && PyErr_Occurred());845    }846 847    if (PyComplex_Check(obj)) {848        PyErr_Clear();849        tmp = PyObject_GetAttrString(obj,"real");850    }851    else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {852        /*pass*/;853    }854    else if (PySequence_Check(obj)) {855        PyErr_Clear();856        tmp = PySequence_GetItem(obj, 0);857    }858 859    if (tmp) {860        if (long_long_from_pyobj(v, tmp, errmess)) {861            Py_DECREF(tmp);862            return 1;863        }864        Py_DECREF(tmp);865    }866    {867        PyObject* err = PyErr_Occurred();868        if (err == NULL) {869            err = #modulename#_error;870        }871        PyErr_SetString(err,errmess);872    }873    return 0;874}875�double_from_pyobj�long_double_from_pyobja�876static int877long_double_from_pyobj(long_double* v, PyObject *obj, const char *errmess)878{879    double d=0;880    if (PyArray_CheckScalar(obj)){881        if PyArray_IsScalar(obj, LongDouble) {882            PyArray_ScalarAsCtype(obj, v);883            return 1;884        }885        else if (PyArray_Check(obj)) {886            PyArrayObject *arr = (PyArrayObject *)obj;887            if (PyArray_TYPE(arr) == NPY_LONGDOUBLE) {888                (*v) = *((npy_longdouble *)PyArray_DATA(arr));889                return 1;890            }891        }892    }893    if (double_from_pyobj(&d, obj, errmess)) {894        *v = (long_double)d;895        return 1;896    }897    return 0;898}899a�900static int901double_from_pyobj(double* v, PyObject *obj, const char *errmess)902{903    PyObject* tmp = NULL;904    if (PyFloat_Check(obj)) {905        *v = PyFloat_AsDouble(obj);906        return !(*v == -1.0 && PyErr_Occurred());907    }908 909    tmp = PyNumber_Float(obj);910    if (tmp) {911        *v = PyFloat_AsDouble(tmp);912        Py_DECREF(tmp);913        return !(*v == -1.0 && PyErr_Occurred());914    }915 916    if (PyComplex_Check(obj)) {917        PyErr_Clear();918        tmp = PyObject_GetAttrString(obj,"real");919    }920    else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {921        /*pass*/;922    }923    else if (PySequence_Check(obj)) {924        PyErr_Clear();925        tmp = PySequence_GetItem(obj, 0);926    }927 928    if (tmp) {929        if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}930        Py_DECREF(tmp);931    }932    {933        PyObject* err = PyErr_Occurred();934        if (err==NULL) err = #modulename#_error;935        PyErr_SetString(err,errmess);936    }937    return 0;938}939�float_from_pyobjz�940static int941float_from_pyobj(float* v, PyObject *obj, const char *errmess)942{943    double d=0.0;944    if (double_from_pyobj(&d,obj,errmess)) {945        *v = (float)d;946        return 1;947    }948    return 0;949}950)r#r"�complex_double_from_pyobjr�complex_long_double_from_pyobja<951static int952complex_long_double_from_pyobj(complex_long_double* v, PyObject *obj, const char *errmess)953{954    complex_double cd = {0.0,0.0};955    if (PyArray_CheckScalar(obj)){956        if PyArray_IsScalar(obj, CLongDouble) {957            PyArray_ScalarAsCtype(obj, v);958            return 1;959        }960        else if (PyArray_Check(obj)) {961            PyArrayObject *arr = (PyArrayObject *)obj;962            if (PyArray_TYPE(arr)==NPY_CLONGDOUBLE) {963                (*v).r = npy_creall(*(((npy_clongdouble *)PyArray_DATA(arr))));964                (*v).i = npy_cimagl(*(((npy_clongdouble *)PyArray_DATA(arr))));965                return 1;966            }967        }968    }969    if (complex_double_from_pyobj(&cd,obj,errmess)) {970        (*v).r = (long_double)cd.r;971        (*v).i = (long_double)cd.i;972        return 1;973    }974    return 0;975}976r^a	977static int978complex_double_from_pyobj(complex_double* v, PyObject *obj, const char *errmess) {979    Py_complex c;980    if (PyComplex_Check(obj)) {981        c = PyComplex_AsCComplex(obj);982        (*v).r = c.real;983        (*v).i = c.imag;984        return 1;985    }986    if (PyArray_IsScalar(obj, ComplexFloating)) {987        if (PyArray_IsScalar(obj, CFloat)) {988            npy_cfloat new;989            PyArray_ScalarAsCtype(obj, &new);990            (*v).r = (double)npy_crealf(new);991            (*v).i = (double)npy_cimagf(new);992        }993        else if (PyArray_IsScalar(obj, CLongDouble)) {994            npy_clongdouble new;995            PyArray_ScalarAsCtype(obj, &new);996            (*v).r = (double)npy_creall(new);997            (*v).i = (double)npy_cimagl(new);998        }999        else { /* if (PyArray_IsScalar(obj, CDouble)) */1000            PyArray_ScalarAsCtype(obj, v);1001        }1002        return 1;1003    }1004    if (PyArray_CheckScalar(obj)) { /* 0-dim array or still array scalar */1005        PyArrayObject *arr;1006        if (PyArray_Check(obj)) {1007            arr = (PyArrayObject *)PyArray_Cast((PyArrayObject *)obj, NPY_CDOUBLE);1008        }1009        else {1010            arr = (PyArrayObject *)PyArray_FromScalar(obj, PyArray_DescrFromType(NPY_CDOUBLE));1011        }1012        if (arr == NULL) {1013            return 0;1014        }1015        (*v).r = npy_creal(*(((npy_cdouble *)PyArray_DATA(arr))));1016        (*v).i = npy_cimag(*(((npy_cdouble *)PyArray_DATA(arr))));1017        Py_DECREF(arr);1018        return 1;1019    }1020    /* Python does not provide PyNumber_Complex function :-( */1021    (*v).i = 0.0;1022    if (PyFloat_Check(obj)) {1023        (*v).r = PyFloat_AsDouble(obj);1024        return !((*v).r == -1.0 && PyErr_Occurred());1025    }1026    if (PyLong_Check(obj)) {1027        (*v).r = PyLong_AsDouble(obj);1028        return !((*v).r == -1.0 && PyErr_Occurred());1029    }1030    if (PySequence_Check(obj) && !(PyBytes_Check(obj) || PyUnicode_Check(obj))) {1031        PyObject *tmp = PySequence_GetItem(obj,0);1032        if (tmp) {1033            if (complex_double_from_pyobj(v,tmp,errmess)) {1034                Py_DECREF(tmp);1035                return 1;1036            }1037            Py_DECREF(tmp);1038        }1039    }1040    {1041        PyObject* err = PyErr_Occurred();1042        if (err==NULL)1043            err = PyExc_TypeError;1044        PyErr_SetString(err,errmess);1045    }1046    return 0;1047}1048�complex_float_from_pyobja1049static int1050complex_float_from_pyobj(complex_float* v,PyObject *obj,const char *errmess)1051{1052    complex_double cd={0.0,0.0};1053    if (complex_double_from_pyobj(&cd,obj,errmess)) {1054        (*v).r = (float)cd.r;1055        (*v).i = (float)cd.i;1056        return 1;1057    }1058    return 0;1059}1060a�1061static int try_pyarr_from_character(PyObject* obj, character* v) {1062    PyArrayObject *arr = (PyArrayObject*)obj;1063    if (!obj) return -2;1064    if (PyArray_Check(obj)) {1065        if (F2PY_ARRAY_IS_CHARACTER_COMPATIBLE(arr))  {1066            *(character *)(PyArray_DATA(arr)) = *v;1067            return 1;1068        }1069    }1070    {1071        char mess[F2PY_MESSAGE_BUFFER_SIZE];1072        PyObject* err = PyErr_Occurred();1073        if (err == NULL) {1074            err = PyExc_ValueError;1075            strcpy(mess, "try_pyarr_from_character failed"1076                         " -- expected bytes array-scalar|array, got ");1077            f2py_describe(obj, mess + strlen(mess));1078            PyErr_SetString(err, mess);1079        }1080    }1081    return 0;1082}1083�try_pyarr_from_character�try_pyarr_from_charz\static int try_pyarr_from_char(PyObject* obj,char* v) {1084    TRYPYARRAYTEMPLATE(char,'c');1085}1086�try_pyarr_from_signed_charzwstatic int try_pyarr_from_unsigned_char(PyObject* obj,unsigned_char* v) {1087    TRYPYARRAYTEMPLATE(unsigned_char,'b');1088}1089�try_pyarr_from_unsigned_charzqstatic int try_pyarr_from_signed_char(PyObject* obj,signed_char* v) {1090    TRYPYARRAYTEMPLATE(signed_char,'1');1091}1092�try_pyarr_from_shortz_static int try_pyarr_from_short(PyObject* obj,short* v) {1093    TRYPYARRAYTEMPLATE(short,'s');1094}1095�try_pyarr_from_intzYstatic int try_pyarr_from_int(PyObject* obj,int* v) {1096    TRYPYARRAYTEMPLATE(int,'i');1097}1098�try_pyarr_from_longz\static int try_pyarr_from_long(PyObject* obj,long* v) {1099    TRYPYARRAYTEMPLATE(long,'l');1100}1101)r4r=r �try_pyarr_from_long_longzkstatic int try_pyarr_from_long_long(PyObject* obj,long_long* v) {1102    TRYPYARRAYTEMPLATE(long_long,'L');1103}1104�try_pyarr_from_floatz_static int try_pyarr_from_float(PyObject* obj,float* v) {1105    TRYPYARRAYTEMPLATE(float,'f');1106}1107�try_pyarr_from_doublezbstatic int try_pyarr_from_double(PyObject* obj,double* v) {1108    TRYPYARRAYTEMPLATE(double,'d');1109}1110)r:r>r$�try_pyarr_from_complex_floatzvstatic int try_pyarr_from_complex_float(PyObject* obj,complex_float* v) {1111    TRYCOMPLEXPYARRAYTEMPLATE(float,'F');1112}1113)r9r>r%�try_pyarr_from_complex_doublezystatic int try_pyarr_from_complex_double(PyObject* obj,complex_double* v) {1114    TRYCOMPLEXPYARRAYTEMPLATE(double,'D');1115}1116)r(r.r/�create_cb_arglistaG1117static int1118create_cb_arglist(PyObject* fun, PyTupleObject* xa , const int maxnofargs,1119                  const int nofoptargs, int *nofargs, PyTupleObject **args,1120                  const char *errmess)1121{1122    PyObject *tmp = NULL;1123    PyObject *tmp_fun = NULL;1124    Py_ssize_t tot, opt, ext, siz, i, di = 0;1125    CFUNCSMESS("create_cb_arglist\n");1126    tot=opt=ext=siz=0;1127    /* Get the total number of arguments */1128    if (PyFunction_Check(fun)) {1129        tmp_fun = fun;1130        Py_INCREF(tmp_fun);1131    }1132    else {1133        di = 1;1134        if (PyObject_HasAttrString(fun,"im_func")) {1135            tmp_fun = PyObject_GetAttrString(fun,"im_func");1136        }1137        else if (PyObject_HasAttrString(fun,"__call__")) {1138            tmp = PyObject_GetAttrString(fun,"__call__");1139            if (PyObject_HasAttrString(tmp,"im_func"))1140                tmp_fun = PyObject_GetAttrString(tmp,"im_func");1141            else {1142                tmp_fun = fun; /* built-in function */1143                Py_INCREF(tmp_fun);1144                tot = maxnofargs;1145                if (PyCFunction_Check(fun)) {1146                    /* In case the function has a co_argcount (like on PyPy) */1147                    di = 0;1148                }1149                if (xa != NULL)1150                    tot += PyTuple_Size((PyObject *)xa);1151            }1152            Py_XDECREF(tmp);1153        }1154        else if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {1155            tot = maxnofargs;1156            if (xa != NULL)1157                tot += PyTuple_Size((PyObject *)xa);1158            tmp_fun = fun;1159            Py_INCREF(tmp_fun);1160        }1161        else if (F2PyCapsule_Check(fun)) {1162            tot = maxnofargs;1163            if (xa != NULL)1164                ext = PyTuple_Size((PyObject *)xa);1165            if(ext>0) {1166                fprintf(stderr,"extra arguments tuple cannot be used with PyCapsule call-back\n");1167                goto capi_fail;1168            }1169            tmp_fun = fun;1170            Py_INCREF(tmp_fun);1171        }1172    }1173 1174    if (tmp_fun == NULL) {1175        fprintf(stderr,1176                "Call-back argument must be function|instance|instance.__call__|f2py-function "1177                "but got %s.\n",1178                ((fun == NULL) ? "NULL" : Py_TYPE(fun)->tp_name));1179        goto capi_fail;1180    }1181 1182    if (PyObject_HasAttrString(tmp_fun,"__code__")) {1183        if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,"__code__"),"co_argcount")) {1184            PyObject *tmp_argcount = PyObject_GetAttrString(tmp,"co_argcount");1185            Py_DECREF(tmp);1186            if (tmp_argcount == NULL) {1187                goto capi_fail;1188            }1189            tot = PyLong_AsSsize_t(tmp_argcount) - di;1190            Py_DECREF(tmp_argcount);1191        }1192    }1193    /* Get the number of optional arguments */1194    if (PyObject_HasAttrString(tmp_fun,"__defaults__")) {1195        if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,"__defaults__")))1196            opt = PyTuple_Size(tmp);1197        Py_XDECREF(tmp);1198    }1199    /* Get the number of extra arguments */1200    if (xa != NULL)

Showing the first 1,200 of 1285 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai