Bladeren bron

Add support for multiple definitions per name. Only the first shows atm, needs the SciTE code for it to be added.

Martijn Laan 1 jaar geleden
bovenliggende
commit
e3b6a18c84
2 gewijzigde bestanden met toevoegingen van 26 en 14 verwijderingen
  1. 6 6
      ISHelp/isxclasses_wordlists_generated.pas
  2. 20 8
      Projects/Src/Compil32/ScintStylerInnoSetup.pas

+ 6 - 6
ISHelp/isxclasses_wordlists_generated.pas

@@ -73,10 +73,10 @@ var
 
   PascalMembers_Isxclasses: TScriptTable = [
     'function Add(ACaption: String): Integer;',
-    //'function Add(APrompt, AFilter, ADefaultExtension: String): Integer;',
-    //'function Add(APrompt: String): Integer;',
-    //'function Add(APrompt: String; APassword: Boolean): Integer;',
-    //'function Add(S: String): Integer;',
+    'function Add(APrompt, AFilter, ADefaultExtension: String): Integer;',
+    'function Add(APrompt: String): Integer;',
+    'function Add(APrompt: String; APassword: Boolean): Integer;',
+    'function Add(S: String): Integer;',
     'function AddCheckBox(ACaption, ASubItem: String; ALevel: Byte; AChecked, AEnabled, AHasInternalChildren, ACheckWhenParentChecked: Boolean; AObject: TObject): Integer;',
     'function AddEx(ACaption: String; ALevel: Byte; AExclusive: Boolean): Integer;',
     'function AddGroup(ACaption, ASubItem: String; ALevel: Byte; AObject: TObject): Integer;',
@@ -102,8 +102,8 @@ var
     'function TextHeight(Text: String): Integer;',
     'function TextWidth(Text: String): Integer;',
     'function Write(Buffer: AnyString; ByteCount: Longint): Longint;',
-    //'procedure Add(Url, BaseName, RequiredSHA256OfFile: String);',
-    //'procedure AddEx(Url, BaseName, RequiredSHA256OfFile, UserName, Password: String);',
+    'procedure Add(Url, BaseName, RequiredSHA256OfFile: String);',
+    'procedure AddEx(Url, BaseName, RequiredSHA256OfFile, UserName, Password: String);',
     'procedure AddStrings(Strings: TStrings);',
     'procedure Animate;',
     'procedure Append(S: String);',

+ 20 - 8
Projects/Src/Compil32/ScintStylerInnoSetup.pas

@@ -73,7 +73,8 @@ type
     stPascalReservedWord, stPascalString, stPascalNumber,
     stISPPReservedWord, stISPPString, stISPPNumber);
 
-  TFunctionDefinitionsByName = TDictionary<String, AnsiString>;
+  TFunctionDefinitions = array of AnsiString;
+  TFunctionDefinitionsByName = TDictionary<String, TFunctionDefinitions>;
 
   TInnoSetupStyler = class(TScintCustomStyler)
   private
@@ -764,14 +765,22 @@ begin
   for var ScriptFunc in ScriptFuncTable do begin
     var ScriptFuncWithoutHeader := RemoveScriptFuncHeader(ScriptFunc);
     var ScriptFuncName := ExtractScriptFuncWithoutHeaderName(ScriptFuncWithoutHeader);
+    var DoAddWordToList := True;
     if ScriptFuncHasParameters(ScriptFunc) then begin
-      try
-        FScriptFunctionsByName[ClassMembers].Add(String(ScriptFuncName), ScriptFuncWithoutHeader);
-      except on E: Exception do
-        raise Exception.CreateFmt('%s: %s', [ScriptFuncName, E.Message]);
-      end;
+      var Key := String(ScriptFuncName);
+      if FScriptFunctionsByName[ClassMembers].ContainsKey(Key) then begin
+        { Function has multiple prototypes }
+        var ScriptFunctions := FScriptFunctionsByName[ClassMembers][Key];
+        var N := Length(ScriptFunctions);
+        SetLength(ScriptFunctions, N+1);
+        ScriptFunctions[N] := ScriptFuncWithoutHeader;
+        FScriptFunctionsByName[ClassMembers][Key] := ScriptFunctions;
+        DoAddWordToList := False; { Already added it when the first prototype was found }
+      end else
+        FScriptFunctionsByName[ClassMembers].Add(Key, [ScriptFuncWithoutHeader]);
     end;
-    AddWordToList(SL, ScriptFuncName, awtScriptFunction);
+    if DoAddWordToList then
+      AddWordToList(SL, ScriptFuncName, awtScriptFunction);
   end;
 end;
 
@@ -885,7 +894,10 @@ end;
 
 function TInnoSetupStyler.GetScriptFunctionDefinition(const ClassMember: Boolean; const Name: String): AnsiString;
 begin
-  if not FScriptFunctionsByName[ClassMember].TryGetValue(Name, Result) then
+  var ScriptFunctions: TFunctionDefinitions;
+  if FScriptFunctionsByName[ClassMember].TryGetValue(Name, ScriptFunctions) then
+    Result := ScriptFunctions[0]
+  else
     Result := '';
 end;