| Index: third_party/protobuf/python/google/protobuf/pyext/message.h
|
| diff --git a/third_party/protobuf/python/google/protobuf/pyext/message.h b/third_party/protobuf/python/google/protobuf/pyext/message.h
|
| index 3a4bec81c9d504489b81cf34ffb701daaf446366..ce80497e6b4c7b2863adcb805cd69dbb5c231c25 100644
|
| --- a/third_party/protobuf/python/google/protobuf/pyext/message.h
|
| +++ b/third_party/protobuf/python/google/protobuf/pyext/message.h
|
| @@ -54,7 +54,7 @@ class MessageFactory;
|
|
|
| #ifdef _SHARED_PTR_H
|
| using std::shared_ptr;
|
| -using ::std::string;
|
| +using std::string;
|
| #else
|
| using internal::shared_ptr;
|
| #endif
|
| @@ -62,7 +62,7 @@ using internal::shared_ptr;
|
| namespace python {
|
|
|
| struct ExtensionDict;
|
| -struct PyDescriptorPool;
|
| +struct PyMessageFactory;
|
|
|
| typedef struct CMessage {
|
| PyObject_HEAD;
|
| @@ -112,8 +112,12 @@ typedef struct CMessage {
|
| // Similar to composite_fields, acting as a cache, but also contains the
|
| // required extension dict logic.
|
| ExtensionDict* extensions;
|
| +
|
| + // Implements the "weakref" protocol for this object.
|
| + PyObject* weakreflist;
|
| } CMessage;
|
|
|
| +extern PyTypeObject CMessageClass_Type;
|
| extern PyTypeObject CMessage_Type;
|
|
|
|
|
| @@ -132,14 +136,11 @@ struct CMessageClass {
|
| // Owned reference, used to keep the pointer above alive.
|
| PyObject* py_message_descriptor;
|
|
|
| - // The Python DescriptorPool used to create the class. It is needed to resolve
|
| + // The Python MessageFactory used to create the class. It is needed to resolve
|
| // fields descriptors, including extensions fields; its C++ MessageFactory is
|
| // used to instantiate submessages.
|
| - // This can be different from DESCRIPTOR.file.pool, in the case of a custom
|
| - // DescriptorPool which defines new extensions.
|
| - // We own the reference, because it's important to keep the descriptors and
|
| - // factory alive.
|
| - PyDescriptorPool* py_descriptor_pool;
|
| + // We own the reference, because it's important to keep the factory alive.
|
| + PyMessageFactory* py_message_factory;
|
|
|
| PyObject* AsPyObject() {
|
| return reinterpret_cast<PyObject*>(this);
|
| @@ -154,14 +155,6 @@ namespace cmessage {
|
| // The caller must fill self->message, self->owner and eventually self->parent.
|
| CMessage* NewEmptyMessage(CMessageClass* type);
|
|
|
| -// Release a submessage from its proto tree, making it a new top-level messgae.
|
| -// A new message will be created if this is a read-only default instance.
|
| -//
|
| -// Corresponds to reflection api method ReleaseMessage.
|
| -int ReleaseSubMessage(CMessage* self,
|
| - const FieldDescriptor* field_descriptor,
|
| - CMessage* child_cmessage);
|
| -
|
| // Retrieves the C++ descriptor of a Python Extension descriptor.
|
| // On error, return NULL with an exception set.
|
| const FieldDescriptor* GetExtensionDescriptor(PyObject* extension);
|
| @@ -237,10 +230,16 @@ PyObject* HasFieldByDescriptor(
|
| PyObject* HasField(CMessage* self, PyObject* arg);
|
|
|
| // Initializes values of fields on a newly constructed message.
|
| -int InitAttributes(CMessage* self, PyObject* kwargs);
|
| +// Note that positional arguments are disallowed: 'args' must be NULL or the
|
| +// empty tuple.
|
| +int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs);
|
|
|
| PyObject* MergeFrom(CMessage* self, PyObject* arg);
|
|
|
| +// This method does not do anything beyond checking that no other extension
|
| +// has been registered with the same field number on this class.
|
| +PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle);
|
| +
|
| // Retrieves an attribute named 'name' from CMessage 'self'. Returns
|
| // the attribute value on success, or NULL on failure.
|
| //
|
| @@ -260,14 +259,15 @@ int SetOwner(CMessage* self, const shared_ptr<Message>& new_owner);
|
|
|
| int AssureWritable(CMessage* self);
|
|
|
| -// Returns the "best" DescriptorPool for the given message.
|
| -// This is often equivalent to message.DESCRIPTOR.pool, but not always, when
|
| -// the message class was created from a MessageFactory using a custom pool which
|
| -// uses the generated pool as an underlay.
|
| +// Returns the message factory for the given message.
|
| +// This is equivalent to message.MESSAGE_FACTORY
|
| //
|
| -// The returned pool is suitable for finding fields and building submessages,
|
| +// The returned factory is suitable for finding fields and building submessages,
|
| // even in the case of extensions.
|
| -PyDescriptorPool* GetDescriptorPoolForMessage(CMessage* message);
|
| +// Returns a *borrowed* reference, and never fails because we pass a CMessage.
|
| +PyMessageFactory* GetFactoryForMessage(CMessage* message);
|
| +
|
| +PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
|
|
|
| } // namespace cmessage
|
|
|
| @@ -280,25 +280,25 @@ PyDescriptorPool* GetDescriptorPoolForMessage(CMessage* message);
|
|
|
| #define GOOGLE_CHECK_GET_INT32(arg, value, err) \
|
| int32 value; \
|
| - if (!CheckAndGetInteger(arg, &value, kint32min_py, kint32max_py)) { \
|
| + if (!CheckAndGetInteger(arg, &value)) { \
|
| return err; \
|
| }
|
|
|
| #define GOOGLE_CHECK_GET_INT64(arg, value, err) \
|
| int64 value; \
|
| - if (!CheckAndGetInteger(arg, &value, kint64min_py, kint64max_py)) { \
|
| + if (!CheckAndGetInteger(arg, &value)) { \
|
| return err; \
|
| }
|
|
|
| #define GOOGLE_CHECK_GET_UINT32(arg, value, err) \
|
| uint32 value; \
|
| - if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint32max_py)) { \
|
| + if (!CheckAndGetInteger(arg, &value)) { \
|
| return err; \
|
| }
|
|
|
| #define GOOGLE_CHECK_GET_UINT64(arg, value, err) \
|
| uint64 value; \
|
| - if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint64max_py)) { \
|
| + if (!CheckAndGetInteger(arg, &value)) { \
|
| return err; \
|
| }
|
|
|
| @@ -321,20 +321,11 @@ PyDescriptorPool* GetDescriptorPoolForMessage(CMessage* message);
|
| }
|
|
|
|
|
| -extern PyObject* kPythonZero;
|
| -extern PyObject* kint32min_py;
|
| -extern PyObject* kint32max_py;
|
| -extern PyObject* kuint32max_py;
|
| -extern PyObject* kint64min_py;
|
| -extern PyObject* kint64max_py;
|
| -extern PyObject* kuint64max_py;
|
| -
|
| #define FULL_MODULE_NAME "google.protobuf.pyext._message"
|
|
|
| void FormatTypeError(PyObject* arg, char* expected_types);
|
| template<class T>
|
| -bool CheckAndGetInteger(
|
| - PyObject* arg, T* value, PyObject* min, PyObject* max);
|
| +bool CheckAndGetInteger(PyObject* arg, T* value);
|
| bool CheckAndGetDouble(PyObject* arg, double* value);
|
| bool CheckAndGetFloat(PyObject* arg, float* value);
|
| bool CheckAndGetBool(PyObject* arg, bool* value);
|
| @@ -354,6 +345,8 @@ bool CheckFieldBelongsToMessage(const FieldDescriptor* field_descriptor,
|
|
|
| extern PyObject* PickleError_class;
|
|
|
| +bool InitProto2MessageModule(PyObject *m);
|
| +
|
| } // namespace python
|
| } // namespace protobuf
|
|
|
|
|