Ñò
,ÏÐKc           @   sz  d  Z  d d d !Z d d k Z e i Z d d k Z d d k Z d d k Z e i i Z	 e i
 i Z e i Z d d k Td d k Z d d k Z h d d 6d d	 6d
 d g d 6d d 6d d 6d d 6d d 6d d 6Z h h d d 6d d 6d d 6d d 6d d 6d d 6d d  6d d! 6d d" 6d d# 6d d$ 6d% d& 6d d' 6d d( 6d d) 6d d* 6d d+ 6d, 6d- d 6d. d 6d/ d# 6g  d 6d d 6d d0 6d d1 6d2 d 6g  d 6d d  6d d3 6g  d! 6d d" 6d d4 6d d5 6d6 d$ 6d d& 6d d' 6d7 d8 6d9 d: 6d; d< 6d= d> 6d d? 6d d@ 6d dA 6dB d( 6dC d) 6dD d* 6dE d+ 6h dF e 6d e e ƒ 6dG 6h dH d 6h dI e 6dJ h dK e 6g d# 6dL h d e 6dM g d 6dN d0 6e e e e ƒ e e ƒ ƒ dO 6h h dP e 6d 6dQ d 6dR d! 6dS d 6h dT e 6dU h dV e 6g d# 6dL h d e 6dW dX g d 6dY d0 6e dO 6h dZ d 6d[ d" 6d\ d  6d] d 6h dI e 6d^ h d_ e 6g d# 6d` d0 6dL h d e 6dW dM da g d 6e dO 6h db d< 6dc h dF e 6g d* 6dd d? 6e dO 6h e dO 6dY d0 6g Z h	 h de e e e ƒ 6d: 6h de e e e ƒ 6d8 6h db e 6d< 6h df h dF e 6g e e e ƒ 6d) 6h df h dF e 6g e e e ƒ 6d( 6h dc h dF e e e ƒ 6dg e e e ƒ 6g e 6d* 6h dh e e e ƒ 6d@ 6h dh e e e ƒ 6dA 6d di 6h h dj e e e  ƒ 6dk e e e e  ƒ ƒ 6dl e! 6dj e" 6d 6h dm e e e  ƒ 6dn e e e e  ƒ ƒ 6dm e! 6dm e" 6d! 6h da e e e  ƒ 6do e e e e  ƒ ƒ 6do e! 6da e" 6d 6h dp e" 6d1 6h dq e" 6d3 6h dr e" 6d4 6h h ds e e  ƒ 6d 6h d e e  e e# dt ƒ ƒ 6du 6h dv e 6h dw e 6h dx e e e e e$ ƒ e  ƒ ƒ 6h dy e e e e e$ ƒ e e  ƒ ƒ ƒ 6h dz e e e e$ e  ƒ ƒ 6h d{ e e e e$ e e  ƒ ƒ ƒ 6g d# 6h dL dM g e 6h d e 6g d 6e dO 6h h d| e% 6h d} e& 6g d 6h d~ e% 6h d e& 6h da e$ 6g d 6e e e ƒ dO 6d d€ 6h h d e 6d‚ h dƒ e 6g d# 6da dX h d e 6dW g d 6e e" e ƒ dO 6h h d„ e 6h d| e% 6h d… e& 6g d 6h d~ e% 6h d e& 6g d 6e e" e ƒ dO 6d d€ 6h d† d 6d‡ d$ 6e! dO 6d dˆ 6h h d‰ e 6h dŠ e  6d‹ e e  ƒ 6dŒ g d 6e e! e e' e% e& ƒ ƒ dO 6d d€ 6h h dv e 6d h dŽ e  6d h d e 6g d# 6d‘ h da e( 6g d 6e e! e ƒ dO 6h dh d? 6e dO 6g
 Z) h  a* d’ „  Z+ d“ „  Z, d S(”   sJ  

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
s   $Revision: 1.53 $i
   iÿÿÿÿN(   t   *sP   typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);t
   cbtypedefssí
  
#begintitle#
PyObject *#name#_capi = NULL;/*was Py_None*/
PyTupleObject *#name#_args_capi = NULL;
int #name#_nofargs = 0;
jmp_buf #name#_jmpbuf;
/*typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);*/
#static# #rctype# #callbackname# (#optargs##args##strarglens##noargs#) {
	PyTupleObject *capi_arglist = #name#_args_capi;
	PyObject *capi_return = NULL;
	PyObject *capi_tmp = NULL;
	int capi_j,capi_i = 0;
	int capi_longjmp_ok = 1;
#decl#
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_clock();
#endif
	CFUNCSMESS("cb:Call-back function #name# (maxnofargs=#maxnofargs#(-#nofoptargs#))\n");
	CFUNCSMESSPY("cb:#name#_capi=",#name#_capi);
	if (#name#_capi==NULL) {
		capi_longjmp_ok = 0;
		#name#_capi = PyObject_GetAttrString(#modulename#_module,"#argname#");
	}
	if (#name#_capi==NULL) {
		PyErr_SetString(#modulename#_error,"cb: Callback #argname# not defined (as an argument or module #modulename# attribute).\n");
		goto capi_fail;
	}
	if (PyCObject_Check(#name#_capi)) {
	#name#_typedef #name#_cptr;
	#name#_cptr = PyCObject_AsVoidPtr(#name#_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);
			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#
#pyobjfrom#
	CFUNCSMESSPY("cb:capi_arglist=",capi_arglist);
	CFUNCSMESS("cb:Call-back calling Python function #argname#.\n");
#ifdef F2PY_REPORT_ATEXIT
f2py_cb_start_call_clock();
#endif
	capi_return = PyObject_CallObject(#name#_capi,(PyObject *)capi_arglist);
#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);
	if (capi_longjmp_ok)
		longjmp(#name#_jmpbuf,-1);
capi_return_pt:
	;
#return#
}
#endtitle#
t   bodys   setjmp.ht
   CFUNCSMESSt   needs   #maxnofargs#t
   maxnofargss   #nofoptargs#t
   nofoptargssC   	def #argname#(#docsignature#): return #docreturn#\n\
#docstrsigns#t   docstrsc   
{{}\verb@def #argname#(#latexdocsignature#): return #docreturn#@{}}
#routnote#

#latexdocstrsigns#t   latexdocstrs1   def #argname#(#docsignature#): return #docreturn#t   docstrshorts   
t   declt   ,t   argst    t   optargst	   pyobjfromt   freememt   args_tdt
   optargs_tdt   args_nmt
   optargs_nmt	   frompyobjt   setdimss   \n"
"t   docstrsignst   latexdocstrsignst   latexdocstrreqt   latexdocstroptt   latexdocstroutt   latexdocstrcbst   separatorsfors   /*decl*/s   /*pyobjfrom*/s   /*frompyobj*/t   returnt
   strarglenss   /*freemem*/t   strarglens_tdt   strarglens_nmt   noargss   /*setdims*/s   	Required arguments:t	   docstrreqs   	Optional arguments:t	   docstropts   	Return objects:t	   docstrouts   	Call-back functions:t	   docstrcbst	   docreturnt   docsignt
   docsignopts   \noindent Required arguments:s   \noindent Optional arguments:s   \noindent Return objects:s   \noindent Call-back functions:s
   --- #note#t   routnotes   	#ctype# return_value;s)   	CFUNCSMESS("cb:Getting return_value->");sº   	if (capi_j>capi_i)
		GETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\n");s5   	fprintf(stderr,"#showvalueformat#.\n",return_value);s   #ctype#_from_pyobjt   GETSCALARFROMPYTUPLEs   	return return_value;t   _checks?   	fprintf(stderr,"debug-capi:cb:#name#:%d:\n",return_value_len);s)   #ctype# return_value,int return_value_lens   return_value,&return_value_lens   #ctype# ,ints+   	CFUNCSMESS("cb:Getting return_value->\"");s\   	if (capi_j>capi_i)
		GETSTRFROMPYTUPLE(capi_return,capi_i++,return_value,return_value_len);s7   	fprintf(stderr,"#showvalueformat#\".\n",return_value);s   string.ht   GETSTRFROMPYTUPLEs   return;s<   
#ifndef F2PY_CB_RETURNCOMPLEX
#ctype# *return_value
#endif
s3   
#ifndef F2PY_CB_RETURNCOMPLEX
return_value
#endif
s0   
#ifndef F2PY_CB_RETURNCOMPLEX
#ctype# *
#endif
s<   
#ifdef F2PY_CB_RETURNCOMPLEX
	#ctype# return_value;
#endif
s‹  	if (capi_j>capi_i)
#ifdef F2PY_CB_RETURNCOMPLEX
		GETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\n");
#else
		GETSCALARFROMPYTUPLE(capi_return,capi_i++,return_value,#ctype#,"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\n");
#endif
sÄ   
#ifdef F2PY_CB_RETURNCOMPLEX
	fprintf(stderr,"#showvalueformat#.\n",(return_value).r,(return_value).i);
#else
	fprintf(stderr,"#showvalueformat#.\n",(*return_value).r,(*return_value).i);
#endif

sJ   
#ifdef F2PY_CB_RETURNCOMPLEX
	return return_value;
#else
	return;
#endif
s   #ctype#s   		#pydocsignout#s"   \item[]{{}\verb@#pydocsignout#@{}}s   #rname#,s   		#pydocsign#s   \item[]{{}\verb@#pydocsign#@{}}s   --- See above.s
   #varname#,t   depends   #ctype# #varname_i#s   #ctype# *#varname_i#_cb_capis   #ctype# *#varname_i#s   #varname_i#s   #varname_i#_cb_capis	   #ctype# *s   ,int #varname_i#_cb_lens   ,ints   ,#varname_i#_cb_lens,   	#ctype# #varname_i#=(*#varname_i#_cb_capi);s8   intent(c,out) is forbidden for callback scalar argumentst   errors&   	CFUNCSMESS("cb:Getting #varname#->");sÆ   	if (capi_j>capi_i)
		GETSCALARFROMPYTUPLE(capi_return,capi_i++,#varname_i#_cb_capi,#ctype#,"#ctype#_from_pyobj failed in converting argument #varname# of call-back function #name# to C #ctype#\n");s4   	fprintf(stderr,"#showvalueformat#.\n",#varname_i#);s=   	fprintf(stderr,"#showvalueformat#.\n",*#varname_i#_cb_capi);sH   	fprintf(stderr,"#showvalueformat#.\n",(#varname_i#).r,(#varname_i#).i);sZ   	fprintf(stderr,"#showvalueformat#.\n",(*#varname_i#_cb_capi).r,(*#varname_i#_cb_capi).i);s‰   	if (#name#_nofargs>capi_i)
		if (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyobj_from_#ctype#1(#varname_i#)))
			goto capi_fail;s“   	if (#name#_nofargs>capi_i)
		if (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname_i#_cb_capi)))
			goto capi_fail;s   pyobj_from_#ctype#1s   pyarr_from_p_#ctype#1t	   _optionals(   	CFUNCSMESS("cb:Getting #varname#->\"");s]   	if (capi_j>capi_i)
		GETSTRFROMPYTUPLE(capi_return,capi_i++,#varname_i#,#varname_i#_cb_len);sM   	fprintf(stderr,"#showvalueformat#\":%d:.\n",#varname_i#,#varname_i#_cb_len);sf   	fprintf(stderr,"debug-capi:cb:#varname#=\"#showvalueformat#\":%d:\n",#varname_i#,#varname_i#_cb_len);sØ   	if (#name#_nofargs>capi_i) {
		int #varname_i#_cb_dims[] = {#varname_i#_cb_len};
		if (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname_i#,#varname_i#_cb_dims)))
			goto capi_fail;
	}s3   	npy_intp #varname_i#_Dims[#rank#] = {#rank*[-1]#};s   	#cbsetdims#;t   _depends-   	fprintf(stderr,"debug-capi:cb:#varname#\n");sß   	if (#name#_nofargs>capi_i) {
		PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,0,NPY_CARRAY,NULL); /*XXX: Hmm, what will destroy this array??? */
sß   	if (#name#_nofargs>capi_i) {
		PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,0,NPY_FARRAY,NULL); /*XXX: Hmm, what will destroy this array??? */
s‹   
		if (tmp_arr==NULL)
			goto capi_fail;
		if (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,(PyObject *)tmp_arr))
			goto capi_fail;
}s×   	if (capi_j>capi_i) {
		PyArrayObject *rv_cb_arr = NULL;
		if ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;
		rv_cb_arr =  array_from_pyobj(#atype#,#varname_i#_Dims,#rank#,F2PY_INTENT_INs   |F2PY_INTENT_Csô   ,capi_tmp);
		if (rv_cb_arr == NULL) {
			fprintf(stderr,"rv_cb_arr is NULL\n");
			goto capi_fail;
		}
		MEMCOPY(#varname_i#,rv_cb_arr->data,PyArray_NBYTES(rv_cb_arr));
		if (capi_tmp != (PyObject *)rv_cb_arr) {
			Py_DECREF(rv_cb_arr);
		}
	}s   	fprintf(stderr,"<-.\n");t   MEMCOPYc         C   s   g  t  |  d <xj |  d D]^ } | d d j oG xD | d D]4 } | o t | |  d ƒ q; t d |  d ƒ q; Wq q Wd  S(   Nt   nameR   t   blockt	   interfaces   warning: empty body for %s
(   t   cb_mapt   buildcallbackt   errmess(   t   mt   bit   b(    (    sC   P:\graphics\Tools\Python26\Lib\site-packages\numpy\f2py\cb_rules.pyt   buildcallbacks•  s      c         C   sw  t  d |  d | f ƒ t |  ƒ \ } } | t _ |  d } t i |  | ƒ } t h  | ƒ } t | i |  d | d g ƒ x^ t D]V } d | j o | d |  ƒ p d | j o% t	 | | |  ƒ } t | | ƒ } q„ q„ Wh  }	 xô t
 | ƒ D]æ \ }
 } t i | | | d |
 ƒ} | |	 | <x± t D]© } d | j o q*n d | j o t | | ƒ o q*n d | j o | d | | ƒ p d | j o; t	 | | | | ƒ } t | | ƒ } d | j o PqÓq*q*Wqñ WxÙ | D]Ñ } |	 | } x¾ t D]¶ } d | j o qùn d | j p d | j o t | | ƒ o qùn d | j o | d | | ƒ p d | j o; t	 | | | | ƒ } t | | ƒ } d | j o Pq¯qùqùWqâWx» | D]³ } |	 | } x  t D]˜ } d | j o qÕn d | j o qÕn d | j o | d | | ƒ p d | j o; t	 | | | | ƒ } t | | ƒ } d | j o PqmqÕqÕWq¾Wd	 | j oq d
 | j od t | d
 ƒ t g  ƒ j oC | d
 d g | d
 <| d d g | d <| d d g | d <qón t | d ƒ t i j o( t t d h | d d 6ƒ ƒ | d <n t t d h | d d 6ƒ ƒ } | d j o( t t d h | d d 6ƒ ƒ | d <n& t d h | d d 6| d 6ƒ | d <| d i d d ƒ | d <| d i d d ƒ | d <g  | d <g  | d <xÇ d d d  d! g D]³ } | | j o4 t | | ƒ t i j o | d | | | d <n d" | } | | j oU t | | ƒ t i j o; | d | | d# d$ !d% g | | d$ d& g | d <q
