o
    !wÖi•   ã                   @   s¦   d dl Z ddlmZ ddlmZ g d¢Zdd„ ZG dd	„ d	eƒZG d
d„ de j	edZ
G dd„ de jddZdd„ Zdd„ Zdd„ Ze
e _
ee _ee _ee _ee _dS )é    Né   )Úpysafe)Ú_jcustomizer)ÚJClassÚ
JInterfaceÚ	JOverridec                     sB   t | ƒdkrt| d ƒrt | d di ¡ | d S ‡ fdd„}|S )aŒ  Annotation to denote a method as overriding a Java method.

    This annotation applies to customizers, proxies, and extensions
    to Java classes. Apply it to methods to mark them as implementing
    or overriding Java methods.  Keyword arguments are passed to the
    corresponding implementation factory.

    Args:
      sticky=bool: Applies a customizer method to all derived classes.

    r   r   Ú__joverride__c                    s   t  | dˆ ¡ | S )Nr   )ÚobjectÚ__setattr__)Úmethod©Úkwargs© úJ/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/jpype/_jclass.pyÚmodifier+   s   zJOverride.<locals>.modifier)ÚlenÚcallabler	   r
   )Úargsr   r   r   r   r   r      s
   r   c                   @   s   e Zd Zdd„ ZdS )Ú
JClassMetac                 C   s   t |ƒtjkS ©N)ÚtypeÚ_jpypeÚ_JClass)ÚselfÚotherr   r   r   Ú__instancecheck__2   s   zJClassMeta.__instancecheck__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   1   s    r   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	r   aß  Meta class for all Java class instances.

    When called as an object, JClass will contruct a new Java class wrapper.

    All Python wrappers for Java classes derive from this type.
    To test if a Python class is a Java wrapper use
    ``isinstance(obj, jpype.JClass)``.

    Args:
      className (str): name of a Java type.

    Keyword Args:
      loader (java.lang.ClassLoader): specifies a class loader to use
        when creating a class.
      initialize (bool): If true the class will be loaded and initialized.
        Otherwise, static members will be uninitialized.

    Returns:
      JavaClass: a new wrapper for a Java class

    Raises:
      TypeError: if the component class is invalid or could not be found.
    NTc                 C   sÖ   |rt |tƒrtj |||¡}t |tƒrf| d¡rf| d¡}||d d… }t |d |… ¡}t|j	 
¡ ƒ}|dkrAtd|j ƒ‚t|ƒdkrL| d¡}t|ƒdkrdt|ƒt|j	 
¡ ƒkrdtd|j ƒ‚|S t |¡S )	Nú>ú<r   éÿÿÿÿr   z(Java class '%s' does not take parametersú,z'Java generic class '%s' length mismatch)Ú
isinstanceÚstrr   Ú_java_lang_ClassÚforNameÚendswithÚfindÚ	_getClassr   Úclass_ÚgetTypeParametersÚ	TypeErrorr   Úsplit)ÚclsÚjcÚloaderÚ
initializeÚiÚparamsÚretÚacceptParamsr   r   r   Ú__new__N   s&   
ÿ
"ÿ
zJClass.__new__c                 C   s   t dƒ| S )Nzjava.lang.Class)r   )r.   Úindexr   r   r   Ú__class_getitem__e   s   zJClass.__class_getitem__)NT)r   r   r   Ú__doc__r6   r8   r   r   r   r   r   6   s    
r   )Ú	metaclassc                   @   s   e Zd ZdZdS )r   at  A meta class for all Java Interfaces.

    ``JInterface`` is serves as the base class for any Java class that is
    a pure interface without implementation. It is not possible to create
    a instance of a Java interface.

    Example:

    .. code-block:: python

       if isinstance(java.util.function.Function, jpype.JInterface):
          print("is interface")

    N)r   r   r   r9   r   r   r   r   r   j   s    r   T)Úinternalc                 C   sb   t | ¡ ƒ}|D ]\}}t|ƒ}||kr||= |r|||< qt | ¡}| | ||¡ | t|ƒ|fS r   )ÚlistÚitemsr   r   ÚgetClassHintsÚapplyCustomizersÚtuple)ÚnameÚbasesÚmembersÚmÚkÚvÚk2Úhintsr   r   r   Ú
