sl@0: // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __TEXTBASEPANIC_H__ sl@0: #define __TEXTBASEPANIC_H__ sl@0: sl@0: //#ifdef __GDI_H__ sl@0: void TextBasePanic(TTextBasePanic aPanicCode); sl@0: void TextBasePanicWithCondAndInfo(TTextBasePanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine); sl@0: //#endif sl@0: sl@0: void TextBasePanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine); sl@0: sl@0: // helper macros sl@0: #define TEXTBASE_ASSERT_FILENAME(f) _LIT(KPanicFileName, f); sl@0: #define TEXTBASE_ASSERT_PANICNAME(p) _LIT(KPanicEnum ## p, # p); sl@0: #define TEXTBASE_ASSERT_PANICCOMMAND(a) _LIT(KPanicCommand, a); sl@0: #define TEXTBASE_ASSERT_CONDITION(c) _LIT(KPanicCondition, c); sl@0: sl@0: /* Use these macros for GDI Asserts & Panics with diagnostic logging: sl@0: TEXTBASE_ASSERT_ALWAYS, TEXTBASE_ASSERT_ALWAYS_GENERAL, TEXTBASE_ASSERT_DEBUG sl@0: and TEXTBASE_ASSERT_DEBUG_GENERAL sl@0: Note that the "do { ... } while (0)" construction forces the invocation to have a ';' sl@0: and makes the macro expansion safe in nested "if ... else ..." clauses that forget to use the sl@0: { braces } in the Coding Standard. sl@0: */ sl@0: sl@0: #define TEXTBASE_ASSERT_ALWAYS(c, p) \ sl@0: do { \ sl@0: if (!(c)) \ sl@0: { \ sl@0: TEXTBASE_ASSERT_FILENAME(__FILE__); \ sl@0: TEXTBASE_ASSERT_PANICNAME(p); \ sl@0: TEXTBASE_ASSERT_CONDITION(#c); \ sl@0: TextBasePanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TEXTBASE_ASSERT_ALWAYS_GENERAL(c, a) \ sl@0: do { \ sl@0: if (!(c)) \ sl@0: { \ sl@0: TEXTBASE_ASSERT_FILENAME(__FILE__); \ sl@0: TEXTBASE_ASSERT_PANICCOMMAND(#a); \ sl@0: TEXTBASE_ASSERT_CONDITION(#c); \ sl@0: TextBasePanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \ sl@0: a ; \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #if defined(_DEBUG) sl@0: #define TEXTBASE_ASSERT_DEBUG(c, p) \ sl@0: do { \ sl@0: if (!(c)) \ sl@0: { \ sl@0: TEXTBASE_ASSERT_FILENAME(__FILE__); \ sl@0: TEXTBASE_ASSERT_PANICNAME(p); \ sl@0: TEXTBASE_ASSERT_CONDITION(#c); \ sl@0: TextBasePanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TEXTBASE_ASSERT_DEBUG_GENERAL(c, a) \ sl@0: do { \ sl@0: if (!(c)) \ sl@0: { \ sl@0: TEXTBASE_ASSERT_FILENAME(__FILE__); \ sl@0: TEXTBASE_ASSERT_PANICCOMMAND(#a); \ sl@0: TEXTBASE_ASSERT_CONDITION(#c); \ sl@0: TextBasePanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \ sl@0: a ; \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #else sl@0: #define TEXTBASE_ASSERT_DEBUG(c, p) sl@0: #define TEXTBASE_ASSERT_DEBUG_GENERAL(c, p) sl@0: sl@0: #endif sl@0: sl@0: #endif