diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/Error.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/Error.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/Error.cpp b/src/3rdparty/angle/src/libANGLE/Error.cpp index fed1594972..388f0259fa 100644 --- a/src/3rdparty/angle/src/libANGLE/Error.cpp +++ b/src/3rdparty/angle/src/libANGLE/Error.cpp @@ -10,35 +10,38 @@ #include "libANGLE/Error.h" #include "common/angleutils.h" +#include "common/debug.h" +#include "common/utilities.h" #include <cstdarg> +namespace +{ +std::unique_ptr<std::string> EmplaceErrorString(std::string &&message) +{ + return message.empty() ? std::unique_ptr<std::string>() + : std::unique_ptr<std::string>(new std::string(std::move(message))); +} +} // anonymous namespace + namespace gl { -Error::Error(GLenum errorCode, const char *msg, ...) : mCode(errorCode), mID(errorCode) +Error::Error(GLenum errorCode, std::string &&message) + : mCode(errorCode), mID(errorCode), mMessage(EmplaceErrorString(std::move(message))) { - va_list vararg; - va_start(vararg, msg); - createMessageString(); - *mMessage = FormatString(msg, vararg); - va_end(vararg); } -Error::Error(GLenum errorCode, GLuint id, const char *msg, ...) : mCode(errorCode), mID(id) +Error::Error(GLenum errorCode, GLuint id, std::string &&message) + : mCode(errorCode), mID(id), mMessage(EmplaceErrorString(std::move(message))) { - va_list vararg; - va_start(vararg, msg); - createMessageString(); - *mMessage = FormatString(msg, vararg); - va_end(vararg); } void Error::createMessageString() const { if (!mMessage) { - mMessage.reset(new std::string); + mMessage.reset(new std::string(GetGenericErrorMessage(mCode))); } } @@ -64,34 +67,32 @@ bool Error::operator!=(const Error &other) const { return !(*this == other); } + +std::ostream &operator<<(std::ostream &os, const Error &err) +{ + return gl::FmtHexShort(os, err.getCode()); } +} // namespace gl + namespace egl { -Error::Error(EGLint errorCode, const char *msg, ...) : mCode(errorCode), mID(0) +Error::Error(EGLint errorCode, std::string &&message) + : mCode(errorCode), mID(errorCode), mMessage(EmplaceErrorString(std::move(message))) { - va_list vararg; - va_start(vararg, msg); - createMessageString(); - *mMessage = FormatString(msg, vararg); - va_end(vararg); } -Error::Error(EGLint errorCode, EGLint id, const char *msg, ...) : mCode(errorCode), mID(id) +Error::Error(EGLint errorCode, EGLint id, std::string &&message) + : mCode(errorCode), mID(id), mMessage(EmplaceErrorString(std::move(message))) { - va_list vararg; - va_start(vararg, msg); - createMessageString(); - *mMessage = FormatString(msg, vararg); - va_end(vararg); } void Error::createMessageString() const { if (!mMessage) { - mMessage.reset(new std::string); + mMessage.reset(new std::string(GetGenericErrorMessage(mCode))); } } @@ -101,4 +102,9 @@ const std::string &Error::getMessage() const return *mMessage; } +std::ostream &operator<<(std::ostream &os, const Error &err) +{ + return gl::FmtHexShort(os, err.getCode()); } + +} // namespace egl |