|
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 // Panic and logging functions common to both the DirectGDI adaptation layer and |
|
15 // associated modules/interfaces. |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef DIRECTGDIPANICS_H |
|
20 #define DIRECTGDIPANICS_H |
|
21 |
|
22 #include <graphics/directgdipanics.inl> |
|
23 #include <e32cmn.h> |
|
24 |
|
25 |
|
26 /** |
|
27 @publishedPartner |
|
28 @prototype |
|
29 */ |
|
30 |
|
31 #ifndef SYMBIAN_PANIC_CATEGORY |
|
32 #error SYMBIAN_PANIC_CATEGORY not defined. |
|
33 #endif |
|
34 |
|
35 /** Helper macros for the assert and panic macros. |
|
36 */ |
|
37 #define GRAPHICS_SOURCE_FILENAME(sourceFileName) _LIT(KSourceFileName, sourceFileName); |
|
38 #define GRAPHICS_ASSERT_CONDITION(condition) _LIT(KPanicCondition, condition); |
|
39 #define GRAPHICS_LOG_MESSAGE(literalMessage) _LIT(KLogMessage, # literalMessage); |
|
40 |
|
41 #define GRAPHICS_ASSERT_ALWAYS(condition, panicCode) \ |
|
42 if (!(condition)) \ |
|
43 { \ |
|
44 GRAPHICS_SOURCE_FILENAME(__FILE__); \ |
|
45 GRAPHICS_ASSERT_CONDITION(#condition); \ |
|
46 DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, &KPanicCondition); \ |
|
47 } |
|
48 |
|
49 #define GRAPHICS_PANIC_ALWAYS(panicCode) \ |
|
50 { \ |
|
51 GRAPHICS_SOURCE_FILENAME(__FILE__); \ |
|
52 DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, NULL); \ |
|
53 } |
|
54 |
|
55 #define GRAPHICS_LOG_ALWAYS(message) \ |
|
56 { \ |
|
57 GRAPHICS_SOURCE_FILENAME(__FILE__);\ |
|
58 GRAPHICS_LOG_MESSAGE(message); \ |
|
59 DirectGdi::Log(KSourceFileName, __LINE__, KLogMessage); \ |
|
60 } |
|
61 |
|
62 #define GRAPHICS_LOGD_ALWAYS(message) \ |
|
63 { \ |
|
64 GRAPHICS_SOURCE_FILENAME(__FILE__);\ |
|
65 DirectGdi::Log(KSourceFileName, __LINE__, message); \ |
|
66 } |
|
67 |
|
68 /** |
|
69 Define "debug only" macros ONLY when this is a debug build. |
|
70 */ |
|
71 #ifdef _DEBUG |
|
72 #define GRAPHICS_LOG_DEBUG(literalMessage) GRAPHICS_LOG_ALWAYS(literalMessage) // Paste parameter literally to log |
|
73 #define GRAPHICS_LOGD_DEBUG(TDesCRefMessage) GRAPHICS_LOGD_ALWAYS(TDesCRefMessage) // Treat message as const TDesC& |
|
74 #define GRAPHICS_ASSERT_DEBUG(condition, panicCode) GRAPHICS_ASSERT_ALWAYS(condition, panicCode) |
|
75 #define GRAPHICS_PANIC_DEBUG(panicCode) GRAPHICS_PANIC_ALWAYS(panicCode) |
|
76 #else |
|
77 #define GRAPHICS_LOG_DEBUG(literalMessage) |
|
78 #define GRAPHICS_LOGD_DEBUG(TDesCRefMessage) |
|
79 #define GRAPHICS_ASSERT_DEBUG(condition, panicCode) |
|
80 #define GRAPHICS_PANIC_DEBUG(panicCode) |
|
81 #endif // _DEBUG |
|
82 |
|
83 |
|
84 // Cannot enable DirectGDI calltrace unless in debug mode. |
|
85 #ifndef _DEBUG |
|
86 #undef ENABLE_DIRECTGDI_CALLTRACE |
|
87 #endif |
|
88 |
|
89 #ifdef ENABLE_DIRECTGDI_CALLTRACE |
|
90 #define GRAPHICS_TRACE(functionName) RDebug::Print(_L(functionName)); |
|
91 #define GRAPHICS_TRACE1(functionName, p) RDebug::Printf(functionName, p); |
|
92 #define GRAPHICS_TRACE2(functionName, p1, p2) RDebug::Printf(functionName, p1, p2); |
|
93 #else |
|
94 #define GRAPHICS_TRACE(functionName) |
|
95 #define GRAPHICS_TRACE1(functionName, p) |
|
96 #define GRAPHICS_TRACE2(functionName, p1, p2) |
|
97 #endif |
|
98 |
|
99 #endif // DIRECTGDIPANICS_H |