summaryrefslogtreecommitdiff
path: root/src/py_value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:44 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-20 23:23:44 -0500
commitd5e957204c2799f07f9ecf868d2d846bea5682ef (patch)
treee2618ed53b09e0ea7d0d5871c237ec3b5127faae /src/py_value.cc
parentbd455c98743ce354b875d67a1d607a682d604fe0 (diff)
downloadfork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.tar.gz
fork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.tar.bz2
fork-ledger-d5e957204c2799f07f9ecf868d2d846bea5682ef.zip
Fixed Ledger/Python byte vs. char Unicode bridge
Diffstat (limited to 'src/py_value.cc')
-rw-r--r--src/py_value.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/py_value.cc b/src/py_value.cc
index 1a77da72..713dc3d4 100644
--- a/src/py_value.cc
+++ b/src/py_value.cc
@@ -103,6 +103,11 @@ namespace {
value_t py_strip_annotations_1(value_t& value, const keep_details_t& keep) {
return value.strip_annotations(keep);
}
+
+ PyObject * py_value_unicode(value_t& value) {
+ return str_to_py_unicode(value.to_string());
+ }
+
} // unnamed namespace
#define EXC_TRANSLATOR(type) \
@@ -115,16 +120,16 @@ EXC_TRANSLATOR(value_error)
void export_value()
{
enum_< value_t::type_t >("ValueType")
- .value("VOID", value_t::VOID)
- .value("BOOLEAN", value_t::BOOLEAN)
- .value("DATETIME", value_t::DATETIME)
- .value("DATE", value_t::DATE)
- .value("INTEGER", value_t::INTEGER)
- .value("AMOUNT", value_t::AMOUNT)
- .value("BALANCE", value_t::BALANCE)
- .value("STRING", value_t::STRING)
- .value("SEQUENCE", value_t::SEQUENCE)
- .value("SCOPE", value_t::SCOPE)
+ .value("Void", value_t::VOID)
+ .value("Boolean", value_t::BOOLEAN)
+ .value("DateTime", value_t::DATETIME)
+ .value("Date", value_t::DATE)
+ .value("Integer", value_t::INTEGER)
+ .value("Amount", value_t::AMOUNT)
+ .value("Balance", value_t::BALANCE)
+ .value("String", value_t::STRING)
+ .value("Sequence", value_t::SEQUENCE)
+ .value("Scope", value_t::SCOPE)
;
class_< value_t > ("Value")
@@ -309,11 +314,13 @@ void export_value()
.def("to_date", &value_t::to_date)
.def("to_amount", &value_t::to_amount)
.def("to_balance", &value_t::to_balance)
+ .def("__str__", &value_t::to_string)
+ .def("__unicode__", py_value_unicode)
.def("to_string", &value_t::to_string)
.def("to_mask", &value_t::to_mask)
.def("to_sequence", &value_t::to_sequence)
- .def("__str__", py_dump_relaxed)
+ .def("__unicode__", py_dump_relaxed)
.def("__repr__", py_dump)
.def("casted", &value_t::casted)