| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 #ifdef _SHARED_PTR_H | 52 #ifdef _SHARED_PTR_H |
| 53 using std::shared_ptr; | 53 using std::shared_ptr; |
| 54 #else | 54 #else |
| 55 using internal::shared_ptr; | 55 using internal::shared_ptr; |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 namespace python { | 58 namespace python { |
| 59 | 59 |
| 60 struct CMessage; | 60 struct CMessage; |
| 61 struct CMessageClass; |
| 61 | 62 |
| 62 // A RepeatedCompositeContainer can be in one of two states: attached | 63 // A RepeatedCompositeContainer can be in one of two states: attached |
| 63 // or released. | 64 // or released. |
| 64 // | 65 // |
| 65 // When in the attached state all modifications to the container are | 66 // When in the attached state all modifications to the container are |
| 66 // done both on the 'message' and on the 'child_messages' | 67 // done both on the 'message' and on the 'child_messages' |
| 67 // list. In this state all Messages referred to by the children in | 68 // list. In this state all Messages referred to by the children in |
| 68 // 'child_messages' are owner by the 'owner'. | 69 // 'child_messages' are owner by the 'owner'. |
| 69 // | 70 // |
| 70 // When in the released state 'message', 'owner', 'parent', and | 71 // When in the released state 'message', 'owner', 'parent', and |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 // The pointer is owned by the global DescriptorPool. | 88 // The pointer is owned by the global DescriptorPool. |
| 88 const FieldDescriptor* parent_field_descriptor; | 89 const FieldDescriptor* parent_field_descriptor; |
| 89 | 90 |
| 90 // Pointer to the C++ Message that contains this container. The | 91 // Pointer to the C++ Message that contains this container. The |
| 91 // RepeatedCompositeContainer does not own this pointer. | 92 // RepeatedCompositeContainer does not own this pointer. |
| 92 // | 93 // |
| 93 // If NULL, this message has been released from its parent (by | 94 // If NULL, this message has been released from its parent (by |
| 94 // calling Clear() or ClearField() on the parent. | 95 // calling Clear() or ClearField() on the parent. |
| 95 Message* message; | 96 Message* message; |
| 96 | 97 |
| 97 // A callable that is used to create new child messages. | 98 // The type used to create new child messages. |
| 98 PyObject* subclass_init; | 99 CMessageClass* child_message_class; |
| 99 | 100 |
| 100 // A list of child messages. | 101 // A list of child messages. |
| 101 PyObject* child_messages; | 102 PyObject* child_messages; |
| 102 } RepeatedCompositeContainer; | 103 } RepeatedCompositeContainer; |
| 103 | 104 |
| 104 extern PyTypeObject RepeatedCompositeContainer_Type; | 105 extern PyTypeObject RepeatedCompositeContainer_Type; |
| 105 | 106 |
| 106 namespace repeated_composite_container { | 107 namespace repeated_composite_container { |
| 107 | 108 |
| 108 // Builds a RepeatedCompositeContainer object, from a parent message and a | 109 // Builds a RepeatedCompositeContainer object, from a parent message and a |
| 109 // field descriptor. | 110 // field descriptor. |
| 110 PyObject *NewContainer( | 111 PyObject *NewContainer( |
| 111 CMessage* parent, | 112 CMessage* parent, |
| 112 const FieldDescriptor* parent_field_descriptor, | 113 const FieldDescriptor* parent_field_descriptor, |
| 113 PyObject *concrete_class); | 114 CMessageClass *child_message_class); |
| 114 | 115 |
| 115 // Appends a new CMessage to the container and returns it. The | 116 // Appends a new CMessage to the container and returns it. The |
| 116 // CMessage is initialized using the content of kwargs. | 117 // CMessage is initialized using the content of kwargs. |
| 117 // | 118 // |
| 118 // Returns a new reference if successful; returns NULL and sets an | 119 // Returns a new reference if successful; returns NULL and sets an |
| 119 // exception if unsuccessful. | 120 // exception if unsuccessful. |
| 120 PyObject* Add(RepeatedCompositeContainer* self, | 121 PyObject* Add(RepeatedCompositeContainer* self, |
| 121 PyObject* args, | 122 PyObject* args, |
| 122 PyObject* kwargs); | 123 PyObject* kwargs); |
| 123 | 124 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void ReleaseLastTo(CMessage* parent, | 170 void ReleaseLastTo(CMessage* parent, |
| 170 const FieldDescriptor* field, | 171 const FieldDescriptor* field, |
| 171 CMessage* target); | 172 CMessage* target); |
| 172 | 173 |
| 173 } // namespace repeated_composite_container | 174 } // namespace repeated_composite_container |
| 174 } // namespace python | 175 } // namespace python |
| 175 } // namespace protobuf | 176 } // namespace protobuf |
| 176 | 177 |
| 177 } // namespace google | 178 } // namespace google |
| 178 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__ | 179 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__ |
| OLD | NEW |