| author | shrivatsa |
| Mon, 27 Sep 2010 14:51:17 +0530 | |
| changeset 12 | a0eee409ff14 |
| parent 3 | ebe3f8f03b59 |
| permissions | -rw-r--r-- |
| 0 | 1 |
/* |
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef CLASSNODEANALYSIS_H_ |
|
20 |
#define CLASSNODEANALYSIS_H_ |
|
21 |
||
22 |
#ifdef __WIN__ |
|
23 |
#pragma warning(disable:4786) |
|
24 |
#endif |
|
25 |
#include <xercesc/dom/DOM.hpp> |
|
26 |
#include <vector> |
|
27 |
#include <list> |
|
28 |
#include <string> |
|
29 |
#include "HANodeIterator.h" |
|
30 |
#include "NodeAnalysis.h" |
|
31 |
#include "NodeIndex.h" |
|
32 |
#include "NodeTypeComparator.h" |
|
33 |
using namespace std; |
|
34 |
||
35 |
XERCES_CPP_NAMESPACE_USE |
|
36 |
||
37 |
||
38 |
||
39 |
template <TIssueType IssueType> |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
40 |
void AddIssueClass(const HANodeIterator* self,TIssueIdentity classType, const HANodeIterator& ignorenode, int lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
41 |
const string& issueloc,const XMLCh* fileid=NULL) |
| 0 | 42 |
{
|
43 |
switch (classType) |
|
44 |
{
|
|
45 |
case EIssueIdentityClass: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
46 |
AddIssue<EIssueIdentityClass,IssueType>(self,ignorenode,lineNo,issueloc,fileid); |
| 0 | 47 |
break; |
48 |
case EIssueIdentityStruct: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
49 |
AddIssue<EIssueIdentityStruct,IssueType>(self,ignorenode,lineNo,issueloc,fileid); |
| 0 | 50 |
break; |
51 |
case EIssueIdentityUnion: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
52 |
AddIssue<EIssueIdentityUnion,IssueType>(self,ignorenode,lineNo,issueloc,fileid); |
| 0 | 53 |
break; |
54 |
default: |
|
55 |
assert(false); |
|
56 |
break; |
|
57 |
||
58 |
}; |
|
59 |
} |
|
60 |
||
61 |
template <TIssueType IssueType> |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
62 |
void AddIssueField(const HANodeIterator* self,TIssueIdentity classType, const HANodeIterator& ignorenode, int lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
63 |
const string& issueLoc, const XMLCh* fileid=NULL, const string name = "") |
| 0 | 64 |
{
|
65 |
switch (classType) |
|
66 |
{
|
|
67 |
case EIssueIdentityField: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
68 |
AddIssue<EIssueIdentityField,IssueType>(self,ignorenode,lineNo,issueLoc,fileid,name); |
| 0 | 69 |
break; |
70 |
case EIssueIdentityFieldInaccessible: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
71 |
AddIssue<EIssueIdentityFieldInaccessible,IssueType>(self,ignorenode,lineNo,issueLoc,fileid, name); |
| 0 | 72 |
break; |
73 |
default: |
|
74 |
assert(false); |
|
75 |
break; |
|
76 |
||
77 |
}; |
|
78 |
} |
|
79 |
||
80 |
/** |
|
81 |
* Add issue field |
|
82 |
* @param self pointer to self |
|
83 |
* @param classType type of issue |
|
84 |
* @param ignorenode reference to node |
|
85 |
* @param fileid pointer to fileid |
|
86 |
* @param name reference to name |
|
87 |
*/ |
|
88 |
template <TIssueType IssueType> |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
89 |
void AddIssueField(const HANodeIterator* self,TIssueIdentity classType, const HANodeIterator& ignorenode, int lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
90 |
const string& issueLoc, const XMLCh* fileid, const DataMember & name) |
| 0 | 91 |
{
|
92 |
switch (classType) |
|
93 |
{
|
|
94 |
case EIssueIdentityField: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
95 |
AddIssue<EIssueIdentityField,IssueType>(self,ignorenode,lineNo,issueLoc,fileid,name); |
| 0 | 96 |
break; |
97 |
case EIssueIdentityFieldInaccessible: |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
98 |
AddIssue<EIssueIdentityFieldInaccessible,IssueType>(self,ignorenode,lineNo,issueLoc,fileid, name); |
| 0 | 99 |
break; |
100 |
default: |
|
101 |
assert(false); |
|
102 |
break; |
|
103 |
||
104 |
}; |
|
105 |
} |
|
106 |
||
107 |
||
108 |
/** |
|
109 |
* The member variables are analyzed for changes in order, type, removal, addition |
|
110 |
* and visibility. Any change, including removal and addition, of the accessible |
|
111 |
* data members of a class is reported. |
|
112 |
*/ |
|
113 |
class ClassNodeAnalysis: public NodeAnalysis |
|
114 |
{
|
|
115 |
public: |
|
116 |
||
117 |
static NodeAnalysis* Construct(); |
|
118 |
public: |
|
119 |
/** |
|
120 |
* Constructor |
|
121 |
*/ |
|
122 |
ClassNodeAnalysis(); |
|
123 |
||
124 |
/** |
|
125 |
* Finds node to analyse it |
|
126 |
* @param baseline baseline node |
|
127 |
* @param current current node |
|
128 |
* @return 0, if there was no issues |
|
129 |
*/ |
|
130 |
int FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current); |
|
131 |
||
132 |
/** |
|
133 |
* Analyse |
|
134 |
* @param baseline baseline node |
|
135 |
* @param current current node |
|
136 |
* @param report report or not (default= true) |
|
137 |
* @return 0, if there was no issues |
|
138 |
*/ |
|
139 |
int Analyse(HANodeIterator baseline,HANodeIterator current, bool report = true); |
|
140 |
||
141 |
/** |
|
142 |
* Destructor |
|
143 |
*/ |
|
144 |
~ClassNodeAnalysis(){}
|
|
145 |
||
146 |
||
147 |
protected: |
|
148 |
||
149 |
/** |
|
150 |
* Analyses fields |
|
151 |
* @param baseline baseline version |
|
152 |
* @param current current version |
|
153 |
* @param bfields base fields vector |
|
154 |
* @param cfields current fields vector |
|
155 |
* @param report to report or not report issues |
|
156 |
* @return 0 if compared fields are equal |
|
157 |
*/ |
|
158 |
virtual int compareFields(HANodeIterator baseline,HANodeIterator current, |
|
159 |
const vector<DOMNode*>& bfields, const vector<DOMNode*>& cfields, |
|
160 |
bool report); |
|
161 |
||
162 |
/** |
|
163 |
* Analyses non-virtual functions |
|
164 |
* @param baseline baseline version |
|
165 |
* @param current current version |
|
166 |
* @param bexportedMethods base exported methods vector |
|
167 |
* @param cexportedMethods current exported methods vector |
|
168 |
* @param identity identity of the issue |
|
169 |
* @param report to report or not report issues |
|
170 |
* @return 0 if compared fields are equal |
|
171 |
*/ |
|
172 |
virtual int compareNonvirtualFunctions( HANodeIterator baseline, |
|
173 |
HANodeIterator current, |
|
174 |
const vector<DOMNode*>& bexportedMethods, |
|
175 |
const vector<DOMNode*>& cexportedMethods, |
|
176 |
TIssueIdentity identity, |
|
177 |
bool report); |
|
178 |
||
179 |
// First bool for signature |
|
180 |
struct MethodMatchFlags |
|
181 |
{
|
|
182 |
MethodMatchFlags(bool sM, bool rM) : signatureMatch(sM),returnValueMatch(rM){};
|
|
183 |
bool signatureMatch; |
|
184 |
bool returnValueMatch; |
|
185 |
bool IsMatch() {return signatureMatch && returnValueMatch;};
|
|
186 |
}; |
|
187 |
||
188 |
/** |
|
189 |
* Analyses virtual functions |
|
190 |
* @param baseline baseline version |
|
191 |
* @param current current version |
|
192 |
* @param bvirtualMethods base virtual methods vector |
|
193 |
* @param cvirtualMethods current virtual methods vector |
|
194 |
* @param report to report or not report issues |
|
195 |
* @return 0 if compared fields are equal |
|
196 |
*/ |
|
197 |
virtual int compareVirtualFunctions(HANodeIterator baseline,HANodeIterator current, |
|
198 |
const vector<DOMNode*>& bvirtualMethods, |
|
199 |
const vector<DOMNode*>& cvirtualMethods, |
|
200 |
bool report); |
|
201 |
/** |
|
202 |
* Analyses other members |
|
203 |
* @param baseline baseline version |
|
204 |
* @param current current version |
|
205 |
* @param bothers base other items vector |
|
206 |
* @param cothers current other items vector |
|
207 |
* @param report to report or not report issues |
|
208 |
* @return 0 if compared fields are equal |
|
209 |
*/ |
|
210 |
virtual int compareOthers(HANodeIterator baseline,HANodeIterator current, |
|
211 |
const vector<DOMNode*>& bothers, const vector<DOMNode*>& cothers, |
|
212 |
bool report); |
|
213 |
||
214 |
/** |
|
215 |
* Compares the base sizes of the classes |
|
216 |
* @param baseline to which to compare |
|
217 |
* @param current what to compare |
|
218 |
* @param bfields base data member table |
|
219 |
* @param cfields current data member table |
|
220 |
* @param report if true finding are reported |
|
221 |
* @return 0 if compared fields are equal |
|
222 |
*/ |
|
223 |
virtual int compareBaseSizes(HANodeIterator baseline, HANodeIterator current, const NodeIndex::dtable_t& bfields, const NodeIndex::dtable_t& cfields, bool report); |
|
224 |
||
225 |
protected: |
|
226 |
||
227 |
/** |
|
228 |
* Compares changes in inheritance |
|
229 |
* @param baseline to which to compare |
|
230 |
* @param current what to compare |
|
231 |
* @param report if true findings are reported |
|
232 |
* @return 0 if compared fields are equal |
|
233 |
*/ |
|
234 |
int compareBases(HANodeIterator baseline,HANodeIterator current, bool report); |
|
235 |
||
236 |
/** |
|
237 |
* Compares methods by function signature (return value is not involved) |
|
238 |
* @param basemethod basemethod to compare |
|
239 |
* @param currentmethod current to compare |
|
240 |
* @return true if signature isn't changed |
|
241 |
*/ |
|
242 |
bool compareMethodsSignature(HANodeIterator basemethod,HANodeIterator currentmethod, const NodeTypeComparator& comparator); |
|
243 |
||
244 |
/** |
|
245 |
* Compares all the members of the class |
|
246 |
* @param baseline baseline version |
|
247 |
* @param current current version |
|
248 |
* @param report if true findings are reported |
|
249 |
* @return 0 if there was no issues |
|
250 |
*/ |
|
251 |
int compareClassMembers(HANodeIterator baseline,HANodeIterator current, bool report); |
|
252 |
||
253 |
/** |
|
254 |
* Analyses and reports the differences between two fields |
|
255 |
* @param basefield baseline field |
|
256 |
* @param currentfield current field |
|
257 |
* @param report if true findings are reported |
|
258 |
* @return 0 if compared fields are equal |
|
259 |
*/ |
|
260 |
//int compareField(HANodeIterator basefield,HANodeIterator currentfield, bool report); |
|
261 |
||
262 |
/** |
|
263 |
* Analyses and reports the differences between two fields |
|
264 |
* @param baseline baseline version |
|
265 |
* @param current current version |
|
266 |
* @param basemember base member to compare |
|
267 |
* @param currentmember current member to compare |
|
268 |
* @param report if true findings are reported |
|
269 |
* @return 0 if compared fields are equal |
|
270 |
*/ |
|
271 |
int compareField(HANodeIterator baseline, HANodeIterator current, const DataMember& basemember,const DataMember& currentmember, bool report); |
|
272 |
||
273 |
/** |
|
274 |
* Analyses the methods return value |
|
275 |
* @param basemethod baseline method |
|
276 |
* @param currentmethod current method |
|
277 |
* @return true if method returns are equal |
|
278 |
*/ |
|
279 |
bool compareMethodsReturn(HANodeIterator basemethod,HANodeIterator currentmethod,NodeTypeComparator& cmp); |
|
280 |
||
281 |
/** |
|
282 |
* Index virtual methods |
|
283 |
* @param node node to index |
|
284 |
* @param virtualMethods virtual methods in node |
|
285 |
* @param vtable virtual method table |
|
286 |
* @param virtualMethodsWithIndex methods indexed |
|
287 |
*/ |
|
288 |
void indexVirtualMethods(HANodeIterator node, |
|
289 |
const vector<DOMNode*>& virtualMethods, |
|
290 |
const NodeIndex::vtable_t& vtable, |
|
291 |
vector<pair<DOMNode*,int> >& virtualMethodsWithIndex); |
|
292 |
||
293 |
/** |
|
294 |
* Compare virtual methods |
|
295 |
* @param baseline baseline version |
|
296 |
* @param current current version |
|
297 |
* @param basevtable base virtual method table |
|
298 |
* @param currentvtable current virtual method table |
|
299 |
* @param report if true findings are reported |
|
300 |
*/ |
|
301 |
int compareVirtualTables(HANodeIterator baseline,HANodeIterator current, |
|
302 |
const NodeIndex::vtable_t& basevtable, |
|
303 |
const NodeIndex::vtable_t& currentvtable, |
|
304 |
bool report); |
|
305 |
||
306 |
// Contains basemethod pointer and a boolean flag telling whether |
|
307 |
// the method was found in current methods or not. |
|
308 |
typedef map<DOMNode*, MethodMatchFlags> MethodMatchMap; |
|
309 |
virtual int compareNonvirtualFunctions( HANodeIterator baseline, |
|
310 |
HANodeIterator current, |
|
311 |
const vector<DOMNode*>& bexportedMethods, |
|
312 |
const vector<DOMNode*>& cexportedMethods, |
|
313 |
TIssueIdentity identity, |
|
314 |
bool report, |
|
315 |
ComparatorVector::const_iterator comparator, |
|
316 |
MethodMatchMap& baseMap, |
|
317 |
MethodMatchMap& currMap, |
|
318 |
int comparatorRound); |
|
319 |
||
320 |
protected: |
|
321 |
||
322 |
//! To report added members |
|
323 |
bool iReportAddedMembers; |
|
324 |
//! Identity of the issue found |
|
325 |
TIssueIdentity iIdentity; |
|
326 |
}; |
|
327 |
||
328 |
#endif |