
    _ez$                       d Z ddlZddlZddlmZmZ esJ ddlmZmZ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mZ dd
lmZ  ej,                  d      ZddlmZ dZej4                  r	 ddlmZ ddlmZmZmZm Z m!Z! esesej                  d       dZd Z%d Z&de&_'         G d de      Z G d de(      Z!d Z)y# e"$ rZ#ejI                  d       Y dZ#[#YdZ#[#ww xY w)zEThe wrapping code for providing natural ctypes-based OpenGL interface    N)platformerror)STORE_POINTERSERROR_ON_COPYSIZE_1_ARRAY_UNPACK)
converters)DefaultCConverter)returnCArgumentreturnPyArgument)LateBind)arrayhelpersarraydatatype)NULLzOpenGL.wrapper)acceleratesupport)WrapperCArgCalculatorPyArgCalculatorCArgumentCalculatorMultiReturnz\OpenGL_accelerate seems to be installed, but unable to import expected wrapper entry points!zYou've specified (not STORE_POINTERS) yet ERROR_ON_COPY is False, this would cause segfaults, so (not STORE_POINTERS) is being ignoredTc                 <    t        | t              st        |       S | S )z$Convert to a list if not already one)
isinstancelist)os    0/usr/lib/python3/dist-packages/OpenGL/wrapper.pyasListr   #   s    q$ AwH    c                     | S N )incomingfunction	argumentss      r   none_or_passr#   )   s    Or   c                        e Zd ZdZdZd Zd Zd ZeZ fdZ	d Z
d Zd	d
d
edfdZd ZesddZnddZefdZd ZefdZefdZefdZd Zd Zd Z xZS )r   a  Wrapper around a ctypes cFunction object providing SWIG-like hooks

    Attributes:

        wrappedOperation -- base operation, normally a ctypes function
            with data-types and error-checking specified
        pyConverters -- converters for incoming Python arguments,
            provide 1:1 mapping to incoming Python arguments, can
            suppress an argument from the argument-set as well
                see setPyConverter
        pyConverterNames -- caching/storage of the argument names
            for the Python converters
        cConverters -- converters for incoming C-level arguments
            produce Python-level objects in 1:1 mapping to ctypes
            arguments from pyConverters results
                see setCConverter
        cResolvers -- converters turning Python-level objects into
            ctypes-compatible data-types
                see setCResolver

    Generic Attributes:

        {ARG1}_LOOKUP_{ARG2} -- lookup dictionaries to provide sizes for
            ARG1 output value from the value of ARG2, provided for
            documentation/reference
        {ARG1}_FROM_{ARG2} -- lookup functions to provide sizes for ARG1
            output value from the value of ARG2, provided for
            documentation/reference
    )	wrappedOperation__file__pyConverterspyConverterNamescConverters
cResolversstoreValuesreturnValues
_finalCallc                 J    t        |t              r|j                  }|| _        y)z0Initialise the wrapper, storing wrappedOperationN)r   r   r%   )selfr%   s     r   __init__zWrapper.__init__V   s!    '2/@@ 0r   c                 N    |dk7  rt        | j                  |      S t        |      )z1Delegate attribute lookup to our wrappedOperationr%   )getattrr%   AttributeError)r/   keys     r   __getattr__zWrapper.__getattr__[   s)    $$D11388c##r   c                 ,    t        | j                        S )z#Is this function/wrapper available?)boolr%   )r/   s    r   __nonzero__zWrapper.__nonzero__`   s    T**,,r   c                 x    || j                   v rt        t        |   ||       yt	        | j
                  ||      S )z1Forward attribute setting to our wrappedOperationN)localPropertiessuperr   __setattr__setattrr%   )r/   r4   value	__class__s      r   r<   zWrapper.__setattr__d   s7    $&&&7D.U<D113??r   c                     t        | dd      }|| j                  j                  }	 t        |      j	                  |      S # t
        t        f$ r t        d|d|      w xY w)z<Return the Python-argument index for the given argument namer(   NNo argument  in argument list )r2   r%   argNamesr   index
