Skip to content

Commit

Permalink
Add ability to create threads in scripts.
Browse files Browse the repository at this point in the history
However many things might not be threadsafe.
  • Loading branch information
ollydev committed Sep 21, 2024
1 parent e3b4161 commit f0c95a7
Show file tree
Hide file tree
Showing 48 changed files with 6,100 additions and 1,576 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
test: Simba-Linux64

- name: MacOS 64
runs-on: macos-latest
runs-on: macos-13
build-mode: MACOS64
binary: Simba-MacOS.dmg
test: Simba

- name: MacOS AArch64
runs-on: macos-14
runs-on: macos-13
build-mode: MACOS-AARCH64
binary: Simba-MacOS-AArch64.dmg
#test: Simba MatchTemplateMask test fails, investigate later
Expand Down Expand Up @@ -96,15 +96,15 @@ jobs:
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output certificate.p12
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security import certificate.p12 -k build.keychain -P "$P12_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
# echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output certificate.p12
# security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
# security default-keychain -s build.keychain
# security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
# security import certificate.p12 -k build.keychain -P "$P12_PASSWORD" -T /usr/bin/codesign
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
codesign --deep --sign "7ACAD7EE0AA3A0783CE9592567098A3F08FC0B0B" Simba.app
codesign -v Simba.app
# codesign --deep --sign "7ACAD7EE0AA3A0783CE9592567098A3F08FC0B0B" Simba.app
# codesign -v Simba.app
brew install create-dmg
Expand Down
32 changes: 13 additions & 19 deletions DocGen/doccomments.simba
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// some monstrosity
// some monstrosity, adds doc headers to lape wrappers

var
Contents, NewContents, Import, WrapperName, Header, DocComment, Line: String;
Expand All @@ -24,34 +24,28 @@ begin
HeaderName := Header.After(' ');
HeaderName := HeaderName.CopyRange(1, HeaderName.IndexOfAny(['(',':',';']) - 1);

Doc := '(*%s%s%s%s%s> %s%s*)'.format([LINE_SEP, HeaderName, LINE_SEP, '~' * Length(HeaderName), LINE_SEP, Header, LINE_SEP]);
Doc := '(*' + LINE_SEP +
'%s' + LINE_SEP +
'%s' + LINE_SEP +
'```' + LINE_SEP +
'%s' + LINE_SEP +
'```' + LINE_SEP +
'*)';

Doc := Format(Doc, [HeaderName, '-' * Length(HeaderName), Header]);

Map += [WrapperName, Doc];
end;

begin
Contents := FileRead('Source/script/imports/simba/simba.import_dialogs.pas');

Contents := FileRead('Source\script\imports\simba.import_threading.pas');
for DocComment in Contents.BetweenAll('(*','*)') do
begin
if DocComment.Contains('===') then // section title
Continue;
Contents := Contents.Replace('(*' + DocComment + '*)' + LINE_SEP, '');
end;

for Import in Contents.BetweenAll("addClassVar(", ");" + LINE_SEP) do
begin
ReadWrapperName := Import.Between('@', '_Read');
WriteWrapperName := Import.Between('_Read, @', '_Write');

