Skip to content

Commit

Permalink
Add #feed method to the Reader class
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Jan 27, 2011
1 parent a5915e3 commit b8c473f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions src/reader.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#include "reader.h"

static PyObject *Reader_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void Reader_dealloc(hiredis_ReaderObject *self);
static PyObject *Reader_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
static PyObject *Reader_feed(hiredis_ReaderObject *self, PyObject *args);

static PyMethodDef hiredis_ReaderMethods[] = {
{"feed", (PyCFunction)Reader_feed, METH_VARARGS, NULL },
{ NULL } /* Sentinel */
};

PyTypeObject hiredis_ReaderType = {
PyObject_HEAD_INIT(NULL)
Expand Down Expand Up @@ -32,7 +38,7 @@ PyTypeObject hiredis_ReaderType = {
0, /*tp_weaklistoffset */
0, /*tp_iter */
0, /*tp_iternext */
0, /*tp_methods */
hiredis_ReaderMethods, /*tp_methods */
0, /*tp_members */
0, /*tp_getset */
0, /*tp_base */
Expand All @@ -45,6 +51,11 @@ PyTypeObject hiredis_ReaderType = {
Reader_new, /*tp_new */
};

static void Reader_dealloc(hiredis_ReaderObject *self) {
redisReplyReaderFree(self->reader);
self->ob_type->tp_free((PyObject*)self);
}

static PyObject *Reader_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
hiredis_ReaderObject *self;
self = (hiredis_ReaderObject*)type->tp_alloc(type, 0);
Expand All @@ -53,7 +64,13 @@ static PyObject *Reader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return (PyObject*)self;
}

static void Reader_dealloc(hiredis_ReaderObject *self) {
redisReplyReaderFree(self->reader);
self->ob_type->tp_free((PyObject*)self);
static PyObject *Reader_feed(hiredis_ReaderObject *self, PyObject *args) {
const char *str;
int len;

if (!PyArg_ParseTuple(args, "s#", &str, &len))
return NULL;

redisReplyReaderFeed(self->reader, str, len);
Py_RETURN_NONE;
}
2 changes: 1 addition & 1 deletion vendor/hiredis
Submodule hiredis updated 5 files
+2 −2 Makefile
+3 −3 hiredis.c
+2 −2 hiredis.h
+1 −1 sds.h
+5 −5 test.c

0 comments on commit b8c473f

Please sign in to comment.