Parcourir la source

Use isxclasses.pas and ISHelpGen's parser to auto generate the ScriptClasses_C word lists instead of doing this manually.

Todo: check the ROPS SIRegister_*_TypesAndConsts functions to find undocumented but used or useful stuff, like TDuplicates and soFromBeginning, both registered by SIRegister_Classes_TypesAndConsts. Ignore undocumented but also unused and unuseful stuff.
Martijn Laan il y a 1 an
Parent
commit
a1e8091051

+ 4 - 2
ISHelp/ISHelpGen/ISHelpGen.dpr

@@ -10,10 +10,11 @@ uses
   ComObj,
   TypInfo,
   XMLParse in 'XMLParse.pas',
-  UIsxclassesParser in 'UIsxclassesParser.pas';
+  UIsxclassesParser in 'UIsxclassesParser.pas',
+  PathFunc in '..\..\Components\PathFunc.pas';
 
 const
-  Version = '1.14';
+  Version = '1.15';
 
   XMLFileVersion = '1';
 
@@ -903,6 +904,7 @@ procedure Go;
         SourceDir + 'isxclasses.header2',
         SourceDir + 'isxclasses.footer',
         SourceDir + 'isxclasses_generated.xml');
+      IsxclassesParser.SaveWordLists(SourceDir + 'isxclasses_wordlists_generated.pas');
     finally
       IsxclassesParser.Free;
     end;

+ 2 - 0
ISHelp/ISHelpGen/ISHelpGen.dproj

@@ -62,6 +62,7 @@
         <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
         <DCC_Optimize>false</DCC_Optimize>
         <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+        <Debugger_RunParams>..</Debugger_RunParams>
     </PropertyGroup>
     <ItemGroup>
         <DelphiCompile Include="$(MainSource)">
@@ -69,6 +70,7 @@
         </DelphiCompile>
         <DCCReference Include="XMLParse.pas"/>
         <DCCReference Include="UIsxclassesParser.pas"/>
+        <DCCReference Include="..\..\Components\PathFunc.pas"/>
         <BuildConfiguration Include="Base">
             <Key>Base</Key>
         </BuildConfiguration>

+ 88 - 40
ISHelp/ISHelpGen/UIsxclassesParser.pas

@@ -10,48 +10,55 @@ type
   private
     FLines: TStringList;
     FTypes: TStringList;
+    FEnumValues: TStringList;
   public
-    constructor Create();
-    destructor Destroy(); override;
+    constructor Create;
+    destructor Destroy; override;
     procedure Parse(const FileName: String);
     procedure SaveXML(const HeaderFileName, HeaderFileName2, FooterFileName, OutputFileName: String);
+    procedure SaveWordLists(const OutputFileName: String);
   end;
 
 implementation
 
 uses
-  Windows,
-  SysUtils;
+  Windows, SysUtils,
+  PathFunc;
 
-constructor TIsxclassesParser.Create();
+constructor TIsxclassesParser.Create;
 begin
   inherited;
-  FLines := TStringList.Create();
-  FTypes := TStringList.Create();
+  FLines := TStringList.Create;
+  FTypes := TStringList.Create;
+  FEnumValues := TStringList.Create;
 end;
 
-destructor TIsxclassesParser.Destroy();
+destructor TIsxclassesParser.Destroy;
 begin
-  FTypes.Free();
-  FLines.Free();
+  FEnumValues.Free;
+  FTypes.Free;
+  FLines.Free;
   inherited;
 end;
 
 procedure TIsxclassesParser.Parse(const FileName: String);
-var
-  F: TextFile;
-  S: String;
-  P: Integer;
 begin
+  var F: TextFile;
   AssignFile(F, FileName);
   Reset(F);
   try
     while not Eof(F) do begin
+      var S: String;
       ReadLn(F, S);
       FLines.Add(S);
