diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /src/3rdparty/angle/src/libANGLE/Error.cpp | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
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 |