o
    éT•jÐ  ã                   @   s�   d dl Z d dlT eeƒZdd„ ZG dd„ deeƒƒZe jdkr/dZ	eZ
G d	d
„ d
eed�ZdS e jdkrDdZ	eZG dd„ deed�Z
dS edƒ‚)é    N)Ú*c                 C   sH   t | tƒr
t| tƒS t| tƒrt| jƒ| j S t| t	ƒr| S t
d|  ƒ‚)zïReturn the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types
    arrays and structures are supported.
    z+This type does not support other endian: %s)ÚhasattrÚ_OTHER_ENDIANÚgetattrÚ
isinstanceÚ_array_typeÚ_other_endianÚ_type_Ú_length_Ú
issubclassÚ	StructureÚ	TypeError)Útyp© r   ú%/usr/lib/python3.10/ctypes/_endian.pyr      s   



r   c                       s   e Zd Z‡ fdd„Z‡  ZS )Ú_swapped_metac                    s^   |dkr&g }|D ]}|d }|d }|dd … }|  |t|ƒf| ¡ q|}tƒ  ||¡ d S )NÚ_fields_r   é   é   )Úappendr   ÚsuperÚ__setattr__)ÚselfÚattrnameÚvalueÚfieldsÚdescÚnamer   Úrest©Ú	__class__r   r   r      s   z_swapped_meta.__setattr__)Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__r   r   r   r   r      s    r   ÚlittleÚ__ctype_be__c                   @   ó   e Zd ZdZdZdZdS )ÚBigEndianStructurez$Structure with big endian byte orderr   N©r!   r"   r#   Ú__doc__Ú	__slots__Ú_swappedbytes_r   r   r   r   r(   .   ó    r(   )Ú	metaclassÚbigÚ__ctype_le__c                   @   r'   )ÚLittleEndianStructurez'Structure with little endian byte orderr   Nr)   r   r   r   r   r1   7   r-   r1   zInvalid byteorder)ÚsysÚctypesÚtypeÚArrayr   r   r   r   Ú	byteorderr   r1   r(   ÚRuntimeErrorr   r   r   r   Ú<module>   s    