Params := Import.BetweenAll(#39, #39);
Params.RemoveAll(', ');

if (ReadWrapperName <> '') then
Add('function ' + Params[0] + '.Get' + Params[1] + ': ' + Params[2], ReadWrapperName + '_Read');
if (WriteWrapperName <> '') then
Add('procedure ' + Params[0] + '.Set' + Params[1] + '(Value: ' + Params[2] + ')', WriteWrapperName + '_Write');
end;

for Import in Contents.BetweenAll("addGlobalFunc(", ");" + LINE_SEP) do
begin
WrapperName := Import.After('@');
Expand All @@ -60,7 +54,7 @@ begin
Add(Header, WrapperName);
end;

for Line in Contents.Split(LINE_SEP) do
for Line in Contents.Split(LINE_SEP, False) do
begin
for I := 0 to High(Map) do
if (Line.Contains('procedure ' + Map[i].WrapperName + '(')) then
Expand Down
31 changes: 1 addition & 30 deletions DocGen/docgen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ begin
APIFiles += ['Source\script\imports\simba.import_image.pas', 'Image' ];
APIFiles += ['Source\script\imports\simba.import_dtm.pas', 'DTM' ];
APIFiles += ['Source\script\imports\simba.import_async.pas', 'ASync' ];
APIFiles += ['Source\script\imports\simba.import_stringmap.pas', 'String Map' ];
APIFiles += ['Source\script\imports\simba.import_threading.pas', 'Threading' ];
end;

procedure H2ToH3(Dir: String);
Expand All @@ -68,31 +68,6 @@ begin
FileWrite(FileName, FileRead(FileName).Replace('h2', 'h3', [rfReplaceAll]));
end;

// The one non sphinx/markdown we change is this:
// - Change lines that begin with '> ' to codeblocks.
procedure RightArrowToCodeBlock(var Str: String);
var
I: Integer;
Lines: TStringArray;
begin
Lines := Str.SplitLines;
while (I < Length(Lines)) do
begin
if Lines[I].StartsWith('> ') then
begin
Lines[I].Delete(1, 2);
Lines.Insert('```', I);
Lines.Insert('```', I+2);

Inc(I, 2);
end;

Inc(I);
end;

Str := LINE_SEP.Join(Lines);
end;

// Delete old api generation
procedure CleanAPI;
var
Expand Down Expand Up @@ -124,12 +99,8 @@ procedure BuildAPI;

Result := Length(Comments) > 0;
if Result then
begin
RightArrowToCodeBlock(Comments);

FileWrite('DocGen/source/api/' + Name + '.md', Comments);
end;
end;

var
I: Integer;
Expand Down
10 changes: 7 additions & 3 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@
</CompilerOptions>
</Item5>
<Item6 Name="MACOS64">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="cocoa"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
<Target>
Expand All @@ -263,9 +266,7 @@
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<DebugInfoType Value="dsDwarf2Set"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
Expand All @@ -291,6 +292,9 @@
</CompilerOptions>
</Item6>
<Item7 Name="MACOS-AARCH64">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="cocoa"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
<Target>
Expand Down Expand Up @@ -343,7 +347,7 @@
</CompilerOptions>
</Item7>
<SharedMatrixOptions Count="1">
<Item1 ID="760724751738" Type="IDEMacro" MacroName="LCLWidgetType" Value="cocoa"/>
<Item1 ID="760724751738" Modes="MACOS64,MACOS-AARCH64" Type="IDEMacro" MacroName="LCLWidgetType" Value="cocoa"/>
</SharedMatrixOptions>
</BuildModes>
<PublishOptions>
Expand Down
2 changes: 2 additions & 0 deletions Source/ide/simba.form_functionlist.pas
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ function GetURL(const Section: String): String;
'Misc': Result := ROOT + 'Misc.html';
'DTM': Result := ROOT + 'DTM.html';
'TCircle': Result := ROOT + 'TCircle.html';
'Threading': Result := ROOT + 'Threading.html';
'ASync': Result := ROOT + 'ASync.html';
end;
end;

Expand Down
4 changes: 2 additions & 2 deletions Source/ide/simba.ide_editor_paramhint.pas
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ procedure TSimbaParamHint.DoEditorCommand(Sender: TObject; AfterProcessing: Bool

if (Length(Decls) > 0) then
begin
if (Decl is TDeclaration_Method) then
FDisplayPoint.X := FDisplayPoint.X - Length(Decl.Name);
if (Decls[0] is TDeclaration_Method) and (Length(Decls[0].Name) > 0) then
FDisplayPoint.X := FDisplayPoint.X - Length(Decls[0].Name);

FHintForm.Font := Font;
FHintForm.Font.Color := Editor.Highlighter.IdentifierAttribute.Foreground;
Expand Down
Loading

0 comments on commit f0c95a7

Please sign in to comment.