upb_extreg, upb_msg
diff --git a/python/convert.c b/python/convert.c index d1229b3..858cbca 100644 --- a/python/convert.c +++ b/python/convert.c
@@ -66,7 +66,7 @@ return ret; } case kUpb_CType_Message: - return PyUpb_CMessage_Get((upb_msg*)val.msg_val, + return PyUpb_CMessage_Get((upb_Message*)val.msg_val, upb_FieldDef_MessageSubDef(f), arena); default: PyErr_Format(PyExc_SystemError, @@ -242,7 +242,7 @@ } } -bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2, +bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, const upb_MessageDef* m); // ----------------------------------------------------------------------------- @@ -341,10 +341,11 @@ return true; } -bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2, +bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, const upb_MessageDef* m) { if (msg1 == msg2) return true; - if (upb_msg_extcount(msg1) != upb_msg_extcount(msg2)) return false; + if (upb_Message_ExtensionCount(msg1) != upb_Message_ExtensionCount(msg2)) + return false; // Compare messages field-by-field. This is slightly tricky, because while // we can iterate over normal fields in a predictable order, the extension @@ -392,8 +393,8 @@ if (upb_Message_Next(msg2, m, NULL, &f2, &val2, &iter2)) return false; size_t usize1, usize2; - const char* uf1 = upb_Message_Getunknown(msg1, &usize1); - const char* uf2 = upb_Message_Getunknown(msg2, &usize2); + const char* uf1 = upb_Message_GetUnknown(msg1, &usize1); + const char* uf2 = upb_Message_GetUnknown(msg2, &usize2); // 100 is arbitrary, we're trying to prevent stack overflow but it's not // obvious how deep we should allow here. return upb_Message_UnknownFieldsAreEqual(uf1, usize1, uf2, usize2, 100) ==
diff --git a/python/convert.h b/python/convert.h index 9188cbb..cc66606 100644 --- a/python/convert.h +++ b/python/convert.h
@@ -53,7 +53,7 @@ const upb_FieldDef* f); // Returns true if the given messages (of type `m`) are equal. -bool PyUpb_Message_IsEqual(const upb_msg* msg1, const upb_msg* msg2, +bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, const upb_MessageDef* m); // Returns true if the two arrays (with element type `f`) are equal.
diff --git a/python/descriptor.c b/python/descriptor.c index 704e474..7a15326 100644 --- a/python/descriptor.c +++ b/python/descriptor.c
@@ -101,7 +101,7 @@ } static PyObject* PyUpb_DescriptorBase_GetOptions(PyUpb_DescriptorBase* self, - const upb_msg* opts, + const upb_Message* opts, const upb_MiniTable* layout, const char* msg_name) { if (!self->options) { @@ -124,7 +124,7 @@ PyObject* py_arena = PyUpb_Arena_New(); upb_Arena* arena = PyUpb_Arena_Get(py_arena); char* pb = upb_Encode(opts, layout, arena, &size); - upb_msg* opts2 = upb_Message_New(m, arena); + upb_Message* opts2 = upb_Message_New(m, arena); assert(opts2); bool ok = _upb_decode(pb, size, opts2, upb_MessageDef_MiniTable(m), upb_DefPool_ExtensionRegistry(symtab), 0, @@ -147,7 +147,7 @@ PyUpb_DescriptorBase* self = (void*)_self; upb_Arena* arena = upb_Arena_New(); if (!arena) PYUPB_RETURN_OOM; - upb_msg* proto = func(self->def, arena); + upb_Message* proto = func(self->def, arena); if (!proto) goto oom; size_t size; char* pb = upb_Encode(proto, layout, arena, &size);
diff --git a/python/extension_dict.c b/python/extension_dict.c index 6139519..2a95bdf 100644 --- a/python/extension_dict.c +++ b/python/extension_dict.c
@@ -70,7 +70,7 @@ const upb_MiniTable* l = upb_MessageDef_MiniTable(m); const upb_FileDef* file = upb_MessageDef_File(m); const upb_DefPool* symtab = upb_FileDef_Pool(file); - const upb_extreg* reg = upb_DefPool_ExtensionRegistry(symtab); + const upb_ExtensionRegistry* reg = upb_DefPool_ExtensionRegistry(symtab); int64_t number = PyLong_AsLong(arg); const upb_MiniTable_Extension* ext = (upb_MiniTable_Extension*)_upb_extreg_get(reg, l, number); @@ -92,7 +92,7 @@ PyUpb_ExtensionDict* self = (PyUpb_ExtensionDict*)_self; const upb_FieldDef* f = PyUpb_CMessage_GetExtensionDef(self->msg, key); if (!f) return -1; - upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg); + upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg); if (!msg) return 0; if (upb_FieldDef_IsRepeated(f)) { upb_MessageValue val = upb_Message_Get(msg, f); @@ -104,8 +104,8 @@ static Py_ssize_t PyUpb_ExtensionDict_Length(PyObject* _self) { PyUpb_ExtensionDict* self = (PyUpb_ExtensionDict*)_self; - upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg); - return msg ? upb_msg_extcount(msg) : 0; + upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg); + return msg ? upb_Message_ExtensionCount(msg) : 0; } static PyObject* PyUpb_ExtensionDict_Subscript(PyObject* _self, PyObject* key) { @@ -190,7 +190,7 @@ PyObject* PyUpb_ExtensionIterator_IterNext(PyObject* _self) { PyUpb_ExtensionIterator* self = (PyUpb_ExtensionIterator*)_self; - upb_msg* msg = PyUpb_CMessage_GetIfReified(self->msg); + upb_Message* msg = PyUpb_CMessage_GetIfReified(self->msg); if (!msg) return NULL; const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(self->msg); const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m));
diff --git a/python/message.c b/python/message.c index e2ac314..37d0aec 100644 --- a/python/message.c +++ b/python/message.c
@@ -192,7 +192,7 @@ uintptr_t def; // Tagged, low bit 1 == upb_FieldDef*, else upb_MessageDef* union { // when def is msgdef, the data for this msg. - upb_msg* msg; + upb_Message* msg; // when def is fielddef, owning pointer to parent struct PyUpb_CMessage* parent; } ptr; @@ -221,7 +221,7 @@ return _PyUpb_CMessage_GetMsgdef((PyUpb_CMessage*)self); } -static upb_msg* PyUpb_CMessage_GetMsg(PyUpb_CMessage* self) { +static upb_Message* PyUpb_CMessage_GetMsg(PyUpb_CMessage* self) { assert(!PyUpb_CMessage_IsStub(self)); return self->ptr.msg; } @@ -243,7 +243,7 @@ // If the message is reified, returns it. Otherwise, returns NULL. // If NULL is returned, the object is empty and has no underlying data. -upb_msg* PyUpb_CMessage_GetIfReified(PyObject* _self) { +upb_Message* PyUpb_CMessage_GetIfReified(PyObject* _self) { PyUpb_CMessage* self = (void*)_self; return PyUpb_CMessage_IsStub(self) ? NULL : self->ptr.msg; } @@ -422,7 +422,7 @@ return ok; } -static bool PyUpb_CMessage_InitScalarAttribute(upb_msg* msg, +static bool PyUpb_CMessage_InitScalarAttribute(upb_Message* msg, const upb_FieldDef* f, PyObject* value, upb_Arena* arena) { @@ -449,7 +449,7 @@ PyObject* name; PyObject* value; PyUpb_CMessage_EnsureReified(self); - upb_msg* msg = PyUpb_CMessage_GetMsg(self); + upb_Message* msg = PyUpb_CMessage_GetMsg(self); upb_Arena* arena = PyUpb_Arena_Get(self->arena); while (PyDict_Next(kwargs, &pos, &name, &value)) { @@ -520,8 +520,8 @@ const upb_MessageDef* m2_msgdef = _PyUpb_CMessage_GetMsgdef(m2); assert(m1_msgdef == m2_msgdef); #endif - const upb_msg* m1_msg = PyUpb_CMessage_GetIfReified((PyObject*)m1); - const upb_msg* m2_msg = PyUpb_CMessage_GetIfReified(_m2); + const upb_Message* m1_msg = PyUpb_CMessage_GetIfReified((PyObject*)m1); + const upb_Message* m2_msg = PyUpb_CMessage_GetIfReified(_m2); return PyUpb_Message_IsEqual(m1_msg, m2_msg, m1_msgdef); } @@ -566,8 +566,8 @@ if (!PyUpb_CMessage_IsStub(self)) return; upb_Arena* arena = PyUpb_Arena_Get(self->arena); - // This is a non-present message. We need to create a real upb_msg for this - // object and every parent until we reach a present message. + // This is a non-present message. We need to create a real upb_Message for + // this object and every parent until we reach a present message. PyUpb_CMessage* child = self; PyUpb_CMessage* parent = self->ptr.parent; const upb_FieldDef* child_f = PyUpb_CMessage_InitAsMsg(child, arena); @@ -600,7 +600,7 @@ * the set state (having a non-owning pointer to self->ptr.msg). */ static void PyUpb_CMessage_Reify(PyUpb_CMessage* self, const upb_FieldDef* f, - upb_msg* msg) { + upb_Message* msg) { assert(f == PyUpb_CMessage_GetFieldDef(self)); if (!msg) { const upb_MessageDef* msgdef = PyUpb_CMessage_GetMsgdef((PyObject*)self); @@ -616,7 +616,7 @@ /* * PyUpb_CMessage_SyncSubobjs() * - * This operation must be invoked whenever the underlying upb_msg has been + * This operation must be invoked whenever the underlying upb_Message has been * mutated directly in C. This will attach any newly-present field data * to previously returned stub wrapper objects. * @@ -635,7 +635,7 @@ PyUpb_WeakMap* subobj_map = self->unset_subobj_map; if (!subobj_map) return; - upb_msg* msg = PyUpb_CMessage_GetMsg(self); + upb_Message* msg = PyUpb_CMessage_GetMsg(self); intptr_t iter = PYUPB_WEAKMAP_BEGIN; const void* key; PyObject* obj; @@ -661,7 +661,7 @@ } else { PyUpb_CMessage* sub = (void*)obj; assert(self == sub->ptr.parent); - PyUpb_CMessage_Reify(sub, f, (upb_msg*)msgval.msg_val); + PyUpb_CMessage_Reify(sub, f, (upb_Message*)msgval.msg_val); } } @@ -675,7 +675,7 @@ if (PyUpb_CMessage_IsStub(self)) { return PyUnicode_FromStringAndSize(NULL, 0); } - upb_msg* msg = PyUpb_CMessage_GetMsg(self); + upb_Message* msg = PyUpb_CMessage_GetMsg(self); const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self); const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(msgdef)); char buf[1024]; @@ -749,7 +749,7 @@ } } -PyObject* PyUpb_CMessage_Get(upb_msg* u_msg, const upb_MessageDef* m, +PyObject* PyUpb_CMessage_Get(upb_Message* u_msg, const upb_MessageDef* m, PyObject* arena) { PyObject* ret = PyUpb_ObjCache_Get(u_msg); if (ret) return ret; @@ -1011,7 +1011,7 @@ } else { // We just need to return a boolean "true" or "false" for whether all // required fields are set. - upb_msg* msg = PyUpb_CMessage_GetIfReified(_self); + upb_Message* msg = PyUpb_CMessage_GetIfReified(_self); const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(_self); const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m)); bool initialized = !upb_util_HasUnsetRequired(msg, m, symtab, NULL); @@ -1052,7 +1052,7 @@ static PyObject* PyUpb_CMessage_ListFields(PyObject* _self, PyObject* arg) { PyObject* list = PyList_New(0); - upb_msg* msg = PyUpb_CMessage_GetIfReified(_self); + upb_Message* msg = PyUpb_CMessage_GetIfReified(_self); if (!msg) return list; size_t iter1 = kUpb_Message_Begin; @@ -1145,7 +1145,7 @@ PyUpb_CMessage_EnsureReified(self); const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self); const upb_FileDef* file = upb_MessageDef_File(msgdef); - const upb_extreg* extreg = + const upb_ExtensionRegistry* extreg = upb_DefPool_ExtensionRegistry(upb_FileDef_Pool(file)); const upb_MiniTable* layout = upb_MessageDef_MiniTable(msgdef); upb_Arena* arena = PyUpb_Arena_Get(self->arena); @@ -1190,7 +1190,7 @@ PyUpb_WeakMap* subobj_map = self->unset_subobj_map; if (subobj_map) { - upb_msg* msg = PyUpb_CMessage_GetMsg(self); + upb_Message* msg = PyUpb_CMessage_GetMsg(self); intptr_t iter = PYUPB_WEAKMAP_BEGIN; const void* key; PyObject* obj; @@ -1290,7 +1290,7 @@ static PyObject* PyUpb_CMessage_FindInitializationErrors(PyObject* _self, PyObject* arg) { PyUpb_CMessage* self = (void*)_self; - upb_msg* msg = PyUpb_CMessage_GetIfReified(_self); + upb_Message* msg = PyUpb_CMessage_GetIfReified(_self); const upb_MessageDef* msgdef = _PyUpb_CMessage_GetMsgdef(self); const upb_DefPool* ext_pool = upb_FileDef_Pool(upb_MessageDef_File(msgdef)); upb_FieldPathEntry* fields; @@ -1363,7 +1363,7 @@ static PyObject* PyUpb_CMessage_HasExtension(PyObject* _self, PyObject* ext_desc) { - upb_msg* msg = PyUpb_CMessage_GetIfReified(_self); + upb_Message* msg = PyUpb_CMessage_GetIfReified(_self); const upb_FieldDef* f = PyUpb_CMessage_GetExtensionDef(_self, ext_desc); if (!f) return NULL; if (upb_FieldDef_IsRepeated(f)) { @@ -1465,7 +1465,7 @@ if (!PyUpb_CMessage_LookupName(self, name, NULL, &o, PyExc_ValueError)) { return NULL; } - upb_msg* msg = PyUpb_CMessage_GetIfReified(_self); + upb_Message* msg = PyUpb_CMessage_GetIfReified(_self); if (!msg) Py_RETURN_NONE; const upb_FieldDef* f = upb_Message_WhichOneof(msg, o); if (!f) Py_RETURN_NONE;
diff --git a/python/message.h b/python/message.h index 6049726..73bac46 100644 --- a/python/message.h +++ b/python/message.h
@@ -45,16 +45,16 @@ // Gets a Python wrapper object for message `u_msg` of type `m`, returning a // cached wrapper if one was previously created. If a new object is created, // it will reference `arena`, which must own `u_msg`. -PyObject* PyUpb_CMessage_Get(upb_msg* u_msg, const upb_MessageDef* m, +PyObject* PyUpb_CMessage_Get(upb_Message* u_msg, const upb_MessageDef* m, PyObject* arena); // Verifies that a Python object is a message. Sets a TypeError exception and // returns false on failure. bool PyUpb_CMessage_Check(PyObject* self); -// Gets the upb_msg* for this message object if the message is reified. +// Gets the upb_Message* for this message object if the message is reified. // Otherwise returns NULL. -upb_msg* PyUpb_CMessage_GetIfReified(PyObject* _self); +upb_Message* PyUpb_CMessage_GetIfReified(PyObject* _self); // Returns the `upb_MessageDef` for a given CMessage. const upb_MessageDef* PyUpb_CMessage_GetMsgdef(PyObject* self);
diff --git a/python/repeated.c b/python/repeated.c index c40bb1f..3520b43 100644 --- a/python/repeated.c +++ b/python/repeated.c
@@ -213,7 +213,7 @@ if (!result) { Py_DECREF(clone); return NULL; - } + } Py_DECREF(result); return (PyObject*)clone; } @@ -577,7 +577,7 @@ const upb_FieldDef* f = PyUpb_RepeatedContainer_GetField(self); upb_Arena* arena = PyUpb_Arena_Get(self->arena); const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); - upb_msg* msg = upb_Message_New(m, arena); + upb_Message* msg = upb_Message_New(m, arena); upb_MessageValue msgval = {.msg_val = msg}; upb_Array_Append(arr, msgval, arena); return PyUpb_CMessage_Get(msg, m, self->arena); @@ -631,7 +631,7 @@ if (upb_FieldDef_IsSubMessage(f)) { // Create message. const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); - upb_msg* msg = upb_Message_New(m, arena); + upb_Message* msg = upb_Message_New(m, arena); PyObject* py_msg = PyUpb_CMessage_Get(msg, m, self->arena); PyObject* ret = PyUpb_CMessage_MergeFrom(py_msg, value); Py_DECREF(py_msg);