관리-도구
편집 파일: cb_rules.cpython-311.pyc
� �܋f�a � � � d Z ddlmZ ddlmZmZmZmZmZm Z m Z mZmZm Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! ddlm"Z" ej# Z$ddg d�dd d ddd �Z%i di dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d�d!d�d"d�d#d��dd$�dd%�dd&�dg �dd�d'd�d(d�dd)�dg �dd�d*d�dg �dd�d+d�d,d�dd-�ddd.d/d0d1dddd2d3d4d5e d6 ee � � did7��d8ed9id:ed;igd<ed=id>gd? ee ee� � ee � � � � d@�edAidBdCdDedEidFedGigd<ed=idHdIgdJedK�dLdMdNdOed9idPedQigdRd<ed=idHd>dSge dT�dUdVe d6igdWedX�edJdY�gZ& eee� � dZi eee� � dZiedUi eee� � d[e d6igi eee� � d[e d6igiedV ee e� � d6 ee e� � d\igi eee� � d]i eee� � d]idd^� eee� � d_ ee ee� � � � d`e daed_i eee� � db ee ee� � � � dce dbedbi eee� � dS ee ee� � � � dde ddedSi eee e� � dSiedeiedfiedgidh� ee� � dii eee e!dj� � � � diedkiedli ee e ee� � e� � � � dmi ee e ee� � ee� � � � � � dni ee eee� � � � doi ee ee ee� � � � � � dpiged<d>gied=igedq�edriedsigedtieduiedSig eee� � ddv�edwidxedyigdSdIed=idHg eee� � dz�ed{ied|ied}iged~ieduig eee� � ddv�dd�e dd��ed�ied� ee� � d�id�g ee e eee� � � � dd��edkid�ed�id�ed�igd�edSig ee e� � dz�d]ed��g Z'i Z(d�� Z)d�� Z*d�S )�aK Build call-back mechanism for f2py2e. Copyright 2000 Pearu Peterson all rights reserved, Pearu Peterson <pearu@ioc.ee> Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. $Date: 2005/07/20 11:27:58 $ Pearu Peterson � )�__version__)� applyrules� debugcapi� dictappend�errmess�getargs�hasnote�isarray� iscomplex�iscomplexarray�iscomplexfunction� isfunction� isintent_c� isintent_hide�isintent_in�isintent_inout�isintent_nothide�isintent_out� isoptional� isrequired�isscalar�isstring�isstringfunction�issubroutine�l_and�l_not�l_or�outmess�replace� stripcomma�throw_error)�cfuncszPtypedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);a^ #begintitle# typedef struct { PyObject *capi; PyTupleObject *args_capi; int nofargs; jmp_buf jmpbuf; } #name#_t; #if defined(F2PY_THREAD_LOCAL_DECL) && !defined(F2PY_USE_PYTHON_TLS) static F2PY_THREAD_LOCAL_DECL #name#_t *_active_#name# = NULL; static #name#_t *swap_active_#name#(#name#_t *ptr) { #name#_t *prev = _active_#name#; _active_#name# = ptr; return prev; } static #name#_t *get_active_#name#(void) { return _active_#name#; } #else static #name#_t *swap_active_#name#(#name#_t *ptr) { char *key = "__f2py_cb_#name#"; return (#name#_t *)F2PySwapThreadLocalCallbackPtr(key, ptr); } static #name#_t *get_active_#name#(void) { char *key = "__f2py_cb_#name#"; return (#name#_t *)F2PyGetThreadLocalCallbackPtr(key); } #endif /*typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);*/ #static# #rctype# #callbackname# (#optargs##args##strarglens##noargs#) { #name#_t cb_local = { NULL, NULL, 0 }; #name#_t *cb = NULL; PyTupleObject *capi_arglist = NULL; PyObject *capi_return = NULL; PyObject *capi_tmp = NULL; PyObject *capi_arglist_list = NULL; int capi_j,capi_i = 0; int capi_longjmp_ok = 1; #decl# #ifdef F2PY_REPORT_ATEXIT f2py_cb_start_clock(); #endif cb = get_active_#name#(); if (cb == NULL) { capi_longjmp_ok = 0; cb = &cb_local; } capi_arglist = cb->args_capi; CFUNCSMESS("cb:Call-back function #name# (maxnofargs=#maxnofargs#(-#nofoptargs#))\n"); CFUNCSMESSPY("cb:#name#_capi=",cb->capi); if (cb->capi==NULL) { capi_longjmp_ok = 0; cb->capi = PyObject_GetAttrString(#modulename#_module,"#argname#"); CFUNCSMESSPY("cb:#name#_capi=",cb->capi); } if (cb->capi==NULL) { PyErr_SetString(#modulename#_error,"cb: Callback #argname# not defined (as an argument or module #modulename# attribute).\n"); goto capi_fail; } if (F2PyCapsule_Check(cb->capi)) { #name#_typedef #name#_cptr; #name#_cptr = F2PyCapsule_AsVoidPtr(cb->capi); #returncptr#(*#name#_cptr)(#optargs_nm##args_nm##strarglens_nm#); #return# } if (capi_arglist==NULL) { capi_longjmp_ok = 0; capi_tmp = PyObject_GetAttrString(#modulename#_module,"#argname#_extra_args"); if (capi_tmp) { capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp); Py_DECREF(capi_tmp); if (capi_arglist==NULL) { PyErr_SetString(#modulename#_error,"Failed to convert #modulename#.#argname#_extra_args to tuple.\n"); goto capi_fail; } } else { PyErr_Clear(); capi_arglist = (PyTupleObject *)Py_BuildValue("()"); } } if (capi_arglist == NULL) { PyErr_SetString(#modulename#_error,"Callback #argname# argument list is not set.\n"); goto capi_fail; } #setdims# #ifdef PYPY_VERSION #define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value) capi_arglist_list = PySequence_List(capi_arglist); if (capi_arglist_list == NULL) goto capi_fail; #else #define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value) #endif #pyobjfrom# #undef CAPI_ARGLIST_SETITEM #ifdef PYPY_VERSION CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list); #else CFUNCSMESSPY("cb:capi_arglist=",capi_arglist); #endif CFUNCSMESS("cb:Call-back calling Python function #argname#.\n"); #ifdef F2PY_REPORT_ATEXIT f2py_cb_start_call_clock(); #endif #ifdef PYPY_VERSION capi_return = PyObject_CallObject(cb->capi,(PyObject *)capi_arglist_list); Py_DECREF(capi_arglist_list); capi_arglist_list = NULL; #else capi_return = PyObject_CallObject(cb->capi,(PyObject *)capi_arglist); #endif #ifdef F2PY_REPORT_ATEXIT f2py_cb_stop_call_clock(); #endif CFUNCSMESSPY("cb:capi_return=",capi_return); if (capi_return == NULL) { fprintf(stderr,"capi_return is NULL\n"); goto capi_fail; } if (capi_return == Py_None) { Py_DECREF(capi_return); capi_return = Py_BuildValue("()"); } else if (!PyTuple_Check(capi_return)) { capi_return = Py_BuildValue("(N)",capi_return); } capi_j = PyTuple_Size(capi_return); capi_i = 0; #frompyobj# CFUNCSMESS("cb:#name#:successful\n"); Py_DECREF(capi_return); #ifdef F2PY_REPORT_ATEXIT f2py_cb_stop_clock(); #endif goto capi_return_pt; capi_fail: fprintf(stderr,"Call-back #name# failed.\n"); Py_XDECREF(capi_return); Py_XDECREF(capi_arglist_list); if (capi_longjmp_ok) { longjmp(cb->jmpbuf,-1); } capi_return_pt: ; #return# } #endtitle# )zsetjmp.h� CFUNCSMESS�F2PY_THREAD_LOCAL_DECLz#maxnofargs#z#nofoptargs#zF def #argname#(#docsignature#): return #docreturn#\n\ #docstrsigns#zc {{}\verb@def #argname#(#latexdocsignature#): return #docreturn#@{}} #routnote# #latexdocstrsigns#z1def #argname#(#docsignature#): return #docreturn#)� cbtypedefs�body�need� maxnofargs� nofoptargs�docstr�latexdocstr�docstrshort� separatorsfor�decl� �args�,�optargs� � pyobjfrom�freemem�args_td� optargs_td�args_nm� optargs_nm� frompyobj�setdims�docstrsignsz\n" "�latexdocstrsigns�latexdocstrreq�latexdocstropt�latexdocstrout�latexdocstrcbsz/*decl*/z /*pyobjfrom*/z /*frompyobj*/�return� strarglensz/*freemem*/� strarglens_td� strarglens_nm�noargsz/*setdims*/z Required arguments:z Optional arguments:z Return objects:z Call-back functions:z\noindent Required arguments:z\noindent Optional arguments:z\noindent Return objects:z\noindent Call-back functions:z --- #note#)r<