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.

95 lines
2.9 KiB

  1. //---------------------------------------------------------------------------
  2. // NtlParse.h - parses a ".ntl" file (Native Theme Language)
  3. //---------------------------------------------------------------------------
  4. #pragma once
  5. //---------------------------------------------------------------------------
  6. #include "Scanner.h"
  7. #include "Utils.h"
  8. #include "CFile.h"
  9. #include "SimpStr.h"
  10. #include "parser.h"
  11. #include "ntl.h"
  12. //---------------------------------------------------------------------------
  13. #define MAX_IF_NESTING 99
  14. #define MAX_STATES 99
  15. //---------------------------------------------------------------------------
  16. struct OPTIONBITENTRY
  17. {
  18. CWideString csName;
  19. int iValue;
  20. };
  21. //---------------------------------------------------------------------------
  22. struct IFRECORD
  23. {
  24. BYTE iBitNum;
  25. BOOL fIfOn;
  26. int iIfOffset;
  27. int iElseOffset;
  28. };
  29. //---------------------------------------------------------------------------
  30. class CNtlParser
  31. {
  32. public:
  33. CNtlParser();
  34. HRESULT ParseBuffer(LPCWSTR pszSource, LPCWSTR pszSourceFileName, INtlParserCallBack *pCallBack,
  35. OUT BYTE **ppPCode, OUT int *piLen);
  36. protected:
  37. HRESULT SourceError(int iMsgResId, ...);
  38. HRESULT ParseOptionBitsSection();
  39. HRESULT AddOptionBitName(LPCWSTR szOptionName, int iOptionValue);
  40. HRESULT ParseDrawingSection();
  41. HRESULT GetBitnumVal(LPCWSTR szName, BYTE *piValue);
  42. HRESULT GetStateNum(LPCWSTR pszStateName, BYTE *piNum);
  43. //---- drawing cmd parsing ----
  44. HRESULT ParseAddBorder();
  45. HRESULT ParseFillBorder();
  46. HRESULT ParseLogicalRect();
  47. HRESULT ParseFillBrush();
  48. HRESULT ParseLineBrush();
  49. HRESULT ParseMoveTo();
  50. HRESULT ParseLineTo();
  51. HRESULT ParseCurveTo();
  52. HRESULT ParseShape();
  53. HRESULT ParseEndShape();
  54. HRESULT ParseIf();
  55. HRESULT ParseElse();
  56. HRESULT ParseEndIf();
  57. HRESULT ParseSetOption();
  58. HRESULT ParseGotoState();
  59. //---- emitting ----
  60. HRESULT EmitCheck(int iLen);
  61. HRESULT EmitByte(BYTE eOpCode);
  62. HRESULT EmitShort(SHORT sValue);
  63. HRESULT EmitInt(int iValue);
  64. HRESULT EmitString(LPCWSTR szValue);
  65. //---- parse parameters ----
  66. HRESULT ParseEmitPoint();
  67. HRESULT ParseEmitRect();
  68. HRESULT ParseEmitSize();
  69. HRESULT ParseEmitSize2();
  70. HRESULT ParseEmitSize4();
  71. HRESULT ParseEmitColor();
  72. HRESULT ParseEmitColor4();
  73. HRESULT ParseEmitImagefile();
  74. HRESULT ParseEmitNone();
  75. //---- private data ----
  76. CScanner _scan;
  77. CSimpleArray<OPTIONBITENTRY> _OptionBits;
  78. int _iStateOffsets[MAX_STATES+1];
  79. INtlParserCallBack *_pCallBack;
  80. //---- pcode ----
  81. BYTE *_pPCode;
  82. int _iPCodeAllocSize; // currently allocated size
  83. MIXEDPTRS _u; // ptr to next pcode byte
  84. //---- IfStack ----
  85. IFRECORD _IfStack[MAX_IF_NESTING];
  86. int _iIfLevel;
  87. };
  88. //---------------------------------------------------------------------------