| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkHRESULT_DEFINED | 8 #ifndef SkHRESULT_DEFINED |
| 9 #define SkHRESULT_DEFINED | 9 #define SkHRESULT_DEFINED |
| 10 | 10 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #ifdef SK_BUILD_FOR_WIN | 12 #ifdef SK_BUILD_FOR_WIN |
| 13 | 13 |
| 14 #include "../../private/SkLeanWindows.h" | 14 #include "SkLeanWindows.h" |
| 15 | 15 |
| 16 void SkTraceHR(const char* file, unsigned long line, | 16 void SkTraceHR(const char* file, unsigned long line, |
| 17 HRESULT hr, const char* msg); | 17 HRESULT hr, const char* msg); |
| 18 | 18 |
| 19 #ifdef SK_DEBUG | 19 #ifdef SK_DEBUG |
| 20 #define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg) | 20 #define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg) |
| 21 #else | 21 #else |
| 22 #define SK_TRACEHR(_hr, _msg) sk_ignore_unused_variable(_hr) | 22 #define SK_TRACEHR(_hr, _msg) sk_ignore_unused_variable(_hr) |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #define HR_GENERAL(_ex, _msg, _ret) {\ | 25 #define HR_GENERAL(_ex, _msg, _ret) {\ |
| 26 HRESULT _hr = _ex;\ | 26 HRESULT _hr = _ex;\ |
| 27 if (FAILED(_hr)) {\ | 27 if (FAILED(_hr)) {\ |
| 28 SK_TRACEHR(_hr, _msg);\ | 28 SK_TRACEHR(_hr, _msg);\ |
| 29 return _ret;\ | 29 return _ret;\ |
| 30 }\ | 30 }\ |
| 31 } | 31 } |
| 32 | 32 |
| 33 //@{ | 33 //@{ |
| 34 /** | 34 /** |
| 35 These macros are for reporting HRESULT errors. | 35 These macros are for reporting HRESULT errors. |
| 36 The expression will be evaluated. | 36 The expression will be evaluated. |
| 37 If the resulting HRESULT SUCCEEDED then execution will continue normally. | 37 If the resulting HRESULT SUCCEEDED then execution will continue normally. |
| 38 If the HRESULT FAILED then the macro will return from the current function. | 38 If the HRESULT FAILED then the macro will return from the current function. |
| 39 In variants ending with 'M' the given message will be traced when FAILED. | 39 In variants ending with 'M' the given message will be traced when FAILED. |
| 40 The HR variants will return the HRESULT when FAILED. | 40 The HR variants will return the HRESULT when FAILED. |
| 41 The HRB variants will return false when FAILED. | 41 The HRB variants will return false when FAILED. |
| 42 The HRN variants will return NULL when FAILED. | 42 The HRN variants will return nullptr when FAILED. |
| 43 The HRV variants will simply return when FAILED. | 43 The HRV variants will simply return when FAILED. |
| 44 The HRZ variants will return 0 when FAILED. | 44 The HRZ variants will return 0 when FAILED. |
| 45 */ | 45 */ |
| 46 #define HR(ex) HR_GENERAL(ex, NULL, _hr) | 46 #define HR(ex) HR_GENERAL(ex, nullptr, _hr) |
| 47 #define HRM(ex, msg) HR_GENERAL(ex, msg, _hr) | 47 #define HRM(ex, msg) HR_GENERAL(ex, msg, _hr) |
| 48 | 48 |
| 49 #define HRB(ex) HR_GENERAL(ex, NULL, false) | 49 #define HRB(ex) HR_GENERAL(ex, nullptr, false) |
| 50 #define HRBM(ex, msg) HR_GENERAL(ex, msg, false) | 50 #define HRBM(ex, msg) HR_GENERAL(ex, msg, false) |
| 51 | 51 |
| 52 #define HRN(ex) HR_GENERAL(ex, NULL, NULL) | 52 #define HRN(ex) HR_GENERAL(ex, nullptr, nullptr) |
| 53 #define HRNM(ex, msg) HR_GENERAL(ex, msg, NULL) | 53 #define HRNM(ex, msg) HR_GENERAL(ex, msg, nullptr) |
| 54 | 54 |
| 55 #define HRV(ex) HR_GENERAL(ex, NULL, ) | 55 #define HRV(ex) HR_GENERAL(ex, nullptr, ) |
| 56 #define HRVM(ex, msg) HR_GENERAL(ex, msg, ) | 56 #define HRVM(ex, msg) HR_GENERAL(ex, msg, ) |
| 57 | 57 |
| 58 #define HRZ(ex) HR_GENERAL(ex, NULL, 0) | 58 #define HRZ(ex) HR_GENERAL(ex, nullptr, 0) |
| 59 #define HRZM(ex, msg) HR_GENERAL(ex, msg, 0) | 59 #define HRZM(ex, msg) HR_GENERAL(ex, msg, 0) |
| 60 //@} | 60 //@} |
| 61 #endif // SK_BUILD_FOR_WIN | 61 #endif // SK_BUILD_FOR_WIN |
| 62 #endif // SkHRESULT_DEFINED | 62 #endif // SkHRESULT_DEFINED |
| OLD | NEW |