aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/pyext/extension_dict.h
diff options
context:
space:
mode:
Diffstat (limited to 'python/google/protobuf/pyext/extension_dict.h')
-rw-r--r--python/google/protobuf/pyext/extension_dict.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/python/google/protobuf/pyext/extension_dict.h b/python/google/protobuf/pyext/extension_dict.h
index 13c874a4..47625e23 100644
--- a/python/google/protobuf/pyext/extension_dict.h
+++ b/python/google/protobuf/pyext/extension_dict.h
@@ -53,13 +53,26 @@ using internal::shared_ptr;
namespace python {
struct CMessage;
-struct CFieldDescriptor;
typedef struct ExtensionDict {
PyObject_HEAD;
+
+ // This is the top-level C++ Message object that owns the whole
+ // proto tree. Every Python container class holds a
+ // reference to it in order to keep it alive as long as there's a
+ // Python object that references any part of the tree.
shared_ptr<Message> owner;
+
+ // Weak reference to parent message. Used to make sure
+ // the parent is writable when an extension field is modified.
CMessage* parent;
+
+ // Pointer to the C++ Message that this ExtensionDict extends.
+ // Not owned by us.
Message* message;
+
+ // A dict of child messages, indexed by Extension descriptors.
+ // Similar to CMessage::composite_fields.
PyObject* values;
} ExtensionDict;
@@ -67,11 +80,8 @@ extern PyTypeObject ExtensionDict_Type;
namespace extension_dict {
-// Gets the _cdescriptor reference to a CFieldDescriptor object given a
-// python descriptor object.
-//
-// Returns a new reference.
-CFieldDescriptor* InternalGetCDescriptorFromExtension(PyObject* extension);
+// Builds an Extensions dict for a specific message.
+ExtensionDict* NewExtensionDict(CMessage *parent);
// Gets the number of extension values in this ExtensionDict as a python object.
//