File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/google/protobuf/internal/__pycache__/decoder.cpython-310.pyc
Back
o �hw� � @ s d Z dZddlZddlZddlmZ ddlmZ ddlmZ ddlm Z ej Zdd � Zd d� Z ede�Ze d e�Zede�Ze de�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Z dJdd�Zee je�Zee je�Zee je�Zee je�Zee jee j�Z ee jee j�Z!ee j"d�Z#ee j$d �Z%ee j"d!�Z&ee j$d"�Z'e� Z(e� Z)ee jee*�Z+ dJd#d$�Z, dJd%d&�Z-d'd(� Z.d)d*� Z/e�0d+e j1�Z2d,d-� Z3d.d/� Z4d0d1� Z5d2d3� Z6d4d5� Z7d6d7� Z8d8d9� Z9d:d;� Z:dKd<d=�Z;d>d?� Z<d@dA� Z=dBdC� Z>dDdE� Z?dFdG� Z@dHdI� ZAeA� ZBdS )La� Code for decoding protocol buffer primitives. This code is very similar to encoder.py -- read the docs for that module first. A "decoder" is a function with the signature: Decode(buffer, pos, end, message, field_dict) The arguments are: buffer: The string containing the encoded message. pos: The current position in the string. end: The position in the string where the current message ends. May be less than len(buffer) if we're reading a sub-message. message: The message object into which we're parsing. field_dict: message._fields (avoids a hashtable lookup). The decoder reads the field and stores it into field_dict, returning the new buffer position. A decoder for a repeated field may proactively decode all of the elements of that field, if they appear consecutively. Note that decoders may throw any of the following: IndexError: Indicates a truncated message. struct.error: Unpacking of a fixed-width field failed. message.DecodeError: Other errors. Decoders are expected to raise an exception if they are called with pos > end. This allows callers to be lax about bounds checking: it's fineto read past "end" as long as you are sure that someone else will notice and throw an exception later on. Something up the call stack is expected to catch IndexError and struct.error and convert them to message.DecodeError. Decoders are constructed using decoder constructors with the signature: MakeDecoder(field_number, is_repeated, is_packed, key, new_default) The arguments are: field_number: The field number of the field we want to decode. is_repeated: Is the field a repeated field? (bool) is_packed: Is the field a packed field? (bool) key: The key to use when looking up the field within field_dict. (This is actually the FieldDescriptor but nothing in this file should depend on that.) new_default: A function which takes a message object as a parameter and returns a new instance of the default value for this field. (This is called for repeated fields and sub-messages, when an instance does not already exist.) As with encoders, we define a decoder constructor for every type of field. Then, for every field of every message class we construct an actual decoder. That decoder goes into a dict indexed by tag, so when we decode a message we repeatedly read a tag, look up the corresponding decoder, and invoke it. z kenton@google.com (Kenton Varda)� N)�message)� containers)�encoder)�wire_formatc s ddt f� �fdd� }|S )a� Return an encoder for a basic varint value (does not include tag). Decoded values will be bitwise-anded with the given mask before being returned, e.g. to limit them to 32 bits. The returned decoder does not take the usual "end" parameter -- the caller is expected to do bounds checking after the fact (often the caller can defer such checking until later). The decoder returns a (value, new_pos) pair. N�posc s� d}d} |d u r2z | � d�d }W n' ty1 } z|dkr%W Y d }~d S tdt|� ��d }~ww | | }|d7 }||d@ |>