Go to the documentation of this file.
56 return self->field & 1;
72 Py_DECREF(
self->arena);
76 Py_DECREF(
self->ptr.parent);
87 :
state->scalar_map_container_type;
99 map->ptr.parent = parent;
103 return &
map->ob_base;
118 Py_DECREF(
self->ptr.parent);
165 PyErr_Format(PyExc_KeyError,
"Key not present in map");
188 memset(&u_val, 0,
sizeof(u_val));
198 if (!
map) Py_RETURN_FALSE;
220 static const char* kwlist[] = {
"key",
"default", NULL};
222 PyObject* default_value = NULL;
224 if (!PyArg_ParseTupleAndKeywords(
args, kwargs,
"O|O", (
char**)kwlist, &
key,
240 Py_INCREF(default_value);
241 return default_value;
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);
277 if (PyDict_Check(_arg)) {
278 return PyErr_Format(PyExc_AttributeError,
"Merging of dict is not allowed");
291 PyObject* dict = PyDict_New();
309 PyDict_SetItem(dict,
key, val);
314 PyObject* repr = PyObject_Repr(dict);
323 if (
ret)
return &
ret->ob_base;
326 ret = (
void*)PyType_GenericAlloc(cls, 0);
333 return &
ret->ob_base;
342 "Tests whether a key is a member of the map."},
344 "Removes all elements from the map."},
346 "Gets the value for the given key if present, or otherwise a default"},
348 "Return the class used to build Entries of (key, value) pairs."},
350 "Merges a map into the current map."},
368 {Py_tp_hash, PyObject_HashNotImplemented},
386 "Tests whether the map contains this element."},
388 "Removes all elements from the map."},
390 "Gets the value for the given key if present, or otherwise a default"},
392 "Alias for getitem, useful to make explicit that the map is mutated."},
394 "Return the class used to build Entries of (key, value) pairs."},
396 "Merges a map into the current map."},
414 {Py_tp_hash, PyObject_HashNotImplemented},
435 (
void*)PyType_GenericAlloc(
state->map_iterator_type, 0);
440 return &
iter->ob_base;
445 Py_DECREF(&
self->map->ob_base);
451 if (
self->version !=
self->map->version) {
452 return PyErr_Format(PyExc_RuntimeError,
"Map modified during iteration.");
455 if (!
map)
return NULL;
466 {Py_tp_iter, PyObject_SelfIter},
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);
486 Py_XDECREF(collections);
494 if (!bases)
return false;
496 state->message_map_container_type =
498 state->scalar_map_container_type =
504 return state->message_map_container_type &&
505 state->scalar_map_container_type &&
state->map_iterator_type;
OPENSSL_EXPORT const ASN1_OBJECT * obj
upb_MessageValue upb_MapIterator_Key(const upb_Map *map, size_t iter)
static PyObject * PyUpb_MapContainer_GetEntryClass(PyObject *_self, PyObject *arg)
size_t upb_Map_Size(const upb_Map *map)
return memset(p, 0, total)
static PyType_Spec PyUpb_MessageMapContainer_Spec
PyObject * PyUpb_MapIterator_IterNext(PyObject *_self)
void PyUpb_MapContainer_Reify(PyObject *_self, upb_Map *map)
bool PyUpb_Map_Init(PyObject *m)
PyTypeObject * PyUpb_MapContainer_GetClass(const upb_FieldDef *f)
Py_ssize_t PyUpb_MapContainer_Length(PyObject *_self)
PyObject * PyUpb_UpbToPy(upb_MessageValue val, const upb_FieldDef *f, PyObject *arena)
static PyType_Spec PyUpb_ScalarMapContainer_Spec
PyUpb_ModuleState * PyUpb_ModuleState_GetFromModule(PyObject *module)
static void PyUpb_MapContainer_Dealloc(void *_self)
static const upb_FieldDef * PyUpb_MapContainer_GetField(PyUpb_MapContainer *self)
void PyUpb_MapContainer_Invalidate(PyObject *obj)
void PyUpb_CMessage_SetConcreteSubobj(PyObject *_self, const upb_FieldDef *f, upb_MessageValue subobj)
static void PyUpb_MapIterator_Dealloc(void *_self)
static PyMethodDef PyUpb_ScalarMapContainer_Methods[]
upb_Map * PyUpb_MapContainer_EnsureReified(PyObject *_self)
grpc_core::ScopedArenaPtr arena
upb_Message * upb_Message_New(const upb_MessageDef *m, upb_Arena *a)
PyTypeObject * PyUpb_AddClassWithBases(PyObject *m, PyType_Spec *spec, PyObject *bases)
static PyObject * PyUpb_MapIterator_New(PyUpb_MapContainer *map)
bool upb_FieldDef_IsMap(const upb_FieldDef *f)
static void PyUpb_Dealloc(void *self)
bool upb_MapIterator_Next(const upb_Map *map, size_t *iter)
static PyMethodDef PyUpb_MessageMapContainer_Methods[]
static PyObject * PyUpb_MapContainer_MergeFrom(PyObject *_self, PyObject *_arg)
PyTypeObject * PyUpb_AddClass(PyObject *m, PyType_Spec *spec)
static PyObject * PyUpb_MapContainer_Repr(PyObject *_self)
static PyObject * GetMutableMappingBase(void)
const upb_Message * msg_val
int PyUpb_MapContainer_AssignSubscript(PyObject *_self, PyObject *key, PyObject *val)
_W64 unsigned int uintptr_t
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
void PyUpb_CMessage_CacheDelete(PyObject *_self, const upb_FieldDef *f)
int PyUpb_CMessage_InitMapAttributes(PyObject *map, PyObject *value, const upb_FieldDef *f)
const upb_MessageDef * upb_FieldDef_MessageSubDef(const upb_FieldDef *f)
bool upb_Map_Set(upb_Map *map, upb_MessageValue key, upb_MessageValue val, upb_Arena *arena)
static PyType_Slot PyUpb_MessageMapContainer_Slots[]
PyObject * PyUpb_MapContainer_Subscript(PyObject *_self, PyObject *key)
PyObject * PyUpb_MapContainer_NewStub(PyObject *parent, const upb_FieldDef *f, PyObject *arena)
PyObject * PyUpb_ObjCache_Get(const void *key)
PyUpb_ModuleState * PyUpb_ModuleState_Get(void)
static PyObject * PyUpb_MapContainer_Get(PyObject *_self, PyObject *args, PyObject *kwargs)
PyObject * PyUpb_MapContainer_Clear(PyObject *_self, PyObject *key)
upb_Arena * PyUpb_Arena_Get(PyObject *arena)
#define PYUPB_MODULE_NAME
bool upb_Map_Delete(upb_Map *map, upb_MessageValue key)
static PyType_Spec PyUpb_MapIterator_Spec
static PyType_Slot PyUpb_ScalarMapContainer_Slots[]
void PyUpb_ObjCache_Add(const void *key, PyObject *py_obj)
static bool PyUpb_MapContainer_IsStub(PyUpb_MapContainer *self)
UniquePtr< SSL_SESSION > ret
PyUpb_MapContainer * PyUpb_MapContainer_Check(PyObject *_self)
PyObject * PyUpb_MapContainer_Contains(PyObject *_self, PyObject *key)
PyObject * PyUpb_MapContainer_GetOrCreateWrapper(upb_Map *map, const upb_FieldDef *f, PyObject *arena)
bool upb_Map_Get(const upb_Map *map, upb_MessageValue key, upb_MessageValue *val)
bool upb_FieldDef_IsSubMessage(const upb_FieldDef *f)
PyObject * PyUpb_Descriptor_GetClass(const upb_MessageDef *m)
upb_Map * upb_Map_New(upb_Arena *a, upb_CType key_type, upb_CType value_type)
void upb_Map_Clear(upb_Map *map)
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern self
const upb_FieldDef * upb_MessageDef_Field(const upb_MessageDef *m, int i)
void PyUpb_ObjCache_Delete(const void *key)
upb_MessageValue upb_MapIterator_Value(const upb_Map *map, size_t iter)
upb_Message * PyUpb_CMessage_GetIfReified(PyObject *_self)
static PyType_Slot PyUpb_MapIterator_Slots[]
static upb_Map * PyUpb_MapContainer_GetIfReified(PyUpb_MapContainer *self)
bool PyUpb_PyToUpb(PyObject *obj, const upb_FieldDef *f, upb_MessageValue *val, upb_Arena *arena)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:31