
    3j                        S r SrSSKrSSKrSSKJr  SSKJr  SSK	J
r
Jr  SSKJr  SSKJr  SS	KJrJrJr  \\4rSSKrS
 r " S S\R0                  5      r\R4                  \R6                  \R8                  \R:                  \R<                  \R>                  \R@                  \RB                  \RD                  \RF                  \RH                  \RJ                  \RL                  \RN                  \RP                  \RR                  \RT                  \RV                  0	r,0 \R6                  \R4                  _\R:                  \R8                  _\R>                  \R<                  _\RB                  \R@                  _\RF                  \RD                  _\RJ                  \RH                  _\RN                  \RL                  _\RR                  \RP                  _\RV                  \RT                  _S\R8                  _S\R4                  _S\R<                  _S\R@                  _S\RD                  _S\RH                  _S\RP                  _S\RT                  _S\RL                  0Er-g)a  Lists/tuples as data-format for storage

Note:
    This implementation is *far* less efficient than using Numpy
    to support lists/tuples, as the code here is all available in
    C-level code there.  This implementation is required to allow
    for usage without numpy installed.
lists    N)_types)_arrayconstants)constanterror)ERROR_ON_COPY)formathandler)bytesunicodeas_8_bitc                 J    [         (       d  U $ S n[        U SS5      Ul        U$ )zNDecorator which raises informative error if we try to copy while ERROR_ON_COPYc                 ^    [         R                  " UR                  R                  < S35      e)Nz passed, cannot copy with ERROR_ON_COPY set, please use an array type which has native data-pointer support (e.g. numpy or ctypes arrays))r   	CopyError	__class____name__)selfvalueargsnameds       M/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/arrays/lists.pyraiseErrorOnCopy%err_on_copy.<locals>.raiseErrorOnCopy   s%    //??++.     r   r   )r   getattrr   )funcr   s     r   err_on_copyr      s,    =	 %,D*>P$Q!r   c                   D   \ rS rSrSr\SS j5       r\" \R                  5      r
\rSr\\S 5       5       r\S 5       r\S 5       r\S	 5       r\SS
 j5       r\S 5       r\S 5       r\\SS j5       5       r\\SS j5       5       r\\SS j5       5       r\SS j5       rSrg)ListHandler)   a^  Storage of array data in Python lists/arrays

This mechanism, unlike multi-dimensional arrays, is not necessarily
uniform in type or dimension, so we have to do a lot of extra checks
to make sure that we get a correctly-structured array.  That, as
well as the need to copy the arrays in Python code, makes this a far
less efficient implementation than the numpy implementation, which
does all the same things, but does them all in C code.

Note: as an *output* format, this format handler produces ctypes
    arrays, not Python lists, this is done for convenience in coding
    the implementation, mostly.
Nc                      [         R                  " U5      $ ! [        [        4 aO  nU R	                  X5      n[         R
                  " [         R                  " U5      5      nU4Ul        Us S nA$ S nAff = fN)ctypesbyref	TypeErrorAttributeErrorasArrayc_void_p	addressof_temporary_array_)r   instancetypeCodeerrarraypps         r   
