std::string now only intercepted if STRING_VERIFY_ON
This commit is contained in:
parent
3dc200983d
commit
817f1ae161
3 changed files with 24 additions and 6 deletions
|
|
@ -74,11 +74,13 @@ typedef register_python_conversion<bool, bool_to_python, bool_from_python>
|
||||||
bool_python_conversion;
|
bool_python_conversion;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(STRING_VERIFY_ON)
|
||||||
|
|
||||||
struct string_to_python
|
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);
|
const char* value = PyString_AsString(obj_ptr);
|
||||||
if (value == 0) throw_error_already_set();
|
if (value == 0) throw_error_already_set();
|
||||||
void* storage =
|
void* storage =
|
||||||
reinterpret_cast<converter::rvalue_from_python_storage<string> *>(data)->storage.bytes;
|
reinterpret_cast<converter::rvalue_from_python_storage<ledger::string> *>(data)->storage.bytes;
|
||||||
new (storage) string(value);
|
new (storage) ledger::string(value);
|
||||||
data->convertible = storage;
|
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;
|
string_python_conversion;
|
||||||
|
|
||||||
|
#endif // STRING_VERIFY_ON
|
||||||
|
|
||||||
|
|
||||||
struct istream_to_python
|
struct istream_to_python
|
||||||
{
|
{
|
||||||
|
|
@ -209,7 +213,9 @@ void export_utils()
|
||||||
;
|
;
|
||||||
|
|
||||||
bool_python_conversion();
|
bool_python_conversion();
|
||||||
|
#if defined(STRING_VERIFY_ON)
|
||||||
string_python_conversion();
|
string_python_conversion();
|
||||||
|
#endif
|
||||||
istream_python_conversion();
|
istream_python_conversion();
|
||||||
ostream_python_conversion();
|
ostream_python_conversion();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,8 @@ void report_memory(std::ostream& out, bool report_all)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(STRING_VERIFY_ON)
|
||||||
|
|
||||||
string::string() : std::string() {
|
string::string() : std::string() {
|
||||||
TRACE_CTOR(string, "");
|
TRACE_CTOR(string, "");
|
||||||
}
|
}
|
||||||
|
|
@ -443,6 +445,8 @@ string::~string() throw() {
|
||||||
TRACE_DTOR(string);
|
TRACE_DTOR(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // STRING_VERIFY_ON
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
||||||
#endif // VERIFY_ON
|
#endif // VERIFY_ON
|
||||||
|
|
|
||||||
10
src/utils.h
10
src/utils.h
|
|
@ -62,6 +62,10 @@
|
||||||
#define TIMERS_ON 1
|
#define TIMERS_ON 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(VERIFY_ON)
|
||||||
|
//#define STRING_VERIFY_ON 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,7 +76,7 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
#if defined(VERIFY_ON)
|
#if defined(STRING_VERIFY_ON)
|
||||||
class string;
|
class string;
|
||||||
#else
|
#else
|
||||||
typedef std::string string;
|
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);
|
void report_memory(std::ostream& out, bool report_all = false);
|
||||||
|
|
||||||
|
#if defined(STRING_VERIFY_ON)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Brief
|
* @brief Brief
|
||||||
*
|
*
|
||||||
|
|
@ -236,6 +242,8 @@ inline bool operator!=(const char* __lhs, const string& __rhs)
|
||||||
inline bool operator!=(const string& __lhs, const char* __rhs)
|
inline bool operator!=(const string& __lhs, const char* __rhs)
|
||||||
{ return __lhs.compare(__rhs) != 0; }
|
{ return __lhs.compare(__rhs) != 0; }
|
||||||
|
|
||||||
|
#endif // STRING_VERIFY_ON
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
||||||
#else // ! VERIFY_ON
|
#else // ! VERIFY_ON
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue