Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 1384b8a5e..1582c6ac9
Browse files Browse the repository at this point in the history
1582c6ac9 further progress on implementing hdf5::lite (#631)
0622af1fe rename "11" exception classes to "Ex" (#630)

git-subtree-dir: externals/coda-oss
git-subtree-split: 1582c6ac9e9f26ee4dbaa7018e6c98ab92ca88ec
  • Loading branch information
Dan Smith authored and Dan Smith committed Dec 28, 2022
1 parent 1b45365 commit 9f17e18
Show file tree
Hide file tree
Showing 27 changed files with 2,649 additions and 2,415 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ if (${CMAKE_PROJECT_NAME} STREQUAL coda-oss)
# set warning level to /W3
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
add_compile_options(/std:c++14)
add_compile_options(/std:c++14)
elseif (UNIX)
add_compile_options(
-Wno-deprecated
-Wno-unused-value
-Wno-unused-but-set-variable
)
add_compile_options(-std=c++14)
add_compile_options(-std=c++14)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
3 changes: 1 addition & 2 deletions UnitTest/TestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ inline void assert_almost_eq(const std::string& testName, long double X1, long d
#undef TEST_EXCEPTION
#undef TEST_THROWS
#undef TEST_SPECIFIC_EXCEPTION
#define TEST_EXCEPTION(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } \
catch (const except::Throwable&){ TEST_ASSERT_TRUE(true); } catch (const except::Throwable11&){ TEST_ASSERT_TRUE(true); }
#define TEST_EXCEPTION(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } CODA_OSS_TEST_EXCEPTION_catch_
#define TEST_THROWS(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } catch (...){ TEST_ASSERT_TRUE(true); }
#define TEST_SPECIFIC_EXCEPTION(X, Y) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::ExpectException<Y>([&](){(X);})

38 changes: 21 additions & 17 deletions modules/c++/except/include/except/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@
/*!
* Useful macro for defining Exception classes
*/
#define DECLARE_EXTENDED_ERROR_(_Name, Error_, _Base, getType_specifiers) \
#define DECLARE_EXTENDED_ERROR_(_Name, Error_, _Base) \
struct _Name##Error_ : public _Base \
{ \
_Name##Error_() = default; virtual ~_Name##Error_() = default; \
_Name##Error_(const except::Context& c) : _Base(c){} \
_Name##Error_(const std::string& msg) : _Base(msg){} \
_Name##Error_(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \
_Name##Error_(const except::Throwable11& t, const except::Context& c) : _Base(t, c){} \
std::string getType() getType_specifiers { return #_Name; } \
_Name##Error_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \
std::string getType() const noexcept override { return #_Name; } \
};
#define DECLARE_EXTENDED_ERROR(_Name, _Base) \
DECLARE_EXTENDED_ERROR_(_Name, Error, _Base, const override)
#define DECLARE_EXTENDED_ERROR11(_Name, _Base) \
DECLARE_EXTENDED_ERROR_(_Name, Error11, _Base, const noexcept override)
#define DECLARE_EXTENDED_ERROR(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, Error, _Base)
#define DECLARE_EXTENDED_ERROREX(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, ErrorEx, _Base)

// Need to keep this around for existing code
#define DECLARE_ERROR(_Name) \
DECLARE_EXTENDED_ERROR(_Name, except::Error); \
DECLARE_EXTENDED_ERROR11(_Name, except::Error11)
DECLARE_EXTENDED_ERROREX(_Name, except::ErrorEx)

namespace except
{
Expand Down Expand Up @@ -99,7 +98,7 @@ struct Error : public Throwable
Throwable(t, c)
{
}
Error(const Throwable11& t, const Context& c) : Throwable(t, c)
Error(const ThrowableEx& t, const Context& c) : Throwable(t, c)
{
}

Expand All @@ -109,24 +108,28 @@ struct Error : public Throwable
}
};

struct Error11 : public Throwable11
// Use this in new code: name is FooErrror (not FooErrorEx), base is except::ErrorEx (not except::Error).
#define CODA_OSS_DECLARE_EXTENDED_ERROR(name_, base_) DECLARE_EXTENDED_ERROR_(name_, Error, base_)
#define CODA_OSS_DECLARE_ERROR(name_) CODA_OSS_DECLARE_EXTENDED_ERROR(name_, except::ErrorEx)

struct ErrorEx : public ThrowableEx
{
Error11() = default;
virtual ~Error11() = default;
ErrorEx() = default;
virtual ~ErrorEx() = default;

/*!
* Constructor. Takes a Context
* \param c The Context
*/
Error11(const Context& c) : Throwable11(c)
ErrorEx(const Context& c) : ThrowableEx(c)
{
}

/*!
* Constructor. Takes a message
* \param message The message
*/
Error11(const std::string& message) : Throwable11(message)
ErrorEx(const std::string& message) : ThrowableEx(message)
{
}

Expand All @@ -135,18 +138,19 @@ struct Error11 : public Throwable11
* \param t The Throwable
* \param c The Context
*/
Error11(const Throwable11& t, const Context& c) : Throwable11(t, c)
ErrorEx(const ThrowableEx& t, const Context& c) : ThrowableEx(t, c)
{
}
Error11(const Throwable& t, const Context& c) : Throwable11(t, c)
ErrorEx(const Throwable& t, const Context& c) : ThrowableEx(t, c)
{
}

std::string getType() const noexcept override
{
return "Error11";
return "ErrorEx";
}
};
using Error11 = ErrorEx; // keep old name around for other projects

/*!
* \class InvalidDerivedTypeError
Expand Down
39 changes: 22 additions & 17 deletions modules/c++/except/include/except/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#endif
#endif

#define DECLARE_EXTENDED_EXCEPTION_(_Name, Exception_, _Base, getType_specifiers) \
#define DECLARE_EXTENDED_EXCEPTION_(_Name, Exception_, _Base) \
struct _Name##Exception_ : public _Base \
{ \
_Name##Exception_() = default; virtual ~_Name##Exception_() = default; \
Expand All @@ -60,18 +60,17 @@
_Name##Exception_(const except::Context& c) : _Base(c){} \
_Name##Exception_(const std::string& msg) : _Base(msg){} \
_Name##Exception_(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \
_Name##Exception_(const except::Throwable11& t, const except::Context& c) : _Base(t, c){} \
_Name##Exception_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \
CODA_OSS_except_Exception_suppress_26447_BEGIN_ \
std::string getType() getType_specifiers { return #_Name #Exception_; } \
std::string getType() const noexcept override { return #_Name #Exception_; } \
CODA_OSS_except_Exception_suppress_26447_END_ };
#define DECLARE_EXTENDED_EXCEPTION(_Name, _Base) \
DECLARE_EXTENDED_EXCEPTION_(_Name, Exception, _Base, const override)
#define DECLARE_EXTENDED_EXCEPTION11(_Name, _Base) \
DECLARE_EXTENDED_EXCEPTION_(_Name, Exception11, _Base, const noexcept override)
#define DECLARE_EXTENDED_EXCEPTION(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, Exception, _Base)
#define DECLARE_EXTENDED_EXCEPTIONEX(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, ExceptionEx, _Base)

// Need to keep this around for existing code
#define DECLARE_EXCEPTION(_Name) \
DECLARE_EXTENDED_EXCEPTION(_Name, except::Exception) \
DECLARE_EXTENDED_EXCEPTION11(_Name, except::Exception11)
DECLARE_EXTENDED_EXCEPTIONEX(_Name, except::ExceptionEx)

namespace except
{
Expand Down Expand Up @@ -105,7 +104,7 @@ struct Exception : public Throwable
Throwable(t, c)
{
}
Exception(const Throwable11& t, const Context& c) : Throwable(t, c)
Exception(const ThrowableEx& t, const Context& c) : Throwable(t, c)
{
}

Expand All @@ -124,16 +123,21 @@ struct Exception : public Throwable
}
};

struct Exception11 : public Throwable11

// Use this in new code: name is FooException (not FooExceptionEx), base is except::ExceptionEx (not except::Exception).
#define CODA_OSS_DECLARE_EXTENDED_EXCEPTION(name_, base_) DECLARE_EXTENDED_EXCEPTION_(name_, Exception, base_)
#define CODA_OSS_DECLARE_EXCEPTION(name_) CODA_OSS_DECLARE_EXTENDED_EXCEPTION(name_, except::ExceptionEx)

struct ExceptionEx : public ThrowableEx
{
Exception11() = default;
virtual ~Exception11() = default;
ExceptionEx() = default;
virtual ~ExceptionEx() = default;

/*!
* Constructor. Takes a Context
* \param c The Context
*/
Exception11(const Context& c) : Throwable11(c)
ExceptionEx(const Context& c) : ThrowableEx(c)
{
}

Expand All @@ -142,26 +146,27 @@ struct Exception11 : public Throwable11
* \param t The Throwable
* \param c The Context
*/
Exception11(const Throwable11& t, const Context& c) : Throwable11(t, c)
ExceptionEx(const ThrowableEx& t, const Context& c) : ThrowableEx(t, c)
{
}
Exception11(const Throwable& t, const Context& c) : Throwable11(t, c)
ExceptionEx(const Throwable& t, const Context& c) : ThrowableEx(t, c)
{
}

/*!
* Constructor. Takes a message
* \param message The message
*/
Exception11(const std::string& message) : Throwable11(message)
ExceptionEx(const std::string& message) : ThrowableEx(message)
{
}

std::string getType() const noexcept override
{
return "Exception11";
return "ExceptionEx";
}
};
using Exception11 = ExceptionEx; // keep old name around for other projects

/*!
* \class IOException
Expand Down
Loading

0 comments on commit 9f17e18

Please sign in to comment.