a
    còf¯  ã                   @   s¨  d Z dZddlZddlmZ ddlmZ dZde> d ZdZdZ	dZ
dZd	Zd
Zd
ZedƒZedƒZdZdZdZdZdZdZdZdZe e¡d	kršedƒ‚e e¡dkr°edƒ‚dd„ Zdd„ Zdd„ Zdd„ Zd d!„ Z d"d#„ Z!d$d%„ Z"d&d'„ Z#d(d)„ Z$d*d+„ Z%d,d-„ Z&d.d/„ Z'd0d1„ Z(d2d3„ Z)d4d5„ Z*d6d7„ Z+d8d9„ Z,d:d;„ Z-d<d=„ Z.d>d?„ Z/d@dA„ Z0dBdC„ Z1dDdE„ Z2dFdG„ Z3dHdI„ Z4dJdK„ Z5ej6j7ej6j8ej6j9ej6j:fZ;dLdM„ Z<dS )NzFConstants and static functions to support protocol buffer wire format.z#robinson@google.com (Will Robinson)é    N)Ú
descriptor)Úmessageé   é   é   é   é   iÿÿÿi   €l   ÿÿ ì   ÿÿÿÿ lûÿÿÿ         ì   ÿÿÿÿ z<Iz<Qz<fz<dz"Format "I" is not a 32-bit number.é   z"Format "Q" is not a 64-bit number.c                 C   s0   d|  krt ks$n t d| ¡‚| t> |B S )a  Returns an unsigned 32-bit integer that encodes the field number and
  wire type information in standard protocol message wire format.

  Args:
    field_number: Expected to be an integer in the range [1, 1 << 29)
    wire_type: One of the WIRETYPE_* constants.
  r   zUnknown wire type: %d)Ú_WIRETYPE_MAXr   ÚEncodeErrorÚTAG_TYPE_BITS)Úfield_numberZ	wire_type© r   úa/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/google/protobuf/internal/wire_format.pyÚPackTag9   s    r   c                 C   s   | t ? | t@ fS )zkThe inverse of PackTag().  Given an unsigned 32-bit number,
  returns a (field_number, wire_type) tuple.
  )r   ÚTAG_TYPE_MASK)Útagr   r   r   Ú	UnpackTagF   s    r   c                 C   s   | dkr| d> S | d> dA S )z‘ZigZag Transform:  Encodes signed integers so that they can be
  effectively used with varint encoding.  See wire_format.h for
  more details.
  r   r   éÿÿÿÿr   ©Úvaluer   r   r   ÚZigZagEncodeM   s    r   c                 C   s   | d@ s| d? S | d? dA S )zInverse of ZigZagEncode().r   r   r   r   r   r   r   ÚZigZagDecodeW   s    r   c                 C   s
   t | |ƒS ©N)ÚInt64ByteSize©r   Úint32r   r   r   ÚInt32ByteSizec   s    r   c                 C   s   t d| @ ƒS ©Nr
   )Ú_VarUInt64ByteSizeNoTag)r   r   r   r   ÚInt32ByteSizeNoTagg   s    r"   c                 C   s   t | d|@ ƒS r    ©ÚUInt64ByteSize©r   Zint64r   r   r   r   k   s    r   c                 C   s
   t | |ƒS r   r#   )r   Zuint32r   r   r   ÚUInt32ByteSizep   s    r&   c                 C   s   t | ƒt|ƒ S r   )ÚTagByteSizer!   )r   Úuint64r   r   r   r$   t   s    r$   c                 C   s   t | t|ƒƒS r   )r&   r   r   r   r   r   ÚSInt32ByteSizex   s    r)   c                 C   s   t | t|ƒƒS r   )r$   r   r%   r   r   r   ÚSInt64ByteSize|   s    r*   c                 C   s   t | ƒd S ©Nr   ©r'   )r   Zfixed32r   r   r   ÚFixed32ByteSize€   s    r-   c                 C   s   t | ƒd S ©Nr   r,   )r   Zfixed64r   r   r   ÚFixed64ByteSize„   s    r/   c                 C   s   t | ƒd S r+   r,   )r   Zsfixed32r   r   r   ÚSFixed32ByteSizeˆ   s    r0   c                 C   s   t | ƒd S r.   r,   )r   Zsfixed64r   r   r   ÚSFixed64ByteSizeŒ   s    r1   c                 C   s   t | ƒd S r+   r,   )r   Zfltr   r   r   ÚFloatByteSize�   s    r2   c                 C   s   t | ƒd S r.   r,   )r   Údoubler   r   r   ÚDoubleByteSize”   s    r4   c                 C   s   t | ƒd S )Nr   r,   ©r   Úbr   r   r   ÚBoolByteSize˜   s    r7   c                 C   s
   t | |ƒS r   )r&   )r   Úenumr   r   r   ÚEnumByteSizeœ   s    r9   c                 C   s   t | | d¡ƒS )Nzutf-8)ÚBytesByteSizeÚencode)r   Ústringr   r   r   ÚStringByteSize    s    r=   c                 C   s   t | ƒtt|ƒƒ t|ƒ S r   )r'   r!   Úlenr5   r   r   r   r:   ¤   s
    
