descriptor_pool.c
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 #include "python/descriptor_pool.h"
29 
31 #include "python/convert.h"
32 #include "python/descriptor.h"
33 #include "python/message.h"
34 #include "python/protobuf.h"
35 #include "upb/def.h"
36 #include "upb/util/def_to_proto.h"
37 
38 // -----------------------------------------------------------------------------
39 // DescriptorPool
40 // -----------------------------------------------------------------------------
41 
42 typedef struct {
45  PyObject* db; // The DescriptorDatabase underlying this pool. May be NULL.
47 
50  return s->default_pool;
51 }
52 
55  if (!s->c_descriptor_symtab) {
56  s->c_descriptor_symtab = upb_DefPool_New();
57  }
58  return google_protobuf_FileDescriptorProto_getmsgdef(s->c_descriptor_symtab);
59 }
60 
62  PyTypeObject* type, PyObject* db, PyUpb_WeakMap* obj_cache) {
63  PyUpb_DescriptorPool* pool = (void*)PyType_GenericAlloc(type, 0);
64  pool->symtab = upb_DefPool_New();
65  pool->db = db;
66  Py_XINCREF(pool->db);
67  PyUpb_WeakMap_Add(obj_cache, pool->symtab, &pool->ob_base);
68  return &pool->ob_base;
69 }
70 
71 static PyObject* PyUpb_DescriptorPool_DoCreate(PyTypeObject* type,
72  PyObject* db) {
75 }
76 
78  return ((PyUpb_DescriptorPool*)pool)->symtab;
79 }
80 
82  visitproc visit, void* arg) {
83  Py_VISIT(self->db);
84  return 0;
85 }
86 
88  Py_CLEAR(self->db);
89  return 0;
90 }
91 
93  PyObject* pool = PyUpb_ObjCache_Get(symtab);
94  assert(pool);
95  return pool;
96 }
97 
100  upb_DefPool_Free(self->symtab);
101  PyUpb_ObjCache_Delete(self->symtab);
102  PyUpb_Dealloc(self);
103 }
104 
105 /*
106  * DescriptorPool.__new__()
107  *
108  * Implements:
109  * DescriptorPool(descriptor_db=None)
110  */
111 static PyObject* PyUpb_DescriptorPool_New(PyTypeObject* type, PyObject* args,
112  PyObject* kwargs) {
113  char* kwlist[] = {"descriptor_db", 0};
114  PyObject* db = NULL;
115 
116  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &db)) {
117  return NULL;
118  }
119 
120  if (db == Py_None) db = NULL;
122 }
123 
124 static PyObject* PyUpb_DescriptorPool_DoAdd(PyObject* _self,
125  PyObject* file_desc);
126 
128  PyObject* proto) {
129  if (proto == NULL) {
130  if (PyErr_ExceptionMatches(PyExc_KeyError)) {
131  // Expected error: item was simply not found.
132  PyErr_Clear();
133  return true; // We didn't accomplish our goal, but we didn't error out.
134  }
135  return false;
136  }
137  if (proto == Py_None) return true;
138  PyObject* ret = PyUpb_DescriptorPool_DoAdd((PyObject*)self, proto);
139  bool ok = ret != NULL;
140  Py_XDECREF(ret);
141  return ok;
142 }
143 
145  PyObject* sym) {
146  if (!self->db) return false;
147  PyObject* file_proto =
148  PyObject_CallMethod(self->db, "FindFileContainingSymbol", "O", sym);
149  bool ret = PyUpb_DescriptorPool_TryLoadFileProto(self, file_proto);
150  Py_XDECREF(file_proto);
151  return ret;
152 }
153 
155  PyObject* filename) {
156  if (!self->db) return false;
157  PyObject* file_proto =
158  PyObject_CallMethod(self->db, "FindFileByName", "O", filename);
159  bool ret = PyUpb_DescriptorPool_TryLoadFileProto(self, file_proto);
160  Py_XDECREF(file_proto);
161  return ret;
162 }
163 
164 bool PyUpb_DescriptorPool_CheckNoDatabase(PyObject* _self) { return true; }
165 
168  size_t n;
169  const upb_StringView* deps =
171  for (size_t i = 0; i < n; i++) {
173  self->symtab, deps[i].data, deps[i].size);
174  if (!dep) {
175  PyObject* filename =
176  PyUnicode_FromStringAndSize(deps[i].data, deps[i].size);
177  if (!filename) return false;
179  Py_DECREF(filename);
180  if (!ok) return false;
181  }
182  }
183  return true;
184 }
185 
187  PyObject* _self, PyObject* serialized_pb) {
190  if (!arena) PYUPB_RETURN_OOM;
191  PyObject* result = NULL;
192 
193  char* buf;
194  Py_ssize_t size;
195  if (PyBytes_AsStringAndSize(serialized_pb, &buf, &size) < 0) {
196  goto done;
197  }
198 
201  if (!proto) {
202  PyErr_SetString(PyExc_TypeError, "Couldn't parse file content!");
203  goto done;
204  }
205 
207  const upb_FileDef* file =
208  upb_DefPool_FindFileByNameWithSize(self->symtab, name.data, name.size);
209 
210  if (file) {
211  // If the existing file is equal to the new file, then silently ignore the
212  // duplicate add.
215  if (!existing) {
216  PyErr_SetNone(PyExc_MemoryError);
217  goto done;
218  }
220  if (PyUpb_Message_IsEqual(proto, existing, m)) {
221  Py_INCREF(Py_None);
222  result = Py_None;
223  goto done;
224  }
225  }
226 
227  if (self->db) {
228  if (!PyUpb_DescriptorPool_LoadDependentFiles(self, proto)) goto done;
229  }
230 
233 
234  const upb_FileDef* filedef =
235  upb_DefPool_AddFile(self->symtab, proto, &status);
236  if (!filedef) {
237  PyErr_Format(PyExc_TypeError,
238  "Couldn't build proto file into descriptor pool: %s",
240  goto done;
241  }
242 
243  result = PyUpb_FileDescriptor_Get(filedef);
244 
245 done:
247  return result;
248 }
249 
250 static PyObject* PyUpb_DescriptorPool_DoAdd(PyObject* _self,
251  PyObject* file_desc) {
252  if (!PyUpb_CMessage_Verify(file_desc)) return NULL;
253  const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(file_desc);
254  const char* file_proto_name =
255  PYUPB_DESCRIPTOR_PROTO_PACKAGE ".FileDescriptorProto";
256  if (strcmp(upb_MessageDef_FullName(m), file_proto_name) != 0) {
257  return PyErr_Format(PyExc_TypeError, "Can only add FileDescriptorProto");
258  }
259  PyObject* subargs = PyTuple_New(0);
260  if (!subargs) return NULL;
261  PyObject* serialized =
262  PyUpb_CMessage_SerializeToString(file_desc, subargs, NULL);
263  Py_DECREF(subargs);
264  if (!serialized) return NULL;
265  PyObject* ret = PyUpb_DescriptorPool_DoAddSerializedFile(_self, serialized);
266  Py_DECREF(serialized);
267  return ret;
268 }
269 
270 /*
271  * PyUpb_DescriptorPool_AddSerializedFile()
272  *
273  * Implements:
274  * DescriptorPool.AddSerializedFile(self, serialized_file_descriptor)
275  *
276  * Adds the given serialized FileDescriptorProto to the pool.
277  */
279  PyObject* _self, PyObject* serialized_pb) {
281  if (self->db) {
282  PyErr_SetString(
283  PyExc_ValueError,
284  "Cannot call AddSerializedFile on a DescriptorPool that uses a "
285  "DescriptorDatabase. Add your file to the underlying database.");
286  return false;
287  }
288  return PyUpb_DescriptorPool_DoAddSerializedFile(_self, serialized_pb);
289 }
290 
291 static PyObject* PyUpb_DescriptorPool_Add(PyObject* _self,
292  PyObject* file_desc) {
294  if (self->db) {
295  PyErr_SetString(
296  PyExc_ValueError,
297  "Cannot call Add on a DescriptorPool that uses a DescriptorDatabase. "
298  "Add your file to the underlying database.");
299  return false;
300  }
301  return PyUpb_DescriptorPool_DoAdd(_self, file_desc);
302 }
303 
304 /*
305  * PyUpb_DescriptorPool_FindFileByName()
306  *
307  * Implements:
308  * DescriptorPool.FindFileByName(self, name)
309  */
310 static PyObject* PyUpb_DescriptorPool_FindFileByName(PyObject* _self,
311  PyObject* arg) {
313 
314  const char* name = PyUpb_VerifyStrData(arg);
315  if (!name) return NULL;
316 
318  if (file == NULL && self->db) {
319  if (!PyUpb_DescriptorPool_TryLoadFilename(self, arg)) return NULL;
321  }
322  if (file == NULL) {
323  return PyErr_Format(PyExc_KeyError, "Couldn't find file %.200s", name);
324  }
325 
327 }
328 
329 /*
330  * PyUpb_DescriptorPool_FindExtensionByName()
331  *
332  * Implements:
333  * DescriptorPool.FindExtensionByName(self, name)
334  */
335 static PyObject* PyUpb_DescriptorPool_FindExtensionByName(PyObject* _self,
336  PyObject* arg) {
338 
339  const char* name = PyUpb_VerifyStrData(arg);
340  if (!name) return NULL;
341 
342  const upb_FieldDef* field =
344  if (field == NULL && self->db) {
345  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
347  }
348  if (field == NULL) {
349  return PyErr_Format(PyExc_KeyError, "Couldn't find extension %.200s", name);
350  }
351 
353 }
354 
355 /*
356  * PyUpb_DescriptorPool_FindMessageTypeByName()
357  *
358  * Implements:
359  * DescriptorPool.FindMessageTypeByName(self, name)
360  */
361 static PyObject* PyUpb_DescriptorPool_FindMessageTypeByName(PyObject* _self,
362  PyObject* arg) {
364 
365  const char* name = PyUpb_VerifyStrData(arg);
366  if (!name) return NULL;
367 
369  if (m == NULL && self->db) {
370  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
372  }
373  if (m == NULL) {
374  return PyErr_Format(PyExc_KeyError, "Couldn't find message %.200s", name);
375  }
376 
377  return PyUpb_Descriptor_Get(m);
378 }
379 
380 // Splits a dotted symbol like foo.bar.baz on the last dot. Returns the portion
381 // after the last dot (baz) and updates `*parent_size` to the length of the
382 // parent (foo.bar). Returns NULL if no dots were present.
383 static const char* PyUpb_DescriptorPool_SplitSymbolName(const char* sym,
384  size_t* parent_size) {
385  const char* last_dot = strrchr(sym, '.');
386  if (!last_dot) return NULL;
387  *parent_size = last_dot - sym;
388  return last_dot + 1;
389 }
390 
391 /*
392  * PyUpb_DescriptorPool_FindFieldByName()
393  *
394  * Implements:
395  * DescriptorPool.FindFieldByName(self, name)
396  */
397 static PyObject* PyUpb_DescriptorPool_FindFieldByName(PyObject* _self,
398  PyObject* arg) {
400 
401  const char* name = PyUpb_VerifyStrData(arg);
402  if (!name) return NULL;
403 
404  size_t parent_size;
405  const char* child = PyUpb_DescriptorPool_SplitSymbolName(name, &parent_size);
406  const upb_FieldDef* f = NULL;
407  if (child) {
408  const upb_MessageDef* parent =
409  upb_DefPool_FindMessageByNameWithSize(self->symtab, name, parent_size);
410  if (parent == NULL && self->db) {
411  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
413  parent_size);
414  }
415  if (parent) {
417  }
418  }
419 
420  if (!f) {
421  return PyErr_Format(PyExc_KeyError, "Couldn't find message %.200s", name);
422  }
423 
425 }
426 
427 /*
428  * PyUpb_DescriptorPool_FindEnumTypeByName()
429  *
430  * Implements:
431  * DescriptorPool.FindEnumTypeByName(self, name)
432  */
433 static PyObject* PyUpb_DescriptorPool_FindEnumTypeByName(PyObject* _self,
434  PyObject* arg) {
436 
437  const char* name = PyUpb_VerifyStrData(arg);
438  if (!name) return NULL;
439 
440  const upb_EnumDef* e = upb_DefPool_FindEnumByName(self->symtab, name);
441  if (e == NULL && self->db) {
442  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
443  e = upb_DefPool_FindEnumByName(self->symtab, name);
444  }
445  if (e == NULL) {
446  return PyErr_Format(PyExc_KeyError, "Couldn't find enum %.200s", name);
447  }
448 
449  return PyUpb_EnumDescriptor_Get(e);
450 }
451 
452 /*
453  * PyUpb_DescriptorPool_FindOneofByName()
454  *
455  * Implements:
456  * DescriptorPool.FindOneofByName(self, name)
457  */
458 static PyObject* PyUpb_DescriptorPool_FindOneofByName(PyObject* _self,
459  PyObject* arg) {
461 
462  const char* name = PyUpb_VerifyStrData(arg);
463  if (!name) return NULL;
464 
465  size_t parent_size;
466  const char* child = PyUpb_DescriptorPool_SplitSymbolName(name, &parent_size);
467 
468  if (child) {
469  const upb_MessageDef* parent =
470  upb_DefPool_FindMessageByNameWithSize(self->symtab, name, parent_size);
471  if (parent == NULL && self->db) {
472  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
474  parent_size);
475  }
476  if (parent) {
479  }
480  }
481 
482  return PyErr_Format(PyExc_KeyError, "Couldn't find oneof %.200s", name);
483 }
484 
485 static PyObject* PyUpb_DescriptorPool_FindServiceByName(PyObject* _self,
486  PyObject* arg) {
488 
489  const char* name = PyUpb_VerifyStrData(arg);
490  if (!name) return NULL;
491 
493  if (s == NULL && self->db) {
494  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
496  }
497  if (s == NULL) {
498  return PyErr_Format(PyExc_KeyError, "Couldn't find service %.200s", name);
499  }
500 
501  return PyUpb_ServiceDescriptor_Get(s);
502 }
503 
504 static PyObject* PyUpb_DescriptorPool_FindMethodByName(PyObject* _self,
505  PyObject* arg) {
507 
508  const char* name = PyUpb_VerifyStrData(arg);
509  if (!name) return NULL;
510  size_t parent_size;
511  const char* child = PyUpb_DescriptorPool_SplitSymbolName(name, &parent_size);
512 
513  if (!child) goto err;
514  const upb_ServiceDef* parent =
515  upb_DefPool_FindServiceByNameWithSize(self->symtab, name, parent_size);
516  if (parent == NULL && self->db) {
517  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
518  parent =
519  upb_DefPool_FindServiceByNameWithSize(self->symtab, name, parent_size);
520  }
521  if (!parent) goto err;
523  if (!m) goto err;
525 
526 err:
527  return PyErr_Format(PyExc_KeyError, "Couldn't find method %.200s", name);
528 }
529 
530 static PyObject* PyUpb_DescriptorPool_FindFileContainingSymbol(PyObject* _self,
531  PyObject* arg) {
533 
534  const char* name = PyUpb_VerifyStrData(arg);
535  if (!name) return NULL;
536 
537  const upb_FileDef* f =
539  if (f == NULL && self->db) {
540  if (!PyUpb_DescriptorPool_TryLoadSymbol(self, arg)) return NULL;
542  }
543  if (f == NULL) {
544  return PyErr_Format(PyExc_KeyError, "Couldn't find symbol %.200s", name);
545  }
546 
547  return PyUpb_FileDescriptor_Get(f);
548 }
549 
550 static PyObject* PyUpb_DescriptorPool_FindExtensionByNumber(PyObject* _self,
551  PyObject* args) {
553  PyObject* message_descriptor;
554  int number;
555  if (!PyArg_ParseTuple(args, "Oi", &message_descriptor, &number)) {
556  return NULL;
557  }
558 
560  self->symtab, PyUpb_Descriptor_GetDef(message_descriptor), number);
561  if (f == NULL) {
562  return PyErr_Format(PyExc_KeyError, "Couldn't find Extension %d", number);
563  }
564 
566 }
567 
568 static PyObject* PyUpb_DescriptorPool_FindAllExtensions(PyObject* _self,
569  PyObject* msg_desc) {
571  const upb_MessageDef* m = PyUpb_Descriptor_GetDef(msg_desc);
572  size_t n;
573  const upb_FieldDef** ext = upb_DefPool_GetAllExtensions(self->symtab, m, &n);
574  PyObject* ret = PyList_New(n);
575  for (size_t i = 0; i < n; i++) {
576  PyObject* field = PyUpb_FieldDescriptor_Get(ext[i]);
577  if (!field) return NULL;
578  PyList_SetItem(ret, i, field);
579  }
580  return ret;
581 }
582 
583 static PyMethodDef PyUpb_DescriptorPool_Methods[] = {
584  {"Add", PyUpb_DescriptorPool_Add, METH_O,
585  "Adds the FileDescriptorProto and its types to this pool."},
586  {"AddSerializedFile", PyUpb_DescriptorPool_AddSerializedFile, METH_O,
587  "Adds a serialized FileDescriptorProto to this pool."},
588  {"FindFileByName", PyUpb_DescriptorPool_FindFileByName, METH_O,
589  "Searches for a file descriptor by its .proto name."},
590  {"FindMessageTypeByName", PyUpb_DescriptorPool_FindMessageTypeByName,
591  METH_O, "Searches for a message descriptor by full name."},
592  {"FindFieldByName", PyUpb_DescriptorPool_FindFieldByName, METH_O,
593  "Searches for a field descriptor by full name."},
594  {"FindExtensionByName", PyUpb_DescriptorPool_FindExtensionByName, METH_O,
595  "Searches for extension descriptor by full name."},
596  {"FindEnumTypeByName", PyUpb_DescriptorPool_FindEnumTypeByName, METH_O,
597  "Searches for enum type descriptor by full name."},
598  {"FindOneofByName", PyUpb_DescriptorPool_FindOneofByName, METH_O,
599  "Searches for oneof descriptor by full name."},
600  {"FindServiceByName", PyUpb_DescriptorPool_FindServiceByName, METH_O,
601  "Searches for service descriptor by full name."},
602  {"FindMethodByName", PyUpb_DescriptorPool_FindMethodByName, METH_O,
603  "Searches for method descriptor by full name."},
604  {"FindFileContainingSymbol", PyUpb_DescriptorPool_FindFileContainingSymbol,
605  METH_O, "Gets the FileDescriptor containing the specified symbol."},
606  {"FindExtensionByNumber", PyUpb_DescriptorPool_FindExtensionByNumber,
607  METH_VARARGS, "Gets the extension descriptor for the given number."},
608  {"FindAllExtensions", PyUpb_DescriptorPool_FindAllExtensions, METH_O,
609  "Gets all known extensions of the given message descriptor."},
610  {NULL}};
611 
612 static PyType_Slot PyUpb_DescriptorPool_Slots[] = {
613  {Py_tp_clear, PyUpb_DescriptorPool_Clear},
614  {Py_tp_dealloc, PyUpb_DescriptorPool_Dealloc},
615  {Py_tp_methods, PyUpb_DescriptorPool_Methods},
616  {Py_tp_new, PyUpb_DescriptorPool_New},
617  {Py_tp_traverse, PyUpb_DescriptorPool_Traverse},
618  {0, NULL}};
619 
620 static PyType_Spec PyUpb_DescriptorPool_Spec = {
621  PYUPB_MODULE_NAME ".DescriptorPool",
622  sizeof(PyUpb_DescriptorPool),
623  0, // tp_itemsize
624  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
626 };
627 
628 // -----------------------------------------------------------------------------
629 // Top Level
630 // -----------------------------------------------------------------------------
631 
632 bool PyUpb_InitDescriptorPool(PyObject* m) {
634  PyTypeObject* descriptor_pool_type =
636 
637  if (!descriptor_pool_type) return false;
638 
640  descriptor_pool_type, NULL, state->obj_cache);
641  return state->default_pool &&
642  PyModule_AddObject(m, "default_pool", state->default_pool) == 0;
643 }
PyUpb_DescriptorPool
Definition: descriptor_pool.c:42
google_protobuf_FileDescriptorProto_getmsgdef
const UPB_INLINE upb_MessageDef * google_protobuf_FileDescriptorProto_getmsgdef(upb_DefPool *s)
Definition: descriptor.upbdefs.h:29
PyUpb_WeakMap
Definition: upb/python/protobuf.c:118
PyUpb_DescriptorPool_GetFileProtoDef
const upb_MessageDef * PyUpb_DescriptorPool_GetFileProtoDef(void)
Definition: descriptor_pool.c:53
convert.h
PyUpb_DescriptorPool_TryLoadSymbol
static bool PyUpb_DescriptorPool_TryLoadSymbol(PyUpb_DescriptorPool *self, PyObject *sym)
Definition: descriptor_pool.c:144
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
PyUpb_ServiceDescriptor_Get
PyObject * PyUpb_ServiceDescriptor_Get(const upb_ServiceDef *s)
Definition: descriptor.c:1519
deps
static _upb_DefPool_Init * deps[4]
Definition: certs.upbdefs.c:72
PyUpb_DescriptorPool_AddSerializedFile
static PyObject * PyUpb_DescriptorPool_AddSerializedFile(PyObject *_self, PyObject *serialized_pb)
Definition: descriptor_pool.c:278
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
PyUpb_MethodDescriptor_Get
PyObject * PyUpb_MethodDescriptor_Get(const upb_MethodDef *m)
Definition: descriptor.c:1328
upb_DefPool_FindEnumByName
const upb_EnumDef * upb_DefPool_FindEnumByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1135
upb_DefPool_GetAllExtensions
const upb_FieldDef ** upb_DefPool_GetAllExtensions(const upb_DefPool *s, const upb_MessageDef *m, size_t *count)
Definition: upb/upb/def.c:3236
PyUpb_DescriptorPool_Slots
static PyType_Slot PyUpb_DescriptorPool_Slots[]
Definition: descriptor_pool.c:612
google_protobuf_FileDescriptorProto_dependency
UPB_INLINE upb_StringView const * google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:272
PyUpb_DescriptorPool_GetDefaultPool
PyObject * PyUpb_DescriptorPool_GetDefaultPool()
Definition: descriptor_pool.c:48
PyUpb_DescriptorPool_New
static PyObject * PyUpb_DescriptorPool_New(PyTypeObject *type, PyObject *args, PyObject *kwargs)
Definition: descriptor_pool.c:111
PyUpb_DescriptorPool_FindMessageTypeByName
static PyObject * PyUpb_DescriptorPool_FindMessageTypeByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:361
PyUpb_DescriptorPool_FindFieldByName
static PyObject * PyUpb_DescriptorPool_FindFieldByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:397
PyUpb_DescriptorPool_LoadDependentFiles
static bool PyUpb_DescriptorPool_LoadDependentFiles(PyUpb_DescriptorPool *self, google_protobuf_FileDescriptorProto *proto)
Definition: descriptor_pool.c:166
PyUpb_CMessage_Verify
bool PyUpb_CMessage_Verify(PyObject *self)
Definition: upb/python/message.c:235
PyUpb_EnumDescriptor_Get
PyObject * PyUpb_EnumDescriptor_Get(const upb_EnumDef *enumdef)
Definition: descriptor.c:649
PyUpb_InitDescriptorPool
bool PyUpb_InitDescriptorPool(PyObject *m)
Definition: descriptor_pool.c:632
upb_MessageDef
Definition: upb/upb/def.c:100
ext
void * ext
Definition: x509v3.h:87
def_to_proto.h
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
PyUpb_DescriptorPool_FindExtensionByName
static PyObject * PyUpb_DescriptorPool_FindExtensionByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:335
upb_MethodDef
Definition: upb/upb/def.c:197
error_ref_leak.err
err
Definition: error_ref_leak.py:35
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
PyUpb_ModuleState_GetFromModule
PyUpb_ModuleState * PyUpb_ModuleState_GetFromModule(PyObject *module)
Definition: upb/python/protobuf.c:82
status
absl::Status status
Definition: rls.cc:251
PyUpb_CMessage_GetMsgdef
const upb_MessageDef * PyUpb_CMessage_GetMsgdef(PyObject *self)
Definition: upb/python/message.c:220
PyUpb_Descriptor_GetDef
const upb_MessageDef * PyUpb_Descriptor_GetDef(PyObject *_self)
Definition: descriptor.c:639
setup.name
name
Definition: setup.py:542
upb_OneofDef
Definition: upb/upb/def.c:157
PyUpb_DescriptorPool_Add
static PyObject * PyUpb_DescriptorPool_Add(PyObject *_self, PyObject *file_desc)
Definition: descriptor_pool.c:291
PyUpb_DescriptorPool_FindFileByName
static PyObject * PyUpb_DescriptorPool_FindFileByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:310
upb_Status_ErrorMessage
const char * upb_Status_ErrorMessage(const upb_Status *status)
Definition: upb/upb/upb.c:52
PyUpb_DescriptorPool_CheckNoDatabase
bool PyUpb_DescriptorPool_CheckNoDatabase(PyObject *_self)
Definition: descriptor_pool.c:164
upb_Arena_New
UPB_INLINE upb_Arena * upb_Arena_New(void)
Definition: upb/upb/upb.h:267
upb_Status_Clear
void upb_Status_Clear(upb_Status *status)
Definition: upb/upb/upb.c:44
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
PyUpb_DescriptorPool_DoAddSerializedFile
static PyObject * PyUpb_DescriptorPool_DoAddSerializedFile(PyObject *_self, PyObject *serialized_pb)
Definition: descriptor_pool.c:186
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
PyUpb_DescriptorPool_FindFileContainingSymbol
static PyObject * PyUpb_DescriptorPool_FindFileContainingSymbol(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:530
upb_ServiceDef
Definition: upb/upb/def.c:208
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
PyUpb_Dealloc
static void PyUpb_Dealloc(void *self)
Definition: upb/python/protobuf.h:208
PyUpb_CMessage_SerializeToString
PyObject * PyUpb_CMessage_SerializeToString(PyObject *_self, PyObject *args, PyObject *kwargs)
Definition: upb/python/message.c:1451
PyUpb_DescriptorPool::PyObject_HEAD
PyObject_HEAD
Definition: descriptor_pool.c:43
upb_DefPool_FindServiceByName
const upb_ServiceDef * upb_DefPool_FindServiceByName(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1186
descriptor.h
PyUpb_Descriptor_Get
PyObject * PyUpb_Descriptor_Get(const upb_MessageDef *m)
Definition: descriptor.c:204
upb_DefPool_New
upb_DefPool * upb_DefPool_New(void)
Definition: upb/upb/def.c:1086
PyUpb_DescriptorPool_FindOneofByName
static PyObject * PyUpb_DescriptorPool_FindOneofByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:458
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
PyUpb_DescriptorPool_FindMethodByName
static PyObject * PyUpb_DescriptorPool_FindMethodByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:504
PyUpb_DescriptorPool_Dealloc
static void PyUpb_DescriptorPool_Dealloc(PyUpb_DescriptorPool *self)
Definition: descriptor_pool.c:98
arg
Definition: cmdline.cc:40
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
PyUpb_AddClass
PyTypeObject * PyUpb_AddClass(PyObject *m, PyType_Spec *spec)
Definition: upb/python/protobuf.c:274
upb_MessageDef_FindFieldByName
const UPB_INLINE upb_FieldDef * upb_MessageDef_FindFieldByName(const upb_MessageDef *m, const char *name)
Definition: upb/upb/def.h:204
googletest-filter-unittest.child
child
Definition: bloaty/third_party/googletest/googletest/test/googletest-filter-unittest.py:62
PyUpb_FieldDescriptor_Get
PyObject * PyUpb_FieldDescriptor_Get(const upb_FieldDef *field)
Definition: descriptor.c:870
upb_Status
Definition: upb/upb/upb.h:52
PyUpb_VerifyStrData
const char * PyUpb_VerifyStrData(PyObject *obj)
Definition: upb/python/protobuf.c:305
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
descriptor.upbdefs.h
PyUpb_DescriptorPool_DoAdd
static PyObject * PyUpb_DescriptorPool_DoAdd(PyObject *_self, PyObject *file_desc)
Definition: descriptor_pool.c:250
PyUpb_ObjCache_Instance
PyUpb_WeakMap * PyUpb_ObjCache_Instance(void)
Definition: upb/python/protobuf.c:185
PyUpb_DescriptorPool_Get
PyObject * PyUpb_DescriptorPool_Get(const upb_DefPool *symtab)
Definition: descriptor_pool.c:92
PyUpb_DescriptorPool_Clear
static int PyUpb_DescriptorPool_Clear(PyUpb_DescriptorPool *self)
Definition: descriptor_pool.c:87
protobuf.h
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
PyUpb_WeakMap_Add
void PyUpb_WeakMap_Add(PyUpb_WeakMap *map, const void *key, PyObject *py_obj)
Definition: upb/python/protobuf.c:139
upb_FieldDef
Definition: upb/upb/def.c:56
PyUpb_DescriptorPool_FindAllExtensions
static PyObject * PyUpb_DescriptorPool_FindAllExtensions(PyObject *_self, PyObject *msg_desc)
Definition: descriptor_pool.c:568
PyUpb_DescriptorPool_FindEnumTypeByName
static PyObject * PyUpb_DescriptorPool_FindEnumTypeByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:433
PyUpb_OneofDescriptor_Get
PyObject * PyUpb_OneofDescriptor_Get(const upb_OneofDef *oneof)
Definition: descriptor.c:1426
PyUpb_DescriptorPool_DoCreateWithCache
static PyObject * PyUpb_DescriptorPool_DoCreateWithCache(PyTypeObject *type, PyObject *db, PyUpb_WeakMap *obj_cache)
Definition: descriptor_pool.c:61
upb_DefPool_FindExtensionByNumber
const upb_FieldDef * upb_DefPool_FindExtensionByNumber(const upb_DefPool *s, const upb_MessageDef *m, int32_t fieldnum)
Definition: upb/upb/def.c:3215
PyUpb_ObjCache_Get
PyObject * PyUpb_ObjCache_Get(const void *key)
Definition: upb/python/protobuf.c:206
symtab
upb_symtab * symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:774
PyUpb_DescriptorPool_GetSymtab
upb_DefPool * PyUpb_DescriptorPool_GetSymtab(PyObject *pool)
Definition: descriptor_pool.c:77
PyUpb_ModuleState_Get
PyUpb_ModuleState * PyUpb_ModuleState_Get(void)
Definition: upb/python/protobuf.c:89
message.h
PYUPB_RETURN_OOM
#define PYUPB_RETURN_OOM
Definition: upb/python/protobuf.h:54
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
PyUpb_DescriptorPool::db
PyObject * db
Definition: descriptor_pool.c:45
PYUPB_MODULE_NAME
#define PYUPB_MODULE_NAME
Definition: upb/python/protobuf.h:43
upb_DefPool_Free
void upb_DefPool_Free(upb_DefPool *s)
Definition: upb/upb/def.c:1081
upb_StringView
Definition: upb/upb/upb.h:72
upb_MessageDef_FindOneofByName
const UPB_INLINE upb_OneofDef * upb_MessageDef_FindOneofByName(const upb_MessageDef *m, const char *name)
Definition: upb/upb/def.h:199
upb_FileDef
Definition: upb/upb/def.c:171
def.h
upb_DefPool_FindMessageByNameWithSize
const upb_MessageDef * upb_DefPool_FindMessageByNameWithSize(const upb_DefPool *s, const char *sym, size_t len)
Definition: upb/upb/def.c:1130
PyUpb_ModuleState
Definition: upb/python/protobuf.h:66
PyUpb_DescriptorPool_Traverse
static int PyUpb_DescriptorPool_Traverse(PyUpb_DescriptorPool *self, visitproc visit, void *arg)
Definition: descriptor_pool.c:81
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
google_protobuf_FileDescriptorProto_parse
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: descriptor.upb.h:223
google_protobuf_FileDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:256
PYUPB_DESCRIPTOR_PROTO_PACKAGE
#define PYUPB_DESCRIPTOR_PROTO_PACKAGE
Definition: upb/python/protobuf.h:41
PyUpb_DescriptorPool_FindServiceByName
static PyObject * PyUpb_DescriptorPool_FindServiceByName(PyObject *_self, PyObject *arg)
Definition: descriptor_pool.c:485
ok
bool ok
Definition: async_end2end_test.cc:197
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
upb_DefPool_FindExtensionByName
const upb_FieldDef * upb_DefPool_FindExtensionByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1181
upb_MessageDef_FullName
const char * upb_MessageDef_FullName(const upb_MessageDef *m)
Definition: upb/upb/def.c:701
PyUpb_DescriptorPool_SplitSymbolName
static const char * PyUpb_DescriptorPool_SplitSymbolName(const char *sym, size_t *parent_size)
Definition: descriptor_pool.c:383
PyUpb_DescriptorPool_TryLoadFilename
static bool PyUpb_DescriptorPool_TryLoadFilename(PyUpb_DescriptorPool *self, PyObject *filename)
Definition: descriptor_pool.c:154
upb_DefPool_AddFile
const upb_FileDef * upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, upb_Status *status)
Definition: upb/upb/def.c:3140
upb_DefPool_FindFileContainingSymbol
const upb_FileDef * upb_DefPool_FindFileContainingSymbol(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1196
PyUpb_DescriptorPool_TryLoadFileProto
static bool PyUpb_DescriptorPool_TryLoadFileProto(PyUpb_DescriptorPool *self, PyObject *proto)
Definition: descriptor_pool.c:127
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
PyUpb_FileDescriptor_Get
PyObject * PyUpb_FileDescriptor_Get(const upb_FileDef *file)
Definition: descriptor.c:1084
upb_EnumDef
Definition: upb/upb/def.c:134
upb_DefPool_FindServiceByNameWithSize
const upb_ServiceDef * upb_DefPool_FindServiceByNameWithSize(const upb_DefPool *s, const char *name, size_t size)
Definition: upb/upb/def.c:1191
upb_FileDef_ToProto
google_protobuf_FileDescriptorProto * upb_FileDef_ToProto(const upb_FileDef *f, upb_Arena *a)
Definition: def_to_proto.c:539
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
PyUpb_DescriptorPool_Spec
static PyType_Spec PyUpb_DescriptorPool_Spec
Definition: descriptor_pool.c:620
descriptor_pool.h
absl::visit
variant_internal::VisitResult< Visitor, Variants... > visit(Visitor &&vis, Variants &&... vars)
Definition: abseil-cpp/absl/types/variant.h:430
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
PyUpb_DescriptorPool_FindExtensionByNumber
static PyObject * PyUpb_DescriptorPool_FindExtensionByNumber(PyObject *_self, PyObject *args)
Definition: descriptor_pool.c:550
self
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern self
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:543
regress.m
m
Definition: regress/regress.py:25
PyUpb_DescriptorPool_Methods
static PyMethodDef PyUpb_DescriptorPool_Methods[]
Definition: descriptor_pool.c:583
PyUpb_ObjCache_Delete
void PyUpb_ObjCache_Delete(const void *key)
Definition: upb/python/protobuf.c:194
upb_DefPool_FindFileByNameWithSize
const upb_FileDef * upb_DefPool_FindFileByNameWithSize(const upb_DefPool *s, const char *name, size_t len)
Definition: upb/upb/def.c:1153
google_protobuf_FileDescriptorProto
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
Definition: descriptor.upb.h:51
upb_DefPool
Definition: upb/upb/def.c:217
upb_Arena
Definition: upb_internal.h:36
upb_DefPool_FindMessageByName
const upb_MessageDef * upb_DefPool_FindMessageByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1125
PyUpb_DescriptorPool::symtab
upb_DefPool * symtab
Definition: descriptor_pool.c:44
upb_Arena_Free
void upb_Arena_Free(upb_Arena *a)
Definition: upb/upb/upb.c:273
fix_build_deps.dep
string dep
Definition: fix_build_deps.py:439
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
upb_ServiceDef_FindMethodByName
const upb_MethodDef * upb_ServiceDef_FindMethodByName(const upb_ServiceDef *s, const char *name)
Definition: upb/upb/def.c:1069
PyUpb_DescriptorPool_DoCreate
static PyObject * PyUpb_DescriptorPool_DoCreate(PyTypeObject *type, PyObject *db)
Definition: descriptor_pool.c:71
upb_DefPool_FindFileByName
const upb_FileDef * upb_DefPool_FindFileByName(const upb_DefPool *s, const char *name)
Definition: upb/upb/def.c:1145
PyUpb_Message_IsEqual
bool PyUpb_Message_IsEqual(const upb_Message *msg1, const upb_Message *msg2, const upb_MessageDef *m)
Definition: upb/python/convert.c:336


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:15