from_paramListHandler.from_param8   sa    	<<))>* 	LL4E!1!1%!89B$)8B I		s    A7AA2,A72A7Tc                 .    [         R                  " U5      $ )zCGiven value in a known data-pointer type, return void_p for pointer)r"   r#   )clsr   s     r   voidDataPointerListHandler.voidDataPointerF   s     ||E""r   c                 <    [         U   nU H  nX4-  nM	     U" 5       $ )z#Return array of zeros in given size)GL_TYPE_TO_ARRAY_MAPPING)r2   dimsr+   typedims        r   zerosListHandler.zerosL   s&     (1CKD vr   c                      [        U5      /nSnU H2  nU R                  U5      nUc  M  XS:w  d  M   [        SU< SU< 3U5      e   g! [        [        [        4 a  n/ s SnA$ SnAff = f)zCalculate total dimension-set of the elements in x

This is *extremely* messy, as it has to track nested arrays
where the arrays could be different sizes on all sorts of
levels...
NzNon-uniform array encountered: z versus )lendimsOf
ValueErrorr$   r%   )r2   x_childDimensionchildnewDimensionr,   s          r   r>   ListHandler.dimsOfT   sz    	QA "N"zz%0!-#5( !- .
  	 	 >:6 	I	s   A	 	A*A%A*%A*c           	          [         R                  UR                  5      nUb  U$ [        SUR                  < S[	        [         R                  5       5      < SU< 35      e)z=Given a value, guess OpenGL type of the corresponding pointerz%Don't know GL type for array of type z, known types: z
value:)ARRAY_TO_GL_TYPE_MAPPINGget_type_r$   listkeys)r2   r   results      r   arrayToGLTypeListHandler.arrayToGLTypeo   sS     *--ell;M -2245	
 	
r   c                 f    SnU R                  U5       H  n[        USS5      nUc  M  X5-  nM     U$ )z6Given a data-value, calculate dimensions for the array   _length_Ntypesr   )r2   r   r+   r7   baselengths         r   	arraySizeListHandler.arraySize   s>     IIe$DT:t4F! % r   c              #   ~   #    UnUb4  Uv   [        USS5      n[        U[        [        45      (       a  SnUb  M3  gg7f)z.Produce iterable producing all composite typesNrI   )r   
isinstancer
   r   )r2   r   	dimObjects      r   rS   ListHandler.types   sD      	#O	8T:I)eW%566 		 #s   7==c              #   h   #    U R                  U5       H  n[        USS5      nUc  M  Uv   M     g7f)z"Produce iterable of all dimensionsrQ   NrR   )r2   r   rT   rU   s       r   r7   ListHandler.dims   s3      IIe$DT:t4F! %s   #2	2c                 P   Uc  [        S5      e[        U   n[        U[        [        45      (       ah  U Vs/ s H  o@R                  XB5      PM     nnU(       a@  U R                  US   5      SSS2    H  nX6-  nM	     U[        U5      -  nU" 5       nXWSS& U$ gU" U5      $ s  snf )zConvert given value to a ctypes array value of given typeCode

This does a *lot* of work just to get the data into the correct
format.  It's not going to be anywhere near as fast as a numpy
or similar approach!
Nz0Haven't implemented type-inference for lists yetr   )NotImplementedErrorr6   rY   rJ   tupler&   
dimensionsr=   )r2   r   r+   	arrayTypeitemsubItemsr9   rL   s           r   r&   ListHandler.asArray   s     %F  -X6	edE]++@EFD3HF>>(1+6tt<C$I =S]*	"$q	  U## Gs   B#c                 <    [        U R                  U5      5      S   $ )z-Determine unit size of an array (if possible)r_   ra   r7   r2   r   r+   s      r   unitSizeListHandler.unitSize   s     SXXe_%b))r   c                 6    [        U R                  U5      5      $ )z<Determine dimensions of the passed array value (if possible)rh   ri   s      r   rb   ListHandler.dimensions   s     SXXe_%%r   c                 .    [         R                  " U5      $ )zCGiven a data-value, calculate number of bytes required to represent)r"   sizeofri   s      r   arrayByteCountListHandler.arrayByteCount   s     }}U##r    r!   )r   
__module____qualname____firstlineno____doc__r   r/   staticmethodr"   r(   dataPointerHANDLED_TYPESisOutputclassmethodr3   r:   r>   rM   rV   rS   r7   r&   rj   rb   rp   __static_attributes__rr   r   r   r   r   )   s1      v//0K!MH#  #    4 
 
   ! !   $  $0 *  * &  & $ $r   r   fdiIhHbBs).rv   REGISTRY_NAMEr"   _ctypesOpenGL.raw.GLr   OpenGL.arraysr   GL_1_1OpenGLr   r   OpenGL._configflagsr   r	   OpenGL._bytesr
   r   r   rJ   ra   ry   operatorr   FormatHandlerr   GLdouble	GL_DOUBLEGLfloatGL_FLOATGLintGL_INTGLuintGL_UNSIGNED_INTGLshortGL_SHORTGLushortGL_UNSIGNED_SHORTGLcharGL_CHARGLbyteGL_BYTEGLubyteGL_UNSIGNED_BYTErG   r6   rr   r   r   <module>r      s(     ! 3 " - ' 2 2u   [$--- [$~ OOV%%
NNFOO
LL&--
MM6))
NNFOO
OOV--
MM6>>
MM6>>
NNF++
 
foo
OOV^^ MM6<< FMM	
 OOV^^ foo NNFMM NNFMM V^^        !" #$ % r   