ValueError
IndexErrorKeyErrorr/   argNamerC   s      r   
pyArgIndexzWrapper.pyArgIndexj   sn    D"4d<,,55H	8%++W66:& 	  	s   A !A"c                     | j                   j                  }	 t        |      j                  |      S # t        t
        f$ r t        d|d|      w xY w)z7Return the C-argument index for the given argument namerA   rB   )r%   rC   r   rD   rE   rF   rG   rH   s      r   	cArgIndexzWrapper.cArgIndexu   sY    ((11	8%++W66:& 	  	s	   2 !A)   NFc                 R   |z| j                  |      }| j                  j                  |   }t        |d      sD|t        j
                  k(  r	ddlm} |}n(t        d|d| j                  j                  d|      |=t        |d      rJ |rt        j                  }	nt        j                  }	 |	|||      }
n~t        |t              rt        | |d	||       |j                   }nt        | |d
||       t        |d      sJ |rt        j"                  }	nt        j$                  }	 |	||||      }
|r|
j&                  }nt        j(                  |      }|r| j+                  |t,               n| j+                  |       | j/                  ||
      j1                  |      S )a1  Set the given argName to be an output array

        size -- either a tuple compatible with arrayType.zeros or
            a function taking pname to produce such a value.
        arrayType -- array data-type used to generate the output
            array using the zeros class method...
        pnameArg -- optional argument passed into size function, that
            is, the name of the argument whose *value* will be passed
            to the size function, often the name of an input argument
            to be "sized" to match the output argument.
        asArrayr   )GLubyteArrayz3Should only have array types for output parameters  on z is __call__)namesize	arrayType_LOOKUP__FROM_)rS   	specifierlookuprU   )rL   r%   argtypeshasattrctypesc_void_pOpenGL.arraysrP   	TypeError__name__r   OutputOrInputOutputr   dictr=   __getitem__SizedOutputOrInputSizedOutputoldStyleReturnr
   setPyConverterr#   setCConvertersetReturnValues)r/   outArgrT   pnameArgrU   rg   orPassInrD   rP   clsconvreturnObjects               r   	setOutputzWrapper.setOutput~   s     NNF,E--66?IIy2/: ,I# 5 5 > >	&   tJ000 .. ''#D 4'vh?G''VH=tED*... 33 ,,"#	D ..L%55v?L )!!D

/
	
