upb/python/descriptor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2021, Google LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Google LLC nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef PYUPB_DESCRIPTOR_H__
29 #define PYUPB_DESCRIPTOR_H__
30 
31 #include <stdbool.h>
32 
33 #include "python/python.h"
34 #include "upb/def.h"
35 
36 typedef enum {
47 
48 // Given a descriptor object |desc|, returns a Python message class object for
49 // the msgdef |m|, which must be from the same pool.
51 
52 // Returns a Python wrapper object for the given def. This will return an
53 // existing object if one already exists, otherwise a new object will be
54 // created. The caller always owns a ref on the returned object.
58 PyObject* PyUpb_FileDescriptor_Get(const upb_FileDef* file);
59 PyObject* PyUpb_OneofDescriptor_Get(const upb_OneofDef* oneof);
60 PyObject* PyUpb_EnumValueDescriptor_Get(const upb_EnumValueDef* enumval);
63 PyObject* PyUpb_MethodDescriptor_Get(const upb_MethodDef* s);
64 
65 // Returns the underlying |def| for a given wrapper object. The caller must
66 // have already verified that the given Python object is of the expected type.
69 const upb_MessageDef* PyUpb_Descriptor_GetDef(PyObject* _self);
70 const void* PyUpb_AnyDescriptor_GetDef(PyObject* _self);
71 
72 // Returns the underlying |def| for a given wrapper object. The caller must
73 // have already verified that the given Python object is of the expected type.
75 const void* PyUpb_AnyDescriptor_GetDef(PyObject* _self);
76 
77 // Module-level init.
78 bool PyUpb_InitDescriptor(PyObject* m);
79 
80 #endif // PYUPB_DESCRIPTOR_H__
PyUpb_FileDescriptor_GetDef
const upb_FileDef * PyUpb_FileDescriptor_GetDef(PyObject *file)
Definition: descriptor.c:1312
python.h
PyUpb_EnumValueDescriptor_Get
PyObject * PyUpb_EnumValueDescriptor_Get(const upb_EnumValueDef *enumval)
Definition: descriptor.c:785
upb_MessageDef
Definition: upb/upb/def.c:100
PyUpb_FieldDescriptor_GetDef
const upb_FieldDef * PyUpb_FieldDescriptor_GetDef(PyObject *file)
Definition: descriptor.c:864
PyUpb_FileDescriptor_Get
PyObject * PyUpb_FileDescriptor_Get(const upb_FileDef *file)
Definition: descriptor.c:1084
upb_MethodDef
Definition: upb/upb/def.c:197
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
PyUpb_OneofDescriptor_Get
PyObject * PyUpb_OneofDescriptor_Get(const upb_OneofDef *oneof)
Definition: descriptor.c:1426
upb_OneofDef
Definition: upb/upb/def.c:157
kPyUpb_FileDescriptor
@ kPyUpb_FileDescriptor
Definition: upb/python/descriptor.h:41
kPyUpb_Descriptor
@ kPyUpb_Descriptor
Definition: upb/python/descriptor.h:37
kPyUpb_MethodDescriptor
@ kPyUpb_MethodDescriptor
Definition: upb/python/descriptor.h:42
kPyUpb_FieldDescriptor
@ kPyUpb_FieldDescriptor
Definition: upb/python/descriptor.h:40
kPyUpb_EnumDescriptor
@ kPyUpb_EnumDescriptor
Definition: upb/python/descriptor.h:38
upb_ServiceDef
Definition: upb/upb/def.c:208
PyUpb_DescriptorType
PyUpb_DescriptorType
Definition: upb/python/descriptor.h:36
kPyUpb_Descriptor_Count
@ kPyUpb_Descriptor_Count
Definition: upb/python/descriptor.h:45
upb_EnumValueDef
Definition: upb/upb/def.c:150
PyUpb_FieldDescriptor_Get
PyObject * PyUpb_FieldDescriptor_Get(const upb_FieldDef *field)
Definition: descriptor.c:870
PyUpb_Descriptor_GetClass
PyObject * PyUpb_Descriptor_GetClass(const upb_MessageDef *m)
Definition: descriptor.c:210
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
upb_FieldDef
Definition: upb/upb/def.c:56
PyUpb_ServiceDescriptor_Get
PyObject * PyUpb_ServiceDescriptor_Get(const upb_ServiceDef *s)
Definition: descriptor.c:1519
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
PyUpb_EnumDescriptor_Get
PyObject * PyUpb_EnumDescriptor_Get(const upb_EnumDef *enumdef)
Definition: descriptor.c:649
PyUpb_Descriptor_GetOrCreateWrapper
PyObject * PyUpb_Descriptor_GetOrCreateWrapper(const upb_MessageDef *msg)
upb_FileDef
Definition: upb/upb/def.c:171
def.h
PyUpb_MethodDescriptor_Get
PyObject * PyUpb_MethodDescriptor_Get(const upb_MethodDef *s)
Definition: descriptor.c:1328
kPyUpb_ServiceDescriptor
@ kPyUpb_ServiceDescriptor
Definition: upb/python/descriptor.h:44
msgdef
const upb_msgdef * msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:808
PyUpb_Descriptor_GetDef
const upb_MessageDef * PyUpb_Descriptor_GetDef(PyObject *_self)
Definition: descriptor.c:639
enumdef
const upb_enumdef * enumdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:839
PyUpb_Descriptor_Get
PyObject * PyUpb_Descriptor_Get(const upb_MessageDef *msgdef)
Definition: descriptor.c:204
upb_EnumDef
Definition: upb/upb/def.c:134
kPyUpb_OneofDescriptor
@ kPyUpb_OneofDescriptor
Definition: upb/python/descriptor.h:43
regress.m
m
Definition: regress/regress.py:25
kPyUpb_EnumValueDescriptor
@ kPyUpb_EnumValueDescriptor
Definition: upb/python/descriptor.h:39
PyUpb_InitDescriptor
bool PyUpb_InitDescriptor(PyObject *m)
Definition: descriptor.c:1654
PyUpb_AnyDescriptor_GetDef
const void * PyUpb_AnyDescriptor_GetDef(PyObject *_self)
Definition: descriptor.c:56


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:05