c bool encoding

This commit is contained in:
Mike Dirolf 2009-02-04 10:03:26 -05:00
parent 4a3105d727
commit 312f8c3cf3
2 changed files with 8 additions and 0 deletions

View File

@ -131,6 +131,10 @@ static PyObject* _cbson_element_to_bson(PyObject* self, PyObject* args) {
} else if (PyInt_CheckExact(value)) {
int int_value = (int)PyInt_AsLong(value);
return build_element(0x10, name, 4, (char*)&int_value);
} else if (PyBool_Check(value)) {
long bool = PyInt_AsLong(value);
char c = bool ? 0x01 : 0x00;
return build_element(0x08, name, 1, &c);
}
PyErr_SetString(CBSONError, "no c encoder for this type yet");
return NULL;

View File

@ -43,6 +43,10 @@ def main():
{"hello": "world",
"mike": u"something",
"here's": u"an\u8744other"},
{"int": 200,
"bool": True,
"an int": 20,
"a bool": False},
{"this": 5,
"is": {"a": True},
"big": [True, 5.5],