sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@internalComponent
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
#ifndef __BITPANIC_H__
|
sl@0
|
21 |
#define __BITPANIC_H__
|
sl@0
|
22 |
|
sl@0
|
23 |
#ifdef __GDI_H__
|
sl@0
|
24 |
void Panic(TGdiPanic aPanicCode);
|
sl@0
|
25 |
void PanicWithCondAndInfo(TGdiPanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine);
|
sl@0
|
26 |
#endif
|
sl@0
|
27 |
|
sl@0
|
28 |
void PanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine);
|
sl@0
|
29 |
|
sl@0
|
30 |
// helper macros
|
sl@0
|
31 |
#define GDI_ASSERT_FILENAME(f) _LIT(KPanicFileName, f);
|
sl@0
|
32 |
#define GDI_ASSERT_PANICNAME(p) _LIT(KPanicEnum ## p, # p);
|
sl@0
|
33 |
#define GDI_ASSERT_PANICCOMMAND(a) _LIT(KPanicCommand, a);
|
sl@0
|
34 |
#define GDI_ASSERT_CONDITION(c) _LIT(KPanicCondition, c);
|
sl@0
|
35 |
|
sl@0
|
36 |
/* Use these macros for GDI Asserts & Panics with diagnostic logging:
|
sl@0
|
37 |
GDI_ASSERT_ALWAYS, GDI_ASSERT_ALWAYS_GENERAL, GDI_ASSERT_DEBUG
|
sl@0
|
38 |
and GDI_ASSERT_DEBUG_GENERAL
|
sl@0
|
39 |
Note that the "do { ... } while (0)" construction forces the invocation to have a ';'
|
sl@0
|
40 |
and makes the macro expansion safe in nested "if ... else ..." clauses that forget to use the
|
sl@0
|
41 |
{ braces } in the Coding Standard.
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
|
sl@0
|
44 |
#define GDI_ASSERT_ALWAYS(c, p) \
|
sl@0
|
45 |
do { \
|
sl@0
|
46 |
if (!(c)) \
|
sl@0
|
47 |
{ \
|
sl@0
|
48 |
GDI_ASSERT_FILENAME(__FILE__); \
|
sl@0
|
49 |
GDI_ASSERT_PANICNAME(p); \
|
sl@0
|
50 |
GDI_ASSERT_CONDITION(#c); \
|
sl@0
|
51 |
PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
|
sl@0
|
52 |
} \
|
sl@0
|
53 |
} while (0)
|
sl@0
|
54 |
|
sl@0
|
55 |
#define GDI_ASSERT_ALWAYS_GENERAL(c, a) \
|
sl@0
|
56 |
do { \
|
sl@0
|
57 |
if (!(c)) \
|
sl@0
|
58 |
{ \
|
sl@0
|
59 |
GDI_ASSERT_FILENAME(__FILE__); \
|
sl@0
|
60 |
GDI_ASSERT_PANICCOMMAND(#a); \
|
sl@0
|
61 |
GDI_ASSERT_CONDITION(#c); \
|
sl@0
|
62 |
PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
|
sl@0
|
63 |
a ; \
|
sl@0
|
64 |
} \
|
sl@0
|
65 |
} while (0)
|
sl@0
|
66 |
|
sl@0
|
67 |
#if defined(_DEBUG)
|
sl@0
|
68 |
#define GDI_ASSERT_DEBUG(c, p) \
|
sl@0
|
69 |
do { \
|
sl@0
|
70 |
if (!(c)) \
|
sl@0
|
71 |
{ \
|
sl@0
|
72 |
GDI_ASSERT_FILENAME(__FILE__); \
|
sl@0
|
73 |
GDI_ASSERT_PANICNAME(p); \
|
sl@0
|
74 |
GDI_ASSERT_CONDITION(#c); \
|
sl@0
|
75 |
PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \
|
sl@0
|
76 |
} \
|
sl@0
|
77 |
} while (0)
|
sl@0
|
78 |
|
sl@0
|
79 |
#define GDI_ASSERT_DEBUG_GENERAL(c, a) \
|
sl@0
|
80 |
do { \
|
sl@0
|
81 |
if (!(c)) \
|
sl@0
|
82 |
{ \
|
sl@0
|
83 |
GDI_ASSERT_FILENAME(__FILE__); \
|
sl@0
|
84 |
GDI_ASSERT_PANICCOMMAND(#a); \
|
sl@0
|
85 |
GDI_ASSERT_CONDITION(#c); \
|
sl@0
|
86 |
PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \
|
sl@0
|
87 |
a ; \
|
sl@0
|
88 |
} \
|
sl@0
|
89 |
} while (0)
|
sl@0
|
90 |
|
sl@0
|
91 |
#else
|
sl@0
|
92 |
#define GDI_ASSERT_DEBUG(c, p)
|
sl@0
|
93 |
#define GDI_ASSERT_DEBUG_GENERAL(c, p)
|
sl@0
|
94 |
|
sl@0
|
95 |
#endif
|
sl@0
|
96 |
|
sl@0
|
97 |
#endif
|