gfx/skia/trunk/include/utils/win/SkHRESULT.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/win/SkHRESULT.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/*
     1.5 + * Copyright 2011 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkHRESULT_DEFINED
    1.12 +#define SkHRESULT_DEFINED
    1.13 +
    1.14 +#include "SkTypes.h"
    1.15 +
    1.16 +void SkTraceHR(const char* file, unsigned long line,
    1.17 +               HRESULT hr, const char* msg);
    1.18 +
    1.19 +#ifdef SK_DEBUG
    1.20 +#define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg)
    1.21 +#else
    1.22 +#define SK_TRACEHR(_hr, _msg) _hr
    1.23 +#endif
    1.24 +
    1.25 +#define HR_GENERAL(_ex, _msg, _ret) {\
    1.26 +    HRESULT _hr = _ex;\
    1.27 +    if (FAILED(_hr)) {\
    1.28 +        SK_TRACEHR(_hr, _msg);\
    1.29 +        return _ret;\
    1.30 +    }\
    1.31 +}
    1.32 +
    1.33 +//@{
    1.34 +/**
    1.35 +These macros are for reporting HRESULT errors.
    1.36 +The expression will be evaluated.
    1.37 +If the resulting HRESULT SUCCEEDED then execution will continue normally.
    1.38 +If the HRESULT FAILED then the macro will return from the current function.
    1.39 +In variants ending with 'M' the given message will be traced when FAILED.
    1.40 +The HR variants will return the HRESULT when FAILED.
    1.41 +The HRB variants will return false when FAILED.
    1.42 +The HRN variants will return NULL when FAILED.
    1.43 +The HRV variants will simply return when FAILED.
    1.44 +The HRZ variants will return 0 when FAILED.
    1.45 +*/
    1.46 +#define HR(ex) HR_GENERAL(ex, NULL, _hr)
    1.47 +#define HRM(ex, msg) HR_GENERAL(ex, msg, _hr)
    1.48 +
    1.49 +#define HRB(ex) HR_GENERAL(ex, NULL, false)
    1.50 +#define HRBM(ex, msg) HR_GENERAL(ex, msg, false)
    1.51 +
    1.52 +#define HRN(ex) HR_GENERAL(ex, NULL, NULL)
    1.53 +#define HRNM(ex, msg) HR_GENERAL(ex, msg, NULL)
    1.54 +
    1.55 +#define HRV(ex) HR_GENERAL(ex, NULL, )
    1.56 +#define HRVM(ex, msg) HR_GENERAL(ex, msg, )
    1.57 +
    1.58 +#define HRZ(ex) HR_GENERAL(ex, NULL, 0)
    1.59 +#define HRZM(ex, msg) HR_GENERAL(ex, msg, 0)
    1.60 +//@}
    1.61 +#endif

mercurial