upb/python/map.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/map.h"
29 
30 #include "python/convert.h"
31 #include "python/message.h"
32 #include "python/protobuf.h"
33 
34 // -----------------------------------------------------------------------------
35 // MapContainer
36 // -----------------------------------------------------------------------------
37 
38 typedef struct {
40  PyObject* arena;
41  // The field descriptor (upb_FieldDef*).
42  // The low bit indicates whether the container is reified (see ptr below).
43  // - low bit set: repeated field is a stub (empty map, no underlying data).
44  // - low bit clear: repeated field is reified (points to upb_Array).
46  union {
47  PyObject* parent; // stub: owning pointer to parent message.
48  upb_Map* map; // reified: the data for this array.
49  } ptr;
50  int version;
52 
54 
56  return self->field & 1;
57 }
58 
59 // If the map is reified, returns it. Otherwise, returns NULL.
60 // If NULL is returned, the object is empty and has no underlying data.
62  return PyUpb_MapContainer_IsStub(self) ? NULL : self->ptr.map;
63 }
64 
66  PyUpb_MapContainer* self) {
67  return (const upb_FieldDef*)(self->field & ~(uintptr_t)1);
68 }
69 
70 static void PyUpb_MapContainer_Dealloc(void* _self) {
71  PyUpb_MapContainer* self = _self;
72  Py_DECREF(self->arena);
73  if (PyUpb_MapContainer_IsStub(self)) {
74  PyUpb_CMessage_CacheDelete(self->ptr.parent,
76  Py_DECREF(self->ptr.parent);
77  } else {
78  PyUpb_ObjCache_Delete(self->ptr.map);
79  }
80  PyUpb_Dealloc(_self);
81 }
82 
84  assert(upb_FieldDef_IsMap(f));
86  return upb_FieldDef_IsSubMessage(f) ? state->message_map_container_type
87  : state->scalar_map_container_type;
88 }
89 
90 PyObject* PyUpb_MapContainer_NewStub(PyObject* parent, const upb_FieldDef* f,
91  PyObject* arena) {
92  // We only create stubs when the parent is reified, by convention. However
93  // this is not an invariant: the parent could become reified at any time.
94  assert(PyUpb_CMessage_GetIfReified(parent) == NULL);
95  PyTypeObject* cls = PyUpb_MapContainer_GetClass(f);
96  PyUpb_MapContainer* map = (void*)PyType_GenericAlloc(cls, 0);
97  map->arena = arena;
98  map->field = (uintptr_t)f | 1;
99  map->ptr.parent = parent;
100  map->version = 0;
101  Py_INCREF(arena);
102  Py_INCREF(parent);
103  return &map->ob_base;
104 }
105 
106 void PyUpb_MapContainer_Reify(PyObject* _self, upb_Map* map) {
107  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
108  if (!map) {
110  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
111  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
112  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
113  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
115  upb_FieldDef_CType(val_f));
116  }
117  PyUpb_ObjCache_Add(map, &self->ob_base);
118  Py_DECREF(self->ptr.parent);
119  self->ptr.map = map; // Overwrites self->ptr.parent.
120  self->field &= ~(uintptr_t)1;
121  assert(!PyUpb_MapContainer_IsStub(self));
122 }
123 
126  self->version++;
127 }
128 
130  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
131  self->version++;
133  if (map) return map; // Already writable.
134 
136  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
137  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
138  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
139  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
140  map =
142  upb_MessageValue msgval = {.map_val = map};
143  PyUpb_CMessage_SetConcreteSubobj(self->ptr.parent, f, msgval);
144  PyUpb_MapContainer_Reify((PyObject*)self, map);
145  return map;
146 }
147 
148 int PyUpb_MapContainer_AssignSubscript(PyObject* _self, PyObject* key,
149  PyObject* val) {
150  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
153  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
154  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
155  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
156  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
157  upb_MessageValue u_key, u_val;
158  if (!PyUpb_PyToUpb(key, key_f, &u_key, arena)) return -1;
159 
160  if (val) {
161  if (!PyUpb_PyToUpb(val, val_f, &u_val, arena)) return -1;
162  upb_Map_Set(map, u_key, u_val, arena);
163  } else {
164  if (!upb_Map_Delete(map, u_key)) {
165  PyErr_Format(PyExc_KeyError, "Key not present in map");
166  return -1;
167  }
168  }
169  return 0;
170 }
171 
172 PyObject* PyUpb_MapContainer_Subscript(PyObject* _self, PyObject* key) {
173  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
176  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
177  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
178  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
179  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
180  upb_MessageValue u_key, u_val;
181  if (!PyUpb_PyToUpb(key, key_f, &u_key, arena)) return NULL;
182  if (!map || !upb_Map_Get(map, u_key, &u_val)) {
184  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
185  if (upb_FieldDef_IsSubMessage(val_f)) {
187  } else {
188  memset(&u_val, 0, sizeof(u_val));
189  }
190  upb_Map_Set(map, u_key, u_val, arena);
191  }
192  return PyUpb_UpbToPy(u_val, val_f, self->arena);
193 }
194 
195 PyObject* PyUpb_MapContainer_Contains(PyObject* _self, PyObject* key) {
196  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
198  if (!map) Py_RETURN_FALSE;
200  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
201  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
202  upb_MessageValue u_key;
203  if (!PyUpb_PyToUpb(key, key_f, &u_key, NULL)) return NULL;
204  if (upb_Map_Get(map, u_key, NULL)) {
205  Py_RETURN_TRUE;
206  } else {
207  Py_RETURN_FALSE;
208  }
209 }
210 
211 PyObject* PyUpb_MapContainer_Clear(PyObject* _self, PyObject* key) {
214  Py_RETURN_NONE;
215 }
216 
217 static PyObject* PyUpb_MapContainer_Get(PyObject* _self, PyObject* args,
218  PyObject* kwargs) {
219  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
220  static const char* kwlist[] = {"key", "default", NULL};
221  PyObject* key;
222  PyObject* default_value = NULL;
224  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", (char**)kwlist, &key,
225  &default_value)) {
226  return NULL;
227  }
228 
230  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
231  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
232  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
233  upb_Arena* arena = PyUpb_Arena_Get(self->arena);
234  upb_MessageValue u_key, u_val;
235  if (!PyUpb_PyToUpb(key, key_f, &u_key, arena)) return NULL;
236  if (map && upb_Map_Get(map, u_key, &u_val)) {
237  return PyUpb_UpbToPy(u_val, val_f, self->arena);
238  }
239  if (default_value) {
240  Py_INCREF(default_value);
241  return default_value;
242  }
243  Py_RETURN_NONE;
244 }
245 
246 static PyObject* PyUpb_MapContainer_GetEntryClass(PyObject* _self,
247  PyObject* arg) {
248  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
250  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
251  return PyUpb_Descriptor_GetClass(entry_m);
252 }
253 
254 Py_ssize_t PyUpb_MapContainer_Length(PyObject* _self) {
255  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
257  return map ? upb_Map_Size(map) : 0;
258 }
259 
262  if (!PyObject_TypeCheck(_self, state->message_map_container_type) &&
263  !PyObject_TypeCheck(_self, state->scalar_map_container_type)) {
264  PyErr_Format(PyExc_TypeError, "Expected protobuf map, but got %R", _self);
265  return NULL;
266  }
267  return (PyUpb_MapContainer*)_self;
268 }
269 
270 int PyUpb_CMessage_InitMapAttributes(PyObject* map, PyObject* value,
271  const upb_FieldDef* f);
272 
273 static PyObject* PyUpb_MapContainer_MergeFrom(PyObject* _self, PyObject* _arg) {
274  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
276 
277  if (PyDict_Check(_arg)) {
278  return PyErr_Format(PyExc_AttributeError, "Merging of dict is not allowed");
279  }
280 
281  if (PyUpb_CMessage_InitMapAttributes(_self, _arg, f) < 0) {
282  return NULL;
283  }
284 
285  Py_RETURN_NONE;
286 }
287 
288 static PyObject* PyUpb_MapContainer_Repr(PyObject* _self) {
289  PyUpb_MapContainer* self = (PyUpb_MapContainer*)_self;
291  PyObject* dict = PyDict_New();
292  if (map) {
294  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
295  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
296  const upb_FieldDef* val_f = upb_MessageDef_Field(entry_m, 1);
297  size_t iter = kUpb_Map_Begin;
298  while (upb_MapIterator_Next(map, &iter)) {
299  PyObject* key =
300  PyUpb_UpbToPy(upb_MapIterator_Key(map, iter), key_f, self->arena);
301  PyObject* val =
302  PyUpb_UpbToPy(upb_MapIterator_Value(map, iter), val_f, self->arena);
303  if (!key || !val) {
304  Py_XDECREF(key);
305  Py_XDECREF(val);
306  Py_DECREF(dict);
307  return NULL;
308  }
309  PyDict_SetItem(dict, key, val);
310  Py_DECREF(key);
311  Py_DECREF(val);
312  }
313  }
314  PyObject* repr = PyObject_Repr(dict);
315  Py_DECREF(dict);
316  return repr;
317 }
318 
320  const upb_FieldDef* f,
321  PyObject* arena) {
323  if (ret) return &ret->ob_base;
324 
325  PyTypeObject* cls = PyUpb_MapContainer_GetClass(f);
326  ret = (void*)PyType_GenericAlloc(cls, 0);
327  ret->arena = arena;
328  ret->field = (uintptr_t)f;
329  ret->ptr.map = map;
330  ret->version = 0;
331  Py_INCREF(arena);
332  PyUpb_ObjCache_Add(map, &ret->ob_base);
333  return &ret->ob_base;
334 }
335 
336 // -----------------------------------------------------------------------------
337 // ScalarMapContainer
338 // -----------------------------------------------------------------------------
339 
340 static PyMethodDef PyUpb_ScalarMapContainer_Methods[] = {
341  {"__contains__", PyUpb_MapContainer_Contains, METH_O,
342  "Tests whether a key is a member of the map."},
343  {"clear", PyUpb_MapContainer_Clear, METH_NOARGS,
344  "Removes all elements from the map."},
345  {"get", (PyCFunction)PyUpb_MapContainer_Get, METH_VARARGS | METH_KEYWORDS,
346  "Gets the value for the given key if present, or otherwise a default"},
347  {"GetEntryClass", PyUpb_MapContainer_GetEntryClass, METH_NOARGS,
348  "Return the class used to build Entries of (key, value) pairs."},
349  {"MergeFrom", PyUpb_MapContainer_MergeFrom, METH_O,
350  "Merges a map into the current map."},
351  /*
352  { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
353  "Makes a deep copy of the class." },
354  { "__reduce__", (PyCFunction)Reduce, METH_NOARGS,
355  "Outputs picklable representation of the repeated field." },
356  */
357  {NULL, NULL},
358 };
359 
360 static PyType_Slot PyUpb_ScalarMapContainer_Slots[] = {
361  {Py_tp_dealloc, PyUpb_MapContainer_Dealloc},
362  {Py_mp_length, PyUpb_MapContainer_Length},
363  {Py_mp_subscript, PyUpb_MapContainer_Subscript},
364  {Py_mp_ass_subscript, PyUpb_MapContainer_AssignSubscript},
365  {Py_tp_methods, PyUpb_ScalarMapContainer_Methods},
366  {Py_tp_iter, PyUpb_MapIterator_New},
367  {Py_tp_repr, PyUpb_MapContainer_Repr},
368  {Py_tp_hash, PyObject_HashNotImplemented},
369  {0, NULL},
370 };
371 
372 static PyType_Spec PyUpb_ScalarMapContainer_Spec = {
373  PYUPB_MODULE_NAME ".ScalarMapContainer",
374  sizeof(PyUpb_MapContainer),
375  0,
376  Py_TPFLAGS_DEFAULT,
378 };
379 
380 // -----------------------------------------------------------------------------
381 // MessageMapContainer
382 // -----------------------------------------------------------------------------
383 
384 static PyMethodDef PyUpb_MessageMapContainer_Methods[] = {
385  {"__contains__", PyUpb_MapContainer_Contains, METH_O,
386  "Tests whether the map contains this element."},
387  {"clear", PyUpb_MapContainer_Clear, METH_NOARGS,
388  "Removes all elements from the map."},
389  {"get", (PyCFunction)PyUpb_MapContainer_Get, METH_VARARGS | METH_KEYWORDS,
390  "Gets the value for the given key if present, or otherwise a default"},
391  {"get_or_create", PyUpb_MapContainer_Subscript, METH_O,
392  "Alias for getitem, useful to make explicit that the map is mutated."},
393  {"GetEntryClass", PyUpb_MapContainer_GetEntryClass, METH_NOARGS,
394  "Return the class used to build Entries of (key, value) pairs."},
395  {"MergeFrom", PyUpb_MapContainer_MergeFrom, METH_O,
396  "Merges a map into the current map."},
397  /*
398  { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
399  "Makes a deep copy of the class." },
400  { "__reduce__", (PyCFunction)Reduce, METH_NOARGS,
401  "Outputs picklable representation of the repeated field." },
402  */
403  {NULL, NULL},
404 };
405 
406 static PyType_Slot PyUpb_MessageMapContainer_Slots[] = {
407  {Py_tp_dealloc, PyUpb_MapContainer_Dealloc},
408  {Py_mp_length, PyUpb_MapContainer_Length},
409  {Py_mp_subscript, PyUpb_MapContainer_Subscript},
410  {Py_mp_ass_subscript, PyUpb_MapContainer_AssignSubscript},
411  {Py_tp_methods, PyUpb_MessageMapContainer_Methods},
412  {Py_tp_iter, PyUpb_MapIterator_New},
413  {Py_tp_repr, PyUpb_MapContainer_Repr},
414  {Py_tp_hash, PyObject_HashNotImplemented},
415  {0, NULL}};
416 
417 static PyType_Spec PyUpb_MessageMapContainer_Spec = {
418  PYUPB_MODULE_NAME ".MessageMapContainer", sizeof(PyUpb_MapContainer), 0,
419  Py_TPFLAGS_DEFAULT, PyUpb_MessageMapContainer_Slots};
420 
421 // -----------------------------------------------------------------------------
422 // MapIterator
423 // -----------------------------------------------------------------------------
424 
425 typedef struct {
427  PyUpb_MapContainer* map; // We own a reference.
428  size_t iter;
429  int version;
431 
435  (void*)PyType_GenericAlloc(state->map_iterator_type, 0);
436  iter->map = map;
437  iter->iter = kUpb_Map_Begin;
438  iter->version = map->version;
439  Py_INCREF(map);
440  return &iter->ob_base;
441 }
442 
443 static void PyUpb_MapIterator_Dealloc(void* _self) {
444  PyUpb_MapIterator* self = (PyUpb_MapIterator*)_self;
445  Py_DECREF(&self->map->ob_base);
446  PyUpb_Dealloc(_self);
447 }
448 
449 PyObject* PyUpb_MapIterator_IterNext(PyObject* _self) {
450  PyUpb_MapIterator* self = (PyUpb_MapIterator*)_self;
451  if (self->version != self->map->version) {
452  return PyErr_Format(PyExc_RuntimeError, "Map modified during iteration.");
453  }
455  if (!map) return NULL;
456  if (!upb_MapIterator_Next(map, &self->iter)) return NULL;
459  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
460  const upb_FieldDef* key_f = upb_MessageDef_Field(entry_m, 0);
461  return PyUpb_UpbToPy(key, key_f, self->map->arena);
462 }
463 
464 static PyType_Slot PyUpb_MapIterator_Slots[] = {
465  {Py_tp_dealloc, PyUpb_MapIterator_Dealloc},
466  {Py_tp_iter, PyObject_SelfIter},
467  {Py_tp_iternext, PyUpb_MapIterator_IterNext},
468  {0, NULL}};
469 
470 static PyType_Spec PyUpb_MapIterator_Spec = {
471  PYUPB_MODULE_NAME ".MapIterator", sizeof(PyUpb_MapIterator), 0,
472  Py_TPFLAGS_DEFAULT, PyUpb_MapIterator_Slots};
473 
474 // -----------------------------------------------------------------------------
475 // Top Level
476 // -----------------------------------------------------------------------------
477 
478 static PyObject* GetMutableMappingBase(void) {
479  PyObject* collections = NULL;
480  PyObject* mapping = NULL;
481  PyObject* bases = NULL;
482  if ((collections = PyImport_ImportModule("collections.abc")) &&
483  (mapping = PyObject_GetAttrString(collections, "MutableMapping"))) {
484  bases = Py_BuildValue("(O)", mapping);
485  }
486  Py_XDECREF(collections);
487  Py_XDECREF(mapping);
488  return bases;
489 }
490 
491 bool PyUpb_Map_Init(PyObject* m) {
493  PyObject* bases = GetMutableMappingBase();
494  if (!bases) return false;
495 
496  state->message_map_container_type =
498  state->scalar_map_container_type =
500  state->map_iterator_type = PyUpb_AddClass(m, &PyUpb_MapIterator_Spec);
501 
502  Py_DECREF(bases);
503 
504  return state->message_map_container_type &&
505  state->scalar_map_container_type && state->map_iterator_type;
506 }
PyUpb_MapIterator
Definition: upb/python/map.c:425
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
convert.h
obj
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1671
upb_MapIterator_Key
upb_MessageValue upb_MapIterator_Key(const upb_Map *map, size_t iter)
Definition: reflection.c:461
PyUpb_MapContainer_GetEntryClass
static PyObject * PyUpb_MapContainer_GetEntryClass(PyObject *_self, PyObject *arg)
Definition: upb/python/map.c:246
upb_Map_Size
size_t upb_Map_Size(const upb_Map *map)
Definition: reflection.c:430
PyUpb_MapIterator::PyObject_HEAD
PyObject_HEAD
Definition: upb/python/map.c:426
kUpb_Map_Begin
#define kUpb_Map_Begin
Definition: upb/upb/upb.h:329
memset
return memset(p, 0, total)
PyUpb_MapContainer::arena
PyObject * arena
Definition: upb/python/map.c:40
PyUpb_MessageMapContainer_Spec
static PyType_Spec PyUpb_MessageMapContainer_Spec
Definition: upb/python/map.c:417
PyUpb_MapIterator_IterNext
PyObject * PyUpb_MapIterator_IterNext(PyObject *_self)
Definition: upb/python/map.c:449
PyUpb_MapContainer_Reify
void PyUpb_MapContainer_Reify(PyObject *_self, upb_Map *map)
Definition: upb/python/map.c:106
PyUpb_Map_Init
bool PyUpb_Map_Init(PyObject *m)
Definition: upb/python/map.c:491
PyUpb_MapContainer_GetClass
PyTypeObject * PyUpb_MapContainer_GetClass(const upb_FieldDef *f)
Definition: upb/python/map.c:83
upb_MessageDef
Definition: upb/upb/def.c:100
PyUpb_MapContainer::version
int version
Definition: upb/python/map.c:50
PyUpb_MapContainer_Length
Py_ssize_t PyUpb_MapContainer_Length(PyObject *_self)
Definition: upb/python/map.c:254
PyUpb_UpbToPy
PyObject * PyUpb_UpbToPy(upb_MessageValue val, const upb_FieldDef *f, PyObject *arena)
Definition: upb/python/convert.c:35
PyUpb_ScalarMapContainer_Spec
static PyType_Spec PyUpb_ScalarMapContainer_Spec
Definition: upb/python/map.c:372
PyUpb_ModuleState_GetFromModule
PyUpb_ModuleState * PyUpb_ModuleState_GetFromModule(PyObject *module)
Definition: upb/python/protobuf.c:82
PyUpb_MapContainer_Dealloc
static void PyUpb_MapContainer_Dealloc(void *_self)
Definition: upb/python/map.c:70
PyUpb_MapContainer_GetField
static const upb_FieldDef * PyUpb_MapContainer_GetField(PyUpb_MapContainer *self)
Definition: upb/python/map.c:65
PyUpb_MapIterator::version
int version
Definition: upb/python/map.c:429
PyUpb_MapContainer::field
uintptr_t field
Definition: upb/python/map.c:45
PyUpb_MapContainer_Invalidate
void PyUpb_MapContainer_Invalidate(PyObject *obj)
Definition: upb/python/map.c:124
PyUpb_CMessage_SetConcreteSubobj
void PyUpb_CMessage_SetConcreteSubobj(PyObject *_self, const upb_FieldDef *f, upb_MessageValue subobj)
Definition: upb/python/message.c:713
PyUpb_MapIterator_Dealloc
static void PyUpb_MapIterator_Dealloc(void *_self)
Definition: upb/python/map.c:443
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
PyUpb_ScalarMapContainer_Methods
static PyMethodDef PyUpb_ScalarMapContainer_Methods[]
Definition: upb/python/map.c:340
PyUpb_MapIterator::iter
size_t iter
Definition: upb/python/map.c:428
PyUpb_MapContainer_EnsureReified
upb_Map * PyUpb_MapContainer_EnsureReified(PyObject *_self)
Definition: upb/python/map.c:129
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
PyUpb_MapContainer::PyObject_HEAD
PyObject_HEAD
Definition: upb/python/map.c:39
upb_Message_New
upb_Message * upb_Message_New(const upb_MessageDef *m, upb_Arena *a)
Definition: reflection.c:95
PyUpb_AddClassWithBases
PyTypeObject * PyUpb_AddClassWithBases(PyObject *m, PyType_Spec *spec, PyObject *bases)
Definition: upb/python/protobuf.c:284
upb_MessageValue
Definition: upb/upb/reflection.h:40
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
PyUpb_MapIterator_New
static PyObject * PyUpb_MapIterator_New(PyUpb_MapContainer *map)
Definition: upb/python/map.c:432
upb_FieldDef_IsMap
bool upb_FieldDef_IsMap(const upb_FieldDef *f)
Definition: upb/upb/def.c:659
PyUpb_Dealloc
static void PyUpb_Dealloc(void *self)
Definition: upb/python/protobuf.h:208
upb_MapIterator_Next
bool upb_MapIterator_Next(const upb_Map *map, size_t *iter)
Definition: reflection.c:448
PyUpb_MapContainer::map
upb_Map * map
Definition: upb/python/map.c:48
PyUpb_MessageMapContainer_Methods
static PyMethodDef PyUpb_MessageMapContainer_Methods[]
Definition: upb/python/map.c:384
arg
Definition: cmdline.cc:40
PyUpb_MapContainer_MergeFrom
static PyObject * PyUpb_MapContainer_MergeFrom(PyObject *_self, PyObject *_arg)
Definition: upb/python/map.c:273
PyUpb_AddClass
PyTypeObject * PyUpb_AddClass(PyObject *m, PyType_Spec *spec)
Definition: upb/python/protobuf.c:274
PyUpb_MapContainer_Repr
static PyObject * PyUpb_MapContainer_Repr(PyObject *_self)
Definition: upb/python/map.c:288
GetMutableMappingBase
static PyObject * GetMutableMappingBase(void)
Definition: upb/python/map.c:478
upb_MessageValue::msg_val
const upb_Message * msg_val
Definition: upb/upb/reflection.h:49
PyUpb_MapContainer_AssignSubscript
int PyUpb_MapContainer_AssignSubscript(PyObject *_self, PyObject *key, PyObject *val)
Definition: upb/python/map.c:148
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
upb_FieldDef_CType
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
Definition: upb/upb/def.c:500
PyUpb_CMessage_CacheDelete
void PyUpb_CMessage_CacheDelete(PyObject *_self, const upb_FieldDef *f)
Definition: upb/python/message.c:708
PyUpb_CMessage_InitMapAttributes
int PyUpb_CMessage_InitMapAttributes(PyObject *map, PyObject *value, const upb_FieldDef *f)
Definition: upb/python/message.c:338
protobuf.h
upb_FieldDef_MessageSubDef
const upb_MessageDef * upb_FieldDef_MessageSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:619
upb_Map_Set
bool upb_Map_Set(upb_Map *map, upb_MessageValue key, upb_MessageValue val, upb_Arena *arena)
Definition: reflection.c:439
upb_FieldDef
Definition: upb/upb/def.c:56
PyUpb_MapContainer::parent
PyObject * parent
Definition: upb/python/map.c:47
upb_MessageValue::map_val
const upb_Map * map_val
Definition: upb/upb/reflection.h:48
PyUpb_MessageMapContainer_Slots
static PyType_Slot PyUpb_MessageMapContainer_Slots[]
Definition: upb/python/map.c:406
PyUpb_MapContainer_Subscript
PyObject * PyUpb_MapContainer_Subscript(PyObject *_self, PyObject *key)
Definition: upb/python/map.c:172
value
const char * value
Definition: hpack_parser_table.cc:165
PyUpb_MapContainer_NewStub
PyObject * PyUpb_MapContainer_NewStub(PyObject *parent, const upb_FieldDef *f, PyObject *arena)
Definition: upb/python/map.c:90
PyUpb_ObjCache_Get
PyObject * PyUpb_ObjCache_Get(const void *key)
Definition: upb/python/protobuf.c:206
PyUpb_ModuleState_Get
PyUpb_ModuleState * PyUpb_ModuleState_Get(void)
Definition: upb/python/protobuf.c:89
message.h
PyUpb_MapContainer_Get
static PyObject * PyUpb_MapContainer_Get(PyObject *_self, PyObject *args, PyObject *kwargs)
Definition: upb/python/map.c:217
PyUpb_MapContainer_Clear
PyObject * PyUpb_MapContainer_Clear(PyObject *_self, PyObject *key)
Definition: upb/python/map.c:211
PyUpb_Arena_Get
upb_Arena * PyUpb_Arena_Get(PyObject *arena)
Definition: upb/python/protobuf.c:231
key
const char * key
Definition: hpack_parser_table.cc:164
PYUPB_MODULE_NAME
#define PYUPB_MODULE_NAME
Definition: upb/python/protobuf.h:43
upb_Map_Delete
bool upb_Map_Delete(upb_Map *map, upb_MessageValue key)
Definition: reflection.c:444
PyUpb_MapIterator_Spec
static PyType_Spec PyUpb_MapIterator_Spec
Definition: upb/python/map.c:470
PyUpb_ScalarMapContainer_Slots
static PyType_Slot PyUpb_ScalarMapContainer_Slots[]
Definition: upb/python/map.c:360
PyUpb_MapContainer
Definition: upb/python/map.c:38
PyUpb_ModuleState
Definition: upb/python/protobuf.h:66
PyUpb_ObjCache_Add
void PyUpb_ObjCache_Add(const void *key, PyObject *py_obj)
Definition: upb/python/protobuf.c:190
PyUpb_MapContainer_IsStub
static bool PyUpb_MapContainer_IsStub(PyUpb_MapContainer *self)
Definition: upb/python/map.c:55
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
PyUpb_MapIterator::map
PyUpb_MapContainer * map
Definition: upb/python/map.c:427
PyUpb_MapContainer_Check
PyUpb_MapContainer * PyUpb_MapContainer_Check(PyObject *_self)
Definition: upb/python/map.c:260
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
PyUpb_MapContainer_Contains
PyObject * PyUpb_MapContainer_Contains(PyObject *_self, PyObject *key)
Definition: upb/python/map.c:195
PyUpb_MapContainer_GetOrCreateWrapper
PyObject * PyUpb_MapContainer_GetOrCreateWrapper(upb_Map *map, const upb_FieldDef *f, PyObject *arena)
Definition: upb/python/map.c:319
upb_Map_Get
bool upb_Map_Get(const upb_Map *map, upb_MessageValue key, upb_MessageValue *val)
Definition: reflection.c:432
upb_FieldDef_IsSubMessage
bool upb_FieldDef_IsSubMessage(const upb_FieldDef *f)
Definition: upb/upb/def.c:642
upb_Map
Definition: msg_internal.h:581
PyUpb_Descriptor_GetClass
PyObject * PyUpb_Descriptor_GetClass(const upb_MessageDef *m)
Definition: descriptor.c:210
iter
Definition: test_winkernel.cpp:47
upb_Map_New
upb_Map * upb_Map_New(upb_Arena *a, upb_CType key_type, upb_CType value_type)
Definition: reflection.c:425
upb_Map_Clear
void upb_Map_Clear(upb_Map *map)
Definition: reflection.c:437
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
upb_MessageDef_Field
const upb_FieldDef * upb_MessageDef_Field(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:828
regress.m
m
Definition: regress/regress.py:25
PyUpb_ObjCache_Delete
void PyUpb_ObjCache_Delete(const void *key)
Definition: upb/python/protobuf.c:194
upb_MapIterator_Value
upb_MessageValue upb_MapIterator_Value(const upb_Map *map, size_t iter)
Definition: reflection.c:470
map.h
PyUpb_CMessage_GetIfReified
upb_Message * PyUpb_CMessage_GetIfReified(PyObject *_self)
Definition: upb/python/message.c:246
upb_Arena
Definition: upb_internal.h:36
PyUpb_MapIterator_Slots
static PyType_Slot PyUpb_MapIterator_Slots[]
Definition: upb/python/map.c:464
PyUpb_MapContainer_GetIfReified
static upb_Map * PyUpb_MapContainer_GetIfReified(PyUpb_MapContainer *self)
Definition: upb/python/map.c:61
PyUpb_PyToUpb
bool PyUpb_PyToUpb(PyObject *obj, const upb_FieldDef *f, upb_MessageValue *val, upb_Arena *arena)
Definition: upb/python/convert.c:179


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:31