Factor out name differences into macros.

pull/13171/head
Joshua Haberman 3 years ago
parent 936a753290
commit 6a94a385f8
  1. 12
      python/descriptor.c
  2. 3
      python/descriptor_pool.c
  3. 3
      python/message.c

@ -1016,7 +1016,8 @@ static PyObject* PyUpb_FieldDescriptor_GetOptions(PyObject* _self,
PyUpb_DescriptorBase* self = (void*)_self;
return PyUpb_DescriptorBase_GetOptions(self, upb_FieldDef_Options(self->def),
&google_protobuf_FieldOptions_msginit,
PYUPB_DESCRIPTOR_PROTO_PACKAGE ".FieldOptions");
PYUPB_DESCRIPTOR_PROTO_PACKAGE
".FieldOptions");
}
static PyGetSetDef PyUpb_FieldDescriptor_Getters[] = {
@ -1255,7 +1256,8 @@ static PyObject* PyUpb_FileDescriptor_GetOptions(PyObject* _self,
PyUpb_DescriptorBase* self = (void*)_self;
return PyUpb_DescriptorBase_GetOptions(self, upb_FileDef_Options(self->def),
&google_protobuf_FileOptions_msginit,
PYUPB_DESCRIPTOR_PROTO_PACKAGE ".FileOptions");
PYUPB_DESCRIPTOR_PROTO_PACKAGE
".FileOptions");
}
static PyObject* PyUpb_FileDescriptor_CopyToProto(PyObject* _self,
@ -1362,7 +1364,8 @@ static PyObject* PyUpb_MethodDescriptor_GetOptions(PyObject* _self,
PyUpb_DescriptorBase* self = (void*)_self;
return PyUpb_DescriptorBase_GetOptions(self, upb_MethodDef_Options(self->def),
&google_protobuf_MethodOptions_msginit,
PYUPB_DESCRIPTOR_PROTO_PACKAGE ".MethodOptions");
PYUPB_DESCRIPTOR_PROTO_PACKAGE
".MethodOptions");
}
static PyObject* PyUpb_MethodDescriptor_CopyToProto(PyObject* _self,
@ -1467,7 +1470,8 @@ static PyObject* PyUpb_OneofDescriptor_GetOptions(PyObject* _self,
PyUpb_DescriptorBase* self = (void*)_self;
return PyUpb_DescriptorBase_GetOptions(self, upb_OneofDef_Options(self->def),
&google_protobuf_OneofOptions_msginit,
PYUPB_DESCRIPTOR_PROTO_PACKAGE ".OneofOptions");
PYUPB_DESCRIPTOR_PROTO_PACKAGE
".OneofOptions");
}
static PyGetSetDef PyUpb_OneofDescriptor_Getters[] = {

@ -251,7 +251,8 @@ static PyObject* PyUpb_DescriptorPool_DoAdd(PyObject* _self,
PyObject* file_desc) {
if (!PyUpb_CMessage_Verify(file_desc)) return NULL;
const upb_MessageDef* m = PyUpb_CMessage_GetMsgdef(file_desc);
const char* file_proto_name = PYUPB_DESCRIPTOR_PROTO_PACKAGE ".FileDescriptorProto";
const char* file_proto_name =
PYUPB_DESCRIPTOR_PROTO_PACKAGE ".FileDescriptorProto";
if (strcmp(upb_MessageDef_FullName(m), file_proto_name) != 0) {
return PyErr_Format(PyExc_TypeError, "Can only add FileDescriptorProto");
}

@ -1832,7 +1832,8 @@ bool PyUpb_InitMessage(PyObject* m) {
state->listfields_item_key = PyObject_GetAttrString(
(PyObject*)state->cmessage_type, "_ListFieldsItemKey");
PyObject* mod = PyImport_ImportModule(PYUPB_PROTOBUF_PUBLIC_PACKAGE ".message");
PyObject* mod =
PyImport_ImportModule(PYUPB_PROTOBUF_PUBLIC_PACKAGE ".message");
if (mod == NULL) return false;
state->encode_error_class = PyObject_GetAttrString(mod, "EncodeError");

Loading…
Cancel
Save