os/graphics/graphicsdeviceinterface/gdi/sgdi/GDIPANIC.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/gdi/sgdi/GDIPANIC.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,97 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @internalComponent
    1.21 +*/
    1.22 +
    1.23 +#ifndef __BITPANIC_H__
    1.24 +#define __BITPANIC_H__
    1.25 +
    1.26 +#ifdef __GDI_H__
    1.27 +void Panic(TGdiPanic aPanicCode);
    1.28 +void PanicWithCondAndInfo(TGdiPanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine);
    1.29 +#endif 
    1.30 +
    1.31 +void PanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine);
    1.32 +
    1.33 +// helper macros
    1.34 +#define GDI_ASSERT_FILENAME(f)	_LIT(KPanicFileName, f);
    1.35 +#define GDI_ASSERT_PANICNAME(p)	_LIT(KPanicEnum ## p, # p);
    1.36 +#define GDI_ASSERT_PANICCOMMAND(a)	_LIT(KPanicCommand, a);
    1.37 +#define GDI_ASSERT_CONDITION(c)	_LIT(KPanicCondition, c);
    1.38 +
    1.39 +/* Use these macros for GDI Asserts & Panics with diagnostic logging:
    1.40 +   GDI_ASSERT_ALWAYS, GDI_ASSERT_ALWAYS_GENERAL, GDI_ASSERT_DEBUG
    1.41 +   and GDI_ASSERT_DEBUG_GENERAL
    1.42 +   Note that the "do { ... } while (0)" construction forces the invocation to have a ';'
    1.43 +   and makes the macro expansion safe in nested "if ... else ..." clauses that forget to use the
    1.44 +   { braces } in the Coding Standard.
    1.45 + */
    1.46 + 
    1.47 +#define GDI_ASSERT_ALWAYS(c, p) \
    1.48 +		do  { \
    1.49 +			if (!(c)) \
    1.50 +				{ \
    1.51 +				GDI_ASSERT_FILENAME(__FILE__); \
    1.52 +				GDI_ASSERT_PANICNAME(p); \
    1.53 +				GDI_ASSERT_CONDITION(#c); \
    1.54 +				PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
    1.55 +				} \
    1.56 +			} while (0)
    1.57 +	
    1.58 +#define GDI_ASSERT_ALWAYS_GENERAL(c, a) \
    1.59 +		do  { \
    1.60 +			if (!(c)) \
    1.61 +				{ \
    1.62 +				GDI_ASSERT_FILENAME(__FILE__); \
    1.63 +				GDI_ASSERT_PANICCOMMAND(#a); \
    1.64 +				GDI_ASSERT_CONDITION(#c); \
    1.65 +				PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
    1.66 +				a ; \
    1.67 +				} \
    1.68 +			} while (0)
    1.69 +
    1.70 +#if defined(_DEBUG)
    1.71 +#define GDI_ASSERT_DEBUG(c, p) \
    1.72 +		do  { \
    1.73 +			if (!(c)) \
    1.74 +				{ \
    1.75 +				GDI_ASSERT_FILENAME(__FILE__); \
    1.76 +				GDI_ASSERT_PANICNAME(p); \
    1.77 +				GDI_ASSERT_CONDITION(#c); \
    1.78 +				PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
    1.79 +				} \
    1.80 +			} while (0)
    1.81 +
    1.82 +#define GDI_ASSERT_DEBUG_GENERAL(c, a) \
    1.83 +		do  { \
    1.84 +			if (!(c)) \
    1.85 +				{ \
    1.86 +				GDI_ASSERT_FILENAME(__FILE__); \
    1.87 +				GDI_ASSERT_PANICCOMMAND(#a); \
    1.88 +				GDI_ASSERT_CONDITION(#c); \
    1.89 +				PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
    1.90 +				a ; \
    1.91 +				} \
    1.92 +			} while (0)
    1.93 +			
    1.94 +#else
    1.95 +#define GDI_ASSERT_DEBUG(c, p)
    1.96 +#define GDI_ASSERT_DEBUG_GENERAL(c, p)
    1.97 +
    1.98 +#endif
    1.99 +
   1.100 +#endif