_jclassPre|   s   €
rI   c                 G   sj   t  | j¡}|| _| | ¡ tjr1| j ¡ D ]}| 	¡ d@ dkr!qt 
|¡}|  t| ¡ ƒ|¡ qd S d S )Nr   r   )r   r>   r   Ú_hintsÚapplyInitializerr   r%   r*   ÚgetDeclaredClassesÚgetModifiersr   Ú
_customizer$   ÚgetSimpleName)Úresr   rH   r.   Úwrapperr   r   r   Ú_jclassPost   s   

ûrR   c              	   C   sÎ  g }t | dƒs:tdƒƒ }| | ¡}|dur:t| d|ƒ |jdur(| t|jƒ¡ |jdur5| t|jƒ¡ d |¡S t| ddƒ ddl	m
} | j}| d| ¡  ¡ | d¡ | ¡ }|rp| d¡ | d	| ¡  ¡ | d¡ | ¡ }|r˜| d
¡ d dd„ |D ƒ¡}|ddd}	| |	 |¡¡ | d¡ | ¡ }
|
rýg }| ¡ }g }|
D ]'}| ¡ }|d@ s³q¨d dd„ | ¡ D ƒ¡}| d||f ¡ | | ¡ ¡ q¨|rá| d¡ | |¡ | d¡ |rý| d¡ t|ƒD ]}| d| ¡  ¡ qì| d¡ | ¡ }|rbg }|D ]G}| ¡ }|d@ sqg }|d@ r!| d¡ |d@ r+| d¡ | ¡ r6| d¡ n| d¡ | d| ¡ | ¡  ¡ d |¡f ¡ q|rb| d¡ | |¡ | d¡ d |¡S ) z•Generator for JClass.__doc__ property

    Parameters:
       cls (JClass): class to document.

    Returns:
      The doc string for the class.
    Ú__javadoc__z"org.jpype.javadoc.JavadocExtractorNÚ r   )ÚTextWrapperzJava class '%s'z    Extends:z
        %sz    Interfaces:z, c                 S   ó   g | ]}t | ¡ ƒ‘qS r   ©r$   ÚgetCanonicalName©Ú.0r2   r   r   r   Ú
<listcomp>Á   s    z_jclassDoc.<locals>.<listcomp>z        )Úinitial_indentÚsubsequent_indentr   c                 S   rV   r   rW   rY   r   r   r   r[   Ð   s    ÿz    * %s(%s)z  Constructors:z	  Raises:z    %s: from javaé   Úfinalé   Ústaticzenum constantÚfieldz    %s (%s): %sú z  Attributes:Ú
)Úhasattrr   ÚgetDocumentationÚsetattrÚdescriptionÚappendr$   ÚctorsÚjoinÚtextwraprU   r*   ÚgetNameÚgetSuperclassÚgetInterfacesÚextendÚwrapÚgetDeclaredConstructorsrO   rM   ÚgetParameterTypesÚgetExceptionTypesÚsetrX   ÚgetDeclaredFieldsÚisEnumConstantÚgetType)r.   ÚoutÚjdeÚjdrU   ÚjclassÚsupÚintfsÚwordsrQ   rj   Ú
exceptionsrA   ÚctordeclÚctorÚ	modifiersr3   ÚexcÚfieldsÚ	fielddescrb   Ú	fieldInfor   r   r   Ú
_jclassDocž   sš   	









ÿ

ÿ












þ



rˆ   )r   Ú_pykeywordsr   rT   r   Ú__all__r   r   r   r   r   Ú_JObjectr   rI   rR   rˆ   r   r   r   r   Ú<module>   s    4\