-      P := Pos('=', S);
-      if P > 1 then
-        FTypes.Add(Trim(Copy(S, 1, P-1)))
+      var P := Pos('=', S);
+      if P > 1 then begin
+        FTypes.Add(Trim(Copy(S, 1, P-1)));
+        Delete(S, 1, P+1);
+        var N := Length(S);
+        if (N > 3) and (S[1] = '(') and (S[N-1] = ')') and (S[N] = ';') then
+          FEnumValues.Add(Copy(S, 2, N-3));
+      end;
     end;
   finally
     CloseFile(F);
@@ -61,13 +68,12 @@ end;
 procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, FooterFileName, OutputFileName: String);
 
   procedure FCopyFile(const SourceFileName, DestFileName: String; AppendToDestFile: Boolean);
-  var
-    F1, F2: TextFile;
-    S: String;
   begin
+    var F1: TextFile;
     AssignFile(F1, SourceFileName);
     Reset(F1);
     try
+      var F2: TextFile;
       AssignFile(F2, DestFileName);
       if AppendToDestFile then begin
         if FileExists(DestFileName) then
@@ -78,6 +84,7 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
         Rewrite(F2);
       try
         while not Eof(F1) do begin
+          var S: String;
           ReadLn(F1, S);
           WriteLn(F2, S);
         end;
@@ -90,8 +97,6 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
   end;
 
   function FGetNextPart(var Text: PChar): String;
-  var
-    P: PChar;
   begin
     case Text^ of
       #0:
@@ -100,7 +105,7 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
         end;
       #1..#32:
         begin