r   c                 V    | j                  |      }| j                  j                  |   S )z:Retrieve the defined data-type for the given outArg (name))rL   r%   rZ   )r/   rk   rD   s      r   	typeOfArgzWrapper.typeOfArg   s'    ($$--u66r   c                 x   | j                  |      }t        |d      s|t        j                  k(  rd| j	                  |t        j                  t        j                  j                               | j                  |t        j                  |             | S t        |d      rt        |j                  d      r| S t        d|      |'| j	                  |t        j                  ||             n%| j	                  |t        j                   |             | j                  |t        j                  |             | S )   Decorate function with vector-handling code for a single argument
            
            if OpenGL.ERROR_ON_COPY is False, then we return the 
            named argument, converting to the passed array type,
            optionally checking that the array matches size.
            
            if OpenGL.ERROR_ON_COPY is True, then we will dramatically 
            simplify this function, only wrapping if size is True, i.e.
            only wrapping if we intend to do a size check on the array.
            rO   _type_z8Should only have array types for output parameters: got )rs   r[   r\   r]   rh   r   CallFuncPyConverterr   ArrayDatatyperO   ri   getPyArgsNamerv   r_   r   asArrayTypeSizeasArrayTyper/   rI   rT   rU   s       r   setInputArraySizezWrapper.setInputArraySize   s    1IIy2/''"668S8S8[8[] &&1I1I71TVKi3	@P@PRZ8\  K#cl%npp##Wl.J.J9VZ.[]##Wl.F.Fy.QS)A)A7)LNKr   c                     |h| j                  |      }t        |d      rK| j                  |t        j                  ||             | j                  |t        j                  |             | S )ru   rO   )rs   r[   rh   r   rz   ri   r   ry   r|   s       r   r}   zWrapper.setInputArraySize   se      NNG5	Iy2'',2N2NyZ^2_a&&"00'; Kr   c           	         t        | d      sLdgt        | j                  j                        z  | _        t        | j                  j                        | _        	 t        | j                        j                  |      }|t        u r| j                  |= | j                  |= | S || j                  |<   | S # t        $ r3 t        d|d| j                  j                  d| j                        w xY w)a  Set Python-argument converter for given argument

        argName -- the argument name which will be coerced to a usable internal
            format using the function provided.
        function -- None (indicating a simple copy), NULL (default) to eliminate
            the argument from the Python argument-list, or a callable object with
            the signature:

                converter(arg, wrappedOperation, args)

            where arg is the particular argument on which the convert is working,
            wrappedOperation is the underlying wrapper, and args is the set of
            original Python arguments to the function.

        Note that you need exactly the same number of pyConverters as Python
        arguments.
        r'   NNo argument named z left in pyConverters for : )r[   lenr%   rC   r'   r   r(   r   rD   rE   r3   r`   r   r/   rI   r!   is       r   rh   zWrapper.setPyConverter  s    $ n.!%sD,A,A,J,J'L LD$()>)>)G)G$HD!	--/55w@A
 t!!!$%%a(  $,Da   	 ..779N9N#  	s   $B3 3<C/c                 F   t        | d      s(dgt        | j                  j                        z  | _        	 t        | j                  j                  t              s.t        | j                  j                        | j                  _        t        | j                  j                        j                  |      }| j                  |   t        d|d| j                        || j                  |<   | S # t        $ r& t        d|d| j                  j                        w xY w)a  Set C-argument converter for a given argument

        argName -- the argument name whose C-compatible representation will
            be calculated with the passed function.
        function -- None (indicating a simple copy), a non-callable object to
            be copied into the result-list itself, or a callable object with
            the signature:

                converter( pyArgs, index, wrappedOperation )

            where pyArgs is the set of passed Python arguments, with the
            pyConverters already applied, index is the index of the C argument
            and wrappedOperation is the underlying function.

        C-argument converters are your chance to expand/contract a Python
        argument list (pyArgs) to match the number of arguments expected by
        the ctypes baseOperation.  You can't have a "null" C-argument converter,
        as *something* has to be passed to the C-level function in the
        parameter.
        r)   Nr    left in cConverters: z%Double wrapping of output parameter: rQ   )r[   r   r%   rC   r)   r   r   r   rD   rE   r3   RuntimeErrorr`   r   s       r   ri   zWrapper.setCConverter#  s   * m- $vc4+@+@+I+I&KKD	d33<<dC15t7L7L7U7U1W%%.--668>>IA
 A*    '  	 ..77#  	s   B C1 1/D c                     t        | d      s(dgt        | j                  j                        z  | _        	 t        | j                  j                  t              s.t        | j                  j                        | j                  _        t        | j                  j                        j                  |      }|t        u r| j                  |= | S || j                  |<   | S # t        $ r& t        d|d| j                  j                        w xY w)z-Set C-argument converter for a given argumentr*   Nr   r   )r[   r   r%   rC   r*   r   r   r   rD   rE   r3   r   r   s       r   setCResolverzWrapper.setCResolverH  s    l,#fS$*?*?*H*H%JJDO	d33<<dC15t7L7L7U7U1W%%.--667==wHA
 t"  "*DOOA  	 ..77#  	s   B C /Dc                 f    |t         u st        rt        s	 | `| S || _        | S # t        $ r Y | S w xY w)z;Set the storage-of-arguments function for the whole wrapper)r   r   r   r+   	Exceptionr/   r!   s     r   setStoreValueszWrapper.setStoreValuesY  sJ    t}^$
   (D	   	s   # 	00c                    |t         u r	 | `| S t        | d      rTt	        | j                  t
              r| j                  j                  |       | S t        | j                  |      | _        | S || _        | S # t        $ r Y | S w xY w)z8Set the return-of-results function for the whole wrapperr,   )r   r,   r   r[   r   r   appendr   s     r   rj   zWrapper.setReturnValuesc  s    t%  tN+d//<%%,,h8
  )4T5F5F(RD%  %-!   s   A7 7	BBc                    dD ]D  }t        | |d      }|t        |      D ]$  \  }}t        |d      s	 |j                  |        & F t        | d	      rmt        | j                        D ]U  \  }}t        |t        d      t        f      s"t        | j                  | j                  |               | j                  |<   W d
