Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h

Issue 1291903002: Pull new version of protobuf sources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 // Author: anuraag@google.com (Anuraag Agrawal)
32 // Author: tibell@google.com (Johan Tibell)
33
34 #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
35 #define GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
36
37 #include <Python.h>
38
39 #include <memory>
40 #ifndef _SHARED_PTR_H
41 #include <google/protobuf/stubs/shared_ptr.h>
42 #endif
43
44 #include <google/protobuf/descriptor.h>
45
46 namespace google {
47 namespace protobuf {
48
49 class Message;
50
51 using internal::shared_ptr;
52
53 namespace python {
54
55 struct CMessage;
56
57 typedef struct RepeatedScalarContainer {
58 PyObject_HEAD;
59
60 // This is the top-level C++ Message object that owns the whole
61 // proto tree. Every Python RepeatedScalarContainer holds a
62 // reference to it in order to keep it alive as long as there's a
63 // Python object that references any part of the tree.
64 shared_ptr<Message> owner;
65
66 // Pointer to the C++ Message that contains this container. The
67 // RepeatedScalarContainer does not own this pointer.
68 Message* message;
69
70 // Weak reference to a parent CMessage object (i.e. may be NULL.)
71 //
72 // Used to make sure all ancestors are also mutable when first
73 // modifying the container.
74 CMessage* parent;
75
76 // Pointer to the parent's descriptor that describes this
77 // field. Used together with the parent's message when making a
78 // default message instance mutable.
79 // The pointer is owned by the global DescriptorPool.
80 const FieldDescriptor* parent_field_descriptor;
81 } RepeatedScalarContainer;
82
83 extern PyTypeObject RepeatedScalarContainer_Type;
84
85 namespace repeated_scalar_container {
86
87 // Builds a RepeatedScalarContainer object, from a parent message and a
88 // field descriptor.
89 extern PyObject *NewContainer(
90 CMessage* parent, const FieldDescriptor* parent_field_descriptor);
91
92 // Appends the scalar 'item' to the end of the container 'self'.
93 //
94 // Returns None if successful; returns NULL and sets an exception if
95 // unsuccessful.
96 PyObject* Append(RepeatedScalarContainer* self, PyObject* item);
97
98 // Releases the messages in the container to a new message.
99 //
100 // Returns 0 on success, -1 on failure.
101 int Release(RepeatedScalarContainer* self);
102
103 // Appends all the elements in the input iterator to the container.
104 //
105 // Returns None if successful; returns NULL and sets an exception if
106 // unsuccessful.
107 PyObject* Extend(RepeatedScalarContainer* self, PyObject* value);
108
109 // Set the owner field of self and any children of self.
110 void SetOwner(RepeatedScalarContainer* self,
111 const shared_ptr<Message>& new_owner);
112
113 } // namespace repeated_scalar_container
114 } // namespace python
115 } // namespace protobuf
116
117 } // namespace google
118 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698