Skip to content

Commit

Permalink
Normalize some naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 14, 2024
1 parent 1cf6f72 commit 2b4fffd
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 184 deletions.
97 changes: 25 additions & 72 deletions Source/script/imports/simba.import_encoding.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ implementation
lptypes, ffi,
simba.encoding, simba.hash, simba.compress, simba.image, simba.image_fastcompress;

type
PImageCompressThread = ^TImageCompressThread;

(*
Encoding
========
Expand Down Expand Up @@ -181,41 +178,6 @@ procedure _LapeTOTPCalculateToken(const Params: PParamArray; const Result: Point
PInteger(Result)^ := TOTPCalculateToken(PString(Params^[0])^);
end;

procedure _LapeImageCompressThread_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PImageCompressThread(Result)^ := TImageCompressThread.Create();
end;

procedure _LapeImageCompressThread_Push(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PImageCompressThread(Params^[0])^.Push(PSimbaImageArray(Params^[1])^);
end;

procedure _LapeImageCompressThread_OnCompressed_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PImageCompressThread(Params^[0])^.OnCompressed := TImageCompressedEvent(Params^[1]^);
end;

procedure _LapeImageCompressThread_OnCompressed_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
TImageCompressedEvent(Result^) := PImageCompressThread(Params^[0])^.OnCompressed;
end;

procedure _LapeImageCompressThread_TimeUsed(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PDouble(Result)^ := PImageCompressThread(Params^[0])^.TimeUsed;
end;

procedure _LapeImageCompressThread_IsCompressing(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PBoolean(Result)^ := PImageCompressThread(Params^[0])^.IsCompressing;
end;

procedure _LapeImageCompressThread_WaitCompressing(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PImageCompressThread(Params^[0])^.WaitCompressing();
end;

(*
CompressBytes
-------------
Expand Down Expand Up @@ -281,49 +243,49 @@ procedure _LapeDeCompressString(const Params: PParamArray; const Result: Pointer
end;

(*
SynLZCompress
-------------
FastCompress
------------
```
function SynLZCompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer;
function FastCompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer;
```
*)
procedure _LapeSynLZCompress(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeFastCompress(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PInteger(Result)^ := SynLZcompress(PPointer(Params^[0])^, PInteger(Params^[1])^, PPointer(Params^[2])^);
end;

(*
SynLZDecompress
---------------
FastDecompress
--------------
```
function SynLZDecompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer;
function FastDecompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer;
```
*)
procedure _LapeSynLZDecompress(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeFastDecompress(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PInteger(Result)^ := SynLZdecompress(PPointer(Params^[0])^, PInteger(Params^[1])^, PPointer(Params^[2])^);
end;

(*
SynLZCompressDestLen
--------------------
FastCompressDestLen
-------------------
```
function SynLZCompressDestLen(Len: Integer): Integer;
function FastCompressDestLen(Len: Integer): Integer;
```
*)
procedure _LapeSynLZCompressDestLen(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeFastCompressDestLen(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PInteger(Result)^ := SynLZcompressdestlen(PInteger(Params^[0])^);
end;

(*
SynLZDecompressDestLen
----------------------
FastDecompressDestLen
---------------------
```
function SynLZDecompressDestLen(Src: Pointer): Integer;
function FastDecompressDestLen(Src: Pointer): Integer;
```
*)
procedure _LapeSynLZDecompressDestLen(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeFastDecompressDestLen(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PInteger(Result)^ := SynLZdecompressdestlen(PPointer(Params^[0])^);
end;
Expand All @@ -341,15 +303,15 @@ procedure _LapeFastCompressImages(const Params: PParamArray); LAPE_WRAPPER_CALLI
end;

(*
FastDeCompressImages
FastDecompressImages
--------------------
```
function FastDeCompressImages(Data: Pointer; DataLen: SizeUInt): TSimbaImageArray;
function FastDecompressImages(Data: Pointer; DataLen: SizeUInt): TSimbaImageArray;
```
*)
procedure _LapeFastDeCompressImages(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
procedure _LapeFastDecompressImages(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
TSimbaImageArray(Result^) := SimbaImage_FastDeCompress(PPointer(Params^[0])^, PSizeUInt(Params^[1])^);
TSimbaImageArray(Result^) := SimbaImage_FastDecompress(PPointer(Params^[0])^, PSizeUInt(Params^[1])^);
end;

procedure ImportEncoding(Compiler: TSimbaScript_Compiler);
Expand Down Expand Up @@ -382,24 +344,15 @@ procedure ImportEncoding(Compiler: TSimbaScript_Compiler);
addGlobalFunc('function CompressString(S: String; Encoding: EBaseEncoding = EBaseEncoding.b64): String', @_LapeCompressString);
addGlobalFunc('function DecompressString(S: String; Encoding: EBaseEncoding = EBaseEncoding.b64): String', @_LapeDeCompressString);

addGlobalFunc('function SynLZCompressDestLen(Len: Integer): Integer', @_LapeSynLZCompressDestLen);
addGlobalFunc('function SynLZDecompressDestLen(Src: Pointer): Integer', @_LapeSynLZDecompressDestLen);
addGlobalFunc('function SynLZCompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer', @_LapeSynLZCompress);
addGlobalFunc('function SynLZDecompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer', @_LapeSynLZDecompress);
addGlobalFunc('function FastCompressDestLen(Len: Integer): Integer', @_LapeFastCompressDestLen);
addGlobalFunc('function FastDecompressDestLen(Src: Pointer): Integer', @_LapeFastDecompressDestLen);
addGlobalFunc('function FastCompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer', @_LapeFastCompress);
addGlobalFunc('function FastDecompress(Src: Pointer; Size: Integer; Dest: Pointer): Integer', @_LapeFastDecompress);

addGlobalFunc('procedure FastCompressImages(Images: TImageArray; var Data: Pointer; out DataSize: SizeUInt);', @_LapeFastCompressImages);
addGlobalFunc('function FastDeCompressImages(Data: Pointer; out DataLen: SizeUInt): TImageArray', @_LapeFastDeCompressImages);
addGlobalFunc('function FastDecompressImages(Data: Pointer; out DataLen: SizeUInt): TImageArray', @_LapeFastDecompressImages);

ImportingSection := '';

addClass('TImageCompressThread');
addClassConstructor('TImageCompressThread', '', @_LapeImageCompressThread_Create);
addGlobalType('procedure(Sender: TImageCompressThread; Images: TImageArray; Data: Pointer; DataSize: SizeUInt) of object', 'TImageCompressedEvent', FFI_DEFAULT_ABI);
addGlobalFunc('procedure TImageCompressThread.Push(Images: TImageArray)', @_LapeImageCompressThread_Push);
addGlobalFunc('function TImageCompressThread.TimeUsed: Double', @_LapeImageCompressThread_TimeUsed);
addGlobalFunc('function TImageCompressThread.IsCompressing: Boolean', @_LapeImageCompressThread_IsCompressing);
addGlobalFunc('procedure TImageCompressThread.WaitCompressing;', @_LapeImageCompressThread_WaitCompressing);
addProperty('TImageCompressThread', 'OnCompressed', 'TImageCompressedEvent', @_LapeImageCompressThread_OnCompressed_Read, @_LapeImageCompressThread_OnCompressed_Write);
end;
end;

Expand Down
6 changes: 3 additions & 3 deletions Source/script/imports/simba.import_externalimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ procedure _LapeExternalImage_DrawText(const Params: PParamArray); LAPE_WRAPPER_C
(*
TExternalImage.DrawText
~~~~~~~~~~~~~~~~~~~~~~~
> procedure TExternalImage.DrawText(Text: String; Box: TBox; Alignments: ETextDrawAlignmentSet);
> procedure TExternalImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign);
*)
procedure _LapeExternalImage_DrawTextEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaExternalImage(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EDrawTextAlignSet(Params^[3]^));
PSimbaExternalImage(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EImageTextAlign(Params^[3]^));
end;

(*
Expand Down Expand Up @@ -600,7 +600,7 @@ procedure ImportSimbaExternalImage(Compiler: TSimbaScript_Compiler);
addProperty('TExternalImage', 'DrawAlpha', 'Byte', @_LapeExternalImage_DrawAlpha_Read, @_LapeExternalImage_DrawAlpha_Write);

addGlobalFunc('procedure TExternalImage.DrawText(Text: String; Position: TPoint); overload', @_LapeExternalImage_DrawText);
addGlobalFunc('procedure TExternalImage.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlign); overload', @_LapeExternalImage_DrawTextEx);
addGlobalFunc('procedure TExternalImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign); overload', @_LapeExternalImage_DrawTextEx);
addGlobalFunc('procedure TExternalImage.DrawTextLines(Text: TStringArray; Position: TPoint);', @_LapeExternalImage_DrawTextLines);

addGlobalFunc('procedure TExternalImage.Fill(Color: TColor)', @_LapeExternalImage_Fill);
Expand Down
10 changes: 5 additions & 5 deletions Source/script/imports/simba.import_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,12 @@ procedure _LapeImage_DrawText(const Params: PParamArray); LAPE_WRAPPER_CALLING_C
TImage.DrawText
---------------
```
procedure TImage.DrawText(Text: String; Box: TBox; Alignments: ETextDrawAlignmentSet; Color: TColor);
procedure TImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign; Color: TColor);
```
*)
procedure _LapeImage_DrawTextEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImage(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EDrawTextAlignSet(Params^[3]^));
PSimbaImage(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EImageTextAlign(Params^[3]^));
end;

(*
Expand Down Expand Up @@ -1816,7 +1816,7 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalType('enum(NEAREST_NEIGHBOUR, BILINEAR)', 'EImageResizeAlgo');
addGlobalType('enum(NEAREST_NEIGHBOUR, BILINEAR)', 'EImageRotateAlgo');
addGlobalType('enum(BOX, GAUSS)', 'EImageBlurAlgo');
addGlobalType('set of enum(LEFT, CENTER, RIGHT, JUSTIFY, TOP, VERTICAL_CENTER, BASE_LINE, BOTTOM)', 'EDrawTextAlign');
addGlobalType('set of enum(LEFT, CENTER, RIGHT, JUSTIFY, TOP, VERTICAL_CENTER, BASE_LINE, BOTTOM)', 'EImageTextAlign');

addGlobalFunc('function TImage.Create: TImage; static; overload', @_LapeImage_Create1);
addGlobalFunc('function TImage.Create(Width, Height: Integer): TImage; static; overload', @_LapeImage_Create2);
Expand Down Expand Up @@ -1886,7 +1886,7 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('function TImage.TextHeight(Text: String): Integer;', @_LapeImage_TextHeight);
addGlobalFunc('function TImage.TextSize(Text: String): TPoint;', @_LapeImage_TextSize);
addGlobalFunc('procedure TImage.DrawText(Text: String; Position: TPoint); overload', @_LapeImage_DrawText);
addGlobalFunc('procedure TImage.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlign); overload', @_LapeImage_DrawTextEx);
addGlobalFunc('procedure TImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign); overload', @_LapeImage_DrawTextEx);
addGlobalFunc('procedure TImage.DrawTextLines(Text: TStringArray; Position: TPoint);', @_LapeImage_DrawTextLines);

addGlobalFunc('procedure TImage.DrawImage(Image: TImage; Position: TPoint)', @_LapeImage_DrawImage);
Expand Down Expand Up @@ -1991,4 +1991,4 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
end;
end;

end.
end.
4 changes: 2 additions & 2 deletions Source/script/imports/simba.import_imagebox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ procedure _LapeImageBoxCanvas_DrawText(const Params: PParamArray); LAPE_WRAPPER_

procedure _LapeImageBoxCanvas_DrawTextEx(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PSimbaImageBoxCanvas(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EDrawTextAlignSet(Params^[3]^), PColor(Params^[4])^);
PSimbaImageBoxCanvas(Params^[0])^.DrawText(PString(Params^[1])^, PBox(Params^[2])^, EImageTextAlign(Params^[3]^), PColor(Params^[4])^);
end;

procedure _LapeSimbaImageBoxCanvas_DrawLine(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -399,7 +399,7 @@ procedure ImportSimbaImageBox(Compiler: TSimbaScript_Compiler);
addGlobalFunc('function TImageBoxCanvas.TextHeight(Text: String): Integer;', @_LapeImageBoxCanvas_TextHeight);
addGlobalFunc('function TImageBoxCanvas.TextSize(Text: String): TPoint;', @_LapeImageBoxCanvas_TextSize);
addGlobalFunc('procedure TImageBoxCanvas.DrawText(Text: String; Position: TPoint; Color: TColor); overload', @_LapeImageBoxCanvas_DrawText);
addGlobalFunc('procedure TImageBoxCanvas.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlign; Color: TColor); overload', @_LapeImageBoxCanvas_DrawTextEx);
addGlobalFunc('procedure TImageBoxCanvas.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign; Color: TColor); overload', @_LapeImageBoxCanvas_DrawTextEx);

addGlobalFunc('procedure TImageBoxCanvas.DrawLine(Start, Stop: TPoint; Color: TColor);', @_LapeSimbaImageBoxCanvas_DrawLine);
addGlobalFunc('procedure TImageBoxCanvas.DrawLineGap(Start, Stop: TPoint; GapSize: Integer; Color: TColor);', @_LapeSimbaImageBoxCanvas_DrawLineGap);
Expand Down
4 changes: 2 additions & 2 deletions Source/simba.component_imageboxcanvas.pas
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TSimbaImageBoxCanvas = class
property FontItalic: Boolean read GetFontItalic write SetFontItalic;

procedure DrawText(Text: String; Position: TPoint; Color: TColor); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet; Color: TColor); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign; Color: TColor); overload;

function TextWidth(Text: String): Integer;
function TextHeight(Text: String): Integer;
Expand Down Expand Up @@ -260,7 +260,7 @@ procedure TSimbaImageBoxCanvas.DrawText(Text: String; Position: TPoint; Color: T
FTextDrawer.DrawText(Text, Position.Offset(FOffset), Color);
end;

procedure TSimbaImageBoxCanvas.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet; Color: TColor);
procedure TSimbaImageBoxCanvas.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign; Color: TColor);
begin
FTextDrawer.DrawText(Text, Box.Offset(FOffset), Alignments, Color);
end;
Expand Down
4 changes: 2 additions & 2 deletions Source/simba.externalimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TSimbaExternalImage = class(TSimbaBaseClass)
function TextSize(Text: String): TPoint;

procedure DrawText(Text: String; Position: TPoint); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign); overload;
procedure DrawTextLines(Text: TStringArray; Position: TPoint);

// Image
Expand Down Expand Up @@ -513,7 +513,7 @@ procedure TSimbaExternalImage.DrawText(Text: String; Position: TPoint);
addDirty(TSimbaImageProtected(FBackBuffer).FTextDrawer.DrawnBox);
end;

procedure TSimbaExternalImage.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet);
procedure TSimbaExternalImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign);
begin
CheckInUpdate();

Expand Down
4 changes: 2 additions & 2 deletions Source/simba.image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TSimbaImage = class(TSimbaBaseClass)

// text draw
procedure DrawText(Text: String; Position: TPoint); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet); overload;
procedure DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign); overload;
procedure DrawTextLines(Text: TStringArray; Position: TPoint);

// Image
Expand Down Expand Up @@ -1777,7 +1777,7 @@ procedure TSimbaImage.DrawText(Text: String; Position: TPoint);
FTextDrawer.DrawText(Text, Position, IfThen(DrawColor > -1, DrawColor, GetDistinctColor(0)));
end;

procedure TSimbaImage.DrawText(Text: String; Box: TBox; Alignments: EDrawTextAlignSet);
procedure TSimbaImage.DrawText(Text: String; Box: TBox; Alignments: EImageTextAlign);
begin
FTextDrawer.DrawText(Text, Box, Alignments, IfThen(DrawColor > -1, DrawColor, GetDistinctColor(0)));
end;
Expand Down
Loading

0 comments on commit 2b4fffd

Please sign in to comment.