[Zope-CVS] CVS: Packages/Spread - spreadmodule.c:1.8
Guido van Rossum
guido@python.org
Wed, 19 Dec 2001 23:19:09 -0500
Update of /cvs-repository/Packages/Spread
In directory cvs.zope.org:/tmp/cvs-serv8698
Modified Files:
spreadmodule.c
Log Message:
Change the return types of new_*_msg() to be PyObject *. Omit
needless casts. Some reformatting to make function definitions have
the name start in column 1.
=== Packages/Spread/spreadmodule.c 1.7 => 1.8 ===
#define GroupId_Check(v) ((v)->ob_type == &GroupId_Type)
-static PyObject *new_group_id(group_id gid)
+static PyObject *
+new_group_id(group_id gid)
{
GroupId *self;
@@ -88,7 +89,8 @@
PyObject_DEL(v);
}
-static PyObject *group_id_repr(GroupId *v)
+static PyObject *
+group_id_repr(GroupId *v)
{
char buf[80];
sprintf(buf, "<group_id %08X:%08X:%08X>",
@@ -150,7 +152,7 @@
#define CAUSED_BY_MASK (CAUSED_BY_JOIN | CAUSED_BY_LEAVE | \
CAUSED_BY_DISCONNECT | CAUSED_BY_NETWORK)
-static MembershipMsg *
+static PyObject *
new_membership_msg(int type, PyObject *group, int num_members,
char (*members)[MAX_GROUP_NAME], char *msg)
{
@@ -158,16 +160,16 @@
extra_member_info *extra = (extra_member_info *)msg;
int i;
+ assert(group != NULL);
self = PyObject_New(MembershipMsg, &MembershipMsg_Type);
if (self == NULL)
return NULL;
self->reason = type & CAUSED_BY_MASK; /* from sp.h defines */
- assert(group != NULL);
Py_INCREF(group);
self->group = group;
self->members = NULL;
self->extra = NULL;
- self->group_id = (PyObject *)new_group_id(extra->gid);
+ self->group_id = new_group_id(extra->gid);
if (self->group_id == NULL) {
Py_DECREF(self);
return NULL;
@@ -204,7 +206,7 @@
}
PyTuple_SET_ITEM(self->extra, i, s);
}
- return self;
+ return (PyObject *)self;
}
static void
@@ -255,7 +257,7 @@
0, /*tp_as_mapping*/
};
-static RegularMsg *
+static PyObject *
new_regular_msg(PyObject *sender, int num_groups,
char (*groups)[MAX_GROUP_NAME], short msg_type,
int endian, PyObject *message, int size)
@@ -293,7 +295,7 @@
self->truncated = 1;
else
self->truncated = 0;
- return self;
+ return (PyObject *)self;
}
static void
@@ -476,9 +478,9 @@
assert(endian == 0);
if (_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender))) < 0)
goto error;
- msg = (PyObject *)new_membership_msg(svc_type, sender,
- num_groups, groups,
- PyString_AS_STRING(message));
+ msg = new_membership_msg(svc_type, sender,
+ num_groups, groups,
+ PyString_AS_STRING(message));
} else if (svc_type & TRANSITION_MESS) {
PyErr_SetString(PyExc_RuntimeError,
"can't handle transitional messages yet");
@@ -488,15 +490,14 @@
goto error;
if (_PyString_Resize(&message, size) < 0)
goto error;
- msg = (PyObject *)new_regular_msg(sender, num_groups, groups,
- msg_type, endian, message, size);
+ msg = new_regular_msg(sender, num_groups, groups,
+ msg_type, endian, message, size);
} else if (svc_type & MEMBERSHIP_MESS) {
assert(svc_type & CAUSED_BY_LEAVE);
if (_PyString_Resize(&sender, strlen(PyString_AS_STRING(sender))) < 0)
goto error;
- msg = (PyObject *)new_membership_msg(svc_type, sender,
- num_groups, groups,
- PyString_AS_STRING(message));
+ msg = new_membership_msg(svc_type, sender, num_groups, groups,
+ PyString_AS_STRING(message));
} else {
/* XXX */
fprintf(stderr, "unexpected service type: %d\n", svc_type);
@@ -593,11 +594,11 @@
};
static PyObject *
-mailbox_getattr(MailboxObject *self, char *name)
+mailbox_getattr(PyObject *self, char *name)
{
PyObject *meth;
- meth = Py_FindMethod(Mailbox_methods, (PyObject *)self, name);
+ meth = Py_FindMethod(Mailbox_methods, self, name);
if (meth)
return meth;
PyErr_Clear();
@@ -822,9 +823,9 @@
MembershipMsg_Type.ob_type = &PyType_Type;
/* XXX AddObject() DECREFs its third argument */
- Py_INCREF((PyObject *)&Mailbox_Type);
- Py_INCREF((PyObject *)&RegularMsg_Type);
- Py_INCREF((PyObject *)&MembershipMsg_Type);
+ Py_INCREF(&Mailbox_Type);
+ Py_INCREF(&RegularMsg_Type);
+ Py_INCREF(&MembershipMsg_Type);
PyModule_AddObject(m, "MailboxType", (PyObject *)&Mailbox_Type);
PyModule_AddObject(m, "RegularMsgType", (PyObject *)&RegularMsg_Type);
PyModule_AddObject(m, "MembershipMsgType",