blob: 2e1298e6291e3de875d7e723dcca527af424567c [file] [log] [blame]
Adam Cozzette501ecec2023-09-26 14:36:20 -07001// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
Adam Cozzette501ecec2023-09-26 14:36:20 -07003//
Protobuf Team Bot0fab7732023-11-20 13:38:15 -08004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
Adam Cozzette501ecec2023-09-26 14:36:20 -07007
8#ifndef PYUPB_MAP_H__
9#define PYUPB_MAP_H__
10
11#include <stdbool.h>
12
13#include "python/python_api.h"
14#include "upb/reflection/def.h"
15
16// Creates a new repeated field stub for field `f` of message object `parent`.
17// Precondition: `parent` must be a stub.
18PyObject* PyUpb_MapContainer_NewStub(PyObject* parent, const upb_FieldDef* f,
19 PyObject* arena);
20
21// Returns a map object wrapping `map`, of field type `f`, which must be on
22// `arena`. If an existing wrapper object exists, it will be returned,
23// otherwise a new object will be created. The caller always owns a ref on the
24// returned value.
25PyObject* PyUpb_MapContainer_GetOrCreateWrapper(upb_Map* map,
26 const upb_FieldDef* f,
27 PyObject* arena);
28
29// Reifies a map stub to point to the concrete data in `map`.
30// If `map` is NULL, an appropriate empty map will be constructed.
31void PyUpb_MapContainer_Reify(PyObject* self, upb_Map* map);
32
33// Reifies this map object if it is not already reified.
34upb_Map* PyUpb_MapContainer_EnsureReified(PyObject* self);
35
Adam Cozzette501ecec2023-09-26 14:36:20 -070036// Invalidates any existing iterators for the map `obj`.
37void PyUpb_MapContainer_Invalidate(PyObject* obj);
38
39// Module-level init.
40bool PyUpb_Map_Init(PyObject* m);
41
42#endif // PYUPB_MAP_H__