Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/ATL_Deprecate.h

Issue 5765952465534976: Issue #276 - Introduce ATL_Deprecate.h (Closed)
Patch Set: Created July 24, 2014, 2:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * \file ATL_Deprecate.h Include package for all the ATL headers, with optional forwarding to detect ATL dependencies.
3 *
4 * This header is a nexus for refactoring work to remove ATL.
5 * The main purpose of this mechanism is to determine the exact scope of the ref actoring effort.
6 * The lifetime of this header is during the work on #276 Stop using ATL https:/ /issues.adblockplus.org/ticket/276
7 *
8 * This file implements namespace forwarding that allows detection of ATL symbol s.
9 * This forwarding is ordinarily disabled, and always disabled in Release config uration for safety.
10 * When forwarding is disabled, it simply includes the ATL headers.
11 * With forwarding turned on, the ATL headers are included within a namespace,
12 * then particular ATL items used are then manually reintroduced into visibili ty.
13 * This method requires explicitly enumerating each of the symbols needed to get the code to compile.
14 *
15 * When the ATL namespace is forwarded, the code does not link.
16 * Since forwarding the namespace is a code analysis tool, this is OK.
17 * The ATL DLL libraries expose symbols in the ATL namespace.
18 * The forwarded libraries use a different namespace.
19 * Thus the external symbols do not match, and the linker reports unresolved ext ernals.
20 */
21
22 /*
23 * NDEBUG is defined for release but not for debug, so release versions never fo rward.
24 * Because the plugin doesn't link correctly with forwarding turned off, forward ing is disabled by default even for debug.
25 */
26 #define DISABLE_FORWARDING_FOR_DEBUG 1
27 #define DISABLE_ATL_FORWARDING defined(NDEBUG) || DISABLE_FORWARDING_FOR_DEBUG
28
29 #if DISABLE_ATL_FORWARDING
30
31 #include <atlbase.h>
32 #include <atlstr.h>
33 #include <atltypes.h>
34 #include <atlcom.h>
35
36 #else
37
38 /*
39 * ATL requires the following includes in the global namespace.
40 */
41 #include <apiset.h>
42 #include <apisetcconv.h>
43 #include <rpc.h>
44 #include <rpcndr.h>
45 #include <pshpack8.h>
46 #include <stddef.h>
47 #include <string.h>
48 #include <malloc.h>
49 #include <mbstring.h>
50 #include <wchar.h>
51 #include <tchar.h>
52 #include <stdlib.h>
53 #include <comutil.h>
54 #include <OaIdl.h>
55 #include <ObjIdl.h>
56 #include <new>
57 #include <propsys.h>
58 #include <ShObjIdl.h>
59 #include <ShlObj.h>
60 #include <Shlwapi.h>
61 #include <MsHTML.h>
62 #include <crtdbg.h>
63 #include <ole2.h>
64 #include <MsHtmHst.h>
65
66 /*
67 * ATL is used as an explicit global namespace within ATL itself.
68 * These declarations forward the wrapped ATL namespace back into the global one .
69 * Fortuitously, none of the plugin code uses explicitly global ATL
70 */
71 namespace OLD_ATL {
72 namespace ATL {
73 }
74 }
75 namespace ATL = OLD_ATL::ATL ;
76
77 namespace OLD_ATL {
78 /*
79 * We need to bring some globals back into this namespace.
80 */
81 using ::tagVARIANT ;
82 using ::IStream ;
83
84 /*
85 * The original ATL include files.
86 */
87 #include <atlbase.h>
88 #include <atlstr.h>
89 #include <atltypes.h>
90 #include <atlcom.h>
91 }
92
93 /*
94 * The list of symbols that appear in the code.
95 * Each needs to be explicitly incorporated back in the global namespace when fo rwarding is on.
96 */
97 using OLD_ATL::_AtlBaseModule;
98 using OLD_ATL::CAtlBaseModule;
99 using OLD_ATL::CComAggObject;
100 using OLD_ATL::CComAutoCriticalSection;
101 using OLD_ATL::CComBSTR;
102 using OLD_ATL::CComClassFactory;
103 using OLD_ATL::CComCoClass;
104 using OLD_ATL::CComCreator;
105 using OLD_ATL::CComCreator2;
106 using OLD_ATL::CComModule;
107 using OLD_ATL::CComMultiThreadModel;
108 using OLD_ATL::CComObject;
109 using OLD_ATL::CComObjectNoLock;
110 using OLD_ATL::CComObjectRootEx;
111 using OLD_ATL::CComPtr;
112 using OLD_ATL::CComQIPtr;
113 using OLD_ATL::CComSingleThreadModel;
114 using OLD_ATL::CComVariant;
115 using OLD_ATL::CString;
116 using OLD_ATL::CW2A;
117 using OLD_ATL::IDispatchImpl;
118 using OLD_ATL::IObjectWithSiteImpl;
119 using OLD_ATL::OLE2T;
120
121 #endif
122
123 /*
124 * Deprecation pragmas use the compiler to identify refactoring targets.
125 */
126 #if DISABLE_ATL_FORWARDING
127 namespace ATL {
128 #else
129 namespace OLD_ATL {
130 #endif
131 #pragma deprecated( CRect )
132 #pragma deprecated( CSimpleArray )
133 }
134
135 /*
136 * Note:
137 * The preprocessor symbols ATLASSERT and ATLTRACE appear in the source.
138 * These resolve to nothing in Release configurations.
139 * In Debug configurations, these are non-trivial.
140 * ATLASSERT resolves to an expression with _CrtDbgReportW and _CrtDbgBreak.
141 * ATLTRACE resolves to a ATL::CTraceFileAndLineInfo.
142 * These will need to be replaced or removed.
143 */
OLDNEW

Powered by Google App Engine
This is Rietveld