webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
repeated_scalar_container.h
Go to the documentation of this file.
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
42 #endif
43 
45 
46 namespace google {
47 namespace protobuf {
48 
49 class Message;
50 
51 #ifdef _SHARED_PTR_H
52 using std::shared_ptr;
53 #else
54 using internal::shared_ptr;
55 #endif
56 
57 namespace python {
58 
59 struct CMessage;
60 
61 typedef struct RepeatedScalarContainer {
63 
64  // This is the top-level C++ Message object that owns the whole
65  // proto tree. Every Python RepeatedScalarContainer holds a
66  // reference to it in order to keep it alive as long as there's a
67  // Python object that references any part of the tree.
69 
70  // Pointer to the C++ Message that contains this container. The
71  // RepeatedScalarContainer does not own this pointer.
73 
74  // Weak reference to a parent CMessage object (i.e. may be NULL.)
75  //
76  // Used to make sure all ancestors are also mutable when first
77  // modifying the container.
79 
80  // Pointer to the parent's descriptor that describes this
81  // field. Used together with the parent's message when making a
82  // default message instance mutable.
83  // The pointer is owned by the global DescriptorPool.
86 
87 extern PyTypeObject RepeatedScalarContainer_Type;
88 
89 namespace repeated_scalar_container {
90 
91 // Builds a RepeatedScalarContainer object, from a parent message and a
92 // field descriptor.
93 extern PyObject *NewContainer(
95 
96 // Appends the scalar 'item' to the end of the container 'self'.
97 //
98 // Returns None if successful; returns NULL and sets an exception if
99 // unsuccessful.
100 PyObject* Append(RepeatedScalarContainer* self, PyObject* item);
101 
102 // Releases the messages in the container to a new message.
103 //
104 // Returns 0 on success, -1 on failure.
106 
107 // Appends all the elements in the input iterator to the container.
108 //
109 // Returns None if successful; returns NULL and sets an exception if
110 // unsuccessful.
111 PyObject* Extend(RepeatedScalarContainer* self, PyObject* value);
112 
113 // Set the owner field of self and any children of self.
115  const shared_ptr<Message>& new_owner);
116 
117 } // namespace repeated_scalar_container
118 } // namespace python
119 } // namespace protobuf
120 
121 } // namespace google
122 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__
PyTypeObject RepeatedScalarContainer_Type
Definition: repeated_scalar_container.cc:771
Definition: message.h:179
Message * message
Definition: repeated_scalar_container.h:72
int SetOwner(CMessage *self, const shared_ptr< Message > &new_owner)
Definition: message.cc:1546
item
Definition: planet-cache.py:145
Message
Definition: peerconnection_unittest.cc:105
PyObject * Extend(RepeatedCompositeContainer *self, PyObject *value)
Definition: repeated_composite_container.cc:192
Definition: descriptor.h:439
CMessage * parent
Definition: repeated_scalar_container.h:78
struct google::protobuf::python::CMessage CMessage
EGLAttrib * value
Definition: eglext.h:120
Definition: __init__.py:1
Definition: message.h:67
int Release(RepeatedCompositeContainer *self)
Definition: repeated_composite_container.cc:458
Definition: shared_ptr.h:76
struct google::protobuf::python::RepeatedScalarContainer RepeatedScalarContainer
shared_ptr< Message > owner
Definition: repeated_scalar_container.h:68
PyObject * NewContainer(CMessage *parent, const FieldDescriptor *parent_field_descriptor, CMessageClass *concrete_class)
Definition: repeated_composite_container.cc:504
Definition: gflags_completions.h:115
Definition: repeated_scalar_container.h:61
PyObject_HEAD
Definition: repeated_scalar_container.h:62
const FieldDescriptor * parent_field_descriptor
Definition: repeated_scalar_container.h:84