Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

730 lines
25 KiB

  1. #define PDLPARSE
  2. #ifndef _PDLPARSE_HXX_
  3. #define _PDLPARSE_HXX_
  4. #define COLLECT_STATISTICS 0 // Set to 1 to enable statics gathering
  5. class CVTableHash;
  6. extern const char *rgszCcssString[];
  7. #define CCSSF_NONE 0 // no flags
  8. #define CCSSF_CLEARCACHES 1 // clear the caches when changing
  9. #define CCSSF_REMEASURECONTENTS 2 // need to resize site after changing this
  10. #define CCSSF_SIZECHANGED 4 // notify the parent of a size change.
  11. #define CCSSF_REMEASUREINPARENT 8 // remeasure in parent layout's context
  12. #define CCSSF_CLEARFF 16 // clear the caches when changing
  13. #define CCSSF_REMEASUREALLCONTENTS 32 // resize self & all nested layout elements
  14. struct CCachedAttrArrayInfo
  15. {
  16. char *szDispId;
  17. DWORD dwFlags;
  18. };
  19. enum StorageType
  20. {
  21. STORAGETYPE_OTHER,
  22. STORAGETYPE_NUMBER,
  23. STORAGETYPE_STRING,
  24. };
  25. struct AssociateDataType
  26. {
  27. char *szKey;
  28. char *szValue;
  29. char *szMethodFnPrefix;
  30. StorageType stStorageType;
  31. };
  32. struct Associate
  33. {
  34. char *szKey;
  35. char *szValue;
  36. };
  37. // Maximum allowed length of a parse line
  38. #define MAX_LINE_LEN 2048
  39. // Max number of tags per token
  40. #define MAX_TAGS 64
  41. #define MAX_SUBTOKENS 8
  42. class CString
  43. {
  44. char szString [ MAX_LINE_LEN+1 ];
  45. public:
  46. CString() { szString [ 0 ] = '\0'; }
  47. BOOL operator== ( LPCSTR szStr1 )
  48. {
  49. return _stricmp ( (const char *)szString, (const char *)szStr1 ) == 0 ? TRUE : FALSE;
  50. }
  51. #ifndef UNIX
  52. static BOOL operator== ( const CString& szStr1, LPCSTR szStr2 )
  53. {
  54. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? TRUE : FALSE;
  55. }
  56. static BOOL operator== ( LPCSTR szStr1, const CString &szStr2 )
  57. {
  58. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? TRUE : FALSE;
  59. }
  60. #endif
  61. BOOL operator!= ( LPCSTR szStr1 )
  62. {
  63. return _stricmp ( (const char *)szString, (const char *)szStr1 ) == 0 ? FALSE : TRUE;
  64. }
  65. #ifndef UNIX
  66. static BOOL operator!= ( const CString& szStr1, LPCSTR szStr2 )
  67. {
  68. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? FALSE : TRUE;
  69. }
  70. static BOOL operator!= ( LPCSTR szStr1, const CString &szStr2 )
  71. {
  72. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? FALSE : TRUE;
  73. }
  74. #endif
  75. const CString &operator= ( LPCSTR pStr )
  76. {
  77. strcpy ( szString, pStr );
  78. return *this;
  79. }
  80. const CString &operator+= ( LPCSTR pStr )
  81. {
  82. strcat ( szString, pStr );
  83. return *this;
  84. }
  85. const CString &operator+ ( CString szStr )
  86. {
  87. strcat ( szString, (LPCSTR)szStr );
  88. return *this;
  89. }
  90. const CString &operator+ ( LPCSTR pStr )
  91. {
  92. strcat ( szString, pStr );
  93. return *this;
  94. }
  95. char operator[] ( INT nIndex )
  96. {
  97. return szString [ nIndex ];
  98. }
  99. operator LPCSTR () const
  100. {
  101. return (const char *)szString;
  102. }
  103. CString &ToUpper ()
  104. {
  105. _strupr ( szString );
  106. return *this;
  107. }
  108. int Length ( void )
  109. {
  110. return strlen ( szString );
  111. }
  112. char * FindChar ( char ch )
  113. {
  114. return strchr(szString, ch);
  115. }
  116. void PutChar (INT nIndex, char ch)
  117. {
  118. if (nIndex < Length())
  119. szString[nIndex] = ch;
  120. }
  121. UINT Lookup ( Associate *pArray, LPCSTR pStr );
  122. UINT Lookup ( AssociateDataType *pArray, LPCSTR pStr );
  123. };
  124. #ifdef UNIX
  125. inline BOOL operator== ( const CString& szStr1, LPCSTR szStr2 )
  126. {
  127. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? TRUE : FALSE;
  128. }
  129. inline BOOL operator== ( LPCSTR szStr1, const CString &szStr2 )
  130. {
  131. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? TRUE : FALSE;
  132. }
  133. inline BOOL operator== ( const CString& szStr1, const CString& szStr2)
  134. {
  135. return _stricmp( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? TRUE : FALSE;
  136. }
  137. inline BOOL operator!= ( const CString& szStr1, LPCSTR szStr2 )
  138. {
  139. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? FALSE : TRUE;
  140. }
  141. #if 0 // apogee can't tell the difference between these two.
  142. inline BOOL operator!= ( LPCSTR szStr1, const CString &szStr2 )
  143. {
  144. return _stricmp ( (LPCSTR)szStr1, (LPCSTR)szStr2 ) == 0 ? FALSE : TRUE;
  145. }
  146. #endif
  147. #endif
  148. struct TagDescriptor
  149. {
  150. char *szTag;
  151. BOOL fIsFlag;
  152. BOOL fIsRequired;
  153. BOOL fRefersToClass;
  154. };
  155. // This enum must match the order that the corresponding structs appear in AllDescriptors
  156. enum DESCRIPTOR_TYPE;
  157. class TagArray
  158. {
  159. char *szValues [ MAX_TAGS ];
  160. static char *szEmptyString;
  161. public:
  162. BOOL AddTag ( int iTag, LPCSTR szStr, int nLen );
  163. TagArray()
  164. {
  165. INT i;
  166. for ( i = 0 ; i < MAX_TAGS ; i++ )
  167. {
  168. szValues [ i ] = NULL;
  169. }
  170. }
  171. ~TagArray()
  172. {
  173. INT i;
  174. for ( i = 0 ; i < MAX_TAGS ; i++ )
  175. {
  176. if ( szValues [ i ] )
  177. delete szValues [ i ];
  178. }
  179. }
  180. BOOL CompareTag ( INT nIndex, char *szWith );
  181. char *GetTagValue ( INT nIndex );
  182. BOOL IsSet ( INT nIndex )
  183. {
  184. return szValues [ nIndex ] == NULL ? FALSE : TRUE;
  185. }
  186. // Only use this method if you must - use GetTagValue normaly
  187. char *GetInternalValue ( INT nIndex )
  188. {
  189. return szValues [ nIndex ];
  190. }
  191. };
  192. struct TokenDescriptor;
  193. class CTokenList;
  194. class Token
  195. {
  196. friend class CRuntimeTokenList;
  197. friend class CPDLParser;
  198. friend class CTokenList;
  199. friend class CTokenListWalker;
  200. protected:
  201. DESCRIPTOR_TYPE nType;
  202. // Calculate bitwise enum vaklidation mask
  203. UINT uEnumMask;
  204. UINT nNextEnumValue;
  205. //
  206. Token *_pNextToken;
  207. CTokenList *_pChildList;
  208. public:
  209. Token ( DESCRIPTOR_TYPE nDescriptorType )
  210. {
  211. nType = nDescriptorType;
  212. uEnumMask = 0; nNextEnumValue = 0;
  213. _pNextToken = NULL;
  214. _pChildList = NULL;
  215. }
  216. void Clone ( Token *pFrom );
  217. ~Token();
  218. TagArray TagValues; // Array of values size == nTag
  219. BOOL CompareTag ( INT nIndex, char *szWith )
  220. {
  221. return TagValues.CompareTag ( nIndex, szWith );
  222. }
  223. char *GetTagValue ( INT nIndex )
  224. {
  225. return TagValues.GetTagValue ( nIndex );
  226. }
  227. BOOL AddTag ( int iTag, LPCSTR szStr, int nLen = -1 )
  228. {
  229. if ( nLen == -1 )
  230. nLen = strlen ( szStr );
  231. return TagValues.AddTag ( iTag, szStr, nLen );
  232. }
  233. BOOL IsSet ( INT nIndex )
  234. {
  235. return TagValues.IsSet ( nIndex );
  236. }
  237. // Sets a flag value to TRUE
  238. BOOL Set ( INT nIndex )
  239. {
  240. return TagValues.AddTag ( nIndex, "", 1 );
  241. }
  242. void AddParam ( CString &szArg, INT nTag, LPCSTR szText );
  243. void AddParamStr ( CString &szArg, INT nTag, LPCSTR szText );
  244. void GetTagValueOrDefault ( CString &szArg, INT nTag,
  245. LPCSTR szDefault )
  246. {
  247. if ( IsSet ( nTag ) )
  248. szArg = (LPCSTR)GetTagValue ( nTag );
  249. else
  250. szArg = (LPCSTR)szDefault;
  251. }
  252. DESCRIPTOR_TYPE GetType ( void ) const { return nType; }
  253. void SetNextToken ( Token *pToken ) { _pNextToken = pToken; }
  254. Token *GetNextToken ( void ) const { return _pNextToken; }
  255. Token *AddChildToken ( DESCRIPTOR_TYPE nType );
  256. void CalculateEnumMask ( Token *pParentToken );
  257. UINT GetChildTokenCount ( void );
  258. };
  259. struct TokenDescriptor
  260. {
  261. char *szTokenName;
  262. BOOL fIsParentToken;
  263. TagDescriptor Tags [MAX_TAGS];
  264. //
  265. BOOL LookupTagName ( char *szTag, int nTagLen, INT *pnIndex )
  266. {
  267. for ( *pnIndex = 0 ; Tags [ *pnIndex ].szTag != NULL ; (*pnIndex)++ )
  268. {
  269. if ( _strnicmp ( Tags [ *pnIndex ].szTag, szTag, nTagLen ) == 0 )
  270. {
  271. // Descriptors never have an entry for the "name", so
  272. // the actual tag array index is always 1 more than the
  273. // corresponding descriptor index
  274. (*pnIndex)++;
  275. return TRUE;
  276. }
  277. }
  278. return FALSE;
  279. }
  280. };
  281. class CTokenList
  282. {
  283. private:
  284. // Linked list of all tokens
  285. Token *_pFirstToken;
  286. // Pointer to last item in token list
  287. Token *_pLastToken;
  288. // Count of number of tokens in list
  289. UINT _uTokens;
  290. ULONG ulRefs;
  291. // protect out destructor so people don't delete us, use Release() instead
  292. ~CTokenList();
  293. public:
  294. CTokenList()
  295. {
  296. _pFirstToken = NULL;
  297. _pLastToken = NULL;
  298. _uTokens = 0;
  299. ulRefs = 1;
  300. }
  301. Token *AddNewToken ( DESCRIPTOR_TYPE nTokenDescriptor );
  302. Token *FindToken ( char *pTokenName, DESCRIPTOR_TYPE nType ) const;
  303. Token *GetFirst ( void ) const { return _pFirstToken; }
  304. UINT GetTokenCount ( void ) const { return _uTokens; }
  305. // We reference count to simplify Cloning of arg lists
  306. // for ref properties
  307. void AddRef ( void ) { ulRefs++; };
  308. void Release ( void ) { if ( --ulRefs == 0 ) delete this; }
  309. };
  310. class CTokenListWalker
  311. {
  312. private:
  313. CTokenList *_pList;
  314. Token *_pCurrentToken;
  315. char *_pszFileName;
  316. BOOL _fInCurrentFile;
  317. BOOL _fAtEnd;
  318. private:
  319. Token *GetNextToken ( void )
  320. {
  321. if ( _fAtEnd || _pList == NULL )
  322. {
  323. return NULL;
  324. }
  325. if ( _pCurrentToken == NULL )
  326. _pCurrentToken = _pList -> GetFirst ();
  327. else
  328. {
  329. _pCurrentToken = _pCurrentToken -> GetNextToken();
  330. if ( _pCurrentToken == NULL )
  331. _fAtEnd = TRUE;
  332. }
  333. return _pCurrentToken;
  334. }
  335. public:
  336. Token *CurrentToken ( void )
  337. {
  338. return _pCurrentToken;
  339. }
  340. void Reset ( void );
  341. // Generic walker
  342. CTokenListWalker ( CTokenList *pList )
  343. {
  344. _pList = pList;
  345. _pszFileName = NULL;
  346. Reset();
  347. }
  348. // Walker that will just walk definitions in a given pdl file
  349. CTokenListWalker ( CTokenList *pList, char *pszFileName )
  350. {
  351. _pList = pList;
  352. _pszFileName = pszFileName;
  353. Reset();
  354. }
  355. // Child token list walker
  356. CTokenListWalker ( Token *pParentToken )
  357. {
  358. if ( pParentToken )
  359. _pList = pParentToken -> _pChildList;
  360. else
  361. _pList = NULL;
  362. _pszFileName = NULL;
  363. Reset();
  364. }
  365. Token *GetNext ( void );
  366. Token *GetNext ( DESCRIPTOR_TYPE Type, LPCSTR pName = NULL );
  367. UINT GetTokenCount ( void )
  368. {
  369. return _pList ? _pList -> GetTokenCount() : 0;
  370. }
  371. BOOL IsGenericWalker ( void )
  372. {
  373. return _pszFileName == 0;
  374. }
  375. };
  376. struct PropdescInfo{
  377. LPCSTR _szClass;
  378. LPCSTR _szPropName;
  379. BOOL _fAppendA;
  380. BOOL _fProperty; // TRUE if property FALSE if method
  381. UINT _uVTblIndex; // VTable Index of method or first Property (Get or Set) primary interface IIDIndex is zero
  382. LPCSTR _szAttrName;
  383. LPCSTR _szSortKey;
  384. UINT _uIIDIndex; // IID index always non-zero
  385. UINT _uOMParserWalker;
  386. Token *_pToken; // Pointer to prop/method token.
  387. PropdescInfo() { memset (this, 0, sizeof(PropdescInfo)); }
  388. void Set(LPCSTR szClass, LPCSTR szPropName, BOOL fAppendA, LPCSTR szAttrName, UINT uVTblIndex = 0, BOOL fProperty = TRUE, UINT uIIDIndex = 0, Token *pToken = NULL)
  389. {
  390. _szClass = szClass;
  391. _szPropName = szPropName;
  392. _fAppendA = fAppendA;
  393. _szAttrName = szAttrName;
  394. // If szAttribute specified, use that to override property name for sorting.
  395. _szSortKey = strlen(szAttrName) ? szAttrName : szPropName;
  396. _uVTblIndex = uVTblIndex;
  397. _fProperty = fProperty;
  398. _uIIDIndex = uIIDIndex;
  399. _pToken = pToken;
  400. }
  401. void SetVTable(LPCSTR szClass, LPCSTR szPropName, BOOL fAppendA, LPCSTR szAttrName, UINT uVTblIndex = 0, BOOL fProperty = TRUE, UINT uIIDIndex = 0, Token *pToken = NULL)
  402. {
  403. _szClass = szClass;
  404. _szPropName = szPropName;
  405. _fAppendA = fAppendA;
  406. _szAttrName = szAttrName;
  407. // If szPropName use that it's the exported name else the szAttrName is the usd.
  408. _szSortKey = strlen(szPropName) ? szPropName : szAttrName;
  409. _uVTblIndex = uVTblIndex;
  410. _fProperty = fProperty;
  411. _uIIDIndex = uIIDIndex;
  412. _pToken = pToken;
  413. }
  414. };
  415. #define MAX_ARGS 8 // Maximum # of args (w/ default parameters PDL handles)
  416. class CPDLParser
  417. {
  418. private:
  419. enum PropertyType { NotProperty, SetProperty, GetProperty };
  420. enum ParamType { None = 0, Object = 1, GenericObject = 2, AnyObject = 3};
  421. char *_pszPDLFileName;
  422. char *_pszOutputFileRoot;
  423. char *_pszInputFile;
  424. char *_pszOutputPath;
  425. CTokenList *pRuntimeList;
  426. FILE *fpHComPlusFile;
  427. FILE *fpCComPlusFile;
  428. FILE *fpHDLFile;
  429. FILE *fpIDLFile;
  430. FILE *fpHeaderFile;
  431. FILE *fpLOGFile;
  432. FILE *fpHTMFile;
  433. FILE *fpHTMIndexFile;
  434. FILE *fpDISPIDFile;
  435. FILE *fpMaxLenFile;
  436. int cOnFileSignatures;
  437. int cOnFileIIDs;
  438. char **rgszSignatures;
  439. char **rgszIIDs;
  440. int cSignatures;
  441. int cIIDs;
  442. int _numPropDescs;
  443. int _numVTblEntries;
  444. void RemoveSignatures ( void );
  445. BOOL LoadSignatures ( char *pszOutputPath );
  446. BOOL SaveSignatures ( char *pszOutputPath );
  447. void MakeSignature (LPCSTR szType, LPCSTR szSignature, CString & szLookup);
  448. BOOL FindAndAddSignature ( LPCSTR szType, LPCSTR szSignature, LPSTR pszInvokeMethod );
  449. int FindAndAddIIDs ( CString szInterface );
  450. #if COLLECT_STATISTICS==1
  451. #define MAX_STATS 20
  452. #define NUM_PROPTURDS 0 // Number of code turds for all properties
  453. #define NUM_EMUMTURDS 1 // Number of code turds for enum properties
  454. #define NUM_GETENUMS 2 // Number of unique enum property gets per interface
  455. #define NUM_SETENUMS 3 // Number of unique enum property gets per interface
  456. #define NUM_GETPROPERTY 4 // Number of unique property sets per interface
  457. #define NUM_SETPROPERTY 5 // Number of unique property sets per interface
  458. long rgcStats[MAX_STATS];
  459. void LoadStatistics ( char *pszOutputPath );
  460. void SaveStatistics ( char *pszOutputPath );
  461. void CollectStatistic (long lStatisticIdx, long lValue)
  462. { rgcStats[lStatisticIdx] = lValue; }
  463. long GetStatistic (long lStatisticIdx)
  464. { return rgcStats[lStatisticIdx]; }
  465. #endif
  466. // Used to use this fn, leaving it for posterity
  467. UINT CountTags ( TokenDescriptor *tokdesc );
  468. //
  469. Token * IsSuperInterface( CString szSuper, Token * pInterface );
  470. Token * FindMatchingEntryWOPropDesc(Token *pClass, Token *pToFindToken, BOOL fNameMatchOnly = FALSE);
  471. Token * FindMethodInInterfaceWOPropDesc(Token *pInterface, Token *pToFindToken, BOOL fNameMatchOnly = FALSE);
  472. BOOL IsElementEvent(Token *pEventInterface);
  473. Token * FindEventMethod(Token *pClassToken, LPCSTR szEvent);
  474. Token * FindEventProp(Token *pClassToken, LPCSTR szEvent);
  475. void GenerateThunkContext ( Token *pClassToken );
  476. void GenerateThunkContextImplemenation ( Token *pClassToken );
  477. void GenerateSingleThunkContextPrototype ( Token *pClassToken, Token * pChildToken, BOOL fNodeContext );
  478. void GenerateSingleThunkContextImplementation ( Token *pClassToken, Token * pChildToken, BOOL fNodeContext );
  479. void GenerateClassDISPIDs ( void );
  480. void GenerateInterfaceDISPIDs ( void );
  481. void GenerateExternalInterfaceDISPIDs ( void );
  482. void GenerateEventDISPIDs ( FILE *fp, BOOL fPutDIID );
  483. BOOL ComputePROPDESC_STRUCT ( FILE *fp, Token *pClassToken, Token *pChild, CString & szHandler, CString & szFnPrefix );
  484. Token * FindEnum ( Token *pChild );
  485. char * MapTypeToIDispatch ( CString & szType );
  486. BOOL ComputeProperty ( Token *pClassToken, Token *pChild );
  487. BOOL ComputeMethod ( Token *pClassToken, Token *pChild );
  488. BOOL BuildMethodSignature(Token *pChild,
  489. CString &szTypesSig,
  490. CString &szArgsType,
  491. BOOL &fBSTRArg,
  492. BOOL &fVARIANTArg,
  493. int &cArgs,
  494. int &cRequiredArgs,
  495. char *pDefaultParams[MAX_ARGS] = NULL,
  496. char *pDefaultStrParams[MAX_ARGS] = NULL);
  497. BOOL GeneratePROPDESCs ( void );
  498. BOOL GenerateCPC ( Token *pThisClassToken );
  499. void GenerateVTableArray ( Token *pThisClassToken, int *pNumVTblEntries );
  500. void SortPropDescInfo ( PropdescInfo *pPI, int cPDI );
  501. BOOL ComputeVTable ( Token *pClass,
  502. Token *pInterface,
  503. BOOL fDerived,
  504. PropdescInfo *pPI,
  505. int *piPI,
  506. UINT *pUVTblIdx,
  507. CVTableHash *pVTableHash,
  508. BOOL &bHookToCElement,
  509. BOOL fPrimaryTearoff = FALSE );
  510. #ifdef COMPLUS_SHIM
  511. BOOL GenComPlusArgumentSignature ( Token *pMethod, CString & resultCStr, CString & argCStr, PropertyType propType = NotProperty );
  512. void GenComPlusMethodsInInterfaces ( Token *pInterfaceToken, Token *pClass =NULL );
  513. void GenComPlusInterfaces ( Token *pInterfaceToken, char* pszSuper );
  514. void GenComPlusESI ();
  515. void GenComPlusDeclarations ( Token *pClass, PropdescInfo *pPI );
  516. void GenComPlusInheritance ( Token *pClass, CString & inheritanceCStr );
  517. #endif // COMPLUS_SHIM
  518. BOOL GeneratePropMethodImplementation ( void );
  519. void SplitTag ( char *pStr, int nLen, char **pTag, int *pnTagLen,
  520. char **pValue, int *pnValueLen );
  521. BOOL IsStoredAsString( Token *pClassToken );
  522. BOOL LookupToken ( LPCSTR pTokenName, int nTokenLen,
  523. TokenDescriptor **ppTokenDescriptor, DESCRIPTOR_TYPE *pnTokenDes );
  524. BOOL GetElem ( char **pStr, char **pElem, int *pnLen, BOOL fBreakOnOpenParenthesis = FALSE,
  525. BOOL fBreakOnCloseParenthesis = FALSE, BOOL fBreakOnComma=FALSE );
  526. LPCSTR ConvertType ( LPCSTR szType, BOOL fComPlus = FALSE, LPSTR pCPString = 0, BOOL *pfInterfaceFound = 0);
  527. BOOL ParseInputFile ( BOOL fDebugging );
  528. BOOL GenerateHDLFile ( void );
  529. void GenerateCPPEnumDefs ( void );
  530. BOOL GetTypeDetails ( char *szTypeName, CString& szHandler, CString &szFnPrefix, StorageType *pStorageType = NULL );
  531. void GenerateMethodImp ( Token *pClassToken,
  532. Token *pChildToken, BOOL fIsSet, CString &szHandler,
  533. CString &szHandlerArgs, CString &szOffsetOf, CString &szAType );
  534. BOOL FindTearoffMethod ( Token *pTearoff, LPCSTR pszTearoffMethod, LPSTR pszUseTearoff);
  535. BOOL GenerateTearoffTable ( Token *pClassToken, Token *pTearoff, LPCSTR pszInterface, BOOL fMostDerived );
  536. BOOL GenerateTearOffMethods ( LPCSTR szClassName, Token *pTearoff, LPCSTR szInterfaceName, BOOL fMostDerived = FALSE );
  537. BOOL GenerateIDispatchTearoff(LPCSTR szClassName, Token *pTearoff, LPCSTR pszInterfaceName, BOOL fMostDerived = FALSE );
  538. BOOL HasMondoDispInterface ( Token *pClassToken );
  539. BOOL PatchInterfaceRefTypes ( void );
  540. BOOL CloneToken ( Token *pChildToken, DESCRIPTOR_TYPE Type, INT nClassName, INT nTagName );
  541. void GeneratePropMethodDecl ( Token *pClassToken );
  542. void GenerateGetAAXImplementations ( Token *pClassToken );
  543. void GenerateGetAAXPrototypes ( Token *pClassToken );
  544. BOOL PrimaryTearoff (Token *pInterface);
  545. Token* NextTearoff (LPCSTR szClassname, Token *pLastTearoff = NULL);
  546. Token* FindTearoff (LPCSTR szClassname, LPCSTR szInterface);
  547. BOOL GenerateClassIncludes ( void );
  548. BOOL GenerateEventFireDecl ( Token *pToken );
  549. BOOL GenerateEventDecl ( Token *pClassToken, Token *pEventToken );
  550. BOOL GenerateIDLFile ( char *szFileName );
  551. void GenerateIDLInterfaceDecl ( Token *pInterfaceToken,
  552. char *pszGUID,
  553. char *pszSuper,
  554. BOOL fDispInterface = FALSE,
  555. Token *pClassToken = NULL );
  556. void ComputePropType ( Token *pPropertyToken, CString &szProp, BOOL fComment );
  557. void GenerateMkTypelibDecl ( Token *pInterfaceToken, BOOL fDispInterface = FALSE, Token *pClass =NULL );
  558. void GenerateMidlInterfaceDecl ( Token *pInterfaceToken, char *pszGUID, char *pszSuper );
  559. void GenerateCoClassDecl ( Token *pClassToken );
  560. void GenerateEnumDescIDL ( Token *pEnumToken );
  561. void ReportError ( LPCSTR szErrorString );
  562. void GenerateHeaderFile ( void );
  563. void GenerateIncludeStatement ( Token *pImportToken );
  564. void GenerateIncludeInterface ( Token *pInterfaceToken );
  565. void GenerateIncludeEnum(Token *pEnumToken, BOOL fSpitExtern, FILE *pFile = NULL);
  566. BOOL GenerateHTMFile ( void );
  567. void GenerateArg ( Token *pArgToken );
  568. void GenerateInterfaceArg ( Token *pArgToken );
  569. void GenerateMethodHTM ( Token *pClassToken );
  570. void GenerateInterfaceMethodHTM ( Token *pClassToken );
  571. void GenerateEventMethodHTM ( Token *pClassToken );
  572. void GenerateEnumHTM ( Token *pClassToken, char *pEnumPrefix );
  573. void GeneratePropertiesHTM ( Token *pClassToken, BOOL fAttributes );
  574. void GenerateInterfacePropertiesHTM ( Token *pIntfToken );
  575. void GenerateStruct(Token *pStructToken, FILE *pFile);
  576. Token* FindInterface (CString szInterfaceMatch);
  577. Token* FindInterfaceLocally (CString szInterfaceMatch);
  578. BOOL IsPrimaryInterface(CString szInterface);
  579. Token* FindClass (CString szClassMatch);
  580. BOOL IsUniqueCPC ( Token *pClassToken );
  581. BOOL FindTearoffProperty ( Token *pPropertyToken, LPSTR szTearoffMethod,
  582. LPSTR szTearOffClassName, LPSTR szPropArgs, BOOL fPropGet );
  583. BOOL GeneratePropDescsInVtblOrder(Token *pClassToken, int *pNumVtblPropDescs);
  584. BOOL IsSpecialProperty(Token *pClassToken);
  585. BOOL IsSpecialTearoff(Token *pTearoff);
  586. const CCachedAttrArrayInfo* GetCachedAttrArrayInfo( LPCSTR szDispId );
  587. // Manage a dynamic list of types
  588. CTokenList *pDynamicTypeList;
  589. CTokenList *pDynamicEventTypeList;
  590. enum
  591. {
  592. DATATYPE_NAME,
  593. DATATYPE_HANDLER,
  594. };
  595. enum
  596. {
  597. TYPE_DATATYPE=-1
  598. };
  599. BOOL LookupType ( LPCSTR szTypeName, CString &szIntoString,
  600. CString &szFnPrefix, StorageType *pStorageType = NULL );
  601. BOOL AddType ( LPCSTR szTypeName, LPCSTR szHandler );
  602. BOOL LookupEventType ( CString &szIntoString, LPCSTR szTypeName );
  603. BOOL AddEventType ( LPCSTR szTypeName, LPCSTR szVTSType );
  604. BOOL PatchPropertyTypes ( void );
  605. BOOL PatchInterfaces ();
  606. BOOL HasClassGotProperties ( Token *pClassToken );
  607. Token *GetSuperClassTokenPtr ( Token *pClassToken );
  608. Token *GetPropAbstractClassTokenPtr ( Token *pClassToken );
  609. BOOL GeneratePropdescReference ( Token *pClassToken,
  610. BOOL fDerivedClass,
  611. PropdescInfo *pPI,
  612. int *pnPI,
  613. BOOL &bHookToCElement,
  614. int *pnSharedEntries );
  615. void GeneratePropdescExtern ( Token *pClassToken, BOOL fRecurse = TRUE );
  616. void Init ( void );
  617. public:
  618. CPDLParser ();
  619. ~CPDLParser ()
  620. {
  621. if (fpMaxLenFile)
  622. fclose(fpMaxLenFile);
  623. if ( fpHComPlusFile )
  624. fclose ( fpHComPlusFile );
  625. if ( fpCComPlusFile )
  626. fclose ( fpCComPlusFile );
  627. if ( fpHDLFile )
  628. fclose ( fpHDLFile );
  629. if ( fpHeaderFile )
  630. fclose ( fpHeaderFile );
  631. if ( fpIDLFile )
  632. fclose ( fpIDLFile );
  633. if ( fpLOGFile )
  634. fclose ( fpLOGFile );
  635. if ( fpDISPIDFile )
  636. fclose ( fpDISPIDFile );
  637. if ( fpHTMFile )
  638. fclose ( fpHTMFile );
  639. if ( fpHTMIndexFile )
  640. fclose ( fpHTMIndexFile );
  641. pRuntimeList -> Release();
  642. pDynamicTypeList -> Release();
  643. pDynamicEventTypeList -> Release();
  644. }
  645. int Parse ( char *szInputFile,
  646. char *szOutputFileRoot,
  647. char *szPDLFileName,
  648. char *szOutputPath,
  649. BOOL fDebugging );
  650. };
  651. BOOL
  652. GetStdInLine ( char *szLineBuffer, int nMaxLen );
  653. // Every Token array has a name as the first item
  654. #define NAME_TAG 0
  655. // Always have this as the last element in the descriptor array
  656. #define END_OF_ARG_ARRAY { NULL, FALSE, FALSE }
  657. #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof (ar[0]))
  658. #endif