D ]-  }t        | |d      }t        |d      s|j                  |        / | j                         }|st        d|       | j                  |       |S # t        $ r)}t        j                  d|d|d| d|d|
      d}~ww xY w)z@Finalise our various elements into simple index-based operations)r'   r)   r*   NfinalisezError finalising item z in z for z (z): r)   )r+   r,   z Missing finalised call type for )r2   	enumerater[   r   r   r   Errorr)   r   typer	   rJ   rC   finaliseCallr   setFinalCall)r/   	attributer>   r   itemerr	convertercallFunctions           r   r   zWrapper.finaliset  s_   E 	IT9d4E '. 	FAdj2 MM41		 D-)($*:*:< b)y4:6G*IJ*;T__dmm\]N^=_*aD$$Q'b 9 	&ID)T3Dj*t%	& ((*4 RSS |-3  ) "'++$%iT#!"# s   D((	E1$EEc           
         	
 t         dd      }t         dd      t         dd      } j                  t         dd      t         dd      |rft        rt         |      nUt	        |      D cg c]  \  }}|||du f c}}t        |D cg c]  }t        |dd      r| c}       fd	ndrEt        rt               
n4t	              D cg c]  \  }}||t        |d
      f c}} fd
nd
|r,t        rt        |      nt        t	        |            		fdndt        rt        
      S |rʉrh|r5rr
 fd}|S 
 fd}|S r
 fd}|S 
fd}|S rr
 fd}|S 
 fd}|S r
 fd}|S 
fd}|S |r1rr fd}|S  fd}|S r fd}|S fd}|S rr fd}|S  fd}|S r
 fd}|S fd}|S rb|r2rr fd}|S  fd}|S r fd }|S  fd!}|S rr fd"}|S  fd#}|S r
 fd$}|S  fd%}|S |r-rr fd&}|S  fd'}|S r
 fd(}|S fd)}|S rr
 fd*}|S  fd+}|S r	 fd,}|S fd-}|S c c}}w c c}w c c}}w ).a*  Produce specialised versions of call for finalised wrapper object

        This returns a version of __call__ that only does that work which is
        required by the particular wrapper object

        This is essentially a huge set of expanded nested functions, very
        inelegant...
        r'   Nr)   r*   r+   r,   optionalFc              3     K   t        |       kD  rEt        j                  dddj                  j                        dt        |       d| 	      D ]   \  }}}|r| |    	  || |   |        " y # t
        $ r}t         Y d }~:d }~wt        $ r(}t        |d      r|xj                  |fz  c_	         d }~ww xY ww)N
 requires  arguments (, ), received r   args)
