a
    yn„f—  ã                   @  s¤   U d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZ edƒZdZd	ed
< dZd	ed< dddddœdd„Zd
dddœdd„ZdS )é    )Úannotations)ÚCallableÚ
CollectionÚ	Generator©Úwraps)Úisgenerator)ÚOperationErrorContext)ÚAnyÚ	TypeAliasÚTypeVarÚTz2Callable[..., Generator[Collection[Any], None, T]]r   ÚDispatcherTypezCallable[..., T]ÚHighLevelTypeÚakNÚstrz
str | Nonez)Callable[[DispatcherType], HighLevelType])ÚmoduleÚnameÚreturnc                   s   dddœ‡ ‡fdd„}|S )zZDecorate a high-level function such that it may be overloaded by third-party array objectsr   r   )Úfuncr   c                   s(   ˆd u r| j }nˆ}t| ˆ › d|› �ƒS )NÚ.)Ú__qualname__Únamed_high_level_function)r   Zcaptured_name©r   r   © úT/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/_dispatch.pyÚcapture_func   s    z)high_level_function.<locals>.capture_funcr   )r   r   r   r   r   r   Úhigh_level_function   s    r   )r   r   r   c                   s   t ˆƒ‡ ‡‡fdd„ƒ‰ ˆ S )z`Decorate a named high-level function such that it may be overloaded by third-party array objectsc                    s"  t ˆ| |ƒ� �þ ˆ| i |¤Ž}t|ƒ� rút|ƒ}t|tƒs>J ‚|D ]h}z
|j}W n tyf   Y qBY qB0 |ˆ || |ƒ}|tu r”tdˆ› d|› �ƒ‚qB|  W  d   ƒ S qBzt|ƒ W n8 t	yð } z |j
W  Y d }~W  d   ƒ S d }~0 0 tdƒ‚|W  d   ƒ S 1 �s0    Y  d S )Nzno overload for z with arguments zChigh-level functions should only implement a single yield statement)r	   r   ÚnextÚ
isinstancer   Z__awkward_function__ÚAttributeErrorÚNotImplementedÚNotImplementedErrorÚStopIterationÚvalueÚAssertionError)ÚargsÚkwargsZgen_or_resultZarray_likesZ
array_likeZcustom_implÚresultÚerr©Údispatchr   r   r   r   r+   #   s0    


ÿ*ÿz+named_high_level_function.<locals>.dispatchr   )r   r   r   r*   r   r       s    &r   )r   N)Ú
__future__r   Úcollections.abcr   r   r   Ú	functoolsr   Úinspectr   Zawkward._errorsr	   Zawkward._typingr
   r   r   r   r   Ú__annotations__r   r   r   r   r   r   r   Ú<module>   s    ÿ