ó
™^c           @   s   d  e  f d „  ƒ  YZ d S(   t   Argumentc           B   sã   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z e	 d „  ƒ Z
 e	 d „  ƒ Z e	 d „  ƒ Z e	 d	 „  ƒ Z e	 d
 „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z RS(   së   
    Function argument.

    An argument must have a C type and a name.

    :ivar c_type: the type of the argument in C
    :type c_type: :class:`peachpy.c.types.Type`

    :ivar name: the name of the argument
    :type name: str
    c         C   sÂ  d d l  m } t | | ƒ s8 t d t | ƒ ƒ ‚ n  | |  _ | d k r˜d d l } d d l } | j	 ƒ  d \ } } } } } } | d k r¢ t
 d ƒ ‚ n  | d j ƒ  } | j d | ƒ }	 |	 r€|	 j d ƒ } x | j d	 ƒ rø | d } qÜ W| j d
 ƒ s| j d ƒ r+| t d
 ƒ  } n  | j d ƒ sI| j d ƒ r]| t d ƒ  } n  x  | j d	 ƒ r|| d  } q`Wn  | s˜t
 d ƒ ‚ q˜n  d d l m }
 |
 j | ƒ | |  _ d S(   sÇ  
        :param peachpy.c.types.Type c_type: the type of the argument in C.
            When Go function is generated, the type is automatically converted to similar Go type.
            Note that the ``short``, ``int``, ``long``, and ``long long`` types do not have an equivalents in Go.
            In particular, C's ``int`` type is not an equivalent of Go's ``int`` type. To get Go's ``int`` and ``uint``
            types use ``ptrdiff_t`` and ``size_t`` correspondingly.

        :param str name: the name of the argument. If the name is not provided explicitly, PeachPy tries to parse it
            from the caller code. The name must follow the C rules for identifiers:

            - It can contain only Latin letters, digits, and underscore symbol
            - It can not start with a digit
            - It can not start with double underscore (these names are reserved for PeachPy)
            - Name must be unique among the function arguments
        iÿÿÿÿ(   t   Types   %s is not a C typeNi   sF   Argument name is not specified and the caller context is not availablei    s.   (?:\w+\.)*(\w+)\s*=\s*(?:\w+\.)*Argument\(.+\)t   _t   argumentR    t   argt   ArgsB   Argument name is not specified and can not be parsed from the code(   t   Name(   t   peachpy.c.typesR   t
   isinstancet	   TypeErrort   strt   c_typet   Nonet   inspectt   ret   stackt
   ValueErrort   stript   matcht   groupt
   startswitht   endswitht   lent   peachpy.nameR   t
   check_namet   name(   t   selfR   R   R   R   R   R   t   caller_linest   source_lineR   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   __init__   s6    	"c         C   s   t  |  j ƒ d |  j S(   Nt    (   R
   R   R   (   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   __str__A   s    c         C   s
   t  |  ƒ S(   N(   R
   (   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   __repr__D   s    c         C   s1   t  | t ƒ o0 |  j | j k o0 |  j | j k S(   N(   R   R    R   R   (   R   t   other(    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   __eq__G   s    c         C   s2   t  | t ƒ p1 |  j | j k p1 |  j | j k S(   N(   R   R    R   R   (   R   R!   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   __ne__J   s    c         C   s
   |  j  j S(   N(   R   t   is_floating_point(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR$   M   s    c         C   s
   |  j  j S(   N(   R   t   is_codeunit(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR%   Q   s    c         C   s
   |  j  j S(   N(   R   t
   is_integer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR&   U   s    c         C   s
   |  j  j S(   N(   R   t   is_unsigned_integer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR'   Y   s    c         C   s
   |  j  j S(   N(   R   t   is_signed_integer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR(   ]   s    c         C   s
   |  j  j S(   N(   R   t   is_size_integer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR)   a   s    c         C   s
   |  j  j S(   N(   R   t   is_pointer_integer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR*   e   s    c         C   s
   |  j  j S(   N(   R   t
   is_pointer(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR+   i   s    c         C   s
   |  j  j S(   N(   R   t	   is_vector(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR,   m   s    c         C   s
   |  j  j S(   N(   R   t   is_mask(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR-   q   s    c         C   s
   |  j  j S(   N(   R   t   size(   R   (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR.   u   s    N(   t   __name__t
   __module__t   __doc__R   R   R   R    R"   R#   t   propertyR$   R%   R&   R'   R(   R)   R*   R+   R,   R-   R.   (    (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyR       s"   0				N(   t   objectR    (    (    (    s=   /torch/pytorch/third_party/python-peachpy/peachpy/function.pyt   <module>   t    