forked from organicmaps/organicmaps
Add SetAssertFunction.
This commit is contained in:
parent
bbfac69edc
commit
f15f79bdcc
3 changed files with 14 additions and 3 deletions
|
@ -35,7 +35,7 @@ void InitSystemLog()
|
|||
|
||||
void InitAssertLog()
|
||||
{
|
||||
OnAssertFailed = &AndroidAssertMessage;
|
||||
SetAssertFunction(&AndroidAssertMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,13 @@
|
|||
namespace my
|
||||
{
|
||||
// Called when ASSERT, CHECK or VERIFY failed.
|
||||
extern void (*OnAssertFailed)(SrcPoint const &, string const &);
|
||||
typedef void (*AssertFailedFn)(SrcPoint const &, string const &);
|
||||
extern AssertFailedFn OnAssertFailed;
|
||||
|
||||
/// @return Pointer to previous message function.
|
||||
AssertFailedFn SetAssertFunction(AssertFailedFn fn);
|
||||
}
|
||||
|
||||
// TODO: Evaluate X only once in CHECK().
|
||||
#define CHECK(X, msg) if (X) {} else { \
|
||||
::my::OnAssertFailed(SRC(), ::my::impl::MergeMsg("CHECK("#X")", ::my::impl::Message msg));}
|
||||
|
|
|
@ -32,5 +32,11 @@ namespace my
|
|||
#endif
|
||||
}
|
||||
|
||||
void (*OnAssertFailed)(SrcPoint const &, string const &) = &OnAssertFailedDefault;
|
||||
AssertFailedFn OnAssertFailed = &OnAssertFailedDefault;
|
||||
|
||||
AssertFailedFn SetAssertFunction(AssertFailedFn fn)
|
||||
{
|
||||
std::swap(OnAssertFailed, fn);
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue