fontservices/textbase/sgdi/TextBasePanic.h
changeset 45 662fa7de7023
equal deleted inserted replaced
41:ea44a32a96bc 45:662fa7de7023
       
     1 // Copyright (c) 2007-2010 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 /**
       
    17  @internalComponent
       
    18 */
       
    19 
       
    20 #ifndef __TEXTBASEPANIC_H__
       
    21 #define __TEXTBASEPANIC_H__
       
    22 
       
    23 //#ifdef __GDI_H__
       
    24 void TextBasePanic(TTextBasePanic aPanicCode);
       
    25 void TextBasePanicWithCondAndInfo(TTextBasePanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine);
       
    26 //#endif 
       
    27 
       
    28 void TextBasePanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine);
       
    29 
       
    30 // helper macros
       
    31 #define TEXTBASE_ASSERT_FILENAME(f)	_LIT(KPanicFileName, f);
       
    32 #define TEXTBASE_ASSERT_PANICNAME(p)	_LIT(KPanicEnum ## p, # p);
       
    33 #define TEXTBASE_ASSERT_PANICCOMMAND(a)	_LIT(KPanicCommand, a);
       
    34 #define TEXTBASE_ASSERT_CONDITION(c)	_LIT(KPanicCondition, c);
       
    35 
       
    36 /* Use these macros for GDI Asserts & Panics with diagnostic logging:
       
    37    TEXTBASE_ASSERT_ALWAYS, TEXTBASE_ASSERT_ALWAYS_GENERAL, TEXTBASE_ASSERT_DEBUG
       
    38    and TEXTBASE_ASSERT_DEBUG_GENERAL
       
    39    Note that the "do { ... } while (0)" construction forces the invocation to have a ';'
       
    40    and makes the macro expansion safe in nested "if ... else ..." clauses that forget to use the
       
    41    { braces } in the Coding Standard.
       
    42  */
       
    43 
       
    44 #define TEXTBASE_ASSERT_ALWAYS(c, p) \
       
    45 		do  { \
       
    46 			if (!(c)) \
       
    47 				{ \
       
    48 				TEXTBASE_ASSERT_FILENAME(__FILE__); \
       
    49 				TEXTBASE_ASSERT_PANICNAME(p); \
       
    50 				TEXTBASE_ASSERT_CONDITION(#c); \
       
    51 				TextBasePanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
       
    52 				} \
       
    53 			} while (0)
       
    54 	
       
    55 #define TEXTBASE_ASSERT_ALWAYS_GENERAL(c, a) \
       
    56 		do  { \
       
    57 			if (!(c)) \
       
    58 				{ \
       
    59 				TEXTBASE_ASSERT_FILENAME(__FILE__); \
       
    60 				TEXTBASE_ASSERT_PANICCOMMAND(#a); \
       
    61 				TEXTBASE_ASSERT_CONDITION(#c); \
       
    62 				TextBasePanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
       
    63 				a ; \
       
    64 				} \
       
    65 			} while (0)
       
    66 
       
    67 #if defined(_DEBUG)
       
    68 #define TEXTBASE_ASSERT_DEBUG(c, p) \
       
    69 		do  { \
       
    70 			if (!(c)) \
       
    71 				{ \
       
    72 				TEXTBASE_ASSERT_FILENAME(__FILE__); \
       
    73 				TEXTBASE_ASSERT_PANICNAME(p); \
       
    74 				TEXTBASE_ASSERT_CONDITION(#c); \
       
    75 				TextBasePanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
       
    76 				} \
       
    77 			} while (0)
       
    78 
       
    79 #define TEXTBASE_ASSERT_DEBUG_GENERAL(c, a) \
       
    80 		do  { \
       
    81 			if (!(c)) \
       
    82 				{ \
       
    83 				TEXTBASE_ASSERT_FILENAME(__FILE__); \
       
    84 				TEXTBASE_ASSERT_PANICCOMMAND(#a); \
       
    85 				TEXTBASE_ASSERT_CONDITION(#c); \
       
    86 				TextBasePanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
       
    87 				a ; \
       
    88 				} \
       
    89 			} while (0)
       
    90 			
       
    91 #else
       
    92 #define TEXTBASE_ASSERT_DEBUG(c, p)
       
    93 #define TEXTBASE_ASSERT_DEBUG_GENERAL(c, p)
       
    94 
       
    95 #endif
       
    96 
       
    97 #endif