Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Checkpoint before I run git-filter-branch(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Ballance committed Jul 11, 2009
1 parent 9c3adf9 commit 2a94e85
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ PyObject *LastElement(_YajlDecoder *self)

int PlaceObject(_YajlDecoder *self, PyObject *object)
{
if (self->key)
fprintf(stderr, "PlaceObject, key: %s\n", PyString_AsString(self->key));

PyObject *root = LastElement(self);

if (root == NULL) {
Expand Down Expand Up @@ -153,15 +156,19 @@ int handle_start_dict(void *ctx)
if (!object)
return failure;

PyList_Append(self->elements, object);
return success;
return PlaceObject(self, object);
}

int handle_dict_key(void *ctx, const unsigned char *value, unsigned int length)
{
_YajlDecoder *self = (_YajlDecoder *)(ctx);
PyObject *object = PyString_FromStringAndSize((char *)(value), length);
PyObject *object = NULL;
char *key = (char *)(malloc(sizeof(char) * (length + 1)));

key = strncpy(key, (char *)(value), length);
key[length] = '\0';

object = PyString_FromStringAndSize(key, length);
if (!object)
return failure;

Expand Down Expand Up @@ -252,11 +259,15 @@ PyObject *py_yajldecoder_decode(PYARGS)
yrc = yajl_parse(parser, (const unsigned char *)(buffer), buflen);
yajl_parse_complete(parser);

PyObject *s = PyObject_Str(decoder->elements);
fprintf(stderr, "FOOOOO: %s\n", PyString_AsString(s));


if (yrc != yajl_status_ok) {
/* Raise some sort of exception */
return NULL;
}

root = PyList_GetItem(decoder->elements, 0);
if (!root)
return NULL;
Expand Down

0 comments on commit 2a94e85

Please sign in to comment.