-          P := Text;
+          var P := Text;
           Inc(Text);
           while CharInSet(Text^ , [#1..#32]) do
             Inc(Text);
@@ -113,7 +118,7 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
         end;
       '0'..'9', 'A'..'Z', 'a'..'z', '_', '.':
         begin
-          P := Text;
+          var P := Text;
           Inc(Text);
           while CharInSet(Text^ , ['0'..'9', 'A'..'Z', 'a'..'z', '_', '.']) do
             Inc(Text);
@@ -125,14 +130,11 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
   end;
 
   function FLinkTypes(const S: String): String;
-  var
-    Text: PChar;
-    NextPart: String;
   begin
     Result := '';
-    Text := PChar(S);
+    var Text := PChar(S);
 
-    NextPart := FGetNextPart(Text);
+    var NextPart := FGetNextPart(Text);
     while NextPart <> '' do begin
       if FTypes.IndexOf(NextPart) >= 0 then begin
         if Result = '' then //start of line = object definition
@@ -146,11 +148,9 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
   end;
 
   function FConvertLeadingSpacesToNbsp(const S: String): String;
-  var
-    I: Integer;
   begin
     Result := S;
-    I := 1;
+    var I := 1;
     while (I <= Length(Result)) and (Result[I] = ' ') do begin
       Delete(Result, I, 1);
       Insert('&nbsp;', Result, I);
@@ -158,18 +158,15 @@ procedure TIsxclassesParser.SaveXML(const HeaderFileName, HeaderFileName2, Foote
     end;
   end;
 
-var
-  F: TextFile;
-  I: Integer;
-  S: String;
 begin
   FCopyFile(HeaderFileName, OutputFileName, False);
 
+  var F: TextFile;
   AssignFile(F, OutputFileName);
   Append(F);
   try
-    for I := 0 to FTypes.Count-1 do begin
-      S := '<keyword value="' + FTypes[I] + '" anchor="' + FTypes[I] + '" />';
+    for var I := 0 to FTypes.Count-1 do begin
+      var S := '<keyword value="' + FTypes[I] + '" anchor="' + FTypes[I] + '" />';
       WriteLn(F, S);
     end;
     WriteLn(F, '<keyword value="MainForm" />');
@@ -185,8 +182,8 @@ begin
   Append(F);
   try
     WriteLn(F, '<p><br/><tt>');
-    for I := 0 to FLines.Count-1 do begin
-      S := FLinkTypes(FLines[I]);
+    for var I := 0 to FLines.Count-1 do begin
+      var S := FLinkTypes(FLines[I]);
       S := FConvertLeadingSpacesToNbsp(S);
       WriteLn(F, S, '<br/>');
     end;
@@ -198,4 +195,55 @@ begin
   FCopyFile(FooterFileName, OutputFileName, True);
 end;
 
+procedure TIsxclassesParser.SaveWordLists(const OutputFileName: String);
+
+  procedure WriteStringArray(const F: TextFile; const Name, Indent: String;
+    const Values: TStrings; const NewLineLength: Integer);
+  begin
+    WriteLn(F, Indent + Name + ': array of AnsiString = [');
+    var S: String;
+    for var I := 0 to Values.Count-1 do begin
+      if S <> '' then
+        S := S + ', ';
+      var V := Values[I];
+      V := '''' + StringReplace(V, ', ', ''', ''', [rfReplaceAll]) + '''';
+      S := S + V;
+      if Length(S) > NewLineLength then begin
+        if I <> Values.Count-1 then
+          S := S + ',';
+        WriteLn(F, Indent + Indent + S);
+        S := '';
+      end;
+    end;
+    if S <> '' then
+      WriteLn(F, Indent + Indent + S);
+    WriteLn(F, Indent + '];');
+  end;
+
+begin
+  var F: TextFile;
+  AssignFile(F, OutputFileName);
+  Rewrite(F);
+  try
+    const Indent = '  ';
+    WriteLn(F, 'unit ' + PathChangeExt(PathExtractName(OutputFileName), '') + ';');
+    WriteLn(F);
+    WriteLn(F, '{ This file is automatically generated. Do not edit. }');
+    WriteLn(F);
+    WriteLn(F, 'interface');
+    WriteLn(F);
+    WriteLn(F, 'var');
+    WriteStringArray(F, 'PascalTypes_IsxClasses', Indent, FTypes, 80);
+    WriteLn(F);
+    WriteStringArray(F, 'PascalEnumValues_IsxClasses', Indent, FEnumValues, 0);
+    WriteLn(F);
+    WriteLN(F, 'implementation');
+    WriteLn(F);
+    Write(F, 'end.');
+  finally
+    CloseFile(F);
+  end;
+end;
+
+
 end.

+ 1 - 1
ISHelp/compile.bat

@@ -1,7 +1,7 @@
 @echo off
 
 rem  Inno Setup
-rem  Copyright (C) 1997-2010 Jordan Russell
+rem  Copyright (C) 1997-2024 Jordan Russell
 rem  Portions by Martijn Laan
 rem  For conditions of distribution and use, see LICENSE.TXT.
 rem

+ 66 - 0
ISHelp/isxclasses_wordlists_generated.pas

@@ -0,0 +1,66 @@
+unit isxclasses_wordlists_generated;
+
+{ This file is automatically generated. Do not edit. }
+
+interface
+
+var
+  PascalTypes_IsxClasses: array of AnsiString = [
+    'TObject', 'TPersistent', 'TComponent', 'TStrings', 'TNotifyEvent', 'TStringList',
+    'TStream', 'THandleStream', 'TFileStream', 'TStringStream', 'TGraphicsObject', 'TFontStyle',
+    'TFontStyles', 'TFont', 'TCanvas', 'TPenMode', 'TPenStyle', 'TPen', 'TBrushStyle',
+    'TBrush', 'TGraphic', 'TAlphaFormat', 'TBitmap', 'TAlign', 'TAnchorKind', 'TAnchors',
+    'TControl', 'TWinControl', 'TGraphicControl', 'TCustomControl', 'TScrollBarKind', 'TScrollBarInc',
+    'TScrollingWinControl', 'TFormBorderStyle', 'TBorderIcon', 'TBorderIcons', 'TConstraintSize',
+    'TSizeConstraints', 'TPosition', 'TCloseAction', 'TCloseEvent', 'TCloseQueryEvent',
+    'TEShiftState', 'TShiftState', 'TKeyEvent', 'TKeyPressEvent', 'TForm', 'TCustomLabel',
+    'TAlignment', 'TLabel', 'TCustomEdit', 'TBorderStyle', 'TEditCharCase', 'TEdit', 'TNewEdit',
+    'TCustomMemo', 'TScrollStyle', 'TMemo', 'TNewMemo', 'TCustomComboBox', 'TComboBoxStyle',
+    'TComboBox', 'TNewComboBox', 'TButtonControl', 'TButton', 'TNewButton', 'TCustomCheckBox',
+    'TCheckBoxState', 'TCheckBox', 'TNewCheckBox', 'TRadioButton', 'TNewRadioButton', 'TSysLinkType',
+    'TSysLinkEvent', 'TCustomLinkLabel', 'TLinkLabel', 'TNewLinkLabel', 'TCustomListBox',
+    'TListBoxStyle', 'TListBox', 'TNewListBox', 'TBevelKind', 'TBevelShape', 'TBevelStyle',
+    'TBevel', 'TCustomPanel', 'TPanelBevel', 'TBevelWidth', 'TBorderWidth', 'TPanel', 'TNewStaticText',
+    'TCheckItemOperation', 'TNewCheckListBox', 'TNewProgressBarState', 'TNewProgressBarStyle',
+    'TNewProgressBar', 'TRichEditViewer', 'TPasswordEdit', 'TCustomFolderTreeView', 'TFolderRenameEvent',
+    'TFolderTreeView', 'TStartMenuFolderTreeView', 'TBitmapImage', 'TNewNotebook', 'TNewNotebookPage',
+    'TWizardPageNotifyEvent', 'TWizardPageButtonEvent', 'TWizardPageCancelEvent', 'TWizardPageShouldSkipEvent',
+    'TWizardPage', 'TInputQueryWizardPage', 'TInputOptionWizardPage', 'TInputDirWizardPage',
+    'TInputFileWizardPage', 'TOutputMsgWizardPage', 'TOutputMsgMemoWizardPage', 'TOutputProgressWizardPage',
+    'TOutputMarqueeProgressWizardPage', 'TDownloadWizardPage', 'TUIStateForm', 'TSetupForm',
+    'TMainForm', 'TWizardForm', 'TUninstallProgressForm'
+  ];
+
+  PascalEnumValues_IsxClasses: array of AnsiString = [
+    'fsBold', 'fsItalic', 'fsUnderline', 'fsStrikeOut',
+    'pmBlack', 'pmWhite', 'pmNop', 'pmNot', 'pmCopy', 'pmNotCopy', 'pmMergePenNot', 'pmMaskPenNot', 'pmMergeNotPen', 'pmMaskNotPen', 'pmMerge', 'pmNotMerge', 'pmMask', 'pmNotMask', 'pmXor', 'pmNotXor',
+    'psSolid', 'psDash', 'psDot', 'psDashDot', 'psDashDotDot', 'psClear', 'psInsideFrame',
+    'bsSolid', 'bsClear', 'bsHorizontal', 'bsVertical', 'bsFDiagonal', 'bsBDiagonal', 'bsCross', 'bsDiagCross',
+    'afIgnored', 'afDefined', 'afPremultiplied',
+    'alNone', 'alTop', 'alBottom', 'alLeft', 'alRight', 'alClient',
+    'akLeft', 'akTop', 'akRight', 'akBottom',
+    'sbHorizontal', 'sbVertical',
+    'bsNone', 'bsSingle', 'bsSizeable', 'bsDialog', 'bsToolWindow', 'bsSizeToolWin',
+    'biSystemMenu', 'biMinimize', 'biMaximize', 'biHelp',
+    'poDesigned', 'poDefault', 'poDefaultPosOnly', 'poDefaultSizeOnly', 'poScreenCenter', 'poDesktopCenter', 'poMainFormCenter', 'poOwnerFormCenter',
+    'caNone', 'caHide', 'caFree', 'caMinimize',
+    'ssShift', 'ssAlt', 'ssCtrl', 'ssLeft', 'ssRight', 'ssMiddle', 'ssDouble',
+    'taLeftJustify', 'taRightJustify', 'taCenter',
+    'ecNormal', 'ecUpperCase', 'ecLowerCase',
+    'ssNone', 'ssHorizontal', 'ssVertical', 'ssBoth',
+    'csDropDown', 'csSimple', 'csDropDownList', 'csOwnerDrawFixed', 'csOwnerDrawVariable',
+    'cbUnchecked', 'cbChecked', 'cbGrayed',
+    'sltURL', 'sltID',
+    'lbStandard', 'lbOwnerDrawFixed', 'lbOwnerDrawVariable',
+    'bkNone', 'bkTile', 'bkSoft', 'bkFlat',
+    'bsBox', 'bsFrame', 'bsTopLine', 'bsBottomLine', 'bsLeftLine', 'bsRightLine', 'bsSpacer',
+    'bsLowered', 'bsRaised',
+    'bvNone', 'bvLowered', 'bvRaised', 'bvSpace',
+    'coUncheck', 'coCheck', 'coCheckWithChildren',
+    'npbsNormal', 'npbsError', 'npbsPaused',
+    'npbstNormal', 'npbstMarquee'
+  ];
+
+implementation
+
+end.

+ 2 - 1
Projects/Compil32.dpr

@@ -65,7 +65,8 @@ uses
   SetupTypes in 'Src\SetupTypes.pas',
   Struct in 'Src\Struct.pas',
   SHA1 in '..\Components\SHA1.pas',
-  DotNetVersion in 'Src\DotNetVersion.pas';
+  DotNetVersion in 'Src\DotNetVersion.pas',
+  isxclasses_wordlists_generated in '..\ISHelp\isxclasses_wordlists_generated.pas';
 
 {$SETPEOSVERSION 6.1}
 {$SETPESUBSYSVERSION 6.1}

+ 1 - 0
Projects/Compil32.dproj

@@ -143,6 +143,7 @@
         <DCCReference Include="Src\Struct.pas"/>
         <DCCReference Include="..\Components\SHA1.pas"/>
         <DCCReference Include="Src\DotNetVersion.pas"/>
+        <DCCReference Include="..\ISHelp\isxclasses_wordlists_generated.pas"/>
         <BuildConfiguration Include="Base">
             <Key>Base</Key>
         </BuildConfiguration>

+ 18 - 31
Projects/Src/Compil32/ScintStylerInnoSetup.pas

@@ -156,7 +156,7 @@ implementation
 uses
   Generics.Defaults,
   MsgIDs, ScintInt, SetupSectionDirectives, LangOptionsSectionDirectives,
-  CmnFunc, SetupTypes, Struct, DotNetVersion;
+  CmnFunc, SetupTypes, Struct, DotNetVersion, isxclasses_wordlists_generated;
 
 type
   { Size must be <= SizeOf(TScintLineState) }
@@ -453,33 +453,16 @@ const
     'TArrayOfString', 'TArrayOfChar', 'TArrayOfBoolean', 'TArrayOfInteger', 'DWORD',
     'UINT', 'BOOL', 'DWORD_PTR', 'UINT_PTR', 'INT_PTR', 'TFileTime',
     'TExecWait', 'TExecOutput', 'TFindRec', 'TWindowsVersion',
-    'TOnDownloadProgress', 'TOnLog',
-    { ScriptClasses_C }
-    'TFolderRenameEvent', 'TWizardPageNotifyEvent', 'TWizardPageButtonEvent',
-    'TWizardPageCancelEvent', 'TWizardPageShouldSkipEvent', 'TNewStaticText',
-    'TNewCheckListBox', 'TNewProgressBar', 'TRichEditViewer', 'TPasswordEdit',
-    'TCustomFolderTreeView', 'TFolderTreeView', 'TStartMenuFolderTreeView',
-    'TBitmapImage', 'TNewEdit', 'TNewMemo', 'TNewComboBox', 'TNewListBox',
-    'TNewButton', 'TNewCheckBox', 'TNewRadioButton', 'TNewLinkLabel',
-    'TNewNotebookPage', 'TNewNotebook', 'TUIStateForm', 'TSetupForm',
-    'TMainForm', 'TWizardForm', 'TUninstallProgressForm', 'TWizardPage',
-    'TInputQueryWizardPage', 'TInputOptionWizardPage', 'TInputDirWizardPage',
-    'TInputFileWizardPage', 'TOutputMsgWizardPage', 'TOutputMsgMemoWizardPage',
-    'TOutputProgressWizardPage', 'TOutputMarqueeProgressWizardPage',
-    'TDownloadWizardPage'
+    'TOnDownloadProgress', 'TOnLog'
   ];
 
-  PascalEnums: array of AnsiString = [
+  PascalEnumValues: array of AnsiString = [
     { ScriptFunc_C }
-    'ewNoWait', 'ewWaitUntilTerminated', 'ewWaitUntilIdle',
-    { ScriptClasses_C }
-    'coUncheck', 'coCheck', 'coCheckWithChildren', 'npbsNormal', 'npbsError',
-    'npbsPaused', 'npbstNormal', 'npbstMarquee', 'afIgnored', 'afDefined',
-    'afPremultiplied'
+    'ewNoWait', 'ewWaitUntilTerminated', 'ewWaitUntilIdle'
   ];
 
 var
-  PascalRealEnums: array of PTypeInfo; { Initialized below }
+  PascalRealEnumValues: array of PTypeInfo; { Initialized below }
 
 const
   PascalVariables: array of AnsiString = [
@@ -627,9 +610,13 @@ constructor TInnoSetupStyler.Create(AOwner: TComponent);
         AddWordToList(SL, S, awtScriptKeyword);
       for var S in PascalTypes do
         AddWordToList(SL, S, awtScriptType);
-      for var S in PascalEnums do
+      for var S in PascalTypes_IsxClasses do
+        AddWordToList(SL, S, awtScriptType);
+      for var S in PascalEnumValues do
+        AddWordToList(SL, S, awtScriptEnum);
+      for var S in PascalEnumValues_IsxClasses do
         AddWordToList(SL, S, awtScriptEnum);
-      for var TypeInfo in PascalRealEnums do begin
+      for var TypeInfo in PascalRealEnumValues do begin
         var TypeData := GetTypeData(TypeInfo);
         for var I := TypeData.MinValue to TypeData.MaxValue do
           AddWordToList(SL, AnsiString(GetEnumName(TypeInfo, I)), awtScriptEnum);
@@ -1654,12 +1641,12 @@ begin
 end;
 
 initialization
-  SetLength(PascalRealEnums, 6);
-  PascalRealEnums[0] := TypeInfo(TMsgBoxType);
-  PascalRealEnums[1] := TypeInfo(TSetupMessageID);
-  PascalRealEnums[2] := TypeInfo(TSetupStep);
-  PascalRealEnums[3] := TypeInfo(TUninstallStep);
-  PascalRealEnums[4] := TypeInfo(TSetupProcessorArchitecture);
-  PascalRealEnums[5] := TypeInfo(TDotNetVersion);
+  SetLength(PascalRealEnumValues, 6);
+  PascalRealEnumValues[0] := TypeInfo(TMsgBoxType);
+  PascalRealEnumValues[1] := TypeInfo(TSetupMessageID);
+  PascalRealEnumValues[2] := TypeInfo(TSetupStep);
+  PascalRealEnumValues[3] := TypeInfo(TUninstallStep);
+  PascalRealEnumValues[4] := TypeInfo(TSetupProcessorArchitecture);
+  PascalRealEnumValues[5] := TypeInfo(TDotNetVersion);
 
 end.