a
    i‚jâ	  ã                
   @   sŒ   d Z ddlmZ d ZZejrXzddlmZmZ W n$ eyV Z zW Y dZ[n
dZ[0 0 edu rpG dd„ de	ƒZedu rˆG dd„ de	ƒZdS )	z)Late-bound base-class (with acceleration)é    )ÚacceleratesupportN)ÚLateBindÚCurryc                   @   s<   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dS )r   z¸Provides a __call__ which dispatches to self._finalCall

        When called without self._finalCall() makes a call to
        self.finalise() and then calls self._finalCall()
        Nc                 C   s
   || _ dS )z.Set our finalCall to the callable object givenN)Ú
_finalCall)ÚselfZ	finalCall© r   úM/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/latebind.pyÚsetFinalCall   s    zLateBind.setFinalCallc                 C   s   | j s|  ¡ | _ | j S )z,Retrieve and/or bind and retrieve final call)r   Úfinalise©r   r   r   r   ÚgetFinalCall   s    
zLateBind.getFinalCallc                 C   s   dS )z`Finalise our target to our final callable object

            return final callable
            Nr   r   r   r   r   r
      s    zLateBind.finalisec                 C   s   t |  ¡ ƒS )z8Resolve our final call and check for empty/nonzero on it)Úboolr   r   r   r   r   Ú__nonzero__    s    zLateBind.__nonzero__c              
   O   sd   z| j |i |¤ŽW S  ttfy^ } z0| j du r:|  ¡ | _ | j |i |¤ŽW  Y d}~S d}~0 0 dS )zúCall self._finalCall, calling finalise() first if not already called

            There's actually *no* reason to unpack and repack the arguments,
            but unfortunately I don't know of a Cython syntax to specify
            that.
            N)r   Ú	TypeErrorÚAttributeErrorr
   )r   ÚargsÚnamedÚerrr   r   r   Ú__call__#   s    

zLateBind.__call__)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r
   r   r   r   r   r   r   r   
   s   r   c                   @   s(   e Zd ZdZdZdZdd„ Zdd„ ZdS )r   z¯Provides a simple Curry which can bind (only) the first element

        This is used by lazywrapper, which explains the weird naming
        of the two attributes...
        Nc                 C   s   || _ || _dS )z1Stores self.wrapperFunction and self.baseFunctionN)ÚbaseFunctionÚwrapperFunction)r   r   r   r   r   r   Ú__init__9   s    zCurry.__init__c                 O   s   | j | jg|¢R i |¤ŽS )zAreturns self.wrapperFunction( self.baseFunction, *args, **named ))r   r   )r   r   r   r   r   r   r   =   s    zCurry.__call__)r   r   r   r   r   r   r   r   r   r   r   r   r   1   s
   r   )
r   ZOpenGLr   r   r   ZACCELERATE_AVAILABLEZOpenGL_accelerate.latebindÚImportErrorr   Úobjectr   r   r   r   Ú<module>   s   &