
8	Pc           @   s
  d  Z  d d l Z d d l Z d Z d d l m Z m Z m	 Z	 d d l m
 Z
 d d l m Z d d l m Z d d l m Z m Z d d	 l m Z d d
 l m Z e e k r e d e e   n  e j du k r d d l m Z n  e Z e j d k rBe j d k rBe e j   d j d  d  d k  rBe Z qBn  d d l m Z m Z m  Z! m" Z# d d  Z% d d  Z& i  Z' d   Z( e j dv k rd d l m) Z* d d l m+ Z, e j d k re Z, n  i  Z- d   Z. e. j  r*e( j  j/ d d  e. _  q*n" e j d k r*d d l m0 Z* n  d d l m1 Z1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 d d  l m6 Z6 m7 Z7 d d! l m8 Z8 d d"  Z9 d# e8 f d$     YZ: e9 e: d%  d& e8 f d'     YZ; e9 e;  d( e8 f d)     YZ< e9 e<  d* e8 f d+     YZ= e9 e=  d, e8 f d-     YZ> e9 e>  e d.  e d/  k rNe= Z? e> Z@ n@ d0 e8 f d1     YZ? e9 e?  d2 e8 f d3     YZ@ e9 e@  d4 e8 f d5     YZA e9 eA  d6 e8 f d7     YZB e9 eB  d8 e8 f d9     YZC e1 eC  e1 eB  k reB ZC n  e d/  e d:  k r,e= ZD e> ZE n@ d; e8 f d<     YZD e9 eD  d= e8 f d>     YZE e9 eE  d? e8 f d@     YZF eF eF _G eF _H e9 eF  dA e8 f dB     YZI eI eI _G eI _H e9 eI  dC e8 f dD     YZJ eJ eJ _G eJ _H e9 eJ  dE e8 f dF     YZK e9 eK d%  dG e8 f dH     YZL eL ZM e9 eL  dI e8 f dJ     YZN d dK l mO ZO mP ZP mQ ZQ y d dL l mR ZR Wn eS k
 rnw Xe j dw k reR dM dN  n eR dO dP  dQ e8 f dR     YZT dS e8 f dT     YZU eT jV eO eU  _V d dU  ZW eK jV eO eJ  _V dV   ZX dW   ZY dX eZ f dY     YZ[ dZ e[ f d[     YZ\ e j dx k rd\ e[ f d]     YZ] d d^ l m^ Z^ m8 Z8 d_ e8 f d`     YZ_ da e[ f db     YZ` n  dc eZ f dd     YZa ea e[  Zb ea e\  Zc e j dy k r$e\ de d e jd  Ze n5 e j df k rMe\ dg e jf d   Ze n e\ d  Ze e j dz k rea e]  Zg ea e`  Zh e j d k reg ji jj Zj n eg jk jj Zj d dh l ml Zl mm Zm d d di  Zn n  eL eQ d <e1 e@  e1 eL  k re@ Zo e? Zp nN e1 e>  e1 eL  k r*e> Zo e= Zp n' e1 eE  e1 eL  k rQeE Zo eD Zp n  d dj l mq Zq mr Zr ms Zs mt Zt e( eL eL eL eo  eq  Zu e( eL eL e? eo  er  Zv dk   Zw ew e: eL e: e:  et  Zx dl   Zy ew e: eL e?  es  Zz d dm  Z{ y d dn l m| Z| Wn eS k
 r!	n% Xew e: eL e?  e|  Z} d do  Z~ e j d{ k rj	dp   Z dq   Z n  d dr l m Z m Z eI Z eF Z xk e; e? e= eD g D]W Z e1 e  d k r	e Z q	e1 e  ds k r	e Z q	e1 e  d k r	e Z q	q	Wxk e< e@ e> eE g D]W Z e1 e  d k r.
e Z q
e1 e  ds k rI
e Z q
e1 e  d k r
e Z q
q
W[ e( e?  dt    d S(|   s,   create and manipulate C data types in PythoniNs   1.1.0(   t   Uniont	   Structuret   Array(   t   _Pointer(   t   CFuncPtr(   t   __version__(   t
   RTLD_LOCALt   RTLD_GLOBAL(   t   ArgumentError(   t   calcsizes   Version number mismatcht   ntt   ce(   t   FormatErrort   posixt   darwini   t   .i    i   (   t   FUNCFLAG_CDECLt   FUNCFLAG_PYTHONAPIt   FUNCFLAG_USE_ERRNOt   FUNCFLAG_USE_LASTERRORc         C   s   t  |  t t f  rT | d k r4 t |   d } n  t | } |   } |  | _ | St  |  t t f  r t |  } |   } | St	 |    d S(   s   create_string_buffer(aString) -> character array
    create_string_buffer(anInteger) -> character array
    create_string_buffer(aString, anInteger) -> character array
    i   N(
   t
   isinstancet   strt   unicodet   Nonet   lent   c_chart   valuet   intt   longt	   TypeError(   t   initt   sizet   buftypet   buf(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   create_string_buffer4   s    
		
	c         C   s   t  |  |  S(   N(   R"   (   R   R   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   c_bufferF   s    c            s   t   | j d t  r%  t O n  | j d t  rD  t O n  | rc t d | j     n  y t     f SWnG t k
 r d t	 f     f d     Y} | t     f <| SXd S(   s  CFUNCTYPE(restype, *argtypes,
                 use_errno=False, use_last_error=False) -> function prototype.

    restype: the result type
    argtypes: a sequence specifying the argument types

    The function prototype can be called in different ways to create a
    callable object:

    prototype(integer address) -> foreign function
    prototype(callable) -> create and return a C callable function from callable
    prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method
    prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal
    prototype((function name, dll object)[, paramflags]) -> foreign function exported by name
    t	   use_errnot   use_last_errors!   unexpected keyword argument(s) %st   CFunctionTypec              s   e  Z  Z   Z  Z RS(    (   t   __name__t
   __module__t
   _argtypes_t	   _restype_t   _flags_(    (   t   restypet   argtypest   flags(    s%   /usr/lib/python2.7/ctypes/__init__.pyR&   h   s   N(
   t   _FUNCFLAG_CDECLt   popt   Falset   _FUNCFLAG_USE_ERRNOt   _FUNCFLAG_USE_LASTERRORt
   ValueErrort   keyst   _c_functype_cachet   KeyErrort	   _CFuncPtr(   R,   R-   t   kwR&   (    (   R,   R-   R.   s%   /usr/lib/python2.7/ctypes/__init__.pyt	   CFUNCTYPEN   s    "(   t   LoadLibrary(   t   FUNCFLAG_STDCALLc            s   t   | j d t  r%  t O n  | j d t  rD  t O n  | rc t d | j     n  y t     f SWnG t k
 r d t	 f     f d     Y} | t     f <| SXd  S(   NR$   R%   s!   unexpected keyword argument(s) %st   WinFunctionTypec              s   e  Z  Z   Z  Z RS(    (   R'   R(   R)   R*   R+   (    (   R,   R-   R.   (    s%   /usr/lib/python2.7/ctypes/__init__.pyR=      s   (
   t   _FUNCFLAG_STDCALLR0   R1   R2   R3   R4   R5   t   _win_functype_cacheR7   R8   (   R,   R-   R9   R=   (    (   R,   R-   R.   s%   /usr/lib/python2.7/ctypes/__init__.pyt   WINFUNCTYPEw   s    "R:   R@   (   t   dlopen(   t   sizeoft   byreft	   addressoft	   alignmentt   resize(   t	   get_errnot	   set_errno(   t   _SimpleCDatac         C   sm   d d l  m } | d  k r( |  j } n  t |   | |  } } | | k ri t d |  | | f   n  d  S(   Ni(   R	   s"   sizeof(%s) wrong: %d instead of %d(   t   structR	   R   t   _type_RB   t   SystemError(   t   typt   typecodeR	   t   actualt   required(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   _check_size   s    t	   py_objectc           B   s   e  Z d  Z d   Z RS(   t   Oc         C   s=   y t  t |   j   SWn t k
 r8 d t |   j SXd  S(   Ns
   %s(<NULL>)(   t   superRR   t   __repr__R4   t   typeR'   (   t   self(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRU      s    (   R'   R(   RK   RU   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRR      s   t   Pt   c_shortc           B   s   e  Z d  Z RS(   t   h(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRY      s   t   c_ushortc           B   s   e  Z d  Z RS(   t   H(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR[      s   t   c_longc           B   s   e  Z d  Z RS(   t   l(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR]      s   t   c_ulongc           B   s   e  Z d  Z RS(   t   L(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR_      s   t   iR^   t   c_intc           B   s   e  Z d  Z RS(   Ra   (   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRb      s   t   c_uintc           B   s   e  Z d  Z RS(   t   I(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRc      s   t   c_floatc           B   s   e  Z d  Z RS(   t   f(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRe      s   t   c_doublec           B   s   e  Z d  Z RS(   t   d(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRg      s   t   c_longdoublec           B   s   e  Z d  Z RS(   t   g(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRi      s   t   qt
   c_longlongc           B   s   e  Z d  Z RS(   Rk   (   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRl      s   t   c_ulonglongc           B   s   e  Z d  Z RS(   t   Q(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRm      s   t   c_ubytec           B   s   e  Z d  Z RS(   t   B(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRo      s   t   c_bytec           B   s   e  Z d  Z RS(   t   b(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRq      s   R   c           B   s   e  Z d  Z RS(   t   c(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR      s   t   c_char_pc           B   s2   e  Z d  Z e j d k r' d   Z n	 d   Z RS(   t   zR
   c         C   sL   t  j j |  d  s, d |  j j |  j f Sd |  j j t |  t  j f S(   Nis   %s(%r)s   %s(%s)(   t   windllt   kernel32t   IsBadStringPtrAt	   __class__R'   R   t   castt   c_void_p(   RW   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRU      s    c         C   s    d |  j  j t |  t  j f S(   Ns   %s(%s)(   Ry   R'   Rz   R{   R   (   RW   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRU      s    (   R'   R(   RK   t   _ost   nameRU   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRt      s   R{   c           B   s   e  Z d  Z RS(   RX   (   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR{      s   t   c_boolc           B   s   e  Z d  Z RS(   t   ?(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR~     s   (   t   POINTERt   pointert   _pointer_type_cache(   t   set_conversion_modet   mbcst   ignoret   asciit   strictt	   c_wchar_pc           B   s   e  Z d  Z RS(   t   Z(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   t   c_wcharc           B   s   e  Z d  Z RS(   t   u(   R'   R(   RK   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   c         C   s   t  |  t t f  rT | d k r4 t |   d } n  t | } |   } |  | _ | St  |  t t f  r t |  } |   } | St	 |    d S(   s   create_unicode_buffer(aString) -> character array
        create_unicode_buffer(anInteger) -> character array
        create_unicode_buffer(aString, anInteger) -> character array
        i   N(
   R   R   R   R   R   R   R   R   R   R   (   R   R   R    R!   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   create_unicode_buffer  s    
		
	c         C   sp   t  j | d   d  k	 r' t d   n  t |   t  k rH t d   n  |  j |  |  t  | <t  t |   =d  S(   Ns%   This type already exists in the caches   What's this???(   R   t   getR   t   RuntimeErrort   idt   set_type(   R   t   cls(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   SetPointerType0  s    
c         C   s   |  | S(   N(    (   RM   R   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   ARRAY:  s    t   CDLLc           B   sJ   e  Z d  Z e Z e Z e d e	 e	 d  Z
 d   Z d   Z d   Z RS(   s  An instance of this class represents a loaded dll/shared
    library, exporting functions using the standard C calling
    convention (named 'cdecl' on Windows).

    The exported functions can be accessed as attributes, or by
    indexing with the function name.  Examples:

    <obj>.qsort -> callable object
    <obj>['qsort'] -> callable object

    Calling the functions releases the Python GIL during the call and
    reacquires it afterwards.
    c            s   |   _    j  | r%  t O n  | r8  t O n  d t f    f d     Y} |   _ | d  k r t   j  |    _ n	 |   _ d  S(   Nt   _FuncPtrc              s   e  Z   Z  j Z RS(    (   R'   R(   R+   t   _func_restype_R*   (    (   R.   RW   (    s%   /usr/lib/python2.7/ctypes/__init__.pyR   [  s   (	   t   _namet   _func_flags_R2   R3   R8   R   R   t   _dlopent   _handle(   RW   R}   t   modet   handleR$   R%   R   (    (   RW   R.   s%   /usr/lib/python2.7/ctypes/__init__.pyt   __init__Q  s    			c         C   sD   d |  j  j |  j |  j t j d d @t |   t j d d @f S(   Ns   <%s '%s', handle %x at %x>i   i   (   Ry   R'   R   R   t   _syst   maxintR   (   RW   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRU   e  s    c         C   sP   | j  d  r- | j d  r- t |   n  |  j |  } t |  | |  | S(   Nt   __(   t
   startswitht   endswitht   AttributeErrort   __getitem__t   setattr(   RW   R}   t   func(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   __getattr__k  s
    c         C   s:   |  j  | |  f  } t | t t f  s6 | | _ n  | S(   N(   R   R   R   R   R'   (   RW   t   name_or_ordinalR   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR   r  s    N(   R'   R(   t   __doc__R/   R   Rb   R   t   DEFAULT_MODER   R1   R   RU   R   R   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR   @  s   		t   PyDLLc           B   s   e  Z d  Z e e BZ RS(   s   This class represents the Python library itself.  It allows to
    access Python API functions.  The GIL is not released, and
    Python exceptions are handled correctly.
    (   R'   R(   R   R/   t   _FUNCFLAG_PYTHONAPIR   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR   x  s   t   WinDLLc           B   s   e  Z d  Z e Z RS(   sn   This class represents a dll exporting functions using the
        Windows stdcall calling convention.
        (   R'   R(   R   R>   R   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   (   t   _check_HRESULTRI   t   HRESULTc           B   s   e  Z d  Z e Z RS(   R^   (   R'   R(   RK   R   t   _check_retval_(    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   
t   OleDLLc           B   s   e  Z d  Z e Z e Z RS(   s   This class represents a dll exporting functions using the
        Windows stdcall calling convention, and returning HRESULT.
        HRESULT error values are automatically raised as WindowsError
        exceptions.
        (   R'   R(   R   R>   R   R   R   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   t   LibraryLoaderc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   _dlltype(   RW   t   dlltype(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s    c         C   sB   | d d k r t  |   n  |  j |  } t |  | |  | S(   Ni    t   _(   R   R   R   (   RW   R}   t   dll(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s
    c         C   s   t  |  |  S(   N(   t   getattr(   RW   R}   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s    c         C   s   |  j  |  S(   N(   R   (   RW   R}   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR;     s    (   R'   R(   R   R   R   R;   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s   			s
   python dllt   cygwins   libpython%d.%d.dll(   t   get_last_errort   set_last_errorc         C   sF   |  d  k r t   }  n  | d  k r9 t |   j   } n  t |  |  S(   N(   R   t   GetLastErrorR   t   stript   WindowsError(   t   codet   descr(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   WinError  s
    (   t   _memmove_addrt   _memset_addrt   _string_at_addrt
   _cast_addrc            s#   d t  f    f d     Y} | S(   NR&   c              s   e  Z  Z   Z e e BZ RS(    (   R'   R(   R)   R*   R/   R   R+   (    (   R,   R-   (    s%   /usr/lib/python2.7/ctypes/__init__.pyR&     s   (   R8   (   R,   R-   R&   (    (   R,   R-   s%   /usr/lib/python2.7/ctypes/__init__.pyt
   PYFUNCTYPE  s    c         C   s   t  |  |  |  S(   N(   t   _cast(   t   objRM   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyRz     s    c         C   s   t  |  |  S(   sA   string_at(addr[, size]) -> string

    Return the string at addr.(   t
   _string_at(   t   ptrR   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt	   string_at  s    (   t   _wstring_at_addrc         C   s   t  |  |  S(   sF   wstring_at(addr[, size]) -> string

        Return the string at addr.(   t   _wstring_at(   R   R   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt
   wstring_at  s    c         C   sN   y" t  d t   t   d g  } Wn t k
 r6 d SX| j |  | |  Sd  S(   Ns   comtypes.server.inprocservert   *i(   t
   __import__t   globalst   localst   ImportErrort   DllGetClassObject(   t   rclsidt   riidt   ppvt   ccom(    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s
    "c          C   sA   y" t  d t   t   d g  }  Wn t k
 r6 d SX|  j   S(   Ns   comtypes.server.inprocserverR   i    (   R   R   R   R   t   DllCanUnloadNow(   R   (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyR     s
    "(   t   BigEndianStructuret   LittleEndianStructurei   c           C   s   d  S(   N(   R   (    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   <lambda>%  s    (   s   ntR   (   s   ntR   (   s   ntR   (   s   ntR   (   s   ntR   (   s   ntR   (   s   ntR   (   R   t   osR|   t   sysR   R   t   _ctypesR    R   R   R   R   R8   t   _ctypes_versionR   R   R   RJ   R	   t	   _calcsizet	   ExceptionR}   R   R   t   platformR   t   unamet   splitR   R/   R   R   R   R2   R   R3   R   R"   R#   R6   R:   R;   R   R<   R>   R?   R@   t   replaceRA   RB   RC   RD   RE   RF   RG   RH   RI   RQ   RR   RY   R[   R]   R_   Rb   Rc   Re   Rg   Ri   Rl   Rm   Ro   t   __ctype_le__t   __ctype_be__Rq   R   Rt   R{   t   c_voidpR~   R   R   R   R   R   R   R   t
   from_paramR   R   R   t   objectR   R   R   R   R   R   R   t   cdllt   pydllt	   dllhandlet	   pythonapit   version_infoRv   t   oledllRw   R   t   coredllR   R   R   t   c_size_tt	   c_ssize_tR   R   R   R   t   memmovet   memsetR   R   Rz   R   R   R   R   R   R   R   t   ctypes._endianR   R   t   c_int8t   c_uint8t   kindt   c_int16t   c_int32t   c_int64t   c_uint16t   c_uint32t   c_uint64(    (    (    s%   /usr/lib/python2.7/ctypes/__init__.pyt   <module>   sN  )"	!			(



	



		






	
	8	
			"			 	 	  	 	 