apicompatanamdw/compatanalysercmd/headeranalyser/src/XMLUtils.cpp
changeset 0 638b9c697799
child 12 a0eee409ff14
equal deleted inserted replaced
-1:000000000000 0:638b9c697799
       
     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 #include "CmdGlobals.h"
       
    20 #ifdef __WIN__
       
    21 #pragma warning(disable:4786)
       
    22 #endif
       
    23 
       
    24 #include <assert.h>
       
    25 #include <map>
       
    26 #include <list>
       
    27 #include <string>
       
    28 
       
    29 #include <xercesc/dom/DOM.hpp>
       
    30 #include <xercesc/parsers/AbstractDOMParser.hpp>
       
    31 #include "XMLUtils.h"
       
    32 #include "XMLStringConst.h"
       
    33 #include "NodeIndex.h"
       
    34 #include "XMLModuleErrorHandler.h"
       
    35 #include "BBCFileUtils.h"
       
    36 #include "HAException.h"
       
    37 #include "Utils.h"
       
    38 
       
    39 using namespace std;
       
    40 
       
    41 XERCES_CPP_NAMESPACE_USE
       
    42 
       
    43 //Attributes of the elements, copied from the unofficial DTD for GCCXML
       
    44 
       
    45 
       
    46 //<!ELEMENT Base EMPTY>
       
    47 //<!ATTLIST Base access (public | private | protected) "public">
       
    48 //<!ATTLIST Base type IDREF #REQUIRED>
       
    49 //<!ATTLIST Base virtual (0 | 1) "0">
       
    50 //Base
       
    51 //<Base type="_191" access="public" virtual="0"/>
       
    52 const int KBaseAttributeCount = 3;
       
    53 const EntityAttributeElement KBaseAttributes[KBaseAttributeCount]={
       
    54                                                 {KXMLTypeString,EIdAttribute},
       
    55                                                 {KXMLAccessString,ESimpleAttribute},
       
    56                                                 {KXMLVirtualString,EBooleanAttribute}
       
    57                                                 };
       
    58 
       
    59 //<!ELEMENT Variable EMPTY>
       
    60 //<!ATTLIST Variable access (public | private | protected) "public">
       
    61 //<!ATTLIST Variable artificial CDATA #IMPLIED>
       
    62 //<!ATTLIST Variable attributes CDATA #IMPLIED>
       
    63 //<!ATTLIST Variable context IDREF #REQUIRED>
       
    64 //<!ATTLIST Variable extern (0 | 1) "0">
       
    65 //<!ATTLIST Variable file CDATA #REQUIRED>
       
    66 //<!ATTLIST Variable id ID #REQUIRED>
       
    67 //<!ATTLIST Variable init CDATA #IMPLIED>
       
    68 //<!ATTLIST Variable line CDATA #REQUIRED>
       
    69 //<!ATTLIST Variable location CDATA #REQUIRED>
       
    70 //<!ATTLIST Variable mangled CDATA #IMPLIED>
       
    71 //<!ATTLIST Variable name CDATA #REQUIRED>
       
    72 //<!ATTLIST Variable type CDATA #REQUIRED>
       
    73 //<Variable id="_26" name="KMediaPasswordNotifyUid" type="_575c" init="268454912" context="_1" location="f2:4254" file="f2" line="4254"/>
       
    74 const int KVariableAttributeCount = 4;
       
    75 const EntityAttributeElement KVariableAttributes[KVariableAttributeCount]={
       
    76                                                 {KXMLNameString,ESimpleAttribute},
       
    77                                                 {KXMLTypeString,EIdAttribute},
       
    78                                                 {KXMLInitString,EOptionalSimpleAttribute},
       
    79                                                 //{KXMLContextString,EIdAttribute},
       
    80                                                 {KXMLAccessString,EOptionalSimpleAttribute}
       
    81                                                 };
       
    82 
       
    83 //<!ELEMENT FundamentalType EMPTY>
       
    84 //<!ATTLIST FundamentalType align CDATA #IMPLIED>
       
    85 //<!ATTLIST FundamentalType attributes CDATA #IMPLIED>
       
    86 //<!ATTLIST FundamentalType id ID #REQUIRED>
       
    87 //<!ATTLIST FundamentalType name CDATA #REQUIRED>
       
    88 //<!ATTLIST FundamentalType size CDATA #IMPLIED>
       
    89 //<FundamentalType id="_573" name="unsigned int" size="32" align="32"/>
       
    90 const int KFundamentalTypeAttributeCount = 3;
       
    91 const EntityAttributeElement KFundamentalTypeAttributes[KFundamentalTypeAttributeCount]={
       
    92                                                 {KXMLNameString,ESimpleAttribute},
       
    93                                                 {KXMLSizeString,ESimpleAttribute},
       
    94                                                 {KXMLAlignString,ESimpleAttribute}
       
    95                                                 };
       
    96 
       
    97 //<!ELEMENT Typedef EMPTY>
       
    98 //<!ATTLIST Typedef attributes CDATA #IMPLIED>
       
    99 //<!ATTLIST Typedef context IDREF #REQUIRED>
       
   100 //<!ATTLIST Typedef file CDATA #REQUIRED>
       
   101 //<!ATTLIST Typedef id ID #REQUIRED>
       
   102 //<!ATTLIST Typedef line CDATA #REQUIRED>
       
   103 //<!ATTLIST Typedef location CDATA #REQUIRED>
       
   104 //<!ATTLIST Typedef name CDATA #REQUIRED>
       
   105 //<!ATTLIST Typedef type CDATA #REQUIRED>
       
   106 //<Typedef id="_574" name="TUint" type="_573" context="_1" location="f10:600" file="f10" line="600"/>
       
   107 const int KTypedefAttributeCount = 2;
       
   108 const EntityAttributeElement KTypedefAttributes[KTypedefAttributeCount]={
       
   109                                                 {KXMLNameString,ESimpleAttribute},
       
   110                                                 {KXMLTypeString,EIdAttribute}//,
       
   111                                                 //{KXMLContextString,EIdAttribute}
       
   112                                                 };
       
   113 
       
   114 //<!ELEMENT Namespace EMPTY>
       
   115 //<!ATTLIST Namespace attributes CDATA #IMPLIED>
       
   116 //<!ATTLIST Namespace context IDREF #IMPLIED>
       
   117 //<!ATTLIST Namespace id ID #REQUIRED>
       
   118 //<!ATTLIST Namespace mangled CDATA #IMPLIED>
       
   119 //<!ATTLIST Namespace members CDATA #IMPLIED>
       
   120 //<!ATTLIST Namespace name CDATA #REQUIRED>
       
   121 //<Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
       
   122 const int KNamespaceAttributeCount = 2;
       
   123 const EntityAttributeElement KNamespaceAttributes[KNamespaceAttributeCount]={
       
   124                                                 {KXMLNameString,ESimpleAttribute},
       
   125                                                 {KXMLContextString,EOptionalIdAttribute}//,
       
   126                                                 //{KXMLMembersString,EIdAttribute}
       
   127                                                 };
       
   128 
       
   129 //<!ELEMENT CvQualifiedType EMPTY>
       
   130 //<!ATTLIST CvQualifiedType align CDATA #IMPLIED>
       
   131 //<!ATTLIST CvQualifiedType attributes CDATA #IMPLIED>
       
   132 //<!ATTLIST CvQualifiedType const CDATA #IMPLIED>
       
   133 //<!ATTLIST CvQualifiedType id ID #REQUIRED>
       
   134 //<!ATTLIST CvQualifiedType restrict CDATA #IMPLIED>
       
   135 //<!ATTLIST CvQualifiedType size CDATA #IMPLIED>
       
   136 //<!ATTLIST CvQualifiedType type IDREF #REQUIRED>
       
   137 //<!ATTLIST CvQualifiedType volatile CDATA #IMPLIED>
       
   138 //<CvQualifiedType id="_4c" type="_4" const="1"/>
       
   139 const int KCvQualifiedTypeAttributeCount = 2;
       
   140 const EntityAttributeElement KCvQualifiedTypeAttributes[KCvQualifiedTypeAttributeCount]={
       
   141                                                 {KXMLTypeString,EIdAttribute},
       
   142                                                 {KXMLConstString,EBooleanAttribute}
       
   143                                                 };
       
   144 
       
   145 //<!ELEMENT Function (Argument | Ellipsis)*>
       
   146 //<!ATTLIST Function attributes CDATA #IMPLIED>
       
   147 //<!ATTLIST Function context IDREF #REQUIRED>
       
   148 //<!ATTLIST Function endline CDATA #IMPLIED>
       
   149 //<!ATTLIST Function extern (0 | 1) "0">
       
   150 //<!ATTLIST Function file CDATA #REQUIRED>
       
   151 //<!ATTLIST Function id ID #REQUIRED>
       
   152 //<!ATTLIST Function line CDATA #REQUIRED>
       
   153 //<!ATTLIST Function location CDATA #REQUIRED>
       
   154 //<!ATTLIST Function mangled CDATA #IMPLIED>
       
   155 //<!ATTLIST Function name CDATA #REQUIRED>
       
   156 //<!ATTLIST Function returns CDATA #REQUIRED>
       
   157 //<!ATTLIST Function throw CDATA #IMPLIED>
       
   158 //<Function id="_8" name="PanicTFixedArray" returns="_585" context="_1" mangled="_Z16PanicTFixedArrayv" location="f1:4492" file="f1" line="4492" extern="1"/>
       
   159 const int KFunctionAttributeCount = 4;
       
   160 const EntityAttributeElement KFunctionAttributes[KFunctionAttributeCount]={
       
   161                                                 {KXMLNameString,ESimpleAttribute},
       
   162                                                 {KXMLReturnsString,EIdAttribute},
       
   163                                                 {KXMLContextString,EIdAttribute},
       
   164                                                 {KXMLConstString,EBooleanAttribute}
       
   165                                                 };
       
   166 
       
   167 //<!ELEMENT Enumeration (EnumValue)+>
       
   168 //<!ATTLIST Enumeration access (public | private | protected) "public">
       
   169 //<!ATTLIST Enumeration align CDATA #IMPLIED>
       
   170 //<!ATTLIST Enumeration artificial CDATA #IMPLIED>
       
   171 //<!ATTLIST Enumeration attributes CDATA #IMPLIED>
       
   172 //<!ATTLIST Enumeration context CDATA #REQUIRED>
       
   173 //<!ATTLIST Enumeration file CDATA #REQUIRED>
       
   174 //<!ATTLIST Enumeration id ID #REQUIRED>
       
   175 //<!ATTLIST Enumeration line CDATA #REQUIRED>
       
   176 //<!ATTLIST Enumeration location CDATA #REQUIRED>
       
   177 //<!ATTLIST Enumeration name CDATA #REQUIRED>
       
   178 //<!ATTLIST Enumeration size CDATA #IMPLIED>
       
   179 //<Enumeration id="_25" name="TMediaPswdNotifyExitMode" context="_1" location="f2:4259" file="f2" line="4259" artificial="1" size="32" align="32">
       
   180 const int KEnumerationAttributeCount = 4;
       
   181 const EntityAttributeElement KEnumerationAttributes[KEnumerationAttributeCount]={
       
   182                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   183                                                 {KXMLAlignString,ESimpleAttribute},
       
   184                                                 //{KXMLContextString,EIdAttribute},
       
   185                                                 {KXMLNameString,ESimpleAttribute},
       
   186                                                 {KXMLSizeString,ESimpleAttribute}
       
   187                                                 };
       
   188 
       
   189 //<!ELEMENT Field EMPTY>
       
   190 //<!ATTLIST Field access (public | private | protected) "public">
       
   191 //<!ATTLIST Field attributes CDATA #IMPLIED>
       
   192 //<!ATTLIST Field bits CDATA #IMPLIED>
       
   193 //<!ATTLIST Field context IDREF #REQUIRED>
       
   194 //<!ATTLIST Field file CDATA #REQUIRED>
       
   195 //<!ATTLIST Field id ID #REQUIRED>
       
   196 //<!ATTLIST Field line CDATA #REQUIRED>
       
   197 //<!ATTLIST Field location CDATA #REQUIRED>
       
   198 //<!ATTLIST Field mangled CDATA #IMPLIED>
       
   199 //<!ATTLIST Field mutable (0 | 1) "0">
       
   200 //<!ATTLIST Field name CDATA #REQUIRED>
       
   201 //<!ATTLIST Field offset CDATA #IMPLIED>
       
   202 //<!ATTLIST Field type CDATA #REQUIRED>
       
   203 //<Field id="_2157" name="iFlags" type="_575" offset="256" context="_178" access="private" mangled="_ZN9RMessage26iFlagsE" mutable="1" location="f3:3155" file="f3" line="3155"/>
       
   204 const int KFieldAttributeCount = 5;
       
   205 const EntityAttributeElement KFieldAttributes[KFieldAttributeCount]={
       
   206                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   207                                                 {KXMLMutableString,EBooleanAttribute},
       
   208                                                 {KXMLNameString,ESimpleAttribute},
       
   209                                                 {KXMLOffsetString,ESimpleAttribute},
       
   210                                                 {KXMLTypeString,ETypeAttribute}
       
   211                                                 };
       
   212 
       
   213 //<!ELEMENT Argument EMPTY>
       
   214 //<!ATTLIST Argument attributes CDATA #IMPLIED>
       
   215 //<!ATTLIST Argument default CDATA #IMPLIED>
       
   216 //<!ATTLIST Argument name CDATA #IMPLIED>
       
   217 //<!-- type can not be an IDREF as it might be "_4c" etc. which will be 
       
   218 //an invalid id -->
       
   219 //<!ATTLIST Argument type CDATA #REQUIRED>
       
   220 //<Argument name="_ctor_arg" type="_128" location="f0:91" file="f0" line="91"/>
       
   221 const int KArgumentAttributeCount = 3;
       
   222 const EntityAttributeElement KArgumentAttributes[KArgumentAttributeCount]={
       
   223                                                 {KXMLNameString,ESimpleAttribute},
       
   224                                                 {KXMLTypeString,EIdAttribute},
       
   225                                                 {KXMLDefaultString,EOptionalSimpleAttribute}
       
   226                                                 };
       
   227 //<!ELEMENT Ellipsis EMPTY>
       
   228 const int KEllipsisAttributeCount = 0;
       
   229 //const EntityAttributeElement KEllipsisAttributes[KEllipsisAttributeCount]={};
       
   230 
       
   231 
       
   232 //<!ELEMENT ArrayType EMPTY>
       
   233 //<!ATTLIST ArrayType align CDATA #IMPLIED>
       
   234 //<!ATTLIST ArrayType attributes CDATA #IMPLIED>
       
   235 //<!ATTLIST ArrayType id ID #REQUIRED>
       
   236 //<!ATTLIST ArrayType max CDATA #REQUIRED>
       
   237 //<!ATTLIST ArrayType min CDATA #FIXED "0">
       
   238 //<!ATTLIST ArrayType size CDATA #IMPLIED>
       
   239 //<!ATTLIST ArrayType type IDREF #REQUIRED>
       
   240 const int KArrayTypeAttributeCount = 2;
       
   241 const EntityAttributeElement KArrayTypeAttributes[KArrayTypeAttributeCount]={
       
   242                                                 {KXMLTypeString,EIdAttribute},
       
   243                                                 {KXMLMaxString,ESimpleAttribute}
       
   244                                                 };
       
   245 //<!ELEMENT Class (Base)*>
       
   246 //<!ATTLIST Class abstract (0 | 1) "0">
       
   247 //<!ATTLIST Class access (public | private | protected) "public">
       
   248 //<!ATTLIST Class align CDATA #IMPLIED>
       
   249 //<!ATTLIST Class artificial CDATA #IMPLIED>
       
   250 //<!ATTLIST Class attributes CDATA #IMPLIED>
       
   251 //<!ATTLIST Class bases CDATA #IMPLIED>
       
   252 //<!ATTLIST Class context IDREF #REQUIRED>
       
   253 //<!ATTLIST Class file CDATA #REQUIRED>
       
   254 //<!ATTLIST Class id ID #REQUIRED>
       
   255 //<!ATTLIST Class incomplete (0 | 1) "0">
       
   256 //<!ATTLIST Class line CDATA #REQUIRED>
       
   257 //<!ATTLIST Class location CDATA #REQUIRED>
       
   258 //<!ATTLIST Class mangled CDATA #REQUIRED>
       
   259 //<!ATTLIST Class members CDATA #IMPLIED>
       
   260 //<!ATTLIST Class name CDATA #REQUIRED>
       
   261 //<!ATTLIST Class size CDATA #IMPLIED>
       
   262 const int KClassAttributeCount = 6;
       
   263 const EntityAttributeElement KClassAttributes[KClassAttributeCount]={
       
   264                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   265                                                 {KXMLAlignString,ESimpleAttribute},
       
   266                                                 {KXMIncompleteString,EBooleanAttribute},				
       
   267                                                 {KXMLNameString,ESimpleAttribute},
       
   268                                                 {KXMLSizeString,ESimpleAttribute},
       
   269                                                 {KXMLMebmersString,EIdAttribute}
       
   270                                                 };
       
   271 //<!ELEMENT Constructor (Argument | Ellipsis)*>
       
   272 //<!ATTLIST Constructor access (public | private | protected) "public">
       
   273 //<!ATTLIST Constructor artificial CDATA #IMPLIED>
       
   274 //<!ATTLIST Constructor attributes CDATA #IMPLIED>
       
   275 //<!ATTLIST Constructor context CDATA #REQUIRED>
       
   276 //<!ATTLIST Constructor endline CDATA #IMPLIED>
       
   277 //<!ATTLIST Constructor extern (0 | 1) "0">
       
   278 //<!ATTLIST Constructor file CDATA #REQUIRED>
       
   279 //<!ATTLIST Constructor id ID #REQUIRED>
       
   280 //<!ATTLIST Constructor line CDATA #REQUIRED>
       
   281 //<!ATTLIST Constructor location CDATA #REQUIRED>
       
   282 //<!ATTLIST Constructor mangled CDATA #REQUIRED>
       
   283 //<!ATTLIST Constructor name CDATA #REQUIRED>
       
   284 //<!ATTLIST Constructor throw CDATA #IMPLIED>
       
   285 const int KConstructorAttributeCount = 2;
       
   286 const EntityAttributeElement KConstructorAttributes[KConstructorAttributeCount]={
       
   287                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   288                                                 {KXMLNameString,ESimpleAttribute}
       
   289                                                 };
       
   290 //<!ELEMENT Converter EMPTY>
       
   291 //<!ATTLIST Converter access (public | private | protected) "public">
       
   292 //<!ATTLIST Converter attributes CDATA #IMPLIED>
       
   293 //<!ATTLIST Converter const (0 | 1) "0">
       
   294 //<!ATTLIST Converter context IDREF #REQUIRED>
       
   295 //<!ATTLIST Converter endline CDATA #IMPLIED>
       
   296 //<!ATTLIST Converter extern (0 | 1) "0">
       
   297 //<!ATTLIST Converter file CDATA #REQUIRED>
       
   298 //<!ATTLIST Converter id ID #REQUIRED>
       
   299 //<!ATTLIST Converter line CDATA #REQUIRED>
       
   300 //<!ATTLIST Converter location CDATA #REQUIRED>
       
   301 //<!ATTLIST Converter mangled CDATA #REQUIRED>
       
   302 //<!ATTLIST Converter name CDATA #REQUIRED>
       
   303 //<!ATTLIST Converter returns IDREF #REQUIRED>
       
   304 //<!ATTLIST Converter throw CDATA #IMPLIED>
       
   305 //<!ATTLIST Converter virtual (0 | 1) "0">
       
   306 const int KConverterAttributeCount = 0; 
       
   307 //const EntityAttributeElement KConverterAttributes[KConverterAttributeCount]={};
       
   308 
       
   309 //<!ELEMENT Destructor (Argument)*>
       
   310 //<!ATTLIST Destructor access (public | private | protected) "public">
       
   311 //<!ATTLIST Destructor artificial CDATA #IMPLIED>
       
   312 //<!ATTLIST Destructor attributes CDATA #IMPLIED>
       
   313 //<!ATTLIST Destructor context IDREF #REQUIRED>
       
   314 //<!ATTLIST Destructor endline CDATA #IMPLIED>
       
   315 //<!ATTLIST Destructor extern (0 | 1) "0">
       
   316 //<!ATTLIST Destructor file CDATA #REQUIRED>
       
   317 //<!ATTLIST Destructor id ID #REQUIRED>
       
   318 //<!ATTLIST Destructor line CDATA #REQUIRED>
       
   319 //<!ATTLIST Destructor location CDATA #REQUIRED>
       
   320 //<!ATTLIST Destructor mangled CDATA #REQUIRED>
       
   321 //<!ATTLIST Destructor name CDATA #REQUIRED>
       
   322 //<!ATTLIST Destructor throw CDATA #IMPLIED>
       
   323 //<!ATTLIST Destructor virtual (0 | 1) "0">
       
   324 const int KDestructorAttributeCount = 3;
       
   325 const EntityAttributeElement KDestructorAttributes[KDestructorAttributeCount]={
       
   326                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   327                                                 {KXMLNameString,ESimpleAttribute},
       
   328                                                 {KXMLVirtualString,EBooleanAttribute}
       
   329                                                 };
       
   330 //<!ELEMENT EnumValue EMPTY>
       
   331 //<!ATTLIST EnumValue init CDATA #REQUIRED>
       
   332 //<!ATTLIST EnumValue name CDATA #REQUIRED>
       
   333 const int KEnumValueAttributeCount = 2;
       
   334 const EntityAttributeElement KEnumValueAttributes[KEnumValueAttributeCount]={
       
   335                                                 {KXMLInitString,ESimpleAttribute},
       
   336                                                 {KXMLNameString,ESimpleAttribute} 
       
   337                                                 };
       
   338 //<!ELEMENT File EMPTY>
       
   339 const int KFileAttributeCount = 0;
       
   340 //const EntityAttributeElement KFileAttributes[KFileAttributeCount]={};
       
   341 
       
   342 //<!ELEMENT FunctionType (Argument | Ellipsis)*>
       
   343 //<!ATTLIST FunctionType attributes CDATA #IMPLIED>
       
   344 //<!ATTLIST FunctionType id ID #REQUIRED>
       
   345 //<!ATTLIST FunctionType returns IDREF #REQUIRED>
       
   346 const int KFunctionTypeAttributeCount =	1;
       
   347 const EntityAttributeElement KFunctionTypeAttributes[KFunctionTypeAttributeCount]={
       
   348                                                 {KXMLReturnsString,EIdAttribute}
       
   349                                                 };
       
   350 //<!ELEMENT Method (Argument | Ellipsis)*>
       
   351 //<!ATTLIST Method access (public | private | protected) "public">
       
   352 //<!ATTLIST Method attributes CDATA #IMPLIED>
       
   353 //<!ATTLIST Method const (0 | 1) "0">
       
   354 //<!ATTLIST Method context IDREF #REQUIRED>
       
   355 //<!ATTLIST Method endline CDATA #IMPLIED>
       
   356 //<!ATTLIST Method extern (0 | 1) "0">
       
   357 //<!ATTLIST Method file CDATA #REQUIRED>
       
   358 //<!ATTLIST Method id ID #REQUIRED>
       
   359 //<!ATTLIST Method line CDATA #REQUIRED>
       
   360 //<!ATTLIST Method location CDATA #REQUIRED>
       
   361 //<!ATTLIST Method mangled CDATA #REQUIRED>
       
   362 //<!ATTLIST Method name CDATA #REQUIRED>
       
   363 //<!ATTLIST Method pure_virtual (0 | 1) "0">
       
   364 //<!ATTLIST Method returns CDATA #REQUIRED>
       
   365 //<!ATTLIST Method static (0 | 1) "0">
       
   366 //<!ATTLIST Method throw CDATA #IMPLIED>
       
   367 //<!ATTLIST Method virtual (0 | 1) "0">
       
   368 const int KMethodAttributeCount = 7;
       
   369 const EntityAttributeElement KMethodAttributes[KMethodAttributeCount]={
       
   370                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   371                                                 {KXMLConstString,EBooleanAttribute},
       
   372                                                 {KXMLNameString,ESimpleAttribute},
       
   373                                                 {KXMLPureVirtualString,EBooleanAttribute},
       
   374                                                 {KXMLReturnsString,EIdAttribute},
       
   375                                                 {KXMLStaticString,EBooleanAttribute},
       
   376                                                 {KXMLVirtualString,EBooleanAttribute}
       
   377                                                 };
       
   378 
       
   379 //<!ELEMENT MethodType (Argument | Ellipsis)*>
       
   380 //<!ATTLIST MethodType attributes CDATA #IMPLIED>
       
   381 //<!ATTLIST MethodType basetype IDREF #REQUIRED>
       
   382 //<!ATTLIST MethodType id ID #REQUIRED>
       
   383 //<!ATTLIST MethodType returns CDATA #REQUIRED>
       
   384 const int KMethodTypeAttributeCount = 2;
       
   385 const EntityAttributeElement KMethodTypeAttributes[KMethodTypeAttributeCount]={
       
   386                                                 {KXMLBaseTypeString,EIdAttribute},
       
   387                                                 {KXMLReturnsString,EIdAttribute},
       
   388                                                 };
       
   389 //<!ELEMENT NamespaceAlias EMPTY>
       
   390 //<!ATTLIST NamespaceAlias context IDREF #IMPLIED>
       
   391 //<!ATTLIST NamespaceAlias id ID #REQUIRED>
       
   392 //<!ATTLIST NamespaceAlias mangled CDATA #IMPLIED>
       
   393 //<!ATTLIST NamespaceAlias name CDATA #REQUIRED>
       
   394 //<!ATTLIST NamespaceAlias namespace CDATA #REQUIRED>
       
   395 const int KNamespaceAliasAttributeCount = 0;
       
   396 //const EntityAttributeElement KNamespaceAliasAttributes[KNamespaceAliasAttributeCount]={};
       
   397 
       
   398 //<!ELEMENT OffsetType EMPTY>
       
   399 //<!ATTLIST OffsetType align CDATA #IMPLIED>
       
   400 //<!ATTLIST OffsetType attributes CDATA #IMPLIED>
       
   401 //<!ATTLIST OffsetType id ID #REQUIRED>
       
   402 //<!ATTLIST OffsetType basetype IDREF #REQUIRED>
       
   403 //<!ATTLIST OffsetType size CDATA #IMPLIED>
       
   404 //<!ATTLIST OffsetType type CDATA #REQUIRED>
       
   405 const int KOffsetTypeAttributeCount = 0;
       
   406 //const EntityAttributeElement KOffsetTypeAttributes[KOffsetTypeAttributeCount]={};
       
   407 
       
   408 //<!ELEMENT OperatorFunction (Argument | Ellipsis)*>
       
   409 //<!ATTLIST OperatorFunction attributes CDATA #IMPLIED>
       
   410 //<!ATTLIST OperatorFunction context IDREF #REQUIRED>
       
   411 //<!ATTLIST OperatorFunction endline CDATA #IMPLIED>
       
   412 //<!ATTLIST OperatorFunction extern (0 | 1) "0">
       
   413 //<!ATTLIST OperatorFunction file CDATA #REQUIRED>
       
   414 //<!ATTLIST OperatorFunction id ID #REQUIRED>
       
   415 //<!ATTLIST OperatorFunction line CDATA #REQUIRED>
       
   416 //<!ATTLIST OperatorFunction location CDATA #REQUIRED>
       
   417 //<!ATTLIST OperatorFunction mangled CDATA #REQUIRED>
       
   418 //<!ATTLIST OperatorFunction name CDATA #REQUIRED>
       
   419 //<!ATTLIST OperatorFunction returns IDREF #REQUIRED>
       
   420 //<!ATTLIST OperatorFunction throw CDATA #IMPLIED>
       
   421 const int KOperatorFunctionAttributeCount = 2;
       
   422 const EntityAttributeElement KOperatorFunctionAttributes[KOperatorFunctionAttributeCount]={
       
   423                                                 {KXMLNameString,ESimpleAttribute},
       
   424                                                 {KXMLReturnsString,EIdAttribute}
       
   425                                                 };
       
   426 
       
   427 //<!ELEMENT OperatorMethod (Argument | Ellipsis)*>
       
   428 //<!ATTLIST OperatorMethod access (public | private | protected) "public">
       
   429 //<!ATTLIST OperatorMethod attributes CDATA #IMPLIED>
       
   430 //<!ATTLIST OperatorMethod const (0 | 1) "0">
       
   431 //<!ATTLIST OperatorMethod context IDREF #REQUIRED>
       
   432 //<!ATTLIST OperatorMethod endline CDATA #IMPLIED>
       
   433 //<!ATTLIST OperatorMethod extern (0 | 1) "0">
       
   434 //<!ATTLIST OperatorMethod file CDATA #REQUIRED>
       
   435 //<!ATTLIST OperatorMethod id ID #REQUIRED>
       
   436 //<!ATTLIST OperatorMethod line CDATA #REQUIRED>
       
   437 //<!ATTLIST OperatorMethod location CDATA #REQUIRED>
       
   438 //<!ATTLIST OperatorMethod mangled CDATA #REQUIRED>
       
   439 //<!ATTLIST OperatorMethod name CDATA #REQUIRED>
       
   440 //<!ATTLIST OperatorMethod pure_virtual (0 | 1) "0">
       
   441 //<!ATTLIST OperatorMethod returns IDREF #REQUIRED>
       
   442 //<!ATTLIST OperatorMethod static (0 | 1) "0">
       
   443 //<!ATTLIST OperatorMethod throw CDATA #IMPLIED>
       
   444 //<!ATTLIST OperatorMethod virtual (0 | 1) "0">
       
   445 const int KOperatorMethodAttributeCount = 6;
       
   446 const EntityAttributeElement KOperatorMethodAttributes[KOperatorMethodAttributeCount]={
       
   447                                                 {KXMLAccessString,EOptionalSimpleAttribute},
       
   448                                                 {KXMLConstString,EBooleanAttribute},
       
   449                                                 {KXMLNameString,ESimpleAttribute},
       
   450                                                 {KXMLPureVirtualString,EBooleanAttribute},
       
   451                                                 {KXMLVirtualString,EBooleanAttribute},
       
   452                                                 {KXMLReturnsString,EIdAttribute}
       
   453                                                 };
       
   454 //<!ELEMENT PointerType EMPTY>
       
   455 //<!ATTLIST PointerType align CDATA #IMPLIED>
       
   456 //<!ATTLIST PointerType attributes CDATA #IMPLIED>
       
   457 //<!ATTLIST PointerType id ID #REQUIRED>
       
   458 //<!ATTLIST PointerType size CDATA #IMPLIED>
       
   459 //<!ATTLIST PointerType type CDATA #REQUIRED>
       
   460 const int KPointerTypeAttributeCount = 1;
       
   461 const EntityAttributeElement KPointerTypeAttributes[KPointerTypeAttributeCount]={
       
   462                                                 {KXMLTypeString,EIdAttribute}
       
   463                                                 };
       
   464 //<!ELEMENT ReferenceType EMPTY>
       
   465 //<!ATTLIST ReferenceType align CDATA #IMPLIED>
       
   466 //<!ATTLIST ReferenceType attributes CDATA #IMPLIED>
       
   467 //<!ATTLIST ReferenceType id ID #REQUIRED>
       
   468 //<!ATTLIST ReferenceType size CDATA #IMPLIED>
       
   469 //<!ATTLIST ReferenceType type CDATA #REQUIRED>
       
   470 const int KReferenceTypeAttributeCount = 1;
       
   471 const EntityAttributeElement KReferenceTypeAttributes[KReferenceTypeAttributeCount]={
       
   472                                                 {KXMLTypeString,EIdAttribute}
       
   473                                                 };
       
   474 
       
   475 //<!ELEMENT Struct (Base)*>
       
   476 //<!ATTLIST Struct abstract (0 | 1) "0">
       
   477 //<!ATTLIST Struct access (public | private | protected) "public">
       
   478 //<!ATTLIST Struct align CDATA #IMPLIED>
       
   479 //<!ATTLIST Struct artificial (0 | 1) "0">
       
   480 //<!ATTLIST Struct attributes CDATA #IMPLIED>
       
   481 //<!ATTLIST Struct bases CDATA #IMPLIED>
       
   482 //<!ATTLIST Struct context IDREF #REQUIRED>
       
   483 //<!ATTLIST Struct file CDATA #REQUIRED>
       
   484 //<!ATTLIST Struct id ID #REQUIRED>
       
   485 //<!ATTLIST Struct incomplete (0 | 1) "0">
       
   486 //<!ATTLIST Struct line CDATA #REQUIRED>
       
   487 //<!ATTLIST Struct location CDATA #REQUIRED>
       
   488 //<!ATTLIST Struct mangled CDATA #REQUIRED>
       
   489 //<!ATTLIST Struct members CDATA #IMPLIED>
       
   490 //<!ATTLIST Struct name CDATA #IMPLIED>
       
   491 //<!ATTLIST Struct size CDATA #IMPLIED>
       
   492 const int KStructAttributeCount = 6;
       
   493 const EntityAttributeElement KStructAttributes[KStructAttributeCount]={
       
   494                                                 {KXMLAccessString,ESimpleAttribute},
       
   495                                                 {KXMLAbstractString,EBooleanAttribute},
       
   496                                                 {KXMLBasesString,EIdAttribute},
       
   497                                                 {KXMLNameString,ESimpleAttribute},
       
   498                                                 {KXMLSizeString,ESimpleAttribute},
       
   499                                                 {KXMLMembersString,EIdAttribute}
       
   500                                                 };
       
   501 
       
   502 //<!ELEMENT Unimplemented EMPTY>
       
   503 //<!ATTLIST Unimplemented function CDATA #IMPLIED>
       
   504 //<!ATTLIST Unimplemented id ID #REQUIRED>
       
   505 //<!ATTLIST Unimplemented node CDATA #REQUIRED>
       
   506 //<!ATTLIST Unimplemented tree_code (187 | 190 | 193) #REQUIRED>
       
   507 //<!ATTLIST Unimplemented tree_code_name (template_type_parm | 
       
   508 //	typename_type | using_decl) #REQUIRED>
       
   509 const int KUnimplementedAttributeCount = 0;
       
   510 //const EntityAttributeElement KUnimplementedAttributes[KUnimplementedAttributeCount]={};
       
   511 
       
   512 //<!ELEMENT Union (Base)*>
       
   513 //<!ATTLIST Union abstract (0 | 1) "0">
       
   514 //<!ATTLIST Union access (public | private | protected) "public">
       
   515 //<!ATTLIST Union align CDATA #IMPLIED>
       
   516 //<!ATTLIST Union artificial (0 | 1) "0">
       
   517 //<!ATTLIST Union attributes CDATA #IMPLIED>
       
   518 //<!ATTLIST Union bases CDATA #IMPLIED>
       
   519 //<!ATTLIST Union context IDREF #REQUIRED>
       
   520 //<!ATTLIST Union file CDATA #REQUIRED>
       
   521 //<!ATTLIST Union id ID #REQUIRED>
       
   522 //<!ATTLIST Union incomplete (0 | 1) "0">
       
   523 //<!ATTLIST Union line CDATA #REQUIRED>
       
   524 //<!ATTLIST Union location CDATA #REQUIRED>
       
   525 //<!ATTLIST Union mangled CDATA #REQUIRED>
       
   526 //<!ATTLIST Union members CDATA #IMPLIED>
       
   527 //<!ATTLIST Union name CDATA #IMPLIED>
       
   528 //<!ATTLIST Union size CDATA #IMPLIED>
       
   529 const int KUnionAttributeCount = 5;
       
   530 const EntityAttributeElement KUnionAttributes[KUnionAttributeCount]={
       
   531                                                 {KXMLAccessString,ESimpleAttribute},
       
   532                                                 {KXMLAlignString,ESimpleAttribute},
       
   533                                                 {KXMLBasesString,EOptionalIdAttribute},
       
   534                                                 {KXMLMembersString,EIdAttribute},
       
   535                                                 {KXMLSizeString,ESimpleAttribute}
       
   536                                                 };
       
   537 
       
   538 const EntityComparisonElement KEntityComparisonTable[KEntityComparisonTableCount]=
       
   539     {
       
   540     {KXMLBaseString,KBaseAttributes,KBaseAttributeCount},
       
   541     {KXMLFundamentalTypeString,KFundamentalTypeAttributes,KFundamentalTypeAttributeCount},
       
   542     {KXMLTypedefString,KTypedefAttributes,KTypedefAttributeCount},
       
   543     {KXMLNamespaceString,KNamespaceAttributes,KNamespaceAttributeCount},
       
   544     {KXMLCvQualifiedTypeString,KCvQualifiedTypeAttributes,KCvQualifiedTypeAttributeCount},
       
   545     {KXMLVariableString,KVariableAttributes,KVariableAttributeCount},
       
   546     {KXMLFundamentalTypeString,KFundamentalTypeAttributes,KFundamentalTypeAttributeCount},
       
   547     {KXMLTypedefString,KTypedefAttributes,KTypedefAttributeCount},
       
   548     {KXMLNamespaceString,KNamespaceAttributes,KNamespaceAttributeCount},
       
   549     {KXMLFunctionString,KFunctionAttributes,KFunctionAttributeCount},
       
   550     {KXMLEnumerationString,KEnumerationAttributes,KEnumerationAttributeCount},
       
   551     {KXMLFieldString,KFieldAttributes,KFieldAttributeCount},
       
   552     {KXMLArgumentString,KArgumentAttributes,KArgumentAttributeCount},
       
   553     {KXMLEllipsisString,NULL,KEllipsisAttributeCount},
       
   554     {KXMLArrayTypeString,KArrayTypeAttributes,KArrayTypeAttributeCount},
       
   555     {KXMLClassString,KClassAttributes,KClassAttributeCount},
       
   556     {KXMLConstructorString,KConstructorAttributes,KConstructorAttributeCount},
       
   557     {KXMLConverterString,NULL,KConverterAttributeCount},
       
   558     {KXMLDestructorString,KDestructorAttributes,KDestructorAttributeCount},
       
   559     {KXMLEnumValueString,KEnumValueAttributes,KEnumValueAttributeCount},
       
   560     {KXMLFileString,NULL,KFileAttributeCount},
       
   561     {KXMLFunctionTypeString,KFunctionTypeAttributes,KFunctionTypeAttributeCount},
       
   562     {KXMLMethodString,KMethodAttributes,KMethodAttributeCount},
       
   563     {KXMLMethodTypeString,KMethodTypeAttributes,KMethodTypeAttributeCount},
       
   564     {KXMLNamespaceAliasString,NULL,KNamespaceAliasAttributeCount},
       
   565     {KXMLOffsetTypeString,NULL,KOffsetTypeAttributeCount},
       
   566     {KXMLOperatorFunctionString,KOperatorFunctionAttributes,KOperatorFunctionAttributeCount},
       
   567     {KXMLOperatorMethodString,KOperatorMethodAttributes,KOperatorMethodAttributeCount},
       
   568     {KXMLPointerTypeString,KPointerTypeAttributes,KPointerTypeAttributeCount},
       
   569     {KXMLReferenceTypeString,KReferenceTypeAttributes,KReferenceTypeAttributeCount},
       
   570     {KXMLStructString,KStructAttributes,KStructAttributeCount},
       
   571     {KXMLUnimplementedString,NULL,KUnimplementedAttributeCount},
       
   572     {KXMLUnionString,KUnionAttributes,KUnionAttributeCount}
       
   573     };
       
   574 
       
   575 
       
   576 
       
   577 // ----------------------------------------------------------------------------
       
   578 // IsProperNode
       
   579 // ----------------------------------------------------------------------------
       
   580 //
       
   581 bool IsProperNode(HANodeIterator node)
       
   582 {
       
   583     bool ret = (DOMNode::ELEMENT_NODE == node->getNodeType());
       
   584 
       
   585     if (ret)
       
   586     {
       
   587         const XMLCh * nodecontext = node.GetAttribute(KXMLContextString);
       
   588         if (nodecontext)
       
   589         {
       
   590             ret = !Equals(nodecontext,KXMLIgnoreContext);
       
   591         }
       
   592     }
       
   593 
       
   594     if (ret)
       
   595     {
       
   596         if ( node.CheckForBooleanAttribute(KXMLArtificialString) )
       
   597         {
       
   598         const XMLCh * nodetype = node->getNodeName();
       
   599 
       
   600         ret = Equals(nodetype,KXMLUnionString) || 
       
   601                  Equals(nodetype,KXMLStructString) ||
       
   602                  Equals(nodetype,KXMLEnumerationString) ||
       
   603                  Equals(nodetype,KXMLClassString);
       
   604         }
       
   605     }
       
   606 
       
   607     return ret;
       
   608 
       
   609 }
       
   610 
       
   611 // ----------------------------------------------------------------------------
       
   612 // IsNamedNode
       
   613 // ----------------------------------------------------------------------------
       
   614 //
       
   615 bool IsNamedNode(HANodeIterator node)
       
   616     {
       
   617     bool ret = (DOMNode::ELEMENT_NODE == node->getNodeType());
       
   618 
       
   619     if (ret)
       
   620     {
       
   621 
       
   622         const XMLCh* name = node.GetAttribute(KXMLNameString);
       
   623 
       
   624         if (!name)
       
   625         {
       
   626             return false;
       
   627         }
       
   628 
       
   629         const XMLCh * nodetype = node->getNodeName();
       
   630         assert(nodetype != NULL);
       
   631 
       
   632         if ( !(Equals(nodetype,KXMLClassString ) ||
       
   633             Equals(nodetype,KXMLEnumerationString ) ||
       
   634             Equals(nodetype,KXMLFunctionString ) ||
       
   635             Equals(nodetype,KXMLNamespaceString ) ||
       
   636             Equals(nodetype,KXMLOperatorFunctionString ) ||
       
   637             Equals(nodetype,KXMLStructString  ) ||
       
   638             Equals(nodetype,KXMLTypedefString  ) ||
       
   639             Equals(nodetype,KXMLUnionString  ) ||
       
   640             Equals(nodetype,KXMLVariableString )) )
       
   641         {
       
   642             ret = false;
       
   643         }
       
   644     
       
   645     }
       
   646 
       
   647     return ret;
       
   648 }
       
   649 
       
   650 // ----------------------------------------------------------------------------
       
   651 // IsFunction
       
   652 // ----------------------------------------------------------------------------
       
   653 //
       
   654 void printXMLCh(const XMLCh* s1)
       
   655 {
       
   656     char * tmp = XMLString::transcode(s1);
       
   657 
       
   658     cout << tmp;
       
   659 
       
   660     XMLString::release(&tmp);
       
   661 }
       
   662 
       
   663 // ----------------------------------------------------------------------------
       
   664 // toString
       
   665 // ----------------------------------------------------------------------------
       
   666 //
       
   667 string toString(const XMLCh* s1)
       
   668 {
       
   669     char* ts1 = XMLString::transcode(s1);
       
   670 	string value;
       
   671 	if(ts1 != NULL)
       
   672 	{
       
   673     value = ts1;
       
   674     XMLString::release(&ts1);
       
   675 	}
       
   676     return value;
       
   677 }
       
   678 
       
   679 // ----------------------------------------------------------------------------
       
   680 // Equals
       
   681 // ----------------------------------------------------------------------------
       
   682 //
       
   683 bool Equals(const XMLCh* s1, const XMLCh* s2)
       
   684 {
       
   685     return XMLString::equals(s1,s2);
       
   686 }
       
   687 
       
   688 
       
   689 // ----------------------------------------------------------------------------
       
   690 // Equals
       
   691 // ----------------------------------------------------------------------------
       
   692 //
       
   693 bool Equals(const char* s1, const char* s2)
       
   694 {
       
   695     return XMLString::equals(s1,s2);    
       
   696 }
       
   697 
       
   698 // ----------------------------------------------------------------------------
       
   699 // Equals
       
   700 // ----------------------------------------------------------------------------
       
   701 //
       
   702 bool Equals(const XMLCh* s1, const char* s2)
       
   703 {
       
   704     XMLCh* ts2 = XMLString::transcode(s2);
       
   705     bool ret = XMLString::equals(s1,ts2);
       
   706     XMLString::release(&ts2);
       
   707     return ret;
       
   708 }
       
   709 
       
   710 // ----------------------------------------------------------------------------
       
   711 // StartsWith
       
   712 // ----------------------------------------------------------------------------
       
   713 //
       
   714 bool StartsWith(const XMLCh* s1, const char* s2)
       
   715 {
       
   716     XMLCh* ts2 = XMLString::transcode(s2);
       
   717     bool ret = XMLString::startsWith(s1,ts2);
       
   718     XMLString::release(&ts2);
       
   719     return ret;
       
   720 }
       
   721 
       
   722 // ----------------------------------------------------------------------------
       
   723 // StartsWith
       
   724 // ----------------------------------------------------------------------------
       
   725 //
       
   726 bool StartsWith(const XMLCh* s1, const XMLCh* s2)
       
   727 {
       
   728     bool ret = XMLString::startsWith(s1,s2);
       
   729     return ret;
       
   730 }
       
   731 
       
   732 // ----------------------------------------------------------------------------
       
   733 // Equals
       
   734 // ----------------------------------------------------------------------------
       
   735 //
       
   736 bool Equals(const char* s2, const XMLCh* s1)
       
   737 {
       
   738     return Equals(s1,s2);
       
   739 }
       
   740 
       
   741 
       
   742 // ----------------------------------------------------------------------------
       
   743 // SetAttribute
       
   744 // ----------------------------------------------------------------------------
       
   745 //
       
   746 void SetAttribute(DOMNode * node, const XMLCh* attribute, const XMLCh* value)
       
   747 {
       
   748     short nodetype = node->getNodeType();
       
   749     assert(nodetype == DOMNode::ELEMENT_NODE);
       
   750 
       
   751     DOMElement * element = static_cast<DOMElement*>(node);
       
   752 
       
   753     element->setAttribute(attribute,value);
       
   754 }
       
   755 
       
   756 // ----------------------------------------------------------------------------
       
   757 // SetAttribute
       
   758 // ----------------------------------------------------------------------------
       
   759 //
       
   760 void SetAttribute(DOMNode * node, const char* attribute, const char* value)
       
   761 {
       
   762     XMLCh* tattribute = XMLString::transcode(attribute);
       
   763     XMLCh* tvalue = XMLString::transcode(value);
       
   764     SetAttribute(node,tattribute,tvalue);
       
   765     XMLString::release(&tattribute);
       
   766     XMLString::release(&tvalue);
       
   767 }
       
   768 
       
   769 // ----------------------------------------------------------------------------
       
   770 // GetAttribute
       
   771 // ----------------------------------------------------------------------------
       
   772 //
       
   773 const XMLCh* GetAttribute(DOMNode * node, const XMLCh* attribute)
       
   774 {
       
   775     DOMNamedNodeMap * attributes = node->getAttributes();
       
   776     
       
   777     if ( !attributes )
       
   778     {
       
   779         return NULL;
       
   780     }
       
   781     
       
   782     DOMNode * attributeId = attributes->getNamedItem(attribute);
       
   783     
       
   784     if ( attributeId )
       
   785     {
       
   786         return attributeId->getNodeValue();
       
   787     }
       
   788 
       
   789     return NULL;
       
   790 }
       
   791 
       
   792 // ----------------------------------------------------------------------------
       
   793 // GetAttribute
       
   794 // ----------------------------------------------------------------------------
       
   795 //
       
   796 const XMLCh* GetAttribute(DOMNode * node, const char * attribute)
       
   797 {
       
   798     XMLCh * idident = XMLString::transcode(attribute);
       
   799     const XMLCh * attributeValue = GetAttribute(node,idident);
       
   800     XMLString::release(&idident);
       
   801 
       
   802     return attributeValue;
       
   803     
       
   804 }
       
   805 
       
   806 // ----------------------------------------------------------------------------
       
   807 // CheckForBooleanAttribute
       
   808 // ----------------------------------------------------------------------------
       
   809 //
       
   810 bool CheckForBooleanAttribute(DOMNode * node, const XMLCh* attribute)
       
   811 {
       
   812     const XMLCh* attributeValue = GetAttribute(node, attribute);
       
   813     
       
   814     if ( attributeValue )
       
   815     {
       
   816         return Equals(attributeValue,"1");
       
   817     }
       
   818     return false;
       
   819 }
       
   820 
       
   821 // ----------------------------------------------------------------------------
       
   822 // CheckForBooleanAttribute
       
   823 // ----------------------------------------------------------------------------
       
   824 //
       
   825 bool CheckForBooleanAttribute(DOMNode * node, const char* attribute)
       
   826 {
       
   827     const XMLCh* attributeValue = GetAttribute(node, attribute);
       
   828     
       
   829     if ( attributeValue )
       
   830     {
       
   831         return Equals(attributeValue,"1");
       
   832     }
       
   833     return false;
       
   834 }
       
   835 
       
   836 // ----------------------------------------------------------------------------
       
   837 // GetSize
       
   838 // ----------------------------------------------------------------------------
       
   839 //
       
   840 const XMLCh* GetSize(HANodeIterator node)
       
   841 {
       
   842 	const XMLCh* size = node.GetAttribute(KXMLSizeString);
       
   843 	
       
   844 	if ( !size )
       
   845 	{
       
   846 		const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   847 
       
   848         assert(type);
       
   849 
       
   850         HANodeIterator typenode(node);
       
   851 
       
   852         bool typefound = typenode.FindNodeById(type);
       
   853 
       
   854         assert(typefound);
       
   855 
       
   856         return GetSize(typenode);		
       
   857 	}
       
   858 
       
   859     return size;
       
   860 }
       
   861 
       
   862 // ----------------------------------------------------------------------------
       
   863 // GetTypeName
       
   864 // ----------------------------------------------------------------------------
       
   865 //
       
   866 string GetTypeName(HANodeIterator node)
       
   867 {
       
   868     const XMLCh* fqname = node.GetAttribute(KXMLBBCFQNameString);
       
   869     
       
   870     if (fqname)
       
   871     {
       
   872         return toString(fqname);
       
   873     }
       
   874 
       
   875     string ret;
       
   876 
       
   877     const XMLCh * nodename = node->getNodeName();
       
   878 
       
   879     if ( Equals(nodename,KXMLEllipsisString) )
       
   880     {
       
   881     ret += " ";
       
   882     ret += "...";
       
   883     ret += ",";
       
   884     }
       
   885     else if ( Equals(nodename, KXMLFunctionTypeString) )
       
   886     {
       
   887         //ret += "(*)";
       
   888         const XMLCh* retType = node.GetAttribute(KXMLReturnsString);    
       
   889         if( retType )
       
   890         {
       
   891             HANodeIterator typenode(node);
       
   892             bool typefound = typenode.FindNodeById(retType);
       
   893             assert(typefound);
       
   894             ret += GetTypeName(typenode) + " ";	
       
   895         }
       
   896     
       
   897         ret += "(*) ";
       
   898         ret += GenerateFunctionSignature(node);
       
   899     }
       
   900     else if ( Equals(nodename, KXMLFundamentalTypeString) )
       
   901     {
       
   902         ret += GenerateFullyQualifiedName(node);
       
   903     }
       
   904     else if ( Equals(nodename, KXMLTypedefString) )
       
   905     {
       
   906         ret += GenerateFullyQualifiedName(node);
       
   907     }
       
   908     else if ( Equals(nodename,KXMLCvQualifiedTypeString) )
       
   909     {
       
   910 
       
   911         const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   912 
       
   913         assert(type);
       
   914 
       
   915         HANodeIterator typenode(node);
       
   916 
       
   917         bool typefound = typenode.FindNodeById(type);
       
   918 
       
   919         assert(typefound);
       
   920 
       
   921          if ( node.CheckForBooleanAttribute(KXMLConstString) )
       
   922         {
       
   923         ret += " const ";
       
   924         }
       
   925         ret += GetTypeName(typenode);		
       
   926     }
       
   927     else if ( Equals(nodename,KXMLArrayTypeString) )
       
   928     {
       
   929         const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   930 
       
   931         assert(type);
       
   932 
       
   933         HANodeIterator typenode(node);
       
   934 
       
   935         bool typefound = typenode.FindNodeById(type);
       
   936 
       
   937         assert(typefound);
       
   938         ret += GetTypeName(typenode);		
       
   939         ret += "[]";
       
   940     }
       
   941     else if ( Equals(nodename,KXMLPointerTypeString) )
       
   942     {
       
   943         const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   944 
       
   945         assert(type);
       
   946 
       
   947         HANodeIterator typenode(node);
       
   948 
       
   949         bool typefound = typenode.FindNodeById(type);
       
   950 
       
   951         assert(typefound);
       
   952         ret += GetTypeName(typenode);
       
   953         if(!Equals(typenode->getNodeName(), KXMLFunctionTypeString) )
       
   954         {
       
   955             ret += "*";
       
   956         }
       
   957     }
       
   958     else if ( Equals(nodename,KXMLReferenceTypeString) )
       
   959     {
       
   960         const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   961 
       
   962         assert(type);
       
   963 
       
   964         HANodeIterator typenode(node);
       
   965 
       
   966         bool typefound = typenode.FindNodeById(type);
       
   967 
       
   968         assert(typefound);
       
   969         ret += GetTypeName(typenode);		
       
   970         ret += "&";
       
   971     }	
       
   972     else
       
   973     {
       
   974         const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
   975 
       
   976         //assert(type);
       
   977         if ( type )
       
   978         {
       
   979             HANodeIterator typenode(node);
       
   980 
       
   981             bool typefound = typenode.FindNodeById(type);
       
   982 
       
   983             assert(typefound);
       
   984             ret += GetTypeName(typenode);
       
   985         }else
       
   986         {
       
   987         ret += GenerateFullyQualifiedName(node);
       
   988         }
       
   989     }
       
   990 
       
   991     XMLCh* fqnamep = XMLString::transcode(ret.c_str());
       
   992     node.SetAttribute(KXMLBBCFQNameString, fqnamep);
       
   993     XMLString::release(&fqnamep);
       
   994     
       
   995     return ret;	
       
   996 }
       
   997 
       
   998 const XMLCh* FindAttributeValueForType(const HANodeIterator& node, const char* attribute)
       
   999 {
       
  1000     XMLCh* ch_attribute = XMLString::transcode(attribute);
       
  1001 	const XMLCh* ret = FindAttributeValueForType(node,ch_attribute);
       
  1002 	XMLString::release(&ch_attribute);
       
  1003 	return ret;
       
  1004 
       
  1005 }
       
  1006 
       
  1007 // ----------------------------------------------------------------------------
       
  1008 // FindAttributeValueForType
       
  1009 // ----------------------------------------------------------------------------
       
  1010 // 
       
  1011 const XMLCh* FindAttributeValueForType(const HANodeIterator& node, const XMLCh* attribute)
       
  1012 {
       
  1013     const XMLCh* size = node.GetAttribute(attribute);
       
  1014     
       
  1015     if (size)
       
  1016     {
       
  1017         return size;
       
  1018     }
       
  1019 
       
  1020 	const XMLCh* type = node.GetAttribute(KXMLTypeString);
       
  1021 
       
  1022     if ( !type )
       
  1023 	{
       
  1024 		return NULL;
       
  1025 	}
       
  1026 
       
  1027 	HANodeIterator typenode(node);
       
  1028 
       
  1029     bool typefound = typenode.FindNodeById(type);
       
  1030 
       
  1031     assert(typefound);
       
  1032 
       
  1033 	return FindAttributeValueForType(typenode,attribute);
       
  1034 }
       
  1035 
       
  1036 // ----------------------------------------------------------------------------
       
  1037 // IsFunction
       
  1038 // ----------------------------------------------------------------------------
       
  1039 //
       
  1040 bool IsFunction(HANodeIterator node) 
       
  1041     {
       
  1042         //Add the return value and parameters to the name (due to overloading)
       
  1043         const XMLCh* name = node.current->getNodeName();
       
  1044 
       
  1045         if (!name)
       
  1046         {
       
  1047             return false;
       
  1048         }
       
  1049 
       
  1050         if ( Equals(name,KXMLConstructorString) ||
       
  1051             Equals(name,KXMLMethodString) ||
       
  1052             Equals(name,KXMLFunctionString) ||
       
  1053             Equals(name,KXMLOperatorFunctionString) ||
       
  1054             Equals(name,KXMLOperatorMethodString) ||
       
  1055             Equals(name,KXMLDestructorString) ||
       
  1056             Equals(name,KXMLFunctionTypeString)
       
  1057             )
       
  1058         {
       
  1059             return true;
       
  1060         }
       
  1061 
       
  1062         return false;
       
  1063     }
       
  1064 
       
  1065 void GetElementNodes(   HANodeIterator node, 
       
  1066                         DOMNodeList* domNodes, 
       
  1067                         std::vector<DOMNode*>& elemNodes)
       
  1068 {
       
  1069     XMLSize_t domNodeCount = domNodes->getLength();         
       
  1070     for(unsigned int i = 0; i < domNodeCount; ++i)
       
  1071     {
       
  1072         DOMNode* domNode = domNodes->item(i);
       
  1073         HANodeIterator nodeit(node);
       
  1074         nodeit.current = domNode;
       
  1075         
       
  1076         short nodetype = nodeit->getNodeType();
       
  1077         if (nodetype == DOMNode::ELEMENT_NODE)
       
  1078         {
       
  1079             elemNodes.push_back(domNodes->item(i));
       
  1080         }
       
  1081     }
       
  1082 }
       
  1083 
       
  1084 // ----------------------------------------------------------------------------
       
  1085 // GenerateFunctionSignature
       
  1086 // Builds function signature which contains function name and all the parameters. 
       
  1087 // ----------------------------------------------------------------------------
       
  1088 //
       
  1089 string GenerateFunctionSignature(HANodeIterator node)
       
  1090 {
       
  1091     short nodetype = node->getNodeType();
       
  1092     assert(nodetype == DOMNode::ELEMENT_NODE);
       
  1093     assert(IsFunction(node));
       
  1094 
       
  1095     string ret;
       
  1096 
       
  1097 	const XMLCh * name = node->getNodeName();
       
  1098 
       
  1099     if ( Equals(name, KXMLDestructorString) )
       
  1100     {
       
  1101         ret += "~";
       
  1102     }
       
  1103     else if ( Equals(name,KXMLOperatorMethodString) || Equals(name,KXMLOperatorFunctionString) )
       
  1104 	{
       
  1105         ret += "operator";
       
  1106 	}
       
  1107 
       
  1108     const XMLCh* nameatt = node.GetAttribute(KXMLNameString);
       
  1109     
       
  1110 	if (nameatt)
       
  1111 	{
       
  1112 		ret += toString(nameatt);
       
  1113 	}
       
  1114 
       
  1115     ret +="(";
       
  1116 
       
  1117     DOMElement * nodeelement = static_cast<DOMElement*>(node.current);
       
  1118     DOMNodeList* childs = nodeelement->getChildNodes();
       
  1119     XMLSize_t childcount = childs->getLength();
       
  1120 
       
  1121     unsigned int i = 0;
       
  1122     for (i = 0; i < childcount; ++i)
       
  1123     {
       
  1124         DOMNode* child = childs->item(i);
       
  1125         HANodeIterator childit(node);
       
  1126         childit.current = child;
       
  1127         
       
  1128         short nodetype = childit->getNodeType();
       
  1129         if (nodetype == DOMNode::ELEMENT_NODE)
       
  1130         {
       
  1131             ret += " " + GetTypeName(childit) + ",";
       
  1132         }
       
  1133 
       
  1134     }
       
  1135      
       
  1136     if (ret[ret.length()-1] == ',')
       
  1137     {
       
  1138         ret.resize(ret.length()-1);
       
  1139     }
       
  1140     ret += " )";
       
  1141 
       
  1142     if ( node.CheckForBooleanAttribute(KXMLConstString) )
       
  1143     {
       
  1144         ret += " const";
       
  1145     }	
       
  1146 
       
  1147     return ret;
       
  1148 }
       
  1149 
       
  1150 // ----------------------------------------------------------------------------
       
  1151 // GenerateFullyQualifiedName
       
  1152 // ----------------------------------------------------------------------------
       
  1153 //
       
  1154 string GenerateFullyQualifiedName(HANodeIterator node)
       
  1155 {
       
  1156     const XMLCh* fqname = node.GetAttribute(KXMLBBCFQNameString);
       
  1157     
       
  1158     if (fqname)
       
  1159     {
       
  1160         return toString(fqname);
       
  1161     }
       
  1162 
       
  1163     string name;
       
  1164 
       
  1165     const XMLCh* nameatt = 0;
       
  1166 	const XMLCh* mangledatt = 0;
       
  1167 
       
  1168     if( IsAnonymousType(node) )
       
  1169     {
       
  1170         // Node is of "anonymous" type so it has not name. 
       
  1171         // Let's use the gccxml generated id instead.
       
  1172         nameatt = node.GetAttribute(KXMLIdString);
       
  1173     }
       
  1174     else
       
  1175     {
       
  1176         nameatt = node.GetAttribute(KXMLNameString);
       
  1177     }
       
  1178 
       
  1179     if ( nameatt )
       
  1180     {
       
  1181         if ( Equals(KXMLNamespaceString,node->getNodeName()) )
       
  1182         {
       
  1183             if ( StartsWith(nameatt,KXMLAnonymousNamespacePrefix) )
       
  1184             {
       
  1185                 name += "<unnamed>";
       
  1186             }
       
  1187             else if ( Equals(KXMLGlobalNamespaceString,nameatt) )
       
  1188             { 
       
  1189                 //Skip the global namespace
       
  1190 
       
  1191             }else
       
  1192             {
       
  1193                 name += toString(nameatt);
       
  1194             }
       
  1195 
       
  1196         }
       
  1197         else if ( IsFunction(node) )
       
  1198 		{
       
  1199 			//Add the return value and parameters to the name (due to overloading)
       
  1200 			// Consider mangled attribute here.
       
  1201 			mangledatt = node.GetAttribute(KXMLMangledString);
       
  1202 			string mangled = toString(mangledatt);
       
  1203 			name += GenerateFunctionSignature(node) + __FUN_MANGLED__ + toString(mangledatt);
       
  1204 
       
  1205         }
       
  1206         else
       
  1207         {
       
  1208             name += toString(nameatt);
       
  1209         }
       
  1210     }
       
  1211 
       
  1212     const XMLCh* contextatt = node.GetAttribute(KXMLContextString);
       
  1213 
       
  1214     if ( contextatt )
       
  1215     {
       
  1216         HANodeIterator basenode(node);
       
  1217         basenode.FindNodeById(contextatt);
       
  1218         string basename = GenerateFullyQualifiedName(basenode);
       
  1219         name = basename + "::" + name;
       
  1220     }
       
  1221 
       
  1222 
       
  1223     if ( nameatt || contextatt)
       
  1224     {
       
  1225         XMLCh* fqnamep = XMLString::transcode(name.c_str());
       
  1226         node.SetAttribute(KXMLBBCFQNameString, fqnamep);
       
  1227         XMLString::release(&fqnamep);
       
  1228     }
       
  1229 
       
  1230     return name;
       
  1231 }
       
  1232 
       
  1233 // ----------------------------------------------------------------------------
       
  1234 // FindComparison
       
  1235 // ----------------------------------------------------------------------------
       
  1236 //
       
  1237 const EntityComparisonElement* FindComparison(const XMLCh* nodeName)
       
  1238 {
       
  1239     int i = 0;
       
  1240     for (i = 0;i < KEntityComparisonTableCount; ++i)
       
  1241     {
       
  1242         if ( Equals(KEntityComparisonTable[i].iEntityName,nodeName) )
       
  1243         {
       
  1244             return &KEntityComparisonTable[i];
       
  1245         }
       
  1246     }
       
  1247     return NULL;
       
  1248 
       
  1249 }
       
  1250 
       
  1251 // ----------------------------------------------------------------------------
       
  1252 // CompareIdLists
       
  1253 // ----------------------------------------------------------------------------
       
  1254 //
       
  1255 bool CompareIdLists(HANodeIterator baseline, HANodeIterator current,const XMLCh* idAttributeName)
       
  1256 {
       
  1257     HANodeIterator newbaseline = baseline;
       
  1258     const XMLCh* baselineids = baseline.GetAttribute(idAttributeName);
       
  1259     
       
  1260     HANodeIterator newcurrent = current;
       
  1261     const XMLCh* currentids = current.GetAttribute(idAttributeName);
       
  1262 
       
  1263     BaseRefVectorOf< XMLCh > * baselineidtokens_ptr = XMLString::tokenizeString (baselineids);
       
  1264     BaseRefVectorOf< XMLCh > * currentidtokens_ptr = XMLString::tokenizeString (currentids);
       
  1265 
       
  1266 	auto_ptr<BaseRefVectorOf< XMLCh > > baselineidtokens(baselineidtokens_ptr);
       
  1267 	auto_ptr<BaseRefVectorOf< XMLCh > > currentidtokens(currentidtokens_ptr);
       
  1268     
       
  1269     for (unsigned int i = 0; i < baselineidtokens->size(); ++i)
       
  1270     {
       
  1271         const XMLCh * baselineid = baselineidtokens->elementAt(i);
       
  1272         const XMLCh * currentid = currentidtokens->elementAt(i);
       
  1273         newbaseline.FindNodeById(baselineid);
       
  1274         newcurrent.FindNodeById(currentid);
       
  1275 
       
  1276         if ( !CompareNodes(newbaseline,newcurrent) )
       
  1277         {
       
  1278             
       
  1279             return false;
       
  1280         }
       
  1281     }
       
  1282 
       
  1283 
       
  1284     return true;
       
  1285 }
       
  1286 
       
  1287 // ----------------------------------------------------------------------------
       
  1288 // CompareNodes
       
  1289 // ----------------------------------------------------------------------------
       
  1290 //
       
  1291 bool CompareNodes(HANodeIterator baseline, HANodeIterator current )
       
  1292 {
       
  1293     assert(Equals(baseline->getNodeName(),current->getNodeName()));
       
  1294 
       
  1295     const EntityComparisonElement* compElem = FindComparison(baseline->getNodeName());
       
  1296 
       
  1297     assert(compElem);
       
  1298 
       
  1299     int i = 0;
       
  1300     for (i = 0;i < compElem->iAttributeCount; ++i)
       
  1301     {
       
  1302         const EntityAttributeElement* attributes = &compElem->iAttributeList[i];
       
  1303 
       
  1304         if ( !CompareAttributes(baseline, current, attributes->iAttributeName, attributes->iAttributeType) )
       
  1305         {
       
  1306             return false;
       
  1307         }
       
  1308     }
       
  1309     return true;
       
  1310 }
       
  1311 
       
  1312 // ----------------------------------------------------------------------------
       
  1313 // CompareFileNames
       
  1314 // ----------------------------------------------------------------------------
       
  1315 //
       
  1316 bool CompareFileNames(string first,string second)
       
  1317 {
       
  1318     if (first.length() != second.length() )
       
  1319     {
       
  1320         return false;
       
  1321     }
       
  1322 
       
  1323     unsigned int i = 0;
       
  1324     for (i = 0; i < first.length(); ++i)
       
  1325     {
       
  1326         if (first.at(i) == '\\' || first.at(i) == '/' )
       
  1327         {
       
  1328             if (second.at(i) != '\\' && second.at(i) != '/' )
       
  1329             {
       
  1330                 return false;
       
  1331             }
       
  1332         } else
       
  1333         {
       
  1334             if ( tolower(first.at(i)) != tolower(second.at(i)) )
       
  1335             {
       
  1336                 return false;
       
  1337             }
       
  1338         }
       
  1339 
       
  1340     }
       
  1341     return true;
       
  1342 }
       
  1343 
       
  1344 // ----------------------------------------------------------------------------
       
  1345 // CompareAttributes
       
  1346 // ----------------------------------------------------------------------------
       
  1347 //
       
  1348 bool CompareAttributes(HANodeIterator baseline, HANodeIterator current, const char* attributeName, TAttributeType attributeType)
       
  1349 {
       
  1350     XMLCh* attributeName2 = XMLString::transcode(attributeName);
       
  1351     bool ret = CompareAttributes(baseline,current,attributeName2,attributeType);
       
  1352     XMLString::release(&attributeName2);
       
  1353     return ret;
       
  1354 
       
  1355 }
       
  1356 
       
  1357 // ----------------------------------------------------------------------------
       
  1358 // CompareAttributes
       
  1359 // ----------------------------------------------------------------------------
       
  1360 //
       
  1361 bool CompareAttributes(HANodeIterator baseline, HANodeIterator current, const XMLCh* attributeName, TAttributeType attributeType)
       
  1362 {
       
  1363     switch (attributeType)
       
  1364     {
       
  1365         case EOptionalTypeAttribute:
       
  1366             {
       
  1367             if ( NULL == baseline.GetAttribute(attributeName) ||
       
  1368                 NULL == current.GetAttribute(attributeName) )
       
  1369                 {
       
  1370                     if ( baseline.GetAttribute(attributeName) ||
       
  1371                          current.GetAttribute(attributeName) )
       
  1372                     {
       
  1373                         return false;
       
  1374                     }
       
  1375                     else
       
  1376                     {
       
  1377                         return true;
       
  1378                     }
       
  1379                     break;
       
  1380                 }
       
  1381             }
       
  1382         case ETypeAttribute:
       
  1383             {
       
  1384             const XMLCh * baselineid = baseline.GetAttribute(attributeName);
       
  1385             const XMLCh * currentid = current.GetAttribute(attributeName);
       
  1386             assert(baselineid);
       
  1387             assert(baselineid);
       
  1388             HANodeIterator newbaseline(baseline);
       
  1389             HANodeIterator newcurrent(current);
       
  1390             bool ret1=newbaseline.FindNodeById(baselineid);
       
  1391             bool ret2=newcurrent.FindNodeById(currentid);
       
  1392             assert(ret1 && ret2);
       
  1393             string baselinetype = GetTypeName(newbaseline);
       
  1394             string currenttype = GetTypeName(newcurrent);
       
  1395 
       
  1396             // Test if either of the types is incomplete.
       
  1397             // If either one is incomplete, the size and alignment
       
  1398             // does not match. We don't check the size and alignment
       
  1399             // for incomplete types, since the actual types are 
       
  1400             // checked with their headers.
       
  1401             bool bincomplete = newbaseline.CheckForBooleanAttribute(KXMIncompleteString);
       
  1402             bool cincomplete = newcurrent.CheckForBooleanAttribute(KXMIncompleteString);
       
  1403 	
       
  1404             if( !bincomplete && !cincomplete )
       
  1405                 {
       
  1406 			    const XMLCh * baselinesize = FindAttributeValueForType(newbaseline,KXMLSizeString);
       
  1407 			    const XMLCh * currentsize = FindAttributeValueForType(newcurrent,KXMLSizeString);
       
  1408 
       
  1409 			    const XMLCh * baselinealign = FindAttributeValueForType(newbaseline,KXMLAlignString);
       
  1410 			    const XMLCh * currentalign = FindAttributeValueForType(newcurrent,KXMLAlignString);
       
  1411 
       
  1412 			    if ( !baselinesize )
       
  1413 			        {
       
  1414 				    baselinesize = baselinealign;
       
  1415 			        }
       
  1416 				
       
  1417 			    if ( !currentsize )
       
  1418 			        {
       
  1419 				    currentsize = currentalign;
       
  1420 			        }
       
  1421 
       
  1422 			    return baselinetype == currenttype && Equals(baselinesize,currentsize) && Equals(baselinealign, currentalign);
       
  1423                 }
       
  1424             else
       
  1425                 {
       
  1426                 // either or both of the types were incomplete, so compare just the type names.
       
  1427                 return baselinetype == currenttype;
       
  1428                 }
       
  1429             }
       
  1430         
       
  1431         case EOptionalSimpleAttribute:
       
  1432             {
       
  1433             if ( NULL == baseline.GetAttribute(attributeName) ||
       
  1434                 NULL == current.GetAttribute(attributeName) )
       
  1435                 {
       
  1436                     if ( baseline.GetAttribute(attributeName) ||
       
  1437                          current.GetAttribute(attributeName) )
       
  1438                     {
       
  1439                         return false;
       
  1440                     }
       
  1441                     else
       
  1442                     {
       
  1443                         return true;
       
  1444                     }
       
  1445                     break;
       
  1446                 }
       
  1447             }
       
  1448         case ESimpleAttribute:
       
  1449         case EBooleanAttribute:
       
  1450         {
       
  1451             if (!Equals(
       
  1452                         baseline.GetAttribute(attributeName),
       
  1453                         current.GetAttribute(attributeName)
       
  1454                         )
       
  1455                 )
       
  1456             {
       
  1457                 return false;
       
  1458             }
       
  1459             break;
       
  1460         }
       
  1461 
       
  1462         case EOptionalIdAttribute:
       
  1463         {
       
  1464             if ( NULL == baseline.GetAttribute(attributeName) || 
       
  1465                 NULL == current.GetAttribute(attributeName))
       
  1466             {
       
  1467                 if ( baseline.GetAttribute(attributeName) || 
       
  1468                     current.GetAttribute(attributeName) )
       
  1469                 {
       
  1470                     return false;
       
  1471                 }
       
  1472                 else
       
  1473                 {
       
  1474                     return true;
       
  1475                 }
       
  1476                 break;
       
  1477             }
       
  1478         }
       
  1479         case EIdAttribute:
       
  1480         {
       
  1481             if (!CompareIdLists(baseline, current, attributeName))
       
  1482             {
       
  1483                 return false;
       
  1484             }
       
  1485             break;
       
  1486         }
       
  1487 
       
  1488         default:
       
  1489         {
       
  1490             //Attribute type unknown
       
  1491         assert(false);
       
  1492         }
       
  1493     }
       
  1494     return true;
       
  1495 }
       
  1496 
       
  1497 // ----------------------------------------------------------------------------
       
  1498 // CalcDerivedAccessModifier
       
  1499 // ----------------------------------------------------------------------------
       
  1500 //
       
  1501 #if 0
       
  1502 TAccess CalcDerivedAccessModifier(TAccess member, TAccess inheritance)
       
  1503 {
       
  1504 	TAccess ret=EAccessGlobal;
       
  1505 	switch (inheritance)
       
  1506 	{
       
  1507 	case EAccessGlobal: 
       
  1508 	case EAccessPublic:
       
  1509 		switch(member)
       
  1510 		{
       
  1511 		case EAccessGlobal:
       
  1512 			ret = member;
       
  1513 			break;
       
  1514 		case EAccessPublic:
       
  1515 			ret = member;
       
  1516 			break;
       
  1517 		case EAccessProtected:
       
  1518 			ret = member;
       
  1519 			break;
       
  1520 		case EAccessPrivate:
       
  1521 			ret = EAccessHidden;
       
  1522 			break;
       
  1523         case EAccessHidden:
       
  1524             ret = member;
       
  1525             break;
       
  1526 		default:
       
  1527 			assert(false);
       
  1528 			break;
       
  1529 		}
       
  1530 		break;
       
  1531 	case EAccessProtected:
       
  1532 		switch(member)
       
  1533 		{
       
  1534 		case EAccessGlobal:
       
  1535 			ret = member;
       
  1536 			break;
       
  1537 		case EAccessPublic:
       
  1538 			ret = EAccessProtected;
       
  1539 			break;
       
  1540 		case EAccessProtected:
       
  1541 			ret = EAccessProtected;
       
  1542 			break;
       
  1543 		case EAccessPrivate:
       
  1544 			ret = EAccessHidden;
       
  1545 			break;
       
  1546         case EAccessHidden:
       
  1547             ret = member;
       
  1548             break;
       
  1549 		default:
       
  1550 			assert(false);
       
  1551 			break;
       
  1552 		}
       
  1553 		break;
       
  1554 	case EAccessPrivate:
       
  1555 		switch(member)
       
  1556 		{
       
  1557 		case EAccessGlobal:
       
  1558 			ret = member;
       
  1559 			break;
       
  1560 		case EAccessPublic:
       
  1561 			ret = EAccessHidden;
       
  1562 			break;
       
  1563 		case EAccessProtected:
       
  1564 			ret = EAccessHidden;
       
  1565 			break;
       
  1566 		case EAccessPrivate:
       
  1567 			ret = EAccessHidden;
       
  1568 			break;
       
  1569         case EAccessHidden:
       
  1570             ret = EAccessHidden;
       
  1571             break;
       
  1572 		default:
       
  1573 			assert(false);
       
  1574 			break;
       
  1575 		}
       
  1576 		break;
       
  1577 	default:
       
  1578 		assert(false);
       
  1579 		break;
       
  1580 	}
       
  1581 	return ret;
       
  1582 }
       
  1583 #endif
       
  1584 
       
  1585 // ----------------------------------------------------------------------------
       
  1586 // CalcAccessModifier
       
  1587 // ----------------------------------------------------------------------------
       
  1588 //
       
  1589 TAccess CalcAccessModifier(HANodeIterator node)
       
  1590 {
       
  1591     const XMLCh * ac = node.GetAttribute(KXMLAccessString);
       
  1592 
       
  1593     TAccess ret = EAccessGlobal;
       
  1594 
       
  1595     if ( !ac )
       
  1596     {
       
  1597         ret = EAccessGlobal;
       
  1598     } 
       
  1599     else if ( Equals(ac,KXMLPublicString) )
       
  1600     {
       
  1601         ret = EAccessPublic;
       
  1602     } 
       
  1603     else if ( Equals(ac,KXMLProtectedString) )
       
  1604     {
       
  1605         ret = EAccessProtected;
       
  1606     } 
       
  1607     else if ( Equals(ac,KXMLPrivateString) )
       
  1608     {
       
  1609         ret = EAccessPrivate;
       
  1610     }
       
  1611     else
       
  1612     {
       
  1613         assert(false);
       
  1614     }
       
  1615 
       
  1616     return ret;
       
  1617 
       
  1618 }
       
  1619 
       
  1620 // ----------------------------------------------------------------------------
       
  1621 // CheckAccessModifier
       
  1622 // ----------------------------------------------------------------------------
       
  1623 //
       
  1624 bool CheckAccessModifier(HANodeIterator baseline,HANodeIterator current)
       
  1625 {
       
  1626     TAccess baselineaccess = CalcAccessModifier(baseline);
       
  1627     TAccess currentaccess = CalcAccessModifier(current);
       
  1628 	return CheckAccessModifier(baselineaccess,currentaccess);
       
  1629 }
       
  1630 
       
  1631 // ----------------------------------------------------------------------------
       
  1632 // CheckAccessModifier
       
  1633 // ----------------------------------------------------------------------------
       
  1634 //
       
  1635 bool CheckAccessModifier(TAccess baselineaccess,TAccess currentaccess)
       
  1636 {
       
  1637     return (currentaccess <= baselineaccess);
       
  1638 }
       
  1639 
       
  1640 // ----------------------------------------------------------------------------
       
  1641 // CompareNames
       
  1642 // ----------------------------------------------------------------------------
       
  1643 //
       
  1644 bool CompareNames(HANodeIterator baseline, HANodeIterator current)
       
  1645 {
       
  1646     const XMLCh * basename = baseline.GetAttribute(KXMLNameString);
       
  1647     const XMLCh * currentname = current.GetAttribute(KXMLNameString);
       
  1648 
       
  1649     if ( basename == NULL || currentname == NULL )
       
  1650     {
       
  1651         return false;
       
  1652     }
       
  1653 
       
  1654     return Equals(basename,currentname);
       
  1655 }
       
  1656 
       
  1657 // ----------------------------------------------------------------------------
       
  1658 // ClassIsDerivable
       
  1659 // ----------------------------------------------------------------------------
       
  1660 //
       
  1661 bool ClassIsDerivable(HANodeIterator node)
       
  1662 {
       
  1663     return ( 
       
  1664             (
       
  1665              node.CheckForBooleanAttribute(KXMLBBCPublicConstructorString) ||
       
  1666              node.CheckForBooleanAttribute(KXMLBBCProtectedConstructorString)
       
  1667             )&&
       
  1668             (
       
  1669              Equals(node.GetAttribute(KXMLBBCDestructorAccessString),KXMLBBCAccessPublicString) ||
       
  1670              Equals(node.GetAttribute(KXMLBBCDestructorAccessString),KXMLBBCAccessProtectedString)
       
  1671             )
       
  1672            );
       
  1673 
       
  1674 }
       
  1675 
       
  1676 // ----------------------------------------------------------------------------
       
  1677 // ClassIsInstantiable
       
  1678 // ----------------------------------------------------------------------------
       
  1679 //
       
  1680 bool ClassIsInstantiable(HANodeIterator node)
       
  1681 {
       
  1682     return 	node.CheckForBooleanAttribute(KXMLBBCPublicConstructorString) &&
       
  1683     Equals(node.GetAttribute(KXMLBBCDestructorAccessString),KXMLBBCAccessPublicString);
       
  1684 }
       
  1685 
       
  1686 
       
  1687 // ----------------------------------------------------------------------------
       
  1688 // FindParentContext
       
  1689 // ----------------------------------------------------------------------------
       
  1690 //
       
  1691 bool FindParentContext(HANodeIterator memberNode, HANodeIterator& parentNode)
       
  1692 {
       
  1693     if ( Equals(memberNode->getNodeName(),KXMLEnumValueString) )
       
  1694     {
       
  1695         parentNode.current = memberNode->getParentNode();
       
  1696 		return true;
       
  1697     }
       
  1698 
       
  1699     const XMLCh* contextid = memberNode.GetAttribute(KXMLContextString);
       
  1700 
       
  1701     if (contextid)
       
  1702     {		
       
  1703         bool ret = parentNode.FindNodeById(contextid);
       
  1704         return ret;
       
  1705     }
       
  1706     
       
  1707     return false;
       
  1708 }
       
  1709 
       
  1710 // ----------------------------------------------------------------------------
       
  1711 // CheckAccessibility
       
  1712 // ----------------------------------------------------------------------------
       
  1713 //
       
  1714 bool CheckAccessibility(HANodeIterator memberNode)
       
  1715 {
       
  1716     bool dummy=false;
       
  1717     return CheckAccessibility(memberNode, dummy);
       
  1718 }
       
  1719 
       
  1720 // ----------------------------------------------------------------------------
       
  1721 // CheckAccessibility
       
  1722 // ----------------------------------------------------------------------------
       
  1723 //
       
  1724 bool CheckAccessibility(HANodeIterator memberNode, bool & exposedByInline)
       
  1725 {
       
  1726     TAccess access = CalcAccessModifier(memberNode);
       
  1727     
       
  1728     HANodeIterator parentNode(memberNode);
       
  1729     if ( !FindParentContext(memberNode, parentNode) )
       
  1730     {
       
  1731         // Not a member of a class, so this is accessible
       
  1732         return true;
       
  1733     }
       
  1734         
       
  1735 	return CheckAccessibility(parentNode, exposedByInline, access);
       
  1736 }
       
  1737 
       
  1738 // ----------------------------------------------------------------------------
       
  1739 // CheckAccessibility
       
  1740 // ----------------------------------------------------------------------------
       
  1741 //
       
  1742 bool CheckAccessibility(HANodeIterator parentNode, bool & exposedByInline, TAccess access)
       
  1743 {
       
  1744     if ( !CheckAccessibility(parentNode,exposedByInline) )
       
  1745     {
       
  1746         return false;
       
  1747     }
       
  1748 
       
  1749     if ( EAccessPublic >= access )
       
  1750     {
       
  1751         return true;
       
  1752     }
       
  1753 
       
  1754 	if ( EAccessHidden == access )
       
  1755     {
       
  1756         return false;
       
  1757     }
       
  1758 
       
  1759 	if ( ClassIsDerivable(parentNode) )
       
  1760     {
       
  1761         if ( EAccessProtected == access )
       
  1762         {
       
  1763             // Protected methods are accessible by derived classes
       
  1764             return true; 
       
  1765         }
       
  1766 
       
  1767         if ( 
       
  1768                 EAccessPrivate == access &&
       
  1769                 parentNode.CheckForBooleanAttribute(KXMLBBCProtectedInlineString)
       
  1770             )
       
  1771         {
       
  1772             // Although this method is private, it might be possible that it
       
  1773             // is accessed by protected inline function. Because this is derivable
       
  1774             // class this private method might be exposed by the protected inline
       
  1775             // function.
       
  1776             exposedByInline = true;
       
  1777             return true;
       
  1778         }
       
  1779     }
       
  1780 
       
  1781 	if ( parentNode.CheckForBooleanAttribute(KXMLBBCPublicInlineString) )
       
  1782     {
       
  1783         // Class has public inline function(s) and it is possible that they
       
  1784         // are exposing some private stuff.
       
  1785         exposedByInline = true;
       
  1786         return true;
       
  1787     }
       
  1788 
       
  1789     return false;
       
  1790 }
       
  1791 
       
  1792 // ----------------------------------------------------------------------------
       
  1793 // IsAnonymous
       
  1794 // ----------------------------------------------------------------------------
       
  1795 //
       
  1796 bool IsAnonymous(HANodeIterator node)
       
  1797 {
       
  1798     const XMLCh* nodename = node.GetAttribute(KXMLNameString);
       
  1799 
       
  1800     //If the name starts with the character KAnonymousName 
       
  1801     // this is anonymous
       
  1802     if (nodename)
       
  1803     {
       
  1804         return StartsWith(nodename,KAnonymousName);
       
  1805     }else
       
  1806     {
       
  1807         return true;
       
  1808     }
       
  1809 }
       
  1810 
       
  1811 // ----------------------------------------------------------------------------
       
  1812 // IsAnonymousType
       
  1813 // ----------------------------------------------------------------------------
       
  1814 //
       
  1815 bool IsAnonymousType(HANodeIterator node)
       
  1816 {
       
  1817     const XMLCh* nodetypeid = node.GetAttribute(KXMLTypeString);
       
  1818 
       
  1819     if (nodetypeid)
       
  1820     {
       
  1821         //The node has type attribute so check the parent type for 
       
  1822         // anonymity
       
  1823         HANodeIterator typenode(node);
       
  1824         bool ret = typenode.FindNodeById(nodetypeid);
       
  1825         assert(ret);
       
  1826         
       
  1827         return IsAnonymousType(typenode);
       
  1828     }
       
  1829     
       
  1830     const XMLCh* nodename = node.GetAttribute(KXMLNameString);
       
  1831     const XMLCh* nodetypename = node->getNodeName();
       
  1832 
       
  1833     if ( nodename )
       
  1834     {
       
  1835         if ( Equals(KXMLEnumerationString, nodetypename) && IsAnonymous(node) )
       
  1836         {
       
  1837             //This is anonymous enumeration
       
  1838             return true;
       
  1839         }
       
  1840         //The node does have name so this is not anonymous
       
  1841         return false;	
       
  1842     }
       
  1843 
       
  1844     
       
  1845     if ( !Equals(KXMLUnionString, nodetypename) &&
       
  1846         !Equals(KXMLStructString, nodetypename) &&
       
  1847         !Equals(KXMLEnumerationString, nodetypename) )
       
  1848     {
       
  1849         return false;
       
  1850     }
       
  1851 
       
  1852     //If there is no type and no name attributes the type is anonymous
       
  1853     return true;
       
  1854 }
       
  1855 
       
  1856 // ----------------------------------------------------------------------------
       
  1857 // FindAnonymousType
       
  1858 // ----------------------------------------------------------------------------
       
  1859 //
       
  1860 bool FindAnonymousType(HANodeIterator node, HANodeIterator& anonymousnode)
       
  1861 {
       
  1862     const XMLCh* nodetypeid = node.GetAttribute(KXMLTypeString);
       
  1863 
       
  1864     if (nodetypeid)
       
  1865     {
       
  1866         //The node has type attribute so check the parent type for 
       
  1867         // anonymity
       
  1868         HANodeIterator typenode(node);
       
  1869         bool ret = typenode.FindNodeById(nodetypeid);
       
  1870         assert(ret);
       
  1871         
       
  1872         return FindAnonymousType(typenode,anonymousnode);
       
  1873     }
       
  1874     
       
  1875     const XMLCh* nodename = node.GetAttribute(KXMLNameString);
       
  1876     const XMLCh* nodetypename = node->getNodeName();
       
  1877 
       
  1878     if ( nodename && !(Equals(KXMLEnumerationString, nodetypename) && IsAnonymous(node)) )
       
  1879     {
       
  1880         //The node does have name so this is not anonymous
       
  1881         return false;
       
  1882     }
       
  1883 
       
  1884     //If there is no type and no name attributes the type is anonymous
       
  1885     anonymousnode.current = node.current;
       
  1886     return true;
       
  1887 }
       
  1888 
       
  1889 // ----------------------------------------------------------------------------
       
  1890 // ClassPrimaryBase
       
  1891 // ----------------------------------------------------------------------------
       
  1892 //
       
  1893 bool ClassPrimaryBase(const HANodeIterator& classnode,HANodeIterator& primarybase )
       
  1894 {
       
  1895     //Iterate through the base classes
       
  1896     DOMNodeList* childs = classnode.GetElementsByTagName(KXMLBaseString);
       
  1897    
       
  1898 	if (childs)
       
  1899 	{
       
  1900 		XMLSize_t childcount = childs->getLength();
       
  1901 
       
  1902 		for (unsigned int i = 0; i < childcount; ++i)
       
  1903 		{
       
  1904 			HANodeIterator classit(classnode);
       
  1905 			classit.current = childs->item(i);
       
  1906 
       
  1907 			//If the subclass' offset is zero, it is the primary base
       
  1908 			if ( Equals( KXML0String, classit.GetAttribute(KXMLOffsetString)) )
       
  1909 			{
       
  1910 				bool found = primarybase.FindNodeById(classit.GetAttribute(KXMLTypeString));
       
  1911 				assert(found);
       
  1912 				
       
  1913 				if ( primarybase.CheckForBooleanAttribute(KXMLBBCVirtualString) )
       
  1914 				{
       
  1915 					return true;
       
  1916 				} else
       
  1917 				{
       
  1918 					return false;
       
  1919 				}
       
  1920 			}
       
  1921 		}
       
  1922 	}
       
  1923 	return false;
       
  1924 }
       
  1925 
       
  1926 // ----------------------------------------------------------------------------
       
  1927 // ClassOrderMembers
       
  1928 // ----------------------------------------------------------------------------
       
  1929 //
       
  1930 void ClassOrderMembers(HANodeIterator node,
       
  1931                                     vector<DOMNode*>& virtualMethods,
       
  1932                                     vector<DOMNode*>& inlineMethods,
       
  1933                                     vector<DOMNode*>& exportedMethods,
       
  1934                                     vector<DOMNode*>& methods,
       
  1935                                     vector<DOMNode*>& fields,
       
  1936                                     vector<DOMNode*>& others)
       
  1937 {
       
  1938     const XMLCh* attributeValue = node.GetAttribute(KXMLMembersString);
       
  1939     if (attributeValue)
       
  1940     {
       
  1941         BaseRefVectorOf< XMLCh > * memberids_ptr = XMLString::tokenizeString(attributeValue);
       
  1942 		auto_ptr<BaseRefVectorOf< XMLCh > > memberids(memberids_ptr);
       
  1943 
       
  1944         for (unsigned int i = 0; i < memberids->size(); ++i)
       
  1945         {
       
  1946             const XMLCh * memberid = memberids->elementAt(i);
       
  1947             
       
  1948             HANodeIterator member(node);
       
  1949 
       
  1950             if ( member.FindNodeById(memberid) )
       
  1951             {	
       
  1952 
       
  1953                 if ( !IsProperNode(member) )
       
  1954                 {
       
  1955                     continue;
       
  1956                 }
       
  1957                 //Put it in the right vector
       
  1958                 const XMLCh* membernodename = member->getNodeName();
       
  1959                 assert(membernodename != NULL);
       
  1960                 if ( IsFunction(member) )
       
  1961                 {
       
  1962                     //Check for export
       
  1963                     const XMLCh* attributeValue = member.GetAttribute(KXMLAttributeString);                            
       
  1964 					bool normalMethod = true;
       
  1965 
       
  1966                     //Check for virtuality 
       
  1967                     if ( member.CheckForBooleanAttribute(KXMLVirtualString) ||
       
  1968                          member.CheckForBooleanAttribute(KXMLPureVirtualString) )
       
  1969                     {
       
  1970                         //printMember(member);
       
  1971                         //DEBUG_PRINT(" is virtual member\n");
       
  1972                         //Method is virtual
       
  1973                         virtualMethods.push_back(member.current);
       
  1974 						normalMethod = false;
       
  1975                     }
       
  1976                     //Check for export
       
  1977                     if ( attributeValue && Equals(attributeValue,KXMLExportedString)
       
  1978                             )
       
  1979                     {
       
  1980                         //printMember(member);
       
  1981                         //DEBUG_PRINT(" is exported or inline method\n");
       
  1982                         //Method is exported
       
  1983                         exportedMethods.push_back(member.current);
       
  1984 						normalMethod = false;
       
  1985                     }
       
  1986                     //Check for inline
       
  1987                     if ( member.CheckForBooleanAttribute(KXMLInlineString)
       
  1988                             )
       
  1989                     {
       
  1990                         //printMember(member);
       
  1991                         //DEBUG_PRINT(" is exported or inline method\n");
       
  1992                         //Method is exported
       
  1993                         inlineMethods.push_back(member.current);
       
  1994 						normalMethod = false;
       
  1995                     }
       
  1996 
       
  1997                     //Normal method
       
  1998                     if ( normalMethod )
       
  1999 					{
       
  2000                         //printMember(member);
       
  2001                         //DEBUG_PRINT(" is normal method\n");
       
  2002                         methods.push_back(member.current);
       
  2003                     }
       
  2004                     
       
  2005                 } else if ( Equals(membernodename,KXMLFieldString) )
       
  2006                 {
       
  2007                     //printMember(member);
       
  2008                     //DEBUG_PRINT(" is field\n");
       
  2009                     fields.push_back(member.current);
       
  2010 
       
  2011                 } else
       
  2012                 {
       
  2013                     //printMember(member);
       
  2014                     //DEBUG_PRINT(" is other member\n");
       
  2015                     others.push_back(member.current);
       
  2016                 }
       
  2017 
       
  2018                 
       
  2019             }
       
  2020             else
       
  2021             {
       
  2022                 //The tree is broken
       
  2023                 assert(false);
       
  2024             }
       
  2025         }
       
  2026 
       
  2027     }    
       
  2028 }
       
  2029 
       
  2030 // ----------------------------------------------------------------------------
       
  2031 // ClassOrderMembers
       
  2032 // ----------------------------------------------------------------------------
       
  2033 //
       
  2034 void ClassOrderMembers(HANodeIterator node,
       
  2035                                     vector<DOMNode*>& virtualMethods,
       
  2036                                     vector<DOMNode*>& inlineMethods,
       
  2037                                     vector<DOMNode*>& exportedMethods,
       
  2038                                     vector<DOMNode*>& exportedVirtualMethods,
       
  2039                                     vector<DOMNode*>& methods,
       
  2040                                     vector<DOMNode*>& fields,
       
  2041                                     vector<DOMNode*>& others)
       
  2042 {
       
  2043     const XMLCh* attributeValue = node.GetAttribute(KXMLMembersString);
       
  2044     
       
  2045     if (attributeValue)
       
  2046     {
       
  2047         BaseRefVectorOf< XMLCh > * memberids_ptr = XMLString::tokenizeString(attributeValue);
       
  2048 		auto_ptr<BaseRefVectorOf< XMLCh > > memberids(memberids_ptr);
       
  2049 
       
  2050         for (unsigned int i = 0; i < memberids->size(); ++i)
       
  2051         {
       
  2052             const XMLCh * memberid = memberids->elementAt(i);
       
  2053             
       
  2054             HANodeIterator member(node);
       
  2055 
       
  2056             if ( member.FindNodeById(memberid) )
       
  2057             {	
       
  2058 
       
  2059                 if ( !IsProperNode(member) )
       
  2060                 {
       
  2061                     continue;
       
  2062                 }
       
  2063                 //Put it in the right vector
       
  2064                 const XMLCh* membernodename = member->getNodeName();
       
  2065                 assert(membernodename != NULL);
       
  2066                 if ( IsFunction(member) )
       
  2067                 {
       
  2068                     //Check for export
       
  2069                     const XMLCh* attributeValue = member.GetAttribute(KXMLAttributeString);                            
       
  2070 					bool normalMethod = true;
       
  2071                     bool virtualMethod = false;
       
  2072                     bool exportedMethod = false;
       
  2073 
       
  2074                     //Check for virtuality 
       
  2075                     if ( member.CheckForBooleanAttribute(KXMLVirtualString) ||
       
  2076                          member.CheckForBooleanAttribute(KXMLPureVirtualString) )
       
  2077                     {
       
  2078                         //printMember(member);
       
  2079                         //DEBUG_PRINT(" is virtual member\n");
       
  2080                         //Method is virtual
       
  2081                         virtualMethods.push_back(member.current);
       
  2082 						normalMethod = false;
       
  2083                         virtualMethod = true;
       
  2084                     }
       
  2085                     //Check for export
       
  2086                     if ( attributeValue && Equals(attributeValue,KXMLExportedString) )
       
  2087                     {
       
  2088                         //printMember(member);
       
  2089                         //DEBUG_PRINT(" is exported or inline method\n");
       
  2090                         //Method is exported
       
  2091                         exportedMethods.push_back(member.current);
       
  2092 						normalMethod = false;
       
  2093                         exportedMethod = true;
       
  2094                     }
       
  2095                     /*if (virtualMethod && exportedMethod)
       
  2096                     {
       
  2097                         virtualMethods.pop_back();
       
  2098                         exportedMethods.pop_back();
       
  2099                         exportedVirtualMethods.push_back(member.current);
       
  2100                     }*/
       
  2101                     //Check for inline
       
  2102                     if ( member.CheckForBooleanAttribute(KXMLInlineString) )
       
  2103                     {
       
  2104                         //printMember(member);
       
  2105                         //DEBUG_PRINT(" is exported or inline method\n");
       
  2106                         //Method is exported
       
  2107                         inlineMethods.push_back(member.current);
       
  2108 						normalMethod = false;
       
  2109                     }
       
  2110 
       
  2111                     //Normal method
       
  2112                     if ( normalMethod )
       
  2113 					{
       
  2114                         //printMember(member);
       
  2115                         //DEBUG_PRINT(" is normal method\n");
       
  2116                         methods.push_back(member.current);
       
  2117                     }
       
  2118                     
       
  2119                 } else if ( Equals(membernodename,KXMLFieldString) )
       
  2120                 {
       
  2121                     //printMember(member);
       
  2122                     //DEBUG_PRINT(" is field\n");
       
  2123                     fields.push_back(member.current);
       
  2124 
       
  2125                 } else
       
  2126                 {
       
  2127                     //printMember(member);
       
  2128                     //DEBUG_PRINT(" is other member\n");
       
  2129                     others.push_back(member.current);
       
  2130                 }
       
  2131 
       
  2132                 
       
  2133             }
       
  2134             else
       
  2135             {
       
  2136                 //The tree is broken
       
  2137                 assert(false);
       
  2138             }
       
  2139         }
       
  2140         
       
  2141     }    
       
  2142 }
       
  2143 
       
  2144 // ----------------------------------------------------------------------------
       
  2145 // ClassGenerateVirtualTable
       
  2146 // ----------------------------------------------------------------------------
       
  2147 //
       
  2148 const NodeIndex::vtable_t& ClassGenerateVirtualTable(HANodeIterator& classnode)
       
  2149 {	
       
  2150 	string vtablename = GenerateFullyQualifiedName(classnode);
       
  2151 	
       
  2152 	//Notice that this does not clear vtable, if one already exists
       
  2153 	const NodeIndex::vtable_t* vtable = classnode.iNodeIndex.AddEmptyVirtualTable(vtablename);
       
  2154 
       
  2155 	if ( 0 != vtable->size() )
       
  2156 	{
       
  2157 		//The vtable already exists
       
  2158 		return *vtable;
       
  2159 	}
       
  2160 	else
       
  2161 	{
       
  2162 		vector<DOMNode*> virtualMethods;
       
  2163 		vector<DOMNode*> inlineMethods;
       
  2164 		vector<DOMNode*> exportedMethods;
       
  2165 		vector<DOMNode*> methods;
       
  2166 		vector<DOMNode*> fields;
       
  2167 		vector<DOMNode*> others;
       
  2168 
       
  2169 		ClassOrderMembers(classnode, virtualMethods, inlineMethods, exportedMethods,
       
  2170 						methods, fields, others);
       
  2171 
       
  2172 		HANodeIterator primarybase(classnode);
       
  2173 		//Lets check if we have primary base
       
  2174 		if ( ClassPrimaryBase( classnode,primarybase ) )
       
  2175 		{
       
  2176 			//First copy the virtual table of primary base
       
  2177 			const NodeIndex::vtable_t& primvtable = ClassGenerateVirtualTable(primarybase);
       
  2178 			if (primvtable.size())
       
  2179 			{
       
  2180 				NodeIndex::vtable_t::const_iterator it = primvtable.begin();
       
  2181 				for (; it != primvtable.end(); ++it)
       
  2182 				{
       
  2183 					classnode.iNodeIndex.AddVirtualFunction(vtablename,it->first,it->second);
       
  2184 				}
       
  2185 
       
  2186 				//Then add the new virtual functions and overwritings of the other bases.
       
  2187 				unsigned int i = 0;
       
  2188 				for ( i = 0; i < virtualMethods.size(); ++i)
       
  2189 				{
       
  2190 					HANodeIterator functionnode(classnode);
       
  2191 					functionnode.current = virtualMethods[i];
       
  2192 
       
  2193 					//We assume that the primary base includes virtual destructor so we can skip it
       
  2194 					// here (it overwrites the place from primary base)
       
  2195 					const XMLCh* nodetype = functionnode->getNodeName();
       
  2196 		            if ( Equals(nodetype,KXMLDestructorString) )
       
  2197 					{
       
  2198 						continue;
       
  2199 					}
       
  2200 
       
  2201 					string funcsig = GenerateFunctionSignature(functionnode);
       
  2202 
       
  2203 					//Check the primary base for overwriting
       
  2204 					NodeIndex::vtable_t::const_iterator it = primvtable.begin();
       
  2205 					for (; it != primvtable.end(); ++it)
       
  2206 					{
       
  2207 						if ( funcsig == it->first )
       
  2208 						{
       
  2209 							//This function overwrites one from the primary base and is not added
       
  2210 							//to the end of the vtable
       
  2211 							break;
       
  2212 						}
       
  2213 					}
       
  2214 					if ( it == primvtable.end() )
       
  2215 					{
       
  2216 						//Function was not found from the primary base vtable and is added
       
  2217 						//to the end of the table
       
  2218 						classnode.iNodeIndex.AddVirtualFunction(vtablename,funcsig,functionnode.current);
       
  2219 					}
       
  2220 				}
       
  2221 			}
       
  2222 		}else
       
  2223 		{
       
  2224 			//We do not have primary base and we can construct the virtual table from clean start
       
  2225 			unsigned int i = 0;
       
  2226 			for ( i = 0; i < virtualMethods.size(); ++i)
       
  2227 			{
       
  2228 				HANodeIterator functionnode(classnode);
       
  2229 				functionnode.current = virtualMethods[i];
       
  2230 				string funcsig = GenerateFunctionSignature(functionnode);
       
  2231 				classnode.iNodeIndex.AddVirtualFunction(vtablename,funcsig,functionnode.current);
       
  2232 			}
       
  2233 		}
       
  2234 		return *vtable;
       
  2235 	}
       
  2236 
       
  2237 }
       
  2238 
       
  2239 // ----------------------------------------------------------------------------
       
  2240 // ClassBaseSize
       
  2241 // ----------------------------------------------------------------------------
       
  2242 //
       
  2243 int ClassBaseSize(const HANodeIterator& classnode, const NodeIndex::dtable_t& fields)
       
  2244 {
       
  2245 	//This is empty class
       
  2246 	if ( 0 == fields.size() )
       
  2247 	{
       
  2248 		return 8;
       
  2249 	}
       
  2250 
       
  2251 	DataMember lastmember = fields[fields.size()-1];
       
  2252 
       
  2253 	//The last member is virtual table pointer
       
  2254 	if ( NULL == lastmember.iNode )
       
  2255 	{
       
  2256 		return lastmember.iOffset + 32;
       
  2257 	}
       
  2258 
       
  2259 	HANodeIterator lastfield(classnode);
       
  2260 	lastfield.current = lastmember.iNode;
       
  2261 
       
  2262 	const XMLCh* type = lastfield.GetAttribute(KXMLTypeString);
       
  2263     assert(type);
       
  2264     HANodeIterator typenode(classnode);
       
  2265     bool typefound = typenode.FindNodeById(type);
       
  2266     assert(typefound);
       
  2267 	const XMLCh * nodetype = typenode->getNodeName();
       
  2268 	assert(nodetype);
       
  2269 
       
  2270 	int fieldsize_int = 0;
       
  2271 	//If the last member is class, get the base size for it
       
  2272     if ( Equals(nodetype,KXMLStructString) || Equals(nodetype,KXMLClassString) )
       
  2273 	{
       
  2274 		const NodeIndex::dtable_t& fields = ClassGenerateDataMemberTable(typenode);
       
  2275 		fieldsize_int = ClassBaseSize(typenode,fields);
       
  2276 	}else
       
  2277 	{
       
  2278 		const XMLCh* fieldsize = GetSize(lastfield);
       
  2279 		assert( fieldsize );
       
  2280 		string fieldsize_str = toString(fieldsize);
       
  2281 		fieldsize_int = atoi(fieldsize_str.c_str());
       
  2282 	}
       
  2283 
       
  2284 	/*const XMLCh* offset = lastfield.GetAttribute(KXMLOffsetString);
       
  2285 
       
  2286 	assert( offset );
       
  2287 
       
  2288 	string offset_str = toString(offset);
       
  2289 
       
  2290 	int offset_int = atoi(offset_str.c_str());*/
       
  2291 
       
  2292 	return fieldsize_int+lastmember.iOffset;//offset_int;
       
  2293 }
       
  2294 
       
  2295 // ----------------------------------------------------------------------------
       
  2296 // ClassGenerateDataMemberTable
       
  2297 // ----------------------------------------------------------------------------
       
  2298 //
       
  2299 const NodeIndex::dtable_t& ClassGenerateDataMemberTable(const HANodeIterator& classnode)
       
  2300 {	
       
  2301     string dtablename = GenerateFullyQualifiedName(classnode);
       
  2302 	//Notice that this does not clear dtable, if one already exists
       
  2303 	const NodeIndex::dtable_t* dtable = classnode.iNodeIndex.AddEmptyDataMemberTable(classnode, dtablename);
       
  2304 
       
  2305 	if ( 0 != dtable->size() )
       
  2306 	{
       
  2307 		//The vtable already exists
       
  2308 		return *dtable;
       
  2309 	}
       
  2310 	else
       
  2311 	{
       
  2312 
       
  2313 		//Lets check if we are dynamic class so that we need to add
       
  2314 		// the virtual table pointer
       
  2315 		if ( classnode.CheckForBooleanAttribute(KXMLBBCVirtualString) )
       
  2316 		{
       
  2317 			string name = "::vtableptr";
       
  2318 			int lineNo = 0;
       
  2319 			string line_str = toString(classnode.GetAttribute(KXMLLineString));
       
  2320 			if(line_str.size() > 0)
       
  2321 				lineNo = atoi(line_str.c_str());
       
  2322 			classnode.iNodeIndex.AddDataMember(classnode,dtablename,name,NULL,0,EAccessGlobal,lineNo);
       
  2323 		}
       
  2324 
       
  2325 		//Add the fields from bases
       
  2326 		DOMNodeList* childs = classnode.GetElementsByTagName(KXMLBaseString);	   
       
  2327 		if (childs)
       
  2328 		{
       
  2329 			XMLSize_t childcount = childs->getLength();
       
  2330 
       
  2331 			for (unsigned int i = 0; i < childcount; ++i)
       
  2332 			{
       
  2333 				HANodeIterator classit(classnode);
       
  2334 				classit.current = childs->item(i);
       
  2335 
       
  2336 				HANodeIterator baseclass(classnode);
       
  2337 				bool found = baseclass.FindNodeById(classit.GetAttribute(KXMLTypeString));
       
  2338 				assert(found);
       
  2339 
       
  2340 				if ( baseclass.CheckForBooleanAttribute(KXMLBBCVirtualString) )
       
  2341 				{
       
  2342 					string offset_str = toString(classit.GetAttribute(KXMLOffsetString));
       
  2343 					int offset = atoi(offset_str.c_str());
       
  2344 					//Change offset from bytes to bits
       
  2345 					offset = offset*8;
       
  2346                     int lineNo = 0;
       
  2347 					string line_str = toString(classit.GetAttribute(KXMLLineString));
       
  2348 					lineNo = atoi(line_str.c_str());
       
  2349 
       
  2350 					string name = "[";
       
  2351 					name += GenerateFullyQualifiedName(baseclass);
       
  2352 					name += "::vtableptr";
       
  2353 					name += "]";
       
  2354 					classnode.iNodeIndex.AddDataMember(classnode,dtablename,name,NULL,offset,EAccessGlobal,lineNo);
       
  2355 				}
       
  2356 			}
       
  2357 		}
       
  2358 		
       
  2359 		//Add the current members
       
  2360 		vector<DOMNode*> virtualMethods;
       
  2361 		vector<DOMNode*> inlineMethods;
       
  2362 		vector<DOMNode*> exportedMethods;
       
  2363 		vector<DOMNode*> methods;
       
  2364 		vector<DOMNode*> fields;
       
  2365 		vector<DOMNode*> others;
       
  2366 
       
  2367 		ClassOrderMembers(classnode, virtualMethods, inlineMethods, exportedMethods,
       
  2368 						methods, fields, others);
       
  2369 
       
  2370 		unsigned int i = 0;
       
  2371 		for ( i = 0; i < fields.size(); ++i)
       
  2372 		{
       
  2373 			HANodeIterator fieldnode(classnode);
       
  2374 			fieldnode.current = fields[i];
       
  2375 			string offset_str = toString(fieldnode.GetAttribute(KXMLOffsetString));
       
  2376 			int offset = atoi(offset_str.c_str());
       
  2377 
       
  2378 			const XMLCh* ch_name = fieldnode.GetAttribute(KXMLNameString);
       
  2379 			string name = "::"; //GenerateFullyQualifiedName(fieldnode);
       
  2380 			if (ch_name)
       
  2381 			{
       
  2382 				name += toString(ch_name);
       
  2383 			}
       
  2384 
       
  2385 			int lineNo = 0;
       
  2386 			string line_str = toString(fieldnode.GetAttribute(KXMLLineString));
       
  2387 			lineNo = atoi(line_str.c_str());
       
  2388 
       
  2389 			TAccess access = CalcAccessModifier(fieldnode);
       
  2390 			classnode.iNodeIndex.AddDataMember(classnode,dtablename,name,fieldnode.current,offset,access,lineNo);
       
  2391 		}
       
  2392 		return *dtable;
       
  2393 		
       
  2394 	}
       
  2395 
       
  2396 }
       
  2397 
       
  2398 int ParseXMLFile(   const string& xmlFilename, 
       
  2399                     XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder*& domParser,
       
  2400                     XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*& domDocument,
       
  2401                     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode*& domRootNode )
       
  2402 {    
       
  2403     int ret = 0;
       
  2404 
       
  2405     if( BBCFileUtils::FileExists(xmlFilename) == false )
       
  2406         throw HAException(string("File: ") + xmlFilename + string(" cannot be found!\n"));
       
  2407     
       
  2408     static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
       
  2409     DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
       
  2410     domParser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
       
  2411     XMLModuleErrorHandler errorHandler;
       
  2412     domParser->setErrorHandler(&errorHandler);
       
  2413     XMLCh * nowhitespace = XMLString::transcode("whitespace-in-element-content");
       
  2414     domParser->setFeature(nowhitespace,false);
       
  2415     XMLString::release(&nowhitespace);
       
  2416 
       
  2417     try {
       
  2418             domDocument = domParser->parseURI(xmlFilename.c_str());        
       
  2419         } catch (XMLException& exception) {
       
  2420 
       
  2421             if (domParser != NULL) {
       
  2422                 domParser->release();           
       
  2423                 domParser = 0;
       
  2424             }
       
  2425             if (domDocument != NULL) {
       
  2426                 domDocument = NULL;
       
  2427             }
       
  2428             domRootNode = NULL;
       
  2429             ret = -1;
       
  2430             cout << "XML ERROR: " << exception.getMessage();
       
  2431             return ret;
       
  2432         }
       
  2433         if (domDocument != NULL)
       
  2434         {
       
  2435             domRootNode = (DOMNode*)domDocument->getDocumentElement();
       
  2436             if( domRootNode == 0 )
       
  2437                 throw HAException(string("\nXML ERROR: Root element missing from ") + xmlFilename + "\n");
       
  2438         }
       
  2439         else
       
  2440         {
       
  2441             throw HAException(string("File: ") + xmlFilename + string(" could not be parsed! Please, check the filename.\n"));
       
  2442         }
       
  2443         return ret;
       
  2444 }
       
  2445 
       
  2446 string& toLower(string& name)
       
  2447 {
       
  2448 #ifdef __WIN__    
       
  2449     string::iterator it(name.begin());
       
  2450 
       
  2451     for(; it != name.end(); ++it)
       
  2452     {
       
  2453         *it = tolower((unsigned char)*it);
       
  2454     }
       
  2455 #endif
       
  2456     return name;
       
  2457 }