r   rE   r`   joinr(   rF   r   r   r[   r   )	r   rD   r   isNoner   pyConverters_lengthpyConverters_mappedr/   r%   s	        r   calculate_pyArgsz.Wrapper.finaliseCall.<locals>.calculate_pyArgs  s     *SY6( 0 9 9 3 $		4+@+@ B #D	 $  3F &.i!"&u+-&&/UT4&H H& $. +&*
#, &#*C#9$'HH)$>H %&s<   A'C
+A=:C
=	CBC
C#CCC
rR   c              3      K   D ]  \  }}}|r	  || |       |  y # t         $ r.}t        |d      r|xj                  d|z  | |fz  c_         d }~ww xY ww)Nr   Failure in cConverter %r)r   r[   r   )pyArgsrD   r   canCallr   cConverters_mappedr/   s        r   calculate_cArgsz-Wrapper.finaliseCall.<locals>.calculate_cArgs  s}     3E ,/i"&&/&F F #,O, $- &#*C#9$'HH(F	(R(.t1& %&H !&&s$   A$A	A)AAAc              3      K   D ]  \  }}|| |    	  || |           y # t         $ r}|xj                  |fz  c_         d }~ww xY wwr   )r   r   )cArgsr   r   r   cResolvers_mappeds       r   calculate_cArgumentsz2Wrapper.finaliseCall.<locals>.calculate_cArguments  sa     '8 &)$,"'(N&&/q&; ;& $- & #YL 8 %&s$   A'A	AAAA)r   r   r   r+   r,   c                  R   t         |             }t         |            }t         |            }	  | } |
||        	|
||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY w$Wrapper with all possible operationsNtupler\   ArgumentErrorr   r   GLErrorr   r   )r   r   r   
cArgumentsresultr   r   r   r   r,   r/   r+   r%   s         r   wrapperCallz)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(-ov.G(H-23G3P-Q
!.-=
-LF !,$*$($*$)	!" (4$*$($*$)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s#   A B&$A;;B&B!!B&c                  @   t         |             }t         |            }t         |            }	  | } 
|	||       |S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY w"Wrapper with all save returnValuesNr   )r   r   r   r   r   r   r   r   r   r/   r+   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall   s    ).0@$0H)I(-ov.G(H-23G3P-Q
!.-=
-LF !,$*$($*$)	!" (. (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s#   A BA22BBBc                  <   t         |             }t         |            }t         |            }	  | } 	|
||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY w!Wrapper with all save storeValuesNr   )r   r   r   r   r   r   r   r   r   r,   r/   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall9  s    ).0@$0H)I(-ov.G(H-23G3P-Q
!.-=
-LF (4$*$($*$)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s#   A BA00BBBc                  *   t         |             }t         |            }t         |            }	  	| }|S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY w2Wrapper with all save returnValues and storeValuesNr   )
r   r   r   r   r   r   r   r   r   r%   s
         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallO  s    ).0@$0H)I(-ov.G(H-23G3P-Q
!.-=
-LF (. (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s!   = BA''B=BBc                  4   t         |             }t         |            }|}	  | } 
|	||        |	||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r,   r/   r+   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallc  s    ).0@$0H)I(-ov.G(H-2
!.-=
-LF !,$*$($*$)	!" (4$*$($*$)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.#   A BA,,BBBc                  "   t         |             }t         |            }|}	  
| } 	|||       |S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r/   r+   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(-ov.G(H-2
!.-=
-LF !,$*$($*$)	!" (. (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.!   9 BA##B9B		Bc                     t         |             }t         |            }|}	  
| } |	||      S # t        j                  $ r}|j                  |fz   |_         d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r,   r/   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(-ov.G(H-2
!.-=
-LF (4$*$($*$)	(" !" (.';'; !*/2xx:-/GCH$)',}} !.05CI17CJ*-I!.s!   7 B
A  B6BBc                  
   t         |             }t         |            }|}	  | }|S # t        j                  $ r}|j                  |fz   |_         d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r   r   r%   s	         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(-ov.G(H-2
!.-=
-LF (. (.';'; !*/2xx:-/GCH$)',}} !.05CI17CJ*-I!.s!   . BAB-A==Bc                  4   t         |             }|}t         |            }	  | } 
|	||        |	||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r,   r/   r+   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(.-23G3P-Q
!.-=
-LF !,$*$($*$)	!" (4$*$($*$)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.r   c                  "   t         |             }|}t         |            }	  
| } 	|||       |S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r/   r+   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(.-23G3P-Q
!.-=
-LF !,$*$($*$)	!" (. (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.r   c                     t         |             }|}t         |            }	  
| } |	||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r   r   r,   r/   r%   s         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(.-23G3P-Q
!.-=
-LF (4$*$($*$)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s!   7 B
A!!B7BBc                     t         |             }|}t         |            }	  | }|S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r   r   r%   s	         r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    ).0@$0H)I(.-23G3P-Q
!.-=
-LF (. (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s!   . BAB.A>>Bc                     t         |             }|}	  	| } |||        |||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )
r   r   r   r   r   r   r,   r/   r+   r%   s
        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall$  s    ).0@$0H)I-3
!.-=
-LF !,$*$($*$.	!" (4$*$($*$.	(" !" (.';'; !./2xx:-/GCH*-I',}} !.0:CI17CJ*-I!.!   1 BAB1BBc                      t         |             }|}	  | } |||       |S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r/   r+   r%   s	        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall@  s    ).0@$0H)I-3
!.-=
-LF !,$*$($*$.	!" (. (.';'; !./2xx:-/GCH*-I',}} !.0:CI17CJ*-I!.    ( A=AA=(A88A=c                      t         |             }|}	  | } |||      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r,   r/   r%   s	        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallX  s    ).0@$0H)I-3
!.-=
-LF (4$*$($*$.	(" !" (.';'; !./2xx:-/GCH*-I',}} !.0:CI17CJ*-I!.    & A;AA;&A66A;c                      t         |             }|}	  | }|S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        ||_        |d}~ww xY wr   r   )r   r   r   r   r   r   r%   s        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallm  s}    ).0@$0H)I-3
!.-=
-LF (. (.';'; !./2xx:-/GCH*-I',}} !.0:CI17CJ*-I!.     A2AA2A--A2c                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||             ? t         	|            }	  | } |||        
|||      S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_
        ||_        |d}~ww xY wr   rR   r   r   Nr   r[   r   r   r   r   r\   r   r   r   r   r   )r   r   r   rD   r   r   r   r   r)   r   r,   r/   r+   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s;   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .33G3P-Q
!.-=
-LF !,$*$($*$)	!" (4$*$($*$)	(" !"1 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A>#B7 >	B4(B//B47D
C!!D7DDc                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||
             ? t         	|            }	  | } |
||       |S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_
        ||_        |d}~ww xY wr   rR   r   r   Nr   )r   r   r   rD   r   r   r   r   r)   r   r/   r+   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s'   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .33G3P-Q
!.-=
-LF !,$*$($*$)	!" (.1 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A5#B. 5	B+>(B&&B+.DCD.C>>Dc                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||             ? t         	|            }	  | } 
|||      S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_
        ||_        |d}~ww xY wr   rR   r   r   Nr   )r   r   r   rD   r   r   r   r   r)   r   r,   r/   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s%   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .33G3P-Q
!.-=
-LF (4$*$($*$)	(" !"# 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A3#B, 3	B)<(B$$B),D?CD,C<<Dc                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||
             ? t         	|            }	  | }|S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_
        ||_        |d}~ww xY wr   rR   r   r   Nr   )r   r   r   rD   r   r   r   r   r)   r   r/   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .33G3P-Q
!.-=
-LF (.# 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A*#B# *	B 3(BB #C86CC8#C33C8c                      | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||
             ? |}	  | } |
||        	|
||      S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t
        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_	        ||_
        |d}~ww xY wr   r   r[   r   r   r   r\   r   r   r   r   r   )r   r   r   rD   r   r   r   r   r)   r,   r/   r+   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall"  s0   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .3
!.-=
-LF !,$*$($*$)	!" (4$*$($*$)	(" !"1 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A/B( /	B%8(B  B%(C=;CC=(C88C=c                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||	             ? |}	  | } 
|	||       |S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t
        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_	        ||_
        |d}~ww xY wr   r   )r   r   r   rD   r   r   r   r   r)   r/   r+   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallO  s   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .3
!.-=
-LF !,$*$($*$)	!" (.1 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A&B &	B/(BBC42C		C4C//C4c                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||
             ? |}	  | } 	|
||      S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t
        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_	        ||_
        |d}~ww xY wr   r   )r   r   r   rD   r   r   r   r   r)   r,   r/   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallx  s   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .3
!.-=
-LF (4$*$($*$)	(" !"# 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   A$B $	B-(BBC20CC2C--C2c                     | }g }t              D ]=  \  }}t        |d      s|j                  |       $	 |j                   |||	             ? |}	  
| }|S # t        $ r-}t        |d      r|xj                  d|z  ||fz  c_         d}~ww xY w# t
        j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_	        ||_
        |d}~ww xY wr   r   )r   r   r   rD   r   r   r   r   r)   r/   r%   s           r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s   )-(*9BK9Q !2$5U9+29Z+H(-i(A
)2,1LL0965$0P-.!2  .3
!.-=
-LF (.# 09 )2/6V/E034RT]4^4:E=2 12 -2)2 (.';'; !./2xx:-/GCH*-I',}} !.05CI17CJ*-I!.s;   AB 	B$(BBC)'B>>C)C$$C)c                     | }t         |            }	  	| } || |        || |      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        | |_        |d}~ww xY wr   r   )
r   r   r   r   r   r   r,   r/   r+   r%   s
        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    (,-23G3P-Q
!.-=
-LF !,$*$($($)	!" (4$*$($($)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI15CJ*-I!.r   c                      | }t         |            }	  | } || |       |S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        | |_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r/   r+   r%   s	        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    (,-23G3P-Q
!.-=
-LF !,$*$($($)	!" (. (.';'; !./2xx:-/GCH*-I',}} !.05CI15CJ*-I!.r   c                      | }t         |            }	  | } || |      S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        | |_        |d}~ww xY wr   r   )	r   r   r   r   r   r   r,   r/   r%   s	        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    (,-23G3P-Q
!.-=
-LF (4$*$($($)	(" !" (.';'; !./2xx:-/GCH*-I',}} !.05CI15CJ*-I!.r   c                      | }t         |            }	  | }|S # t        j                  $ r}|j                  |fz   |_        |d}~wt        j
                  $ r}||_        | |_        |d}~ww xY wr   r   )r   r   r   r   r   r   r%   s        r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s}    (,-23G3P-Q
!.-=
-LF (. (.';'; !./2xx:-/GCH*-I',}} !.05CI15CJ*-I!.r   c                      | }	  | } || |        || |      S # t         j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_        | |_        |d}~ww xY wr   r\   r   r   r   r   r   r   )r   r   r   r   r,   r/   r+   r%   s       r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall  s    -1
!.-=
-LF !,$*$($($.	!" (4$*$($($.	(" !" (.';'; !./2xx:-/GCH*-I',}} !.0:CI15CJ*-I!.s      A5A

A5 A00A5c                      | }	  | } || |       |S # t         j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_        | |_        |d}~ww xY wr   r   )r   r   r   r   r/   r+   r%   s       r   r   z)Wrapper.finaliseCall.<locals>.wrapperCall:  s    -1
!.-=
-LF !,$*$($($.	!" (. (.';'; !./2xx:-/GCH*-I',}} !.0:CI15CJ*-I!.s     A,AA,A''A,c                      | }	  | } || |      S # t         j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_        | |_        |d}~ww xY wr   r   )r   r   r   r   r,   r/   r%   s       r   r   z)Wrapper.finaliseCall.<locals>.wrapperCallQ  s    -1
!.-=
-LF (4$*$($($.	(" !" (.';'; !./2xx:-/GCH*-I',}} !.0:CI15CJ*-I!.s    A*?A*A%%A*c                      | }	  | }|S # t         j                  $ r}|j                  |fz   |_        |d}~wt        j                  $ r}||_        | |_        |d}~ww xY wr   r   )r   r   r   r   r%   s       r   r   z)Wrapper.finaliseCall.<locals>.wrapperCalle  sm    -1
!.-=
-LF (. (.';'; !./2xx:-/GCH*-I',}} !.0:CI15CJ*-I!.s    A!6A!AA!)
r2   r%   cWrapperr   r   r   r   r[   r   r   )r/   r'   r*   r   r   pr   r)   r   r   r   r   r   r   r   r,   r+   r%   s   `      @@@@@@@@@@@r   r   zWrapper.finaliseCall  s    nd<t]D:dL$8
00t]D:nd<#2$  *3L)B'%9 y)t"35'# '*l*i'STV`bgJh1*i&j#& &0  $"0$"E *3K)A&%9 y:!>?&", #O':J'H$$(:)>$?!	& $(  !1 /%9')  "'" "6 $/.. ., $/.'" "( $/.. $/. #'" "6 $/.. ., $/.'" "( $/.. $/. "'" "6 $/.. ., $/.'" "( $/.. $/. #'" "4 $/..* $/.'"& $/.. $/. "'*" *"V $/.%. %.L $/.'#" #"H $/..> $/. #'*" *"V $/.%.L $/.'#"H $/..> $/. "'" "4 $/..* $/.'"& $/.. $/. #'"2 $/..( $/.'"$ $/.. $/.K' +j<&s   =KK".K"'K'c                    t        | dd      }|rt        |      t        |      k7  rXt        | j                  j                  dt        |      ddj                  | j                        dt        |      d|	      g }t        ||      D ]2  \  }}||j                  |       |j                   ||| |             4 n|}t        | dd      }|rNg }t        |      D ]=  \  }}t        |d	      s|j                  |       $	 |j                   ||||              ? n|}t        | dd      }
|
rBg }t        |
|      D ]0  \  }}||j                  |       |j                   ||             2 n|}	  | j                  | }t        | dd      }| ||| ||       t        | dd      }| ||| ||      S |S # t        $ r.}	t        |	d
      r|	xj                  d|z  ||| fz  c_         d}	~	ww xY w# t        j                  $ r}	|	j                  |fz   |	_        |	d}	~	wt        j                   $ r}	||	_        ||	_        |	d}	~	ww xY w)zBExpand arguments, call the function, store values and check errorsr'   Nr   r   r   r   r   r)   rR   r   r   r*   r+   r,   )r2   r   rE   r%   r`   r   r(   zipr   r   r[   r   r   r\   r   r   r   r   r   )r/   r   r'   r   r   argr)   r   rD   r   r*   r   r>   r   r+   r,   s                   r   _unspecialised__call__zWrapper._unspecialised__call__z  s   nd<< CI- --66L)		4#8#8:D	  F#&|D#9 @3$MM3(MM9S$#=?	@ Ft]D:E%.%= !yy4LL)-