ÿþr:   c                 C   s   dt | ƒ | ¡  S )Nr   )r'   ÚByteSize©r   r   r   r   r   ÚGroupByteSizeª   s    
ÿrA   c                 C   s   t | ƒt| ¡ ƒ | ¡  S r   ©r'   r!   r?   r@   r   r   r   ÚMessageByteSize¯   s
    
ÿþrC   c                 C   sH   dt dƒ t dƒ t dƒ }|t| ƒ7 }| ¡ }|t|ƒ7 }||7 }|S )Nr   r   r   rB   )r   ÚmsgÚ
total_sizeZmessage_sizer   r   r   ÚMessageSetItemByteSizeµ   s    rF   c                 C   s   t t| dƒƒS )zEReturns the bytes required to serialize a tag with this field number.r   )r!   r   )r   r   r   r   r'   É   s    r'   c                 C   s†   | dkrdS | dkrdS | dkr$dS | dkr0dS | d	kr<d
S | dkrHdS | dkrTdS | dkr`dS | dkrldS | t kr‚t d|  ¡‚dS )z©Returns the number of bytes required to serialize a single varint
  using boundary value comparisons. (unrolled loop optimization -WPierce)
  uint64 must be unsigned.
  é   r   iÿ?  r   iÿÿ r   iÿÿÿr   l   ÿÿ r   l   ÿÿÿé   l   ÿÿÿ é   l   ÿÿÿÿr   r	   é	   zValue out of range: %dé
   )Ú
UINT64_MAXr   r   )r(   r   r   r   r!   Ñ   s    r!   c                 C   s   | t vS )z·Return true iff packable = true is valid for fields of this type.

  Args:
    field_type: a FieldDescriptor::Type value.

  Returns:
    True iff fields of this type are packable.
  )ÚNON_PACKABLE_TYPES)Z
field_typer   r   r   ÚIsTypePackableì   s    	rN   )=Ú__doc__Ú
__author__ÚstructZgoogle.protobufr   r   r   r   ZWIRETYPE_VARINTZWIRETYPE_FIXED64ZWIRETYPE_LENGTH_DELIMITEDZWIRETYPE_START_GROUPZWIRETYPE_END_GROUPZWIRETYPE_FIXED32r   ÚintZ	INT32_MAXZ	INT32_MINZ
UINT32_MAXZ	INT64_MAXZ	INT64_MINrL   ZFORMAT_UINT32_LITTLE_ENDIANZFORMAT_UINT64_LITTLE_ENDIANZFORMAT_FLOAT_LITTLE_ENDIANZFORMAT_DOUBLE_LITTLE_ENDIANÚcalcsizeÚAssertionErrorr   r   r   r   r   r"   r   r&   r$   r)   r*   r-   r/   r0   r1   r2   r4   r7   r9   r=   r:   rA   rC   rF   r'   r!   ZFieldDescriptorZTYPE_STRINGZ
TYPE_GROUPZTYPE_MESSAGEZ
TYPE_BYTESrM   rN   r   r   r   r   Ú<module>   sv   
ü