a
    ij                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlZddlm	Z	m
Z
 ddlmZ ddd	ZG d
d dejZG dd deZejeejejeejejeejejeejejeejejeejejeejejeej iZ!dS )z'String-array-handling code for PyOpenGL    )_types)GL_1_1)formathandlerN)_byteserror)ERROR_ON_COPYc                 C   s   t t | t jjS N)ctypescastc_char_pc_void_pvalue)r   typeCode r   S/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/arrays/strings.pydataPointer   s    r   c                   @   sr   e Zd ZdZejfZedddZe	e
Z
dddZdddZd	d
 ZdddZdddZdddZdddZdS )StringHandlerz,String-specific data-type handler for OpenGLNc                 C   s   t t|S r   )r	   r   r   )clsr   r   r   r   r   
from_param   s    zStringHandler.from_paramc                 C   s   t ddS z.Currently don't allow strings as output types!z0Don't currently support strings as output arraysNNotImplementedErrorselfdimsr   r   r   r   zeros   s    zStringHandler.zerosc                 C   s   t ddS r   r   r   r   r   r   ones    s    zStringHandler.onesc                 C   s   t ddS )z=Given a value, guess OpenGL type of the corresponding pointerz1Can't guess data-type from a string-type argumentNr   )r   r   r   r   r   arrayToGLType&   s    zStringHandler.arrayToGLTypec                 C   s   t | }t|| S )z9Given a data-value, calculate ravelled size for the array)
BYTE_SIZESlen)r   r   r   Z	byteCountr   r   r   	arraySize,   s    zStringHandler.arraySizec                 C   s   t |S )zCGiven a data-value, calculate number of bytes required to represent)r   r   r   r   r   r   r   arrayByteCount2   s    zStringHandler.arrayByteCountc                 C   sV   t |tr|S t|dr | S t|dr2| S t|drB|jS tdt| dS )z7Convert given value to an array value of given typeCodetobytestostringrawz(String handler got non-string object: %rN)
isinstancebyteshasattrr#   r$   r%   	TypeErrortyper!   r   r   r   asArray6   s    



zStringHandler.asArrayc                 C   s   t ddS )z<Determine dimensions of the passed array value (if possible)z2Cannot calculate dimensions for a String data-typeN)r)   r!   r   r   r   
dimensionsD   s    zStringHandler.dimensions)N)N)N)N)N)N)N)__name__
__module____qualname____doc__r   r'   HANDLED_TYPESclassmethodr   staticmethodr   r   r   r   r    r"   r+   r,   r   r   r   r   r      s   




r   c                   @   s,   e Zd ZejfZedddZdddZdS )UnicodeHandlerNc                 C   s4   t |}t|}||ur0tr*td||_|S )NzSUnicode string passed, cannot copy with ERROR_ON_COPY set, please use 8-bit strings)r   as_8_bitr   r   r   r   Z	CopyErrorZ_temporary_array_)r   r   r   Z	convertedresultr   r   r   r   L   s    

zUnicodeHandler.from_paramc                 C   s   t |}tj| ||dS )N)r   )r   r5   r   r+   r!   r   r   r   r+   Y   s    
zUnicodeHandler.asArray)N)N)	r-   r.   r/   r   unicoder1   r2   r   r+   r   r   r   r   r4   I   s   r4   )N)"r0   ZOpenGL.raw.GLr   ZOpenGL.raw.GL.VERSIONr   ZOpenGL.arraysr   r	   ZOpenGLr   r   ZOpenGL._configflagsr   r   ZFormatHandlerr   r4   Z	GL_DOUBLEZsizeofZGLdoubleZGL_FLOATZGLfloatZGL_INTZGLintZGL_SHORTZGLshortZGL_UNSIGNED_BYTEZGLubyteZGL_UNSIGNED_SHORTZGL_BYTEZGLbyteZGL_UNSIGNED_INTZGLuintr   r   r   r   r   <module>   s$   
: