Go to the documentation of this file.
50 return s->default_pool;
55 if (!s->c_descriptor_symtab) {
68 return &
pool->ob_base;
113 char* kwlist[] = {
"descriptor_db", 0};
116 if (!PyArg_ParseTupleAndKeywords(
args, kwargs,
"|O", kwlist, &db)) {
120 if (db == Py_None) db = NULL;
125 PyObject* file_desc);
130 if (PyErr_ExceptionMatches(PyExc_KeyError)) {
137 if (proto == Py_None)
return true;
139 bool ok =
ret != NULL;
146 if (!
self->db)
return false;
147 PyObject* file_proto =
148 PyObject_CallMethod(
self->db,
"FindFileContainingSymbol",
"O", sym);
150 Py_XDECREF(file_proto);
156 if (!
self->db)
return false;
157 PyObject* file_proto =
158 PyObject_CallMethod(
self->db,
"FindFileByName",
"O",
filename);
160 Py_XDECREF(file_proto);
171 for (
size_t i = 0;
i <
n;
i++) {
180 if (!
ok)
return false;
187 PyObject* _self, PyObject* serialized_pb) {
195 if (PyBytes_AsStringAndSize(serialized_pb, &
buf, &
size) < 0) {
202 PyErr_SetString(PyExc_TypeError,
"Couldn't parse file content!");
216 PyErr_SetNone(PyExc_MemoryError);
237 PyErr_Format(PyExc_TypeError,
238 "Couldn't build proto file into descriptor pool: %s",
251 PyObject* file_desc) {
254 const char* file_proto_name =
257 return PyErr_Format(PyExc_TypeError,
"Can only add FileDescriptorProto");
259 PyObject* subargs = PyTuple_New(0);
260 if (!subargs)
return NULL;
261 PyObject* serialized =
264 if (!serialized)
return NULL;
266 Py_DECREF(serialized);
279 PyObject* _self, PyObject* serialized_pb) {
284 "Cannot call AddSerializedFile on a DescriptorPool that uses a "
285 "DescriptorDatabase. Add your file to the underlying database.");
292 PyObject* file_desc) {
297 "Cannot call Add on a DescriptorPool that uses a DescriptorDatabase. "
298 "Add your file to the underlying database.");
315 if (!
name)
return NULL;
323 return PyErr_Format(PyExc_KeyError,
"Couldn't find file %.200s",
name);
340 if (!
name)
return NULL;
349 return PyErr_Format(PyExc_KeyError,
"Couldn't find extension %.200s",
name);
366 if (!
name)
return NULL;
369 if (
m == NULL &&
self->db) {
374 return PyErr_Format(PyExc_KeyError,
"Couldn't find message %.200s",
name);
384 size_t* parent_size) {
385 const char* last_dot = strrchr(sym,
'.');
386 if (!last_dot)
return NULL;
387 *parent_size = last_dot - sym;
402 if (!
name)
return NULL;
410 if (parent == NULL &&
self->db) {
421 return PyErr_Format(PyExc_KeyError,
"Couldn't find message %.200s",
name);
438 if (!
name)
return NULL;
441 if (e == NULL &&
self->db) {
446 return PyErr_Format(PyExc_KeyError,
"Couldn't find enum %.200s",
name);
463 if (!
name)
return NULL;
471 if (parent == NULL &&
self->db) {
482 return PyErr_Format(PyExc_KeyError,
"Couldn't find oneof %.200s",
name);
490 if (!
name)
return NULL;
493 if (s == NULL &&
self->db) {
498 return PyErr_Format(PyExc_KeyError,
"Couldn't find service %.200s",
name);
509 if (!
name)
return NULL;
516 if (parent == NULL &&
self->db) {
521 if (!parent)
goto err;
527 return PyErr_Format(PyExc_KeyError,
"Couldn't find method %.200s",
name);
535 if (!
name)
return NULL;
539 if (
f == NULL &&
self->db) {
544 return PyErr_Format(PyExc_KeyError,
"Couldn't find symbol %.200s",
name);
553 PyObject* message_descriptor;
555 if (!PyArg_ParseTuple(
args,
"Oi", &message_descriptor, &
number)) {
562 return PyErr_Format(PyExc_KeyError,
"Couldn't find Extension %d",
number);
569 PyObject* msg_desc) {
574 PyObject*
ret = PyList_New(
n);
575 for (
size_t i = 0;
i <
n;
i++) {
577 if (!
field)
return NULL;
585 "Adds the FileDescriptorProto and its types to this pool."},
587 "Adds a serialized FileDescriptorProto to this pool."},
589 "Searches for a file descriptor by its .proto name."},
591 METH_O,
"Searches for a message descriptor by full name."},
593 "Searches for a field descriptor by full name."},
595 "Searches for extension descriptor by full name."},
597 "Searches for enum type descriptor by full name."},
599 "Searches for oneof descriptor by full name."},
601 "Searches for service descriptor by full name."},
603 "Searches for method descriptor by full name."},
605 METH_O,
"Gets the FileDescriptor containing the specified symbol."},
607 METH_VARARGS,
"Gets the extension descriptor for the given number."},
609 "Gets all known extensions of the given message descriptor."},
624 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
634 PyTypeObject* descriptor_pool_type =
637 if (!descriptor_pool_type)
return false;
640 descriptor_pool_type, NULL,
state->obj_cache);
641 return state->default_pool &&
642 PyModule_AddObject(
m,
"default_pool",
state->default_pool) == 0;
const UPB_INLINE upb_MessageDef * google_protobuf_FileDescriptorProto_getmsgdef(upb_DefPool *s)
const upb_MessageDef * PyUpb_DescriptorPool_GetFileProtoDef(void)
static bool PyUpb_DescriptorPool_TryLoadSymbol(PyUpb_DescriptorPool *self, PyObject *sym)
PyObject * PyUpb_ServiceDescriptor_Get(const upb_ServiceDef *s)
static _upb_DefPool_Init * deps[4]
static PyObject * PyUpb_DescriptorPool_AddSerializedFile(PyObject *_self, PyObject *serialized_pb)
PyObject * PyUpb_MethodDescriptor_Get(const upb_MethodDef *m)
const upb_EnumDef * upb_DefPool_FindEnumByName(const upb_DefPool *s, const char *sym)
const upb_FieldDef ** upb_DefPool_GetAllExtensions(const upb_DefPool *s, const upb_MessageDef *m, size_t *count)
static PyType_Slot PyUpb_DescriptorPool_Slots[]
UPB_INLINE upb_StringView const * google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
PyObject * PyUpb_DescriptorPool_GetDefaultPool()
static PyObject * PyUpb_DescriptorPool_New(PyTypeObject *type, PyObject *args, PyObject *kwargs)
static PyObject * PyUpb_DescriptorPool_FindMessageTypeByName(PyObject *_self, PyObject *arg)
static PyObject * PyUpb_DescriptorPool_FindFieldByName(PyObject *_self, PyObject *arg)
static bool PyUpb_DescriptorPool_LoadDependentFiles(PyUpb_DescriptorPool *self, google_protobuf_FileDescriptorProto *proto)
bool PyUpb_CMessage_Verify(PyObject *self)
PyObject * PyUpb_EnumDescriptor_Get(const upb_EnumDef *enumdef)
bool PyUpb_InitDescriptorPool(PyObject *m)
static PyObject * PyUpb_DescriptorPool_FindExtensionByName(PyObject *_self, PyObject *arg)
PyUpb_ModuleState * PyUpb_ModuleState_GetFromModule(PyObject *module)
const upb_MessageDef * PyUpb_CMessage_GetMsgdef(PyObject *self)
const upb_MessageDef * PyUpb_Descriptor_GetDef(PyObject *_self)
static PyObject * PyUpb_DescriptorPool_Add(PyObject *_self, PyObject *file_desc)
static PyObject * PyUpb_DescriptorPool_FindFileByName(PyObject *_self, PyObject *arg)
const char * upb_Status_ErrorMessage(const upb_Status *status)
bool PyUpb_DescriptorPool_CheckNoDatabase(PyObject *_self)
UPB_INLINE upb_Arena * upb_Arena_New(void)
void upb_Status_Clear(upb_Status *status)
grpc_core::ScopedArenaPtr arena
static PyObject * PyUpb_DescriptorPool_DoAddSerializedFile(PyObject *_self, PyObject *serialized_pb)
static PyObject * PyUpb_DescriptorPool_FindFileContainingSymbol(PyObject *_self, PyObject *arg)
static void PyUpb_Dealloc(void *self)
PyObject * PyUpb_CMessage_SerializeToString(PyObject *_self, PyObject *args, PyObject *kwargs)
const upb_ServiceDef * upb_DefPool_FindServiceByName(const upb_DefPool *s, const char *name)
PyObject * PyUpb_Descriptor_Get(const upb_MessageDef *m)
upb_DefPool * upb_DefPool_New(void)
static PyObject * PyUpb_DescriptorPool_FindOneofByName(PyObject *_self, PyObject *arg)
static PyObject * PyUpb_DescriptorPool_FindMethodByName(PyObject *_self, PyObject *arg)
static void PyUpb_DescriptorPool_Dealloc(PyUpb_DescriptorPool *self)
PyTypeObject * PyUpb_AddClass(PyObject *m, PyType_Spec *spec)
const UPB_INLINE upb_FieldDef * upb_MessageDef_FindFieldByName(const upb_MessageDef *m, const char *name)
PyObject * PyUpb_FieldDescriptor_Get(const upb_FieldDef *field)
const char * PyUpb_VerifyStrData(PyObject *obj)
static PyObject * PyUpb_DescriptorPool_DoAdd(PyObject *_self, PyObject *file_desc)
PyUpb_WeakMap * PyUpb_ObjCache_Instance(void)
PyObject * PyUpb_DescriptorPool_Get(const upb_DefPool *symtab)
static int PyUpb_DescriptorPool_Clear(PyUpb_DescriptorPool *self)
void PyUpb_WeakMap_Add(PyUpb_WeakMap *map, const void *key, PyObject *py_obj)
static PyObject * PyUpb_DescriptorPool_FindAllExtensions(PyObject *_self, PyObject *msg_desc)
static PyObject * PyUpb_DescriptorPool_FindEnumTypeByName(PyObject *_self, PyObject *arg)
PyObject * PyUpb_OneofDescriptor_Get(const upb_OneofDef *oneof)
static PyObject * PyUpb_DescriptorPool_DoCreateWithCache(PyTypeObject *type, PyObject *db, PyUpb_WeakMap *obj_cache)
const upb_FieldDef * upb_DefPool_FindExtensionByNumber(const upb_DefPool *s, const upb_MessageDef *m, int32_t fieldnum)
PyObject * PyUpb_ObjCache_Get(const void *key)
upb_DefPool * PyUpb_DescriptorPool_GetSymtab(PyObject *pool)
PyUpb_ModuleState * PyUpb_ModuleState_Get(void)
const FieldDescriptor * field
#define PYUPB_MODULE_NAME
void upb_DefPool_Free(upb_DefPool *s)
const UPB_INLINE upb_OneofDef * upb_MessageDef_FindOneofByName(const upb_MessageDef *m, const char *name)
const upb_MessageDef * upb_DefPool_FindMessageByNameWithSize(const upb_DefPool *s, const char *sym, size_t len)
static int PyUpb_DescriptorPool_Traverse(PyUpb_DescriptorPool *self, visitproc visit, void *arg)
UniquePtr< SSL_SESSION > ret
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, upb_Arena *arena)
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg)
#define PYUPB_DESCRIPTOR_PROTO_PACKAGE
static PyObject * PyUpb_DescriptorPool_FindServiceByName(PyObject *_self, PyObject *arg)
const upb_FieldDef * upb_DefPool_FindExtensionByName(const upb_DefPool *s, const char *sym)
const char * upb_MessageDef_FullName(const upb_MessageDef *m)
static const char * PyUpb_DescriptorPool_SplitSymbolName(const char *sym, size_t *parent_size)
static bool PyUpb_DescriptorPool_TryLoadFilename(PyUpb_DescriptorPool *self, PyObject *filename)
const upb_FileDef * upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, upb_Status *status)
const upb_FileDef * upb_DefPool_FindFileContainingSymbol(const upb_DefPool *s, const char *name)
static bool PyUpb_DescriptorPool_TryLoadFileProto(PyUpb_DescriptorPool *self, PyObject *proto)
InternalDescriptorPool * pool
PyObject * PyUpb_FileDescriptor_Get(const upb_FileDef *file)
const upb_ServiceDef * upb_DefPool_FindServiceByNameWithSize(const upb_DefPool *s, const char *name, size_t size)
google_protobuf_FileDescriptorProto * upb_FileDef_ToProto(const upb_FileDef *f, upb_Arena *a)
static PyType_Spec PyUpb_DescriptorPool_Spec
variant_internal::VisitResult< Visitor, Variants... > visit(Visitor &&vis, Variants &&... vars)
static PyObject * PyUpb_DescriptorPool_FindExtensionByNumber(PyObject *_self, PyObject *args)
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern self
static PyMethodDef PyUpb_DescriptorPool_Methods[]
void PyUpb_ObjCache_Delete(const void *key)
const upb_FileDef * upb_DefPool_FindFileByNameWithSize(const upb_DefPool *s, const char *name, size_t len)
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
const upb_MessageDef * upb_DefPool_FindMessageByName(const upb_DefPool *s, const char *sym)
void upb_Arena_Free(upb_Arena *a)
const upb_MethodDef * upb_ServiceDef_FindMethodByName(const upb_ServiceDef *s, const char *name)
static PyObject * PyUpb_DescriptorPool_DoCreate(PyTypeObject *type, PyObject *db)
const upb_FileDef * upb_DefPool_FindFileByName(const upb_DefPool *s, const char *name)
bool PyUpb_Message_IsEqual(const upb_Message *msg1, const upb_Message *msg2, const upb_MessageDef *m)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:15