a i@sddlZddlTeeZddZGdddeeZejdkr\dZ eZ Gd d d eed Z n0ejd krd Z eZ Gdddeed Z ne ddS)N)*cCsLt|trt|tSt|tr.t|j|jSt|t r<|St d|dS)zReturn 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: %sN) hasattr _OTHER_ENDIANgetattr isinstance _array_type _other_endianZ_type_Z_length_ issubclass Structure TypeError)typr &/usr/lib64/python3.9/ctypes/_endian.pyrs    rcseZdZfddZZS) _swapped_metacs^|dkrLg}|D]6}|d}|d}|dd}||t|f|q|}t||dS)NZ_fields_r)appendrsuper __setattr__)selfattrnamevaluefieldsZdescnamer rest __class__r rrs z_swapped_meta.__setattr__)__name__ __module__ __qualname__r __classcell__r r rrrsrlittleZ __ctype_be__c@seZdZdZdZdZdS)BigEndianStructurez$Structure with big endian byte orderr Nrrr__doc__ __slots__Z_swappedbytes_r r r rr".sr") metaclassbigZ __ctype_le__c@seZdZdZdZdZdS)LittleEndianStructurez'Structure with little endian byte orderr Nr#r r r rr(7sr(zInvalid byteorder) sysZctypestypeArrayrrr r byteorderrr(r" RuntimeErrorr r r rs