File: //usr/lib/python3.9/site-packages/google/protobuf/internal/__pycache__/decoder.cpython-39.pyc
a
x��g� � @ sJ d Z dZddlZddlZddlZdZejr0eZnddl Z e �
e�d��Zddl
mZ ddl
mZ ddl
mZ dd lmZ d
Ze Zed ZejZdd� Zd
d� Zede�Zede�Zede�Zede�Zdd� Zdd� Zdd� Z dd� Z!dd� Z"dd� Z#dKd d!�Z$eej%e�Z&eej%e�Z'eej%e�Z(eej%e�Z)e ej%eej*�Z+e ej%eej*�Z,e!ej-d"�Z.e!ej/d#�Z0e!ej-d$�Z1e!ej/d%�Z2e"� Z3e#� Z4e ej%ee5�Z6dLd&d'�Z7dMd(d)�Z8d*d+� Z9d,d-� Z:e�;d.ej<�Z=d/d0� Z>d1d2� Z?d3d4� Z@d5d6� ZAd7d8� ZBd9d:� ZCd;d<� ZDdNd=d>�ZEd?d@� ZFdAdB� ZGdCdD� ZHdEdF� ZIdGdH� ZJdIdJ� ZKeK� ZLdS )Oa� 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 [email protected] (Kenton Varda)� Ni�� z[\ud800-\udfff])�
containers)�encoder)�wire_format)�messageg �c s � �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.
c sj d}d}t �| |�}||d@ |>