ó
ØÆ÷Xc           @` s¹   d  Z  d d l m Z m Z m Z d d d !Z d d l m Z e j Z d d l	 m
 Z
 m Z m Z m Z m Z d d	 l m Z d d
 l m Z d d l m Z d d „ Z d „  Z d S(   sM  

Build common block 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/05/06 10:57:33 $
Pearu Peterson

i    (   t   divisiont   absolute_importt   print_functions   $Revision: 1.19 $i
   iÿÿÿÿi   (   t   __version__(   t   hasbodyt	   hascommont   hasnotet   isintent_hidet   outmess(   t	   capi_maps(   t	   func2subr(   t	   rmbadnamec   
      C` s  g  } t  |  ƒ r x¡ |  d j ƒ  D]U } i  } x( |  d | D] } |  d | | | <q> W| j | |  d | | f ƒ q# Wn7 t |  ƒ r¶ x( |  d D] } | t | d ƒ } q– Wn  | rg  } g  } x? | D]7 }	 |	 d | k rÏ | j |	 d ƒ | j |	 ƒ qÏ qÏ W| S| S(   Nt   commont   varst   bodyi    (   R   t   keyst   appendR   t   findcommonblocks(
   t   blockt   topt   rett   nR   t   vt   bt   trett   namest   t(    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyR      s&    %c      
   C` s  i g  d 6g  d 6d g d 6} d g } | d „ } d g } | d „ } d g } | d „ } d g } | d	 „ }	 x<t  |  ƒ D].\ }
 } } |
 j ƒ  } g  g  } } x; | D]3 } t | | ƒ rÔ | j | ƒ q® | j | ƒ q® W| rt d
 |
 d j | ƒ d j | ƒ f ƒ n t d |
 d j | ƒ f ƒ | d |
 ƒ | d ƒ x$ | D] } | t j | | ƒ ƒ qSW|
 d k r™| d d j | ƒ ƒ n | d |
 d j | ƒ f ƒ | d d j | ƒ ƒ | d ƒ | d |
 ƒ g  } x° | D]¨ } t j	 | | ƒ } t j
 | } t j | | | ƒ } | d rP| j d | d ƒ n | j d ƒ | d j ƒ  } | s|d } n  | d | | d | | f ƒ qòW| d ƒ t | ƒ } d j g  | D] } d | ^ qÁƒ } | d |
 | f ƒ | d ƒ x" | D] } | d |
 | f ƒ qÿW| d ƒ d  | k r<d! } n d" } | d# | | |
 j ƒ  d j d$ g t | ƒ ƒ f ƒ | d% |
 ƒ | d& | | |
 j ƒ  |
 f ƒ | d' ƒ | d( |
 |
 |
 f ƒ |
 j d  d) ƒ } |	 d* | ƒ |	 d+ ƒ x| | D]t } |	 d, t j | | | ƒ ƒ t | | ƒ rø| | d- } t | t ƒ r[d. j | ƒ } n  |	 d/ | ƒ qøqøW|	 d0 ƒ | d j d1 |
 d j t d2 „  | | ƒ ƒ f ƒ q W| | d <| | d <| d3 | d4 <t | d ƒ d5 k röd | d <n  | | d3 f S(6   Nt   commonhookst   initcommonhookss   "COMMON blocks:\n"t   docst    c         S` s   d | d |  f | d <d  S(   Ns   %s
      %si    (    (   t   linet   s(    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   fadd:   s    c         S` s   d | d |  f | d <d  S(   Ns   %s
%si    (    (   R   R    (    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   cadd>   s    c         S` s   d | d |  f | d <d  S(   Ns   %s
%si    (    (   R   R    (    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   iaddB   s    c         S` s   d | d |  f | d <d  S(   Ns   %s
%si    (    (   R   R    (    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   daddF   s    sF   		Constructing COMMON block support for "%s"...
		  %s
		  Hidden: %s
t   ,s7   		Constructing COMMON block support for "%s"...
		  %s
s    subroutine f2pyinit%s(setupfunc)s   external setupfunct   _BLNK_s	   common %ss   common /%s/ %ss   call setupfunc(%s)s   end
s'   static FortranDataDef f2py_%s_def[] = {t   dimss   (%s)s   -1s   	{"%s",%s,{{%s}},%s},t   ranks
   	{NULL}
};s   char *s   static void f2py_setup_%s(%s) {s   	int i_f2py=0;s!   	f2py_%s_def[i_f2py++].data = %s;t   }t   _t	   F_FUNC_USt   F_FUNCs3   extern void %s(f2pyinit%s,F2PYINIT%s)(void(*)(%s));s   char*s    static void f2py_init_%s(void) {s*   	%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);s   }
sP   	F2PyDict_SetItemString(d, "%s", PyFortranObject_New(f2py_%s_def,f2py_init_%s));s   \_s&   \subsection{Common block \texttt{%s}}
s   \begin{description}s   \item[]{{}\verb@%s@{}}t   notes   
s   --- %ss   \end{description}s   "	/%s/ %s\n"c         S` s   |  | S(   N(    (   R   t   d(    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   <lambda>   s    i    t   latexdoci   (   R   t   lowerR   R   R   t   joinR
   t   var2fixfortranR	   t   getctypet
   c2capi_mapt
   getarrdimst   stripR   t   uppert   lent   replacet   getarrdocsignR   t
   isinstancet   listt   map(   t   mR   t   fwrapR!   t   chooksR"   t   ihooksR#   t   docR$   t   namet   vnamesR   t
   lower_namet   hnamest   inamesR   t   idimst   ctt   att   dmt   dmst   inames1R    t   inames1_tpsR,   t   tnameR-   (    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt
   buildhooks5   s¨    				&


	"
&

	!



-

N(   t   __doc__t
   __future__R    R   R   R   R   t   versiont   f2py_versiont   auxfuncsR   R   R   R   R   R	   R
   t   crackfortranR   R   RQ   (    (    (    s6   /tmp/pip-build-X4mzal/numpy/numpy/f2py/common_rules.pyt   <module>   s   	(