Moved pointers left and added some comments.

pull/13171/head
Joshua Haberman 3 years ago
parent deddc20f0c
commit bfc264d098
  1. 1136
      python/descriptor.c
  2. 30
      python/descriptor.h
  3. 6
      python/descriptor_pool.h
  4. 17
      python/protobuf.c

File diff suppressed because it is too large Load Diff

@ -47,31 +47,31 @@ typedef enum {
// Given a descriptor object |desc|, returns a Python message class object for
// the msgdef |m|, which must be from the same pool.
PyObject *PyUpb_Descriptor_GetClass(const upb_msgdef *m);
PyObject* PyUpb_Descriptor_GetClass(const upb_msgdef* m);
// Returns a Python wrapper object for the given def. This will return an
// existing object if one already exists, otherwise a new object will be
// created. The caller always owns a ref on the returned object.
PyObject *PyUpb_Descriptor_Get(const upb_msgdef *msgdef);
PyObject *PyUpb_EnumDescriptor_Get(const upb_enumdef *enumdef);
PyObject *PyUpb_FieldDescriptor_Get(const upb_fielddef *field);
PyObject *PyUpb_FileDescriptor_Get(const upb_filedef *file);
PyObject *PyUpb_OneofDescriptor_Get(const upb_oneofdef *oneof);
PyObject *PyUpb_EnumValueDescriptor_Get(const upb_enumvaldef *enumval);
PyObject *PyUpb_Descriptor_GetOrCreateWrapper(const upb_msgdef *msg);
PyObject *PyUpb_ServiceDescriptor_Get(const upb_servicedef *s);
PyObject* PyUpb_Descriptor_Get(const upb_msgdef* msgdef);
PyObject* PyUpb_EnumDescriptor_Get(const upb_enumdef* enumdef);
PyObject* PyUpb_FieldDescriptor_Get(const upb_fielddef* field);
PyObject* PyUpb_FileDescriptor_Get(const upb_filedef* file);
PyObject* PyUpb_OneofDescriptor_Get(const upb_oneofdef* oneof);
PyObject* PyUpb_EnumValueDescriptor_Get(const upb_enumvaldef* enumval);
PyObject* PyUpb_Descriptor_GetOrCreateWrapper(const upb_msgdef* msg);
PyObject* PyUpb_ServiceDescriptor_Get(const upb_servicedef* s);
// Returns the underlying |def| for a given wrapper object. The caller must
// have already verified that the given Python object is of the expected type.
const upb_filedef *PyUpb_FileDescriptor_GetDef(PyObject *file);
const upb_fielddef *PyUpb_FieldDescriptor_GetDef(PyObject *file);
const upb_msgdef *PyUpb_Descriptor_GetDef(PyObject *_self);
const void *PyUpb_AnyDescriptor_GetDef(PyObject *_self);
const upb_filedef* PyUpb_FileDescriptor_GetDef(PyObject* file);
const upb_fielddef* PyUpb_FieldDescriptor_GetDef(PyObject* file);
const upb_msgdef* PyUpb_Descriptor_GetDef(PyObject* _self);
const void* PyUpb_AnyDescriptor_GetDef(PyObject* _self);
// Returns the underlying |def| for a given wrapper object. The caller must
// have already verified that the given Python object is of the expected type.
const upb_filedef *PyUpb_FileDescriptor_GetDef(PyObject *file);
const void *PyUpb_AnyDescriptor_GetDef(PyObject *_self);
const upb_filedef* PyUpb_FileDescriptor_GetDef(PyObject* file);
const void* PyUpb_AnyDescriptor_GetDef(PyObject* _self);
// Module-level init.
bool PyUpb_InitDescriptor(PyObject* m);

@ -34,9 +34,9 @@
PyObject* PyUpb_DescriptorPool_GetSerializedPb(PyObject* _self,
const char* filename);
PyObject* PyUpb_DescriptorPool_Get(const upb_symtab *symtab);
upb_symtab *PyUpb_DescriptorPool_GetSymtab(PyObject *pool);
PyObject *PyUpb_DescriptorPool_GetDefaultPool(void);
PyObject* PyUpb_DescriptorPool_Get(const upb_symtab* symtab);
upb_symtab* PyUpb_DescriptorPool_GetSymtab(PyObject* pool);
PyObject* PyUpb_DescriptorPool_GetDefaultPool(void);
bool PyUpb_InitDescriptorPool(PyObject* m);

@ -96,23 +96,22 @@ PyObject *PyUpb_ObjCache_Get(const void *key) {
// -----------------------------------------------------------------------------
typedef struct {
PyObject_HEAD
upb_arena *arena;
PyObject_HEAD upb_arena* arena;
} PyUpb_Arena;
PyObject *PyUpb_Arena_New(void) {
PyUpb_ModuleState *state = PyUpb_ModuleState_Get();
PyUpb_Arena *arena = (void*)PyType_GenericAlloc(state->arena_type, 0);
PyObject* PyUpb_Arena_New(void) {
PyUpb_ModuleState* state = PyUpb_ModuleState_Get();
PyUpb_Arena* arena = (void*)PyType_GenericAlloc(state->arena_type, 0);
arena->arena = upb_arena_new();
return &arena->ob_base;
}
static void PyUpb_Arena_Dealloc(PyObject *self) {
static void PyUpb_Arena_Dealloc(PyObject* self) {
upb_arena_free(PyUpb_Arena_Get(self));
PyUpb_Dealloc(self);
}
upb_arena *PyUpb_Arena_Get(PyObject *arena) {
upb_arena* PyUpb_Arena_Get(PyObject* arena) {
return ((PyUpb_Arena*)arena)->arena;
}
@ -129,8 +128,8 @@ static PyType_Spec PyUpb_Arena_Spec = {
PyUpb_Arena_Slots,
};
static bool PyUpb_InitArena(PyObject *m) {
PyUpb_ModuleState *state = PyUpb_ModuleState_GetFromModule(m);
static bool PyUpb_InitArena(PyObject* m) {
PyUpb_ModuleState* state = PyUpb_ModuleState_GetFromModule(m);
state->arena_type = PyUpb_AddClass(m, &PyUpb_Arena_Spec);
return state->arena_type;
}

Loading…
Cancel
Save