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