diff options
Diffstat (limited to 'src/py_utils.cc')
-rw-r--r-- | src/py_utils.cc | 16 |
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(); } |