
    3j                        S r SSKrSSKrSSKJr  SSKJrJrJr  SSKJr  SSK	J
r
Jr  SSKr\R                  " S5      rSSKJr  Sr\R"                  (       a   SS	KJr  SS
KJr  SSKJrJrJr  \cC  S r " S S\R8                  5      r " S S\R8                  5      r " S S\R:                  5      rO\" S5      r\R<                  (       d  SS jrOSS jr\R@                  (       d  \r!O\(       a  \r!OS r!\R<                  (       d  S r"OS r" " S S\#5      r$SS jr%S r&g! \ a  r\R5                  S5         SrCNSrCff = f)zHelper functions for wrapping array-using operations

These are functions intended to be used in wrapping
GL functions that deal with OpenGL array data-types.
    N)_configflags)contextdataerror
converters)arraydatatype)bytesunicodezOpenGL.arrays.arrayhelpers)acceleratesupport)AsArrayTypedSizeChecked)returnPyArgumentIndex)AsArrayOfTypeAsArrayTypedAsArrayTypedSizez>Unable to load arrayhelpers accelerator from OpenGL_acceleratec                     US   $ )zgReturn the converted object as result of function

Note: this is a hack that always returns pyArgs[0]!
r    )resultbaseOperationpyArgscArgss       T/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/arrays/arrayhelpers.pyreturnPointerr       s     ay    c                   0    \ rS rSrSrSrSrSS jrS rSr	g)	r   ,   zGiven arrayName and typeName coerce arrayName to array of type typeName

TODO: It should be possible to drop this if ERROR_ON_COPY,
as array inputs always have to be the final objects in that
case.
	arrayNametypeName)
arrayIndexr   
pyArgIndex)	typeIndexr   r    c                     Xl         X l        g Nr   )selfr   r   s      r   __init__AsArrayOfType.__init__:   s    &N$Mr   c                 f    X0R                      n[        R                  U   nUR                  U5      $ z/Get the arg as an array of the appropriate type)r!   r   GL_CONSTANT_TO_ARRAY_TYPEasArray)r$   argwrappedOperationargstype	arrayTypes         r   __call__AsArrayOfType.__call__>   s/    'D%??EI$$S))r   N)pointerr.   
__name__
__module____qualname____firstlineno____doc__argNamesindexLookupsr%   r0   __static_attributes__r   r   r   r   r   ,   s    	 -

	%	*r   r   c                   0    \ rS rSrSrSrSrSS jrS rSr	g)	r   D   zGiven arrayName and arrayType, convert arrayName to array of type

TODO: It should be possible to drop this if ERROR_ON_COPY,
as array inputs always have to be the final objects in that
case.
r   r/   r   Nc                     Xl         X l        g r#   r>   r$   r   r/   s      r   r%   AsArrayTyped.__init__O       &N&Nr   c                 8    U R                   R                  U5      $ r(   )r/   r*   )r$   r+   r,   r-   s       r   r0   AsArrayTyped.__call__S   s    >>))#..r   r2   Nr3   r   r   r   r   r   D   s    	 .C	'	/r   r   c                   0    \ rS rSrSrSrSrSS jrS rSr	g)	r   W   z:Given arrayName and arrayType, determine size of arrayNamer>   r?   Nc                     Xl         X l        g r#   r>   rA   s      r   r%   AsArrayTypedSize.__init__]   rC   r   c                 P    U R                   R                  XR                     5      $ r(   )r/   	arraySizer   )r$   r   indexr,   s       r   r0   AsArrayTypedSize.__call__a   s    >>++F??,CDDr   rF   r3   r   r   r   r   r   W   s    H-C	'	Er   r   c                 B    [         R                  " U R                  5      $ )z9Create PyConverter to get first argument as array of type)r   CallFuncPyConverterr*   typsizes     r   asArrayTyperT   j   s    --ckk::r   c                     g)zNo converter requiredNr   rQ   s     r   rT   rT   p       r   c                 z   ^ ^^ T R                   m[        R                  " T R                  5      U-  mUUU 4S jnU$ )zuCreate PyConverter function to get array as type and check size

Produces a raw function, not a PyConverter instance
c                    > TR                  U 5      nUR                  U T5      nUR                  U5      nUT:w  a  [        ST< SU< S3U 5      eU$ )Nz	Expected z byte array, got z byte array)
getHandlerr*   arrayByteCount
ValueError)	incomingfunctionr-   handlerr   byteSizedataTypeexpectedBytesrR   s	         r   asArraySize$asArrayTypeSize.<locals>.asArraySize   s_    ..2 8<"11&9},$ *$
 !  r   )typeConstantctypessizeofbaseType)rR   rS   rb   r`   ra   s   `  @@r   asArrayTypeSizerh   |   s4     ''H"MM#,,7$>M  r   c                  N    SSK Jn   [        R                  " U R                  5      $ )z=Create PyConverter returning incoming as an array of any typer   ArrayDatatype)OpenGL.arraysrk   r   rP   r*   rj   s    r   asVoidArrayrm      s    /--m.C.CDDr   c                      g)z9If there's no copying allowed, we can use default passingNr   r   r   r   rm   rm      rV   r   c                   *    \ rS rSrSrS rS rS rSrg)storePointerType   aJ  Store named pointer value in context indexed by constant

pointerName -- named pointer argument
constant -- constant used to index in the context storage

Note: OpenGL.STORE_POINTERS can be set with ERROR_ON_COPY
to ignore this storage operation.

Stores the pyArgs (i.e. result of pyConverters) for the named
pointer argument...
c                     Xl         X l        g r#   )pointerNameconstant)r$   rs   rt   s      r   r%   storePointerType.__init__   s    & r   c                 D    UR                  U R                  5      U l        g r#   )r    rs   pointerIndex)r$   wrappers     r   finalisestorePointerType.finalise   s    #..t/?/?@r   c                 ^    [         R                  " U R                  X0R                     5        g r#   )r   setValuert   rw   )r$   r   r   r   r   s        r   r0   storePointerType.__call__   s    T]]F3D3D,EFr   )rt   rw   rs   N)	r4   r5   r6   r7   r8   r%   ry   r0   r;   r   r   r   rp   rp      s    
!AGr   rp   c                 N    SSK Jn  UR                  U 5      R                  X15      $ )a  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.
r   )rx   )OpenGLrx   setInputArraySize)r   rS   r.   argNamerx   s        r   setInputArraySizeTyper      s!     ??=);;GJJr   c                 0   ^^ U R                   mUU4S jnU$ )Nc                 (   > U S   nUc  T$ T" U5      $ )z+Return the array size of the first argumentr   r   )r   rM   r   arraydefaultunitSizes       r   arraySizeOfFirst.arraySizeOfFirstType.<locals>.arraySizeOfFirst   s     q	=NE?"r   )r   )rR   r   r   r   s    ` @r   arraySizeOfFirstTyper      s    ||H# r   r#   )r   )'r8   r   re   r   r   r   r   rl   r   OpenGL._bytesr   r	   logging	getLogger_logr
   r   ACCELERATE_AVAILABLEOpenGL_accelerate.arraydatatypeOpenGL_accelerate.wrapperr   r   r   r   ImportErrorerrwarningr   PyConverter
CConverterERROR_ON_COPYrT   ARRAY_SIZE_CHECKINGrh   rm   objectrp   r   r   r   r   r   <module>r      s2      1 1 ' ( 56 $ ))	WKC	
 	
 "
*
.. *0/z-- /&E:00 E *!,M!!;
 ''!O1	: !!E
Gv G0K i  WUVVWs   D& &E,EE