#ifndef PYUPB_PROTOBUF_H__
#define PYUPB_PROTOBUF_H__
#include <stdbool.h>
#include "python/descriptor.h"
#include "python/python_api.h"
#include "upb/hash/int_table.h"
#define PYUPB_PROTOBUF_PUBLIC_PACKAGE "google.protobuf"
#define PYUPB_PROTOBUF_INTERNAL_PACKAGE "google.protobuf.internal"
#define PYUPB_DESCRIPTOR_PROTO_PACKAGE "google.protobuf"
#define PYUPB_MODULE_NAME "google._upb._message"
#define PYUPB_DESCRIPTOR_MODULE "google.protobuf.descriptor_pb2"
#define PYUPB_RETURN_OOM return PyErr_SetNone(PyExc_MemoryError), NULL
struct PyUpb_WeakMap;
typedef struct PyUpb_WeakMap PyUpb_WeakMap;
typedef struct {
PyTypeObject* descriptor_types[kPyUpb_Descriptor_Count];
PyTypeObject* by_name_map_type;
PyTypeObject* by_name_iterator_type;
PyTypeObject* by_number_map_type;
PyTypeObject* by_number_iterator_type;
PyTypeObject* generic_sequence_type;
PyObject* default_pool;
PyTypeObject* descriptor_pool_type;
upb_DefPool* c_descriptor_symtab;
PyTypeObject* extension_dict_type;
PyTypeObject* extension_iterator_type;
PyTypeObject* map_iterator_type;
PyTypeObject* message_map_container_type;
PyTypeObject* scalar_map_container_type;
PyObject* decode_error_class;
PyObject* descriptor_string;
PyObject* encode_error_class;
PyObject* enum_type_wrapper_class;
PyObject* message_class;
PyTypeObject* cmessage_type;
PyTypeObject* message_meta_type;
PyObject* listfields_item_key;
bool allow_oversize_protos;
PyObject* wkt_bases;
PyTypeObject* arena_type;
PyUpb_WeakMap* obj_cache;
PyTypeObject* repeated_composite_container_type;
PyTypeObject* repeated_scalar_container_type;
PyTypeObject* unknown_fields_type;
PyObject* unknown_field_type;
} PyUpb_ModuleState;
PyUpb_ModuleState* PyUpb_ModuleState_Get(void);
PyUpb_ModuleState* PyUpb_ModuleState_GetFromModule(PyObject* module);
PyUpb_ModuleState* PyUpb_ModuleState_MaybeGet(void);
PyObject* PyUpb_GetWktBases(PyUpb_ModuleState* state);
PyUpb_WeakMap* PyUpb_WeakMap_New(void);
void PyUpb_WeakMap_Free(PyUpb_WeakMap* map);
void PyUpb_WeakMap_Add(PyUpb_WeakMap* map, const void* key, PyObject* py_obj);
void PyUpb_WeakMap_Delete(PyUpb_WeakMap* map, const void* key);
void PyUpb_WeakMap_TryDelete(PyUpb_WeakMap* map, const void* key);
PyObject* PyUpb_WeakMap_Get(PyUpb_WeakMap* map, const void* key);
#define PYUPB_WEAKMAP_BEGIN UPB_INTTABLE_BEGIN
bool PyUpb_WeakMap_Next(PyUpb_WeakMap* map, const void** key, PyObject** obj,
intptr_t* iter);
void PyUpb_WeakMap_DeleteIter(PyUpb_WeakMap* map, intptr_t* iter);
void PyUpb_ObjCache_Add(const void* key, PyObject* py_obj);
void PyUpb_ObjCache_Delete(const void* key);
PyObject* PyUpb_ObjCache_Get(const void* key); PyUpb_WeakMap* PyUpb_ObjCache_Instance(void);
PyObject* PyUpb_Arena_New(void);
upb_Arena* PyUpb_Arena_Get(PyObject* arena);
PyTypeObject* AddObject(PyObject* m, const char* name, PyType_Spec* spec);
PyTypeObject* PyUpb_AddClass(PyObject* m, PyType_Spec* spec);
PyTypeObject* PyUpb_AddClassWithBases(PyObject* m, PyType_Spec* spec,
PyObject* bases);
PyTypeObject* PyUpb_AddClassWithRegister(PyObject* m, PyType_Spec* spec,
PyObject* virtual_base,
const char** methods);
PyObject* PyUpb_Forbidden_New(PyObject* cls, PyObject* args, PyObject* kwds);
static inline void PyUpb_Dealloc(void* self) {
PyTypeObject* tp = Py_TYPE(self);
assert(PyType_GetFlags(tp) & Py_TPFLAGS_HEAPTYPE);
freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
tp_free(self);
Py_DECREF(tp);
}
static inline PyObject* PyUpb_NewRef(PyObject* obj) {
Py_INCREF(obj);
return obj;
}
const char* PyUpb_GetStrData(PyObject* obj);
const char* PyUpb_VerifyStrData(PyObject* obj);
bool PyUpb_IndexToRange(PyObject* index, Py_ssize_t size, Py_ssize_t* i,
Py_ssize_t* count, Py_ssize_t* step);
#endif