q
Wd	 | j o" d | d	 <d | d' <d | d( <n | i d	 ƒ p | i d
 ƒ p | i d) ƒ p d* | d+ <n t	 t | ƒ } | d, t i | d <t | d- ƒ t i j o | d- g | d- <n d- | j oD xA t i i ƒ  D], } | | d- j o | d- i | ƒ qžqžWn | d. t i | d d/ <| d- i | d d/ ƒ | d- t i | d <h | d0 d0 6| d1 d1 6| d2 d2 6| d3 d3 6| d4 d4 6t i | d <t  d5 | d6 ƒ d  S(7   Ns/   	Constructing call-back function "cb_%s_in_%s"
R3   t   varsR,   t   indexR1   R0   t   _breakR   R   s(   
#ifndef F2PY_CB_RETURNCOMPLEX
,
#endif
R   R   R'   s   #docreturn#s   #docsignopt#R)   R   s	   #docsign#R(   t   docsignatures   #docsign#[#docsignopt#]t   _s   \_t   latexdocsignatureR   s   , R   R   R#   R$   R%   R&   t   latexi    i   s   \begin{description}s   \end{description}R   R   R   t   voidR"   R   R   R   t   _typedefR   R   R   R   t   argnames   	  %s
R	   (   t   outmesst   getargst	   capi_mapst   depargst   cb_routsign2mapt
   dictappendR6   t   appendt   cb_rout_rulest
   applyrulest	   enumeratet   cb_sign2mapt   cb_arg_rulest
   isoptionalt
   isrequiredt   typet   typest   ListTypet
   stripcommat   replacet   gett   cb_routine_rulest   cfuncst	   callbackst
   StringTypet   typedefst   keyst   typedefs_generatedt   needst   lcb2_map(   t   routt   umR   RJ   t   vart   vrdt   rdt   rt   art   savevrdt   it   aR   t   kt   t(    (    sC   P:\graphics\Tools\Python26\Lib\site-packages\numpy\f2py\cb_rules.pyR7      sÜ    	
 + 
 / 
 +/ 
 /(	(

 '
')

0 (-   t   __doc__t   __version__t   versiont   f2py_versiont   pprintt   sysRV   t   stderrt   writeR8   t   stdoutRG   t   showt   auxfuncsRI   R\   R[   t   hasnotet   l_nott	   debugcapit   l_andt
   isfunctiont   isstringfunctiont   iscomplexfunctiont   issubroutineRN   RS   t   isintent_nothideRT   t   isintent_outt   isintent_hidet   isscalart
   isintent_ct   isarrayt   isstringt   throw_errort	   iscomplext   isintent_int   isintent_inoutt   l_ort   iscomplexarrayRR   R6   R<   R7   (    (    (    sC   P:\graphics\Tools\Python26\Lib\site-packages\numpy\f2py\cb_rules.pyt   <module>   sv  		
^

#





"()









	