Skip to content

Commit

Permalink
Codetools: Add "set of (a,b,c)" to globals
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Sep 3, 2023
1 parent f2359a9 commit b61ccb0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
21 changes: 19 additions & 2 deletions DocGen/docgen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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
Expand All @@ -215,11 +226,17 @@ begin
DirCreate('DocGen/build');
DirDelete('DocGen/build', True);

CleanAPI();
BuildAPI();

WriteLn('Sphinx exit code: ', RunCommand('sphinx-build', ['-q', '-E', 'DocGen/source', 'DocGen/build'], SphinxOutput));
if (SphinxOutput <> '') then
WriteLn(SphinxOutput);

WriteLn('Link: "' + PathNormalize('DocGen/build/index.html') + '"');

// it looks a lot better like this...
H2ToH3('DocGen/build/api');

CleanAPI();
end.
1 change: 1 addition & 0 deletions DocGen/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ API
===

.. toctree::
:maxdepth: 2
:glob:

*
1 change: 1 addition & 0 deletions DocGen/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Simba
=====

.. toctree::
:maxdepth: 2

tutorials/index
api/index
1 change: 1 addition & 0 deletions DocGen/source/tutorials/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ Simba
=====

.. toctree::
:maxdepth: 2

Color Finding.rst
35 changes: 26 additions & 9 deletions Source/codetools/simba.ide_codetools_parser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Source/simba.tpa.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b61ccb0

Please sign in to comment.