summaryrefslogtreecommitdiff
path: root/src/py_utils.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-05 02:24:39 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-05 02:27:42 -0500
commit817f1ae1619df06f06f79f772f075041bb70f751 (patch)
treef5714d8dcbf249e1ad3df18b35d297b8ae6c7c71 /src/py_utils.cc
parent3dc200983d5057a7760aeb9e864479c902d7e1d7 (diff)
downloadfork-ledger-817f1ae1619df06f06f79f772f075041bb70f751.tar.gz
fork-ledger-817f1ae1619df06f06f79f772f075041bb70f751.tar.bz2
fork-ledger-817f1ae1619df06f06f79f772f075041bb70f751.zip
std::string now only intercepted if STRING_VERIFY_ON
Diffstat (limited to 'src/py_utils.cc')
-rw-r--r--src/py_utils.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/py_utils.cc b/src/py_utils.cc
index 3e788442..c2177c20 100644
--- a/src/py_utils.cc
+++ b/src/py_utils.cc
@@ -74,11 +74,13 @@ typedef register_python_conversion<bool, bool_to_python, bool_from_python>
bool_python_conversion;
+#if defined(STRING_VERIFY_ON)
+
struct string_to_python
{
- static PyObject* convert(const string& str)
+ static PyObject* convert(const ledger::string& str)
{
- return incref(object(*boost::polymorphic_downcast<const std::string *>(&str)).ptr());
+ return incref(object(static_cast<const std::string&>(str)).ptr());
}
};
@@ -95,15 +97,17 @@ struct string_from_python
const char* value = PyString_AsString(obj_ptr);
if (value == 0) throw_error_already_set();
void* storage =
- reinterpret_cast<converter::rvalue_from_python_storage<string> *>(data)->storage.bytes;
- new (storage) string(value);
+ reinterpret_cast<converter::rvalue_from_python_storage<ledger::string> *>(data)->storage.bytes;
+ new (storage) ledger::string(value);
data->convertible = storage;
}
};
-typedef register_python_conversion<string, string_to_python, string_from_python>
+typedef register_python_conversion<ledger::string, string_to_python, string_from_python>
string_python_conversion;
+#endif // STRING_VERIFY_ON
+
struct istream_to_python
{
@@ -209,7 +213,9 @@ void export_utils()
;
bool_python_conversion();
+#if defined(STRING_VERIFY_ON)
string_python_conversion();
+#endif
istream_python_conversion();
ostream_python_conversion();
}