Source code of Windows XP (NT5)
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.

148 lines
3.1 KiB

  1. /* Copyright (C) Microsoft Corporation, 1998. All rights reserved. */
  2. #ifndef _MACRO_H_
  3. #define _MACRO_H_
  4. #include "getsym.h"
  5. #include "utils.h"
  6. #include "cntlist.h"
  7. #define DEF_BODY_SIZE 2048
  8. #define ARG_ESCAPE_CHAR '$'
  9. #define ARG_INDEX_BASE '0'
  10. // forward class definitions
  11. class CMacro;
  12. class CMacroMgr;
  13. class CMacroInstance;
  14. // list classes
  15. class CMacroInstList : public CList
  16. {
  17. DEFINE_CLIST(CMacroInstList, CMacroInstance*);
  18. void DeleteList ( void );
  19. };
  20. class CMacroList : public CList
  21. {
  22. DEFINE_CLIST(CMacroList, CMacro*);
  23. void DeleteList ( void );
  24. };
  25. class CMacroMgrList : public CList
  26. {
  27. DEFINE_CLIST(CMacroMgrList, CMacroMgr*);
  28. CMacro *FindMacro ( LPSTR pszModuleName, LPSTR pszMacroName );
  29. CMacroMgr *FindMacroMgr ( LPSTR pszModuleName );
  30. void Uninstance ( void );
  31. void DeleteList ( void );
  32. };
  33. class CNameList : public CList
  34. {
  35. DEFINE_CLIST(CNameList, LPSTR);
  36. BOOL AddName ( LPSTR );
  37. LPSTR GetNthItem ( UINT nth );
  38. void DeleteList ( void );
  39. };
  40. class CMacro
  41. {
  42. public:
  43. CMacro ( BOOL *pfRetCode, LPSTR pszMacroName, UINT cbMaxBodySize = DEF_BODY_SIZE );
  44. CMacro ( BOOL *pfRetCode, CMacro *pMacro );
  45. ~CMacro ( void );
  46. void SetArg ( LPSTR pszArgName ) { m_ArgList.AddName(pszArgName); }
  47. void DeleteArgList ( void ) { m_ArgList.DeleteList(); }
  48. BOOL SetBodyPart ( LPSTR pszBodyPart );
  49. void EndMacro ( void );
  50. LPSTR CreateInstanceName ( void );
  51. BOOL InstantiateMacro ( void );
  52. BOOL OutputInstances ( COutput *pOutput );
  53. LPSTR GetName ( void ) { return m_pszMacroName; }
  54. void Uninstance ( void );
  55. BOOL IsImported ( void ) { return m_fImported; }
  56. private:
  57. LPSTR m_pszMacroName;
  58. UINT m_cFormalArgs;
  59. CNameList m_ArgList;
  60. UINT m_cbMaxBodySize;
  61. UINT m_cbBodySize;
  62. LPSTR m_pszCurr;
  63. LPSTR m_pszBodyBuffer;
  64. LPSTR m_pszExpandBuffer;
  65. CMacroInstList m_MacroInstList;
  66. BOOL m_fArgExistsInBody;
  67. BOOL m_fImported;
  68. };
  69. class CMacroMgr
  70. {
  71. public:
  72. CMacroMgr ( void );
  73. ~CMacroMgr ( void );
  74. BOOL AddModuleName ( LPSTR pszModuleName );
  75. LPSTR GetModuleName ( void ) { return m_pszModuleName; }
  76. void AddMacro ( CMacro *pMacro ) { m_MacroList.Append(pMacro); }
  77. CMacro *FindMacro ( LPSTR pszMacroName );
  78. BOOL OutputImportedMacros ( COutput *pOutput );
  79. void Uninstance ( void );
  80. private:
  81. CMacroList m_MacroList;
  82. LPSTR m_pszModuleName;
  83. };
  84. class CMacroInstance
  85. {
  86. public:
  87. CMacroInstance ( BOOL *pfRetCode, LPSTR pszInstanceName, UINT cbBufSize, LPSTR pszInstBuf );
  88. ~CMacroInstance ( void );
  89. LPSTR GetName ( void ) { return m_pszInstanceName; }
  90. UINT GetNameLen ( void ) { return ::strlen(m_pszInstanceName); }
  91. LPSTR GetBuffer ( void ) { return m_pszInstanceBuffer; }
  92. UINT GetBufSize ( void ) { return m_cbBufSize; }
  93. private:
  94. LPSTR m_pszInstanceName;
  95. UINT m_cbBufSize;
  96. LPSTR m_pszInstanceBuffer;
  97. };
  98. #endif // _MACRO_H_