c bool encoding
This commit is contained in:
parent
4a3105d727
commit
312f8c3cf3
@ -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;
|
||||
|
||||
@ -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],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user