From b14c814fec11ab450c552bccf5fe7d96dc2c4e18 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 4 Nov 2009 20:07:32 -0500 Subject: Whitespace fix --- src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index cdb43037..c3d3cf24 100644 --- a/src/utils.h +++ b/src/utils.h @@ -186,7 +186,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int /* version */) { + void serialize(Archive& ar, const unsigned int /* version */) { ar & boost::serialization::base_object(*this); } #endif // HAVE_BOOST_SERIALIZATION -- cgit v1.2.3 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 +++++++++++----- src/utils.cc | 4 ++++ src/utils.h | 10 +++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src/utils.h') 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(); } diff --git a/src/utils.cc b/src/utils.cc index c68737dc..2f2899fb 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -407,6 +407,8 @@ void report_memory(std::ostream& out, bool report_all) } +#if defined(STRING_VERIFY_ON) + string::string() : std::string() { TRACE_CTOR(string, ""); } @@ -443,6 +445,8 @@ string::~string() throw() { TRACE_DTOR(string); } +#endif // STRING_VERIFY_ON + } // namespace ledger #endif // VERIFY_ON diff --git a/src/utils.h b/src/utils.h index c3d3cf24..a8784a66 100644 --- a/src/utils.h +++ b/src/utils.h @@ -62,6 +62,10 @@ #define TIMERS_ON 1 #endif +#if defined(VERIFY_ON) +//#define STRING_VERIFY_ON 1 +#endif + /*@}*/ /** @@ -72,7 +76,7 @@ namespace ledger { using namespace boost; -#if defined(VERIFY_ON) +#if defined(STRING_VERIFY_ON) class string; #else typedef std::string string; @@ -158,6 +162,8 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size); void report_memory(std::ostream& out, bool report_all = false); +#if defined(STRING_VERIFY_ON) + /** * @brief Brief * @@ -236,6 +242,8 @@ inline bool operator!=(const char* __lhs, const string& __rhs) inline bool operator!=(const string& __lhs, const char* __rhs) { return __lhs.compare(__rhs) != 0; } +#endif // STRING_VERIFY_ON + } // namespace ledger #else // ! VERIFY_ON -- cgit v1.2.3