2011-10-10 13:19:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkHRESULT_DEFINED
|
|
|
|
#define SkHRESULT_DEFINED
|
|
|
|
|
|
|
|
#include "SkTypes.h"
|
2015-12-01 17:02:49 +00:00
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
2011-10-10 13:19:10 +00:00
|
|
|
|
|
|
|
void SkTraceHR(const char* file, unsigned long line,
|
|
|
|
HRESULT hr, const char* msg);
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
#define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg)
|
|
|
|
#else
|
2015-12-07 18:41:36 +00:00
|
|
|
#define SK_TRACEHR(_hr, _msg) sk_ignore_unused_variable(_hr)
|
2011-10-10 13:19:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define HR_GENERAL(_ex, _msg, _ret) {\
|
|
|
|
HRESULT _hr = _ex;\
|
|
|
|
if (FAILED(_hr)) {\
|
|
|
|
SK_TRACEHR(_hr, _msg);\
|
|
|
|
return _ret;\
|
|
|
|
}\
|
|
|
|
}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
These macros are for reporting HRESULT errors.
|
|
|
|
The expression will be evaluated.
|
|
|
|
If the resulting HRESULT SUCCEEDED then execution will continue normally.
|
|
|
|
If the HRESULT FAILED then the macro will return from the current function.
|
|
|
|
In variants ending with 'M' the given message will be traced when FAILED.
|
|
|
|
The HR variants will return the HRESULT when FAILED.
|
|
|
|
The HRB variants will return false when FAILED.
|
2012-08-16 16:13:40 +00:00
|
|
|
The HRN variants will return NULL when FAILED.
|
2011-10-10 13:19:10 +00:00
|
|
|
The HRV variants will simply return when FAILED.
|
2013-10-08 21:32:15 +00:00
|
|
|
The HRZ variants will return 0 when FAILED.
|
2011-10-10 13:19:10 +00:00
|
|
|
*/
|
|
|
|
#define HR(ex) HR_GENERAL(ex, NULL, _hr)
|
|
|
|
#define HRM(ex, msg) HR_GENERAL(ex, msg, _hr)
|
|
|
|
|
|
|
|
#define HRB(ex) HR_GENERAL(ex, NULL, false)
|
|
|
|
#define HRBM(ex, msg) HR_GENERAL(ex, msg, false)
|
|
|
|
|
2012-08-16 16:13:40 +00:00
|
|
|
#define HRN(ex) HR_GENERAL(ex, NULL, NULL)
|
|
|
|
#define HRNM(ex, msg) HR_GENERAL(ex, msg, NULL)
|
|
|
|
|
2011-10-10 13:19:10 +00:00
|
|
|
#define HRV(ex) HR_GENERAL(ex, NULL, )
|
|
|
|
#define HRVM(ex, msg) HR_GENERAL(ex, msg, )
|
2013-10-08 21:32:15 +00:00
|
|
|
|
|
|
|
#define HRZ(ex) HR_GENERAL(ex, NULL, 0)
|
|
|
|
#define HRZM(ex, msg) HR_GENERAL(ex, msg, 0)
|
2011-10-10 13:19:10 +00:00
|
|
|
//@}
|
2015-12-01 17:02:49 +00:00
|
|
|
#endif // SK_BUILD_FOR_WIN
|
|
|
|
#endif // SkHRESULT_DEFINED
|