|
1 // Copyright (c) 2007-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 /** |
|
17 @internalComponent |
|
18 */ |
|
19 |
|
20 #ifndef __BITPANIC_H__ |
|
21 #define __BITPANIC_H__ |
|
22 |
|
23 #ifdef __GDI_H__ |
|
24 void Panic(TGdiPanic aPanicCode); |
|
25 void PanicWithCondAndInfo(TGdiPanic aPanic, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine); |
|
26 #endif |
|
27 |
|
28 void PanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine); |
|
29 |
|
30 // helper macros |
|
31 #define GDI_ASSERT_FILENAME(f) _LIT(KPanicFileName, f); |
|
32 #define GDI_ASSERT_PANICNAME(p) _LIT(KPanicEnum ## p, # p); |
|
33 #define GDI_ASSERT_PANICCOMMAND(a) _LIT(KPanicCommand, a); |
|
34 #define GDI_ASSERT_CONDITION(c) _LIT(KPanicCondition, c); |
|
35 |
|
36 /* Use these macros for GDI Asserts & Panics with diagnostic logging: |
|
37 GDI_ASSERT_ALWAYS, GDI_ASSERT_ALWAYS_GENERAL, GDI_ASSERT_DEBUG |
|
38 and GDI_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 GDI_ASSERT_ALWAYS(c, p) \ |
|
45 do { \ |
|
46 if (!(c)) \ |
|
47 { \ |
|
48 GDI_ASSERT_FILENAME(__FILE__); \ |
|
49 GDI_ASSERT_PANICNAME(p); \ |
|
50 GDI_ASSERT_CONDITION(#c); \ |
|
51 PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \ |
|
52 } \ |
|
53 } while (0) |
|
54 |
|
55 #define GDI_ASSERT_ALWAYS_GENERAL(c, a) \ |
|
56 do { \ |
|
57 if (!(c)) \ |
|
58 { \ |
|
59 GDI_ASSERT_FILENAME(__FILE__); \ |
|
60 GDI_ASSERT_PANICCOMMAND(#a); \ |
|
61 GDI_ASSERT_CONDITION(#c); \ |
|
62 PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \ |
|
63 a ; \ |
|
64 } \ |
|
65 } while (0) |
|
66 |
|
67 #if defined(_DEBUG) |
|
68 #define GDI_ASSERT_DEBUG(c, p) \ |
|
69 do { \ |
|
70 if (!(c)) \ |
|
71 { \ |
|
72 GDI_ASSERT_FILENAME(__FILE__); \ |
|
73 GDI_ASSERT_PANICNAME(p); \ |
|
74 GDI_ASSERT_CONDITION(#c); \ |
|
75 PanicWithCondAndInfo(p, KPanicCondition, KPanicFileName, KPanicEnum ## p, __LINE__); \ |
|
76 } \ |
|
77 } while (0) |
|
78 |
|
79 #define GDI_ASSERT_DEBUG_GENERAL(c, a) \ |
|
80 do { \ |
|
81 if (!(c)) \ |
|
82 { \ |
|
83 GDI_ASSERT_FILENAME(__FILE__); \ |
|
84 GDI_ASSERT_PANICCOMMAND(#a); \ |
|
85 GDI_ASSERT_CONDITION(#c); \ |
|
86 PanicLogWithInfo(KPanicCondition, KPanicCommand, KPanicFileName, __LINE__); \ |
|
87 a ; \ |
|
88 } \ |
|
89 } while (0) |
|
90 |
|
91 #else |
|
92 #define GDI_ASSERT_DEBUG(c, p) |
|
93 #define GDI_ASSERT_DEBUG_GENERAL(c, p) |
|
94 |
|
95 #endif |
|
96 |
|
97 #endif |