%vud<  EdL$8
J&):u&> <"E$%%u.%%y%'9;	< J	*T**Z9F t]D:"	 nd<#	  M] % "C1HH >	 J &t) H * ## 	xx:-/CHI}} 	CICJI	s<   F=8G7 =	G4)G//G47I
H!!I7IIr   )r`   
__module____qualname____doc__r:   r0   r5   r8   __bool__r<   rJ   rL   r   rq   rs   r   r}   r   rh   ri   r   r   rj   r   r   r   __classcell__)r?   s   @r   r   r   -   s    :
O1
$
- H@
  $':F
N7
  	D	* 37  B$J /3 " (, 	 )- "" HZ/DOr   r   c                       e Zd Zd Zd Zd Zy)r   c                 $    t        |      | _        y r   )r   children)r/   r   s     r   r0   zMultiReturn.__init__  s    Xr   c                 :    | j                   j                  |       y r   )r   r   )r/   childs     r   r   zMultiReturn.append  s    e%r   c                     g }| j                   D ]  }	 |j                   ||i |        |S # t        $ r}|xj                  |||fz  c_         d }~ww xY wr   )r   r   r   r   )r/   r   namedr   r   r   s         r   rR   zMultiReturn.__call__  sf    ]] 	Eud3U35	   eT522s   .	AAAN)r`   r   r   r0   r   rR   r   r   r   r   r     s    '&r   r   c                     t        | t              r| S | j                  dd}t        | j                  t        f|      }t        | d      r| j                  |_         ||       }|S )a|  Create a Wrapper sub-class instance for the given wrappedOperation

    The purpose of this function is to create a subclass of Wrapper which
    has the __doc__ and __name__ of the wrappedOperation so that the instance of
    the wrapper will show up as <functionname instance @ address> by default,
    and will have the docstring available naturally in pydoc and the like.
    )r%   )r   	__slots__r   )r   r   r   r   r`   r[   r   )r%   rc   rn   instances       r   wrapperr    si     #W.#+++D  ))G:t
=C ,0)44#$HOr   )*r   r\   loggingOpenGLr   r   OpenGL._configflagsr   r   r   r   OpenGL.convertersr	   r
   r   OpenGL.latebindr   r^   r   r   OpenGL._nullr   	getLogger_logr   r   ACCELERATE_AVAILABLEOpenGL_accelerate.latebindOpenGL_accelerate.wrapperr   r   r   r   r   ImportErrorr   warningr   r#   r   objectr  r   r   r   <module>r     s    K  "x R R  / > $ 5 w*, $))
{7	
 	
 

  a  	c \x \|,& A.  {xzz{s   0C C"CC"