• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2023 Google LLC.  All rights reserved.
3 //
4 // 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
7 
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.
18 PyObject* 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.
25 PyObject* 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.
31 void PyUpb_MapContainer_Reify(PyObject* self, upb_Map* map);
32 
33 // Reifies this map object if it is not already reified.
34 upb_Map* PyUpb_MapContainer_EnsureReified(PyObject* self);
35 
36 // Invalidates any existing iterators for the map `obj`.
37 void PyUpb_MapContainer_Invalidate(PyObject* obj);
38 
39 // Module-level init.
40 bool PyUpb_Map_Init(PyObject* m);
41 
42 #endif  // PYUPB_MAP_H__
43