os/graphics/graphicsdeviceinterface/bitgdi/inc/BITPANIC.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __BITPANIC_H__
    17 #define __BITPANIC_H__
    18 
    19 #include <e32cmn.h>
    20 /**
    21 @internalTechnology
    22 */
    23 enum TBitgdiPanic
    24 	{
    25 	EBitgdiPanicNoDevicePresent=1,
    26 	EBitgdiPanicNoFBSConnection,
    27 	EBitgdiPanicNoFontSelected,
    28 	EBitgdiPanicNoSpriteSet,
    29 	EBitgdiPanicInvalidScreenDeviceLibrary,
    30 	EBitgdiPanicInvalidParameter,
    31 	EBitgdiPanicInvalidColor,
    32 	EBitgdiPanicInvalidDrawMode,
    33 	EBitgdiPanicInvalidDisplayMode,
    34 	EBitgdiPanicInvalidRegion,
    35 	EBitgdiPanicInvalidWindowHandle,
    36 	EBitgdiPanicInvalidFont,
    37 	EBitgdiPanicInvalidBitmap,
    38 	EBitgdiPanicOutOfBounds,
    39 	EBitgdiPanicReadOnly,
    40 	EBitgdiPanicPolygonFiller,
    41 	EBitgdiPanicZeroLength,
    42 	EBitgdiPanicNullPointer,
    43 	EBitgdiPanicInvalidPointer,
    44 	EBitgdiPanicCharacterTooBig,
    45 	EBitgdiPanicInvalidHalValue,
    46 	EBitgdiPanicInvalidArg,
    47 	EBitgdiPanicNegativeShift,
    48 	EBitgdiPanicInvalidInterfaceHandle,		//This panic may occur if MOutlineAndShadowBlend interface is not implemented.
    49 	EBitgdiPanicInvalidBrushStyle,
    50 	};
    51 
    52 /**
    53 @internalComponent
    54 */
    55 void Panic(TBitgdiPanic aPanicCode);
    56 void PanicWithInfo(TBitgdiPanic aPanic, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine);
    57 void PanicWithCondAndInfo(TBitgdiPanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine);
    58 void InvariantWithCondAndInfo(const TDesC& aCondition, const TDesC& aFileName, TInt aLine);
    59 
    60 // helper macros
    61 #define BG_ASSERT_FILENAME(f)	_LIT(KPanicFileName, f);
    62 #define BG_ASSERT_PANICNAME(p)	_LIT(KPanicEnum ## p, # p);
    63 #define BG_ASSERT_CONDITION(c)	_LIT(KPanicCondition, c);
    64 
    65 /* Use these macros for BitGdi server Asserts & Panics with diagnostic logging:
    66    BG_ASSERT_ALWAYS, BG_PANIC_ALWAYS, BG_ASSERT_DEBUG, BG_PANIC_DEBUG
    67    BG_ASSERT_ALWAYS_INVARIANT and BG_ASSERT_DEBUG_INVARIANT
    68    Note that the "do { ... } while (0)" construction forces the invocation to have a ';'
    69    and makes the macro expansion safe in nested "if ... else ..." clauses that forget to use the
    70    { braces } in the Coding Standard.
    71  */
    72  
    73 #define BG_ASSERT_ALWAYS(c, p) \
    74 		do  { \
    75 			if (!(c)) \
    76 				{ \
    77 				BG_ASSERT_FILENAME(__FILE__); \
    78 				BG_ASSERT_PANICNAME(p); \
    79 				BG_ASSERT_CONDITION(#c); \
    80 				PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
    81 				} \
    82 			} while (EFalse)
    83 
    84 #define BG_PANIC_ALWAYS(p) \
    85 		do  { \
    86 			BG_ASSERT_FILENAME(__FILE__); \
    87 			BG_ASSERT_PANICNAME(p); \
    88 			PanicWithInfo(p, KPanicFileName, KPanicEnum ## p, __LINE__); \
    89 			} while (EFalse)
    90 			
    91 #define BG_ASSERT_ALWAYS_INVARIANT(c) \
    92 		do  { \
    93 			if (!(c)) \
    94 				{ \
    95 				BG_ASSERT_FILENAME(__FILE__); \
    96 				BG_ASSERT_CONDITION(#c); \
    97 				InvariantWithCondAndInfo(KPanicCondition, KPanicFileName, __LINE__); \
    98 				} \
    99 			} while (EFalse)
   100 
   101 #if defined(_DEBUG)
   102 #define BG_ASSERT_DEBUG(c, p) \
   103 		do  { \
   104 			if (!(c)) \
   105 				{ \
   106 				BG_ASSERT_FILENAME(__FILE__); \
   107 				BG_ASSERT_PANICNAME(p); \
   108 				BG_ASSERT_CONDITION(#c); \
   109 				PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
   110 				} \
   111 			} while (EFalse)
   112 
   113 #define BG_PANIC_DEBUG(p) \
   114 		do  { \
   115 			BG_ASSERT_FILENAME(__FILE__); \
   116 			BG_ASSERT_PANICNAME(p); \
   117 			PanicWithInfo(p, KPanicFileName, KPanicEnum ## p, __LINE__); \
   118 			} while (EFalse)
   119 			
   120 #define BG_ASSERT_DEBUG_INVARIANT(c) \
   121 		do  { \
   122 			if (!(c)) \
   123 				{ \
   124 				BG_ASSERT_FILENAME(__FILE__); \
   125 				BG_ASSERT_CONDITION(#c); \
   126 				InvariantWithCondAndInfo(KPanicCondition, KPanicFileName, __LINE__); \
   127 				} \
   128 			} while (EFalse)
   129 			
   130 #else
   131 #define BG_ASSERT_DEBUG(c, p)
   132 #define BG_PANIC_DEBUG(p)
   133 #define BG_ASSERT_DEBUG_INVARIANT(c)
   134 #endif
   135 
   136 /**
   137 Required to ensure BC between NGage and 7.0S platforms.  
   138 Functions are exported at ordinal corresponding to where NGage platform
   139 has extended this library and must not be moved.
   140 @since 7.0S
   141 @internalComponent
   142 */
   143 IMPORT_C void DummyReserved1();
   144 IMPORT_C void DummyReserved2();
   145 IMPORT_C void DummyReserved3();
   146 IMPORT_C void DummyReserved4();
   147 IMPORT_C void DummyReserved5();
   148 IMPORT_C void DummyReserved6();
   149 IMPORT_C void DummyReserved7();
   150 IMPORT_C void DummyReserved8();
   151 IMPORT_C void DummyReserved9();
   152 IMPORT_C void DummyReserved10();
   153 
   154 #endif
   155