a
    i‚jé  ã                   @   s<  d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
 G dd„ deƒZG dd„ deƒZG d	d
„ d
eeƒZeeur†G dd„ deeƒZneZG dd„ deeƒZG dd„ deeƒZedkr8eddƒZeddƒZeddƒZddlZeeefD ]NZe e e¡¡ZeeksJ eeƒeeƒfƒ‚ejejksèJ ejejfƒ‚qèdS )z)Implementation of OpenGL constant objectsé    N)ÚbytesÚunicodeÚas_8_bitÚlongÚinteger_typesÚmaxsize)Ú_configflagsc                       s6   e Zd ZdZd	‡ fdd„	Zdd„ Z‡ fdd„Z‡  ZS )
ÚConstantaH  OpenGL constant that displays itself as a name rather than a value

    The purpose of this class is to make debugging OpenGL code easier,
    as you recieve messages that say what value you passed in in a
    human-readable form, rather than as a bald number that requires
    lookup and disambiguation in the header file.
    Nc                    sî   t |tƒs‚t |tƒr&| tur&t||ƒS t |tƒrB| turBt||ƒS t |tƒr^| tur^t||ƒS t |tt	fƒr‚| t
ur‚t
|t|ƒƒS t |tƒrž|tkrž|t@  }tt| ƒ | |¡}||_tjrêt ¡ j}|rê|jrêd|jjv rê|jjd |_|S )z5Initialise the constant with the given name and valueÚ__name__)Ú
isinstancer	   ÚfloatÚFloatConstantÚintÚIntConstantr   ÚLongConstantr   r   ÚStringConstantr   r   r   ÚsuperÚ__new__Únamer   ZMODULE_ANNOTATIONSÚsysÚ	_getframeÚf_backÚ	f_globalsÚ
__module__)Úclsr   ÚvalueÚbaseÚframe©Ú	__class__© úM/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/constant.pyr      s&    






zConstant.__new__c                 C   s   | j S )z+Return the name, rather than the bald value©r   ©Úselfr    r    r!   Ú__repr__#   s    zConstant.__repr__c                    s   | j ftt| ƒ ¡  S )z5Produce the new arguments for recreating the instance)r   r   r	   Ú__getnewargs__r#   r   r    r!   r&   &   s    zConstant.__getnewargs__)N)r
   r   Ú__qualname__Ú__doc__r   r%   r&   Ú__classcell__r    r    r   r!   r	      s   r	   c                       s0   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Z‡  ZS )ÚNumericConstantz&Base class for numeric-value constantsc                    s   d| j tt| ƒ ¡ f S ©z+Return the value as a human-friendly stringz%s (%s)©r   r   r	   Ú__str__r#   r   r    r!   r-   ,   s    zNumericConstant.__str__c                 C   s   | j S )z&Retrieve state for pickle and the liker"   r#   r    r    r!   Ú__getstate__/   s    zNumericConstant.__getstate__c                 C   s
   || _ d S )Nr"   )r$   Ústater    r    r!   Ú__setstate__2   s    zNumericConstant.__setstate__)r
   r   r'   r(   r-   r.   r0   r)   r    r    r   r!   r*   *   s   r*   c                   @   s   e Zd ZdZdS )r   zInteger constantN©r
   r   r'   r(   r    r    r    r!   r   5   s   r   c                   @   s   e Zd ZdZdS )r   zLong integer constantNr1   r    r    r    r!   r   8   s   r   c                   @   s   e Zd ZdZdS )r   zFloat constantNr1   r    r    r    r!   r   <   s   r   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   zString constantsc                    s   d| j tt| ƒ ¡ f S r+   r,   r#   r   r    r!   r%   A   s    zStringConstant.__repr__)r
   r   r'   r(   r%   r)   r    r    r   r!   r   ?   s   r   Ú__main__Ztestinté   Z	testfloatg      @Zteststrzsome testing string)r(   r   ZOpenGL._bytesr   r   r   r   r   r   ZOpenGLr   Úobjectr	   r*   r   r   r   r   r   r   r
   ÚxÚyÚzÚpickleÚvalÚloadsÚdumpsZrestoredÚstrr   r    r    r    r!   Ú<module>   s(    $



