webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
descriptor.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: petar@google.com (Petar Petrov)
32 
33 #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
34 #define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
35 
36 #include <Python.h>
37 
39 
40 namespace google {
41 namespace protobuf {
42 namespace python {
43 
44 extern PyTypeObject PyMessageDescriptor_Type;
45 extern PyTypeObject PyFieldDescriptor_Type;
46 extern PyTypeObject PyEnumDescriptor_Type;
47 extern PyTypeObject PyEnumValueDescriptor_Type;
48 extern PyTypeObject PyFileDescriptor_Type;
49 extern PyTypeObject PyOneofDescriptor_Type;
50 
51 // Wraps a Descriptor in a Python object.
52 // The C++ pointer is usually borrowed from the global DescriptorPool.
53 // In any case, it must stay alive as long as the Python object.
54 // Returns a new reference.
59  const EnumValueDescriptor* descriptor);
62  const FileDescriptor* file_descriptor);
63 
64 // Alternate constructor of PyFileDescriptor, used when we already have a
65 // serialized FileDescriptorProto that can be cached.
66 // Returns a new reference.
68  const FileDescriptor* file_descriptor, PyObject* serialized_pb);
69 
70 // Return the C++ descriptor pointer.
71 // This function checks the parameter type; on error, return NULL with a Python
72 // exception set.
76 const FileDescriptor* PyFileDescriptor_AsDescriptor(PyObject* obj);
77 
78 // Returns the raw C++ pointer.
79 const void* PyDescriptor_AsVoidPtr(PyObject* obj);
80 
81 // Check that the calling Python code is the global scope of a _pb2.py module.
82 // This function is used to support the current code generated by the proto
83 // compiler, which insists on modifying descriptors after they have been
84 // created.
85 //
86 // stacklevel indicates which Python frame should be the _pb2.py module.
87 //
88 // Don't use this function outside descriptor classes.
89 bool _CalledFromGeneratedFile(int stacklevel);
90 
91 bool InitDescriptor();
92 
93 } // namespace python
94 } // namespace protobuf
95 
96 } // namespace google
97 #endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__
const void * PyDescriptor_AsVoidPtr(PyObject *obj)
Definition: descriptor.cc:404
PyObject * PyEnumValueDescriptor_FromDescriptor(const EnumValueDescriptor *enumvalue_descriptor)
Definition: descriptor.cc:1214
Definition: protobuf.h:90
PyTypeObject PyEnumValueDescriptor_Type
Definition: descriptor.cc:1180
const Descriptor * descriptor
Definition: descriptor.cc:271
bool InitDescriptor()
Definition: descriptor.cc:1533
EGLNativeFileDescriptorKHR file_descriptor
Definition: eglext.h:357
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1053
PyTypeObject PyOneofDescriptor_Type
Definition: descriptor.cc:1467
const EnumDescriptor * PyEnumDescriptor_AsDescriptor(PyObject *obj)
Definition: descriptor.cc:1106
PyObject * PyFileDescriptor_FromDescriptor(const FileDescriptor *file_descriptor)
Definition: descriptor.cc:1386
Definition: protobuf.h:85
PyTypeObject PyFileDescriptor_Type
Definition: descriptor.cc:1344
PyObject * PyFieldDescriptor_FromDescriptor(const FieldDescriptor *field_descriptor)
Definition: descriptor.cc:952
const Descriptor * PyMessageDescriptor_AsDescriptor(PyObject *obj)
Definition: descriptor.cc:668
const FieldDescriptor * PyFieldDescriptor_AsDescriptor(PyObject *obj)
Definition: descriptor.cc:958
Definition: __init__.py:1
PyTypeObject PyMessageDescriptor_Type
Definition: descriptor.cc:628
const FileDescriptor * PyFileDescriptor_AsDescriptor(PyObject *obj)
Definition: descriptor.cc:1412
PyObject * PyOneofDescriptor_FromDescriptor(const OneofDescriptor *oneof_descriptor)
Definition: descriptor.cc:1501
PyTypeObject PyEnumDescriptor_Type
Definition: descriptor.cc:1066
bool _CalledFromGeneratedFile(int stacklevel)
Definition: descriptor.cc:94
PyObject * PyMessageDescriptor_FromDescriptor(const Descriptor *message_descriptor)
Definition: descriptor.cc:662
PyObject * PyFileDescriptor_FromDescriptorWithSerializedPb(const FileDescriptor *file_descriptor, PyObject *serialized_pb)
Definition: descriptor.cc:1392
PyObject * PyEnumDescriptor_FromDescriptor(const EnumDescriptor *enum_descriptor)
Definition: descriptor.cc:1100
Definition: gflags_completions.h:115
PyTypeObject PyFieldDescriptor_Type
Definition: descriptor.cc:918
Definition: protobuf.h:70
Definition: protobuf.h:95