From 817f1ae1619df06f06f79f772f075041bb70f751 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Nov 2009 02:24:39 -0500 Subject: std::string now only intercepted if STRING_VERIFY_ON --- src/py_utils.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/py_utils.cc') 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_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(&str)).ptr()); + return incref(object(static_cast(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 *>(data)->storage.bytes; - new (storage) string(value); + reinterpret_cast *>(data)->storage.bytes; + new (storage) ledger::string(value); data->convertible = storage; } }; -typedef register_python_conversion +typedef register_python_conversion 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(); } -- cgit v1.2.3