From b61ccb0516652e055a9cfac56dbec68434a31d43 Mon Sep 17 00:00:00 2001 From: Olly Date: Sun, 3 Sep 2023 23:07:05 +0100 Subject: [PATCH] Codetools: Add "set of (a,b,c)" to globals --- DocGen/docgen.simba | 21 +++++++++-- DocGen/source/api/index.rst | 1 + DocGen/source/index.rst | 1 + DocGen/source/tutorials/index.rst | 1 + .../codetools/simba.ide_codetools_parser.pas | 35 ++++++++++++++----- Source/simba.tpa.pas | 3 +- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/DocGen/docgen.simba b/DocGen/docgen.simba index 636624503..58ee34320 100644 --- a/DocGen/docgen.simba +++ b/DocGen/docgen.simba @@ -166,15 +166,18 @@ begin end; end; -procedure BuildAPI; +// Delete old api generation +procedure CleanAPI; var FileName: String; begin - // Delete old api generation for FileName in DirList('DocGen/source/api/') do if (not (PathExtractName(FileName) in ['.gitkeep', 'index.rst'])) then FileDelete(FileName); +end; +procedure BuildAPI; +begin ParseSourceFile('simba.import_colormath', 'Color Math' ); ParseSourceFile('simba.import_point', 'TPoint' ); ParseSourceFile('simba.import_tpa', 'TPointArray' ); @@ -207,6 +210,14 @@ begin ParseSourceFile('simba.import_class_dtm', 'DTM' ); end; +procedure H2ToH3(dir: String); +var + FileName: String; +begin + for FileName in DirList(dir) do + FileWrite(FileName, FileRead(FileName).Replace('h2','h3', [rfReplaceAll])); +end; + var SphinxOutput: String; begin @@ -215,6 +226,7 @@ begin DirCreate('DocGen/build'); DirDelete('DocGen/build', True); + CleanAPI(); BuildAPI(); WriteLn('Sphinx exit code: ', RunCommand('sphinx-build', ['-q', '-E', 'DocGen/source', 'DocGen/build'], SphinxOutput)); @@ -222,4 +234,9 @@ begin WriteLn(SphinxOutput); WriteLn('Link: "' + PathNormalize('DocGen/build/index.html') + '"'); + + // it looks a lot better like this... + H2ToH3('DocGen/build/api'); + + CleanAPI(); end. diff --git a/DocGen/source/api/index.rst b/DocGen/source/api/index.rst index 782790de8..bdb45ae57 100644 --- a/DocGen/source/api/index.rst +++ b/DocGen/source/api/index.rst @@ -3,6 +3,7 @@ API === .. toctree:: + :maxdepth: 2 :glob: * diff --git a/DocGen/source/index.rst b/DocGen/source/index.rst index 2139c1b28..d9bbea31b 100644 --- a/DocGen/source/index.rst +++ b/DocGen/source/index.rst @@ -3,6 +3,7 @@ Simba ===== .. toctree:: + :maxdepth: 2 tutorials/index api/index diff --git a/DocGen/source/tutorials/index.rst b/DocGen/source/tutorials/index.rst index b4656c1c5..72c6ea252 100644 --- a/DocGen/source/tutorials/index.rst +++ b/DocGen/source/tutorials/index.rst @@ -3,5 +3,6 @@ Simba ===== .. toctree:: + :maxdepth: 2 Color Finding.rst diff --git a/Source/codetools/simba.ide_codetools_parser.pas b/Source/codetools/simba.ide_codetools_parser.pas index 185738e68..5890cc1f0 100644 --- a/Source/codetools/simba.ide_codetools_parser.pas +++ b/Source/codetools/simba.ide_codetools_parser.pas @@ -240,7 +240,11 @@ TDeclaration_TypeNativeMethod = class(TDeclaration_Type) function GetMethod: TDeclaration; end; - TDeclaration_TypeSet = class(TDeclaration_Type); + TDeclaration_TypeSet = class(TDeclaration_Type) + public + function EnumElements: TDeclarationArray; + end; + TDeclaration_TypeRange = class(TDeclaration_Type); TDeclaration_TypeUnion = class(TDeclaration_Type); @@ -462,6 +466,11 @@ function TDeclaration_TypeNativeMethod.GetMethod: TDeclaration; Result := FItems.GetByClassFirst(TDeclaration_ParentType); end; +function TDeclaration_TypeSet.EnumElements: TDeclarationArray; +begin + Result := FItems.GetByClass(TDeclaration_EnumElement); +end; + function TDeclaration_TypeMethod.GetResultString: String; begin if FResultString.IsNull then @@ -1234,7 +1243,10 @@ procedure TCodeParser.FindGlobals; Continue; end else if (Decl.ClassType = TDeclaration_TypeEnum) then - FGlobals.Extend(TDeclaration_TypeEnum(Decl).Elements); + FGlobals.Extend(TDeclaration_TypeEnum(Decl).Elements) + else + if (Decl.ClassType = TDeclaration_TypeSet) then + FGlobals.Extend(TDeclaration_TypeSet(Decl).EnumElements); FGlobals.Add(Decl); end; @@ -1836,7 +1848,7 @@ procedure TCodeParser.SetType; procedure TCodeParser.OrdinalType; begin - if (not InDeclaration(TDeclaration_TypeSet, TDeclaration_TypeArray, TDeclaration_TypeStub)) then + if (not InDeclaration(TDeclaration_TypeArray, TDeclaration_TypeStub)) then begin inherited; Exit; @@ -1855,15 +1867,20 @@ procedure TCodeParser.OrdinalType; procedure TCodeParser.EnumeratedType; begin - if Lexer.IsDefined('!SCOPEDENUMS') then + if InDeclaration(TDeclaration_TypeSet) then begin - EnumeratedScopedType(); + inherited; Exit; end; - PushStack(TDeclaration_TypeEnum); - inherited; - PopStack(); + if Lexer.IsDefined('!SCOPEDENUMS') then + EnumeratedScopedType() + else + begin + PushStack(TDeclaration_TypeEnum); + inherited; + PopStack(); + end; end; procedure TCodeParser.EnumeratedScopedType; @@ -1875,7 +1892,7 @@ procedure TCodeParser.EnumeratedScopedType; procedure TCodeParser.EnumeratedTypeItem; begin - if (not InDeclaration(TDeclaration_TypeEnum, TDeclaration_TypeEnumScoped)) then + if (not InDeclaration(TDeclaration_TypeSet, TDeclaration_TypeEnum, TDeclaration_TypeEnumScoped)) then begin inherited; Exit; diff --git a/Source/simba.tpa.pas b/Source/simba.tpa.pas index d243e2938..51b084238 100644 --- a/Source/simba.tpa.pas +++ b/Source/simba.tpa.pas @@ -1331,10 +1331,9 @@ function TPointArrayHelper.ExtractPie(StartDegree, EndDegree, MinRadius, MaxRadi Buffer.Add(Self[I]); end; - //Result := Buffer.Trim(); Result := TPointArray(Buffer.Trim()).ExtractDist(Center, MinRadius, MaxRadius); end else - //Result := Self.ExcludeDist(Center, MinRadius, MaxRadius); + Result := Self.ExtractDist(Center, MinRadius, MaxRadius); end; function TPointArrayHelper.Extremes: TPointArray;