mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove obsolete source files
This commit is contained in:
@@ -1,335 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Windows structured exception handling
|
|
||||||
//
|
|
||||||
#if BEAST_MSVC
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
namespace vf
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
class ScopedPlatformExceptionCatcher : public Uncopyable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScopedPlatformExceptionCatcher ()
|
|
||||||
{
|
|
||||||
//s_mutex.enter ();
|
|
||||||
|
|
||||||
if (++s_count == 1)
|
|
||||||
s_sehPrev = ::SetUnhandledExceptionFilter (sehFilter);
|
|
||||||
|
|
||||||
//s_mutex.exit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ScopedPlatformExceptionCatcher ()
|
|
||||||
{
|
|
||||||
//s_mutex.enter ();
|
|
||||||
|
|
||||||
if (--s_count == 0)
|
|
||||||
SetUnhandledExceptionFilter (s_sehPrev);
|
|
||||||
|
|
||||||
//s_mutex.exit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static LONG WINAPI sehFilter (_EXCEPTION_POINTERS* ei)
|
|
||||||
{
|
|
||||||
EXCEPTION_RECORD* er = ei->ExceptionRecord;
|
|
||||||
|
|
||||||
if (er->ExceptionCode == EXCEPTION_BREAKPOINT ||
|
|
||||||
er->ExceptionCode == EXCEPTION_SINGLE_STEP)
|
|
||||||
{
|
|
||||||
// pass through
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s;
|
|
||||||
|
|
||||||
switch (er->ExceptionCode)
|
|
||||||
{
|
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
|
||||||
s = TRANS ("an access violation occurred");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
|
||||||
s = TRANS ("array bounds were exceeded");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
|
||||||
s = TRANS ("memory access was unaligned");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
|
||||||
s = TRANS ("a floating point operation produced a denormal");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
|
||||||
s = TRANS ("a floating point divide by zero was attempted");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
|
||||||
s = TRANS ("the floating point operation was unrepresentable");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
|
||||||
s = TRANS ("the floating point operation was invalid");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_OVERFLOW:
|
|
||||||
s = TRANS ("the floating point operation overflowed");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_STACK_CHECK:
|
|
||||||
s = TRANS ("a stack check resulted from a floating point operation");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_FLT_UNDERFLOW:
|
|
||||||
s = TRANS ("the floating point operation underflowed");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
|
||||||
s = TRANS ("an invalid instruction was received");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_IN_PAGE_ERROR:
|
|
||||||
s = TRANS ("a virtual paging error occurred");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
|
||||||
s = TRANS ("an integer divide by zero was attempted");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_INT_OVERFLOW:
|
|
||||||
s = TRANS ("an integer operation overflowed");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_INVALID_DISPOSITION:
|
|
||||||
s = TRANS ("the exception handler returned an invalid disposition");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
|
||||||
s = TRANS ("a non-continuable exception occurred");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_PRIV_INSTRUCTION:
|
|
||||||
s = TRANS ("a privileged instruction was attempted");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCEPTION_STACK_OVERFLOW:
|
|
||||||
s = TRANS ("the stack overflowed");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
s = TRANS ("an unknown system exception of code ");
|
|
||||||
s << String ((unsigned int)er->ExceptionCode);
|
|
||||||
s << " " << TRANS ("occurred");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
beast_reportFatalError (s, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_sehPrev (ei);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static int s_count;
|
|
||||||
static CriticalSection s_mutex;
|
|
||||||
static LPTOP_LEVEL_EXCEPTION_FILTER s_sehPrev;
|
|
||||||
};
|
|
||||||
|
|
||||||
CriticalSection ScopedPlatformExceptionCatcher::s_mutex;
|
|
||||||
int ScopedPlatformExceptionCatcher::s_count = 0;
|
|
||||||
LPTOP_LEVEL_EXCEPTION_FILTER ScopedPlatformExceptionCatcher::s_sehPrev = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// TODO: POSIX SIGNAL HANDLER
|
|
||||||
|
|
||||||
#pragma message(BEAST_FILEANDLINE_ "Missing class ScopedPlatformExceptionCatcher")
|
|
||||||
|
|
||||||
namespace vf
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
class ScopedPlatformExceptionCatcher
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Missing
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
END_BEAST_NAMESPACE
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
bool CatchAny (Function <void (void)> f, bool returnFromException)
|
|
||||||
{
|
|
||||||
bool caughtException = true; // assume the worst
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//ScopedPlatformExceptionCatcher platformExceptionCatcher;
|
|
||||||
|
|
||||||
f ();
|
|
||||||
|
|
||||||
caughtException = false;
|
|
||||||
}
|
|
||||||
catch (std::exception& e)
|
|
||||||
{
|
|
||||||
if (!returnFromException)
|
|
||||||
{
|
|
||||||
JUCEApplication* app = JUCEApplication::getInstance ();
|
|
||||||
|
|
||||||
if (app)
|
|
||||||
{
|
|
||||||
app->unhandledException (&e, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << e.what ();
|
|
||||||
std::unexpected ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
if (!returnFromException)
|
|
||||||
{
|
|
||||||
JUCEApplication* app = JUCEApplication::getInstance ();
|
|
||||||
|
|
||||||
if (app)
|
|
||||||
{
|
|
||||||
app->unhandledException (0, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::unexpected ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return caughtException;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class ProtectedCall::DefaultHandler : public Handler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void onException (Exception const&) const
|
|
||||||
{
|
|
||||||
ScopedLockType lock (s_mutex);
|
|
||||||
fatal_error ("An unhandled exception was thrown");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef CriticalSection LockType;
|
|
||||||
typedef CriticalSection::ScopedLockType ScopedLockType;
|
|
||||||
|
|
||||||
static LockType s_mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
ProtectedCall::DefaultHandler::LockType ProtectedCall::DefaultHandler::s_mutex;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ProtectedCall::Handler const* ProtectedCall::s_handler;
|
|
||||||
|
|
||||||
void ProtectedCall::setHandler (Handler const& handler)
|
|
||||||
{
|
|
||||||
s_handler = &handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProtectedCall::call (Call& c)
|
|
||||||
{
|
|
||||||
static DefaultHandler defaultHandler;
|
|
||||||
|
|
||||||
Handler const* handler = s_handler;
|
|
||||||
|
|
||||||
if (handler == nullptr)
|
|
||||||
handler = &defaultHandler;
|
|
||||||
|
|
||||||
#if BEAST_CATCH_UNHANDLED_EXCEPTIONS
|
|
||||||
try
|
|
||||||
{
|
|
||||||
c ();
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
Exception e;
|
|
||||||
|
|
||||||
handler->onException (e);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
c ();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class ProtectedCallTests : public UnitTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProtectedCallTests () : UnitTest ("ProtectedCall", "beast", runManual)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void testThrow ()
|
|
||||||
{
|
|
||||||
throw std::runtime_error ("uncaught exception");
|
|
||||||
}
|
|
||||||
|
|
||||||
void runTest ()
|
|
||||||
{
|
|
||||||
beginTestCase ("throw");
|
|
||||||
|
|
||||||
ProtectedCall (&ProtectedCallTests::testThrow, this);
|
|
||||||
|
|
||||||
// If we get here then we failed
|
|
||||||
fail ();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static ProtectedCallTests protectedCallTests;
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_CORE_PROTECTEDCALL_H_INCLUDED
|
|
||||||
#define BEAST_CORE_PROTECTEDCALL_H_INCLUDED
|
|
||||||
|
|
||||||
/** Call a function in a protected exception context.
|
|
||||||
|
|
||||||
This is for intercepting unhandled exceptions, reporting on the extended
|
|
||||||
information provided by @ref Throw, and calling a customizable unhandled
|
|
||||||
exception callback. Some implementations will also catch native exceptions
|
|
||||||
such as memory violations or segmentation faults.
|
|
||||||
|
|
||||||
An unhandled exception should terminate the process with a non zero
|
|
||||||
return code.
|
|
||||||
|
|
||||||
To use this, construct an instance with your funtion and arguments as
|
|
||||||
parameters. For example:
|
|
||||||
|
|
||||||
@code
|
|
||||||
|
|
||||||
extern void funcThatMightThrow (int numberOfTimes);
|
|
||||||
|
|
||||||
ProtectedCall (&funcThatMightThrow, 3);
|
|
||||||
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
Every Beast Thread object's @ref Thread::run method is wrapped in a
|
|
||||||
@ProtectedCall
|
|
||||||
|
|
||||||
@see Thread, Throw
|
|
||||||
*/
|
|
||||||
class ProtectedCall
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct Exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
/** This receives the unhandled exception. */
|
|
||||||
struct Handler
|
|
||||||
{
|
|
||||||
/** Called when an uhandled exception is thrown.
|
|
||||||
|
|
||||||
@note This can be called from multiple threads, which is
|
|
||||||
why it is const.
|
|
||||||
*/
|
|
||||||
virtual void onException (Exception const& e) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** The default handler writes to std::cerr makes the process exit. */
|
|
||||||
class DefaultHandler;
|
|
||||||
|
|
||||||
static void setHandler (Handler const& handler);
|
|
||||||
|
|
||||||
public:
|
|
||||||
#if BEAST_VARIADIC_MAX >= 1
|
|
||||||
template <class Fn>
|
|
||||||
explicit ProtectedCall (Fn f)
|
|
||||||
{ callf (functional::bind (f)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 2
|
|
||||||
template <class Fn, class T1>
|
|
||||||
ProtectedCall (Fn f, T1 t1)
|
|
||||||
{ callf (functional::bind (f, t1)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 3
|
|
||||||
template <class Fn, class T1, class T2>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2)
|
|
||||||
{ callf (functional::bind (f, t1, t2)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 4
|
|
||||||
template <class Fn, class T1, class T2, class T3>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 5
|
|
||||||
template <class Fn, class T1, class T2, class T3, class T4>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3, T4 t4)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3, t4)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 6
|
|
||||||
template <class Fn, class T1, class T2, class T3, class T4, class T5>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3, t4, t5)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 7
|
|
||||||
template <class Fn, class T1, class T2, class T3, class T4, class T5, class T6>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3, t4, t5, t6)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 8
|
|
||||||
template <class Fn, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3, t4, t5, t6, t7)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BEAST_VARIADIC_MAX >= 9
|
|
||||||
template <class Fn, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
|
||||||
ProtectedCall (Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
|
|
||||||
{ callf (functional::bind (f, t1, t2, t3, t4, t5, t6, t7, t8)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef SharedFunction <void (void)> FunctionType;
|
|
||||||
typedef FunctionType::Call Call;
|
|
||||||
|
|
||||||
template <class Function>
|
|
||||||
void callf (Function f)
|
|
||||||
{
|
|
||||||
//CallType <Functor> wrapper (f);
|
|
||||||
FunctionType::CallType <Function> wrapper (
|
|
||||||
BEAST_MOVE_CAST(Function)(f));
|
|
||||||
|
|
||||||
call (wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
void call (Call& call);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static Handler const* s_handler;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user