From 21ca68cd5578830e4b748e4cac4225637d831aef Mon Sep 17 00:00:00 2001 From: Olly Date: Wed, 11 Dec 2024 03:35:50 +0000 Subject: [PATCH] Lape update (wip) --- .../simba.ide_codetools_arrayhelpers.pas | 37 +- .../simba.ide_codetools_generics.pas | 44 +- .../simba.ide_codetools_pasparser.pas | 2 +- Source/ide/simba.form_main.pas | 4 +- Source/ide/simba.ide_package.pas | 2 +- .../imports/simba.import_pointbuffer.pas | 131 ----- Source/script/imports/simba.import_string.pas | 461 ++++++++---------- Source/script/simba.script_compiler.pas | 11 +- Source/script/simba.script_genericbase.pas | 1 + Source/script/simba.script_genericheap.pas | 2 +- Source/script/simba.script_genericmap.pas | 2 +- .../script/simba.script_genericstringmap.pas | 2 +- Source/script/simba.script_imports.pas | 3 +- Source/script/simba.script_pluginloader.pas | 2 +- Source/simba.aca.pas | 4 +- Source/simba.containers.pas | 3 +- .../imports => }/simba.externalcanvas.pas | 0 Source/simba.vartype_string.pas | 373 +++++--------- Tests/generic_heap.simba | 2 +- Tests/generic_map.simba | 2 +- Tests/generic_stringmap.simba | 4 +- Tests/string.simba | 17 - Third-Party/lape | 2 +- 23 files changed, 417 insertions(+), 694 deletions(-) delete mode 100644 Source/script/imports/simba.import_pointbuffer.pas rename Source/{script/imports => }/simba.externalcanvas.pas (100%) diff --git a/Source/ide/codetools/simba.ide_codetools_arrayhelpers.pas b/Source/ide/codetools/simba.ide_codetools_arrayhelpers.pas index bce2896c9..265b40f38 100644 --- a/Source/ide/codetools/simba.ide_codetools_arrayhelpers.pas +++ b/Source/ide/codetools/simba.ide_codetools_arrayhelpers.pas @@ -14,22 +14,6 @@ interface simba.base, simba.ide_codetools_parser; const - HELPERS_STRING: TStringArray = ( - 'property .Length: Integer;', - 'property .First: ;', - 'property .Last: ;', - 'property .Pop: ;', - 'procedure .SetLength(NewLength: Integer);', - 'function .Copy: ;', - 'function .Copy(StartIndex: Integer; Count: Integer = High(Integer)): ;', - 'procedure .Delete(StartIndex: Integer; Count: Integer = High(Integer));', - 'function .Remove(Value: ): ;', - 'function .RandomValue: ;', - 'procedure .Reverse;', - 'function .Reversed: ;', - 'procedure .Clear;' - ); - HELPERS_DYNARRAY: TStringArray = ( 'property .Length: Integer;', 'property .Low: Integer;', @@ -57,19 +41,17 @@ interface 'function .Sorted(CompareFunc: function(constref L, R: ): Integer): ;', 'function .Sorted(Weights: TIntegerArray; LowToHigh: Boolean): ;', 'function .Copy: ;', - 'function .Copy(StartIndex: Integer; Count: Integer = High(Integer)): ;', - 'function .RandomValue: ;', + 'function .CopyRange(StartIndex, EndIndex: Integer): ;', + 'function .Random: ;', 'function .Reversed: ;', 'function .Slice(Start, Stop, Step: Integer): ;', - 'function .Remove(Value: ): ;', - 'procedure .Delete(Index: Integer; Count: Integer = High(Integer));', + 'function .Delete(Value: ): ;', + 'procedure .DeleteIndex(Index: Integer; Count: Integer);', + 'procedure .DeleteRange(StartIndex, EndIndex: Integer);', 'procedure .Insert(Item: ; Index: Integer);', 'procedure .SetLength(NewLength: Integer);', - 'function .RandomValue: ;', 'procedure .Reverse;', 'procedure .Clear;', - 'procedure .Append(Value: );', - 'procedure .Extend(Value: );', 'function .Equals(Other: ): Boolean;', 'function .Intersection(Other: ): ;', 'function .Difference(Other: ): ;', @@ -143,14 +125,7 @@ function GetArrayHelpers(Decl: TDeclaration): TDeclarationArray; ElementType := Decl.Items.GetTextOfClass(TDeclaration_VarType); if (ElementType <> '') then Parser := Get(HELPERS_DYNARRAY, IfThen(Decl.Name <> '', Decl.Name, 'array'), ElementType, IfThen(Decl.Name <> '', Decl.Name, 'array of ' + ElementType)); - end - else if (Decl is TDeclaration_TypeAlias) then - case UpperCase(Decl.Name) of - 'STRING': Parser := Get(HELPERS_STRING, 'String', 'Char', 'String'); - 'ANSISTRING': Parser := Get(HELPERS_STRING, 'AnsiString', 'Char', 'AnsiString'); - 'WIDESTRING': Parser := Get(HELPERS_STRING, 'WideString', 'WideChar', 'WideString'); - 'UNICODESTRING': Parser := Get(HELPERS_STRING, 'UnicodeString', 'UnicodeChar', 'UnicodeString'); - end; + end; if (Parser <> nil) then Result := Parser.Items.ToArray diff --git a/Source/ide/codetools/simba.ide_codetools_generics.pas b/Source/ide/codetools/simba.ide_codetools_generics.pas index 8f5ccbfbc..6d07c132a 100644 --- a/Source/ide/codetools/simba.ide_codetools_generics.pas +++ b/Source/ide/codetools/simba.ide_codetools_generics.pas @@ -48,6 +48,16 @@ interface 'procedure .Clear; external;' + LineEnding + 'function .ToString: String; external;' + LineEnding; + ARRAYBUFFER_METHODS = + 'property .First: ; external;' + LineEnding + + 'property .Last: ; external;' + LineEnding + + 'property .Pop: ; external;' + LineEnding + + 'property .ToArray: array of ; external;' + LineEnding + + 'procedure .Add(Value: ); overload; external;' + LineEnding + + 'procedure .Add(Values: array of ); overload; external;' + LineEnding + + 'procedure .Clear; external;' + LineEnding + + 'function .ToString: String; external;' + LineEnding; + function GetGeneric(Decl: TDeclaration): TDeclarationArray; implementation @@ -122,6 +132,27 @@ function GetGeneric(Decl: TDeclaration): TDeclarationArray; GenericParsers.Add(Result); end; + function RunArrayBuffer(Name, Value: String): TCodeParser; + var + I: Integer; + Methods, FileName: String; + begin + FileName := '!GenericArrayBuffer::' + Name + '::' + Value; + for I := 0 to GenericParsers.Count - 1 do + if (GenericParsers[I].Lexer.FileName = FileName) then + Exit(GenericParsers[I]); + + Methods := ARRAYBUFFER_METHODS; + Methods := Methods.Replace('', Name); + Methods := Methods.Replace('', Value); + + Result := TCodeParser.Create(); + Result.SetScript(Methods); + Result.Run(); + + GenericParsers.Add(Result); + end; + var Parser: TCodeParser; Params: TDeclarationArray; @@ -137,26 +168,33 @@ function GetGeneric(Decl: TDeclaration): TDeclarationArray; Name := Kind; case LowerCase(Kind) of - 'stringmap': + 'tstringmap': begin Params := Decl.Items.GetByClass(TDeclaration_Parameter, True, True); if Length(Params) = 1 then Parser := RunStrMap(Name, 'String', Params[0].Name); end; - 'map': + 'tmap': begin Params := Decl.Items.GetByClass(TDeclaration_Parameter, True, True); if Length(Params) = 2 then Parser := RunMap(Name, Params[0].Name, Params[1].Name); end; - 'heap': + 'theap': begin Params := Decl.Items.GetByClass(TDeclaration_Parameter, True, True); if Length(Params) = 1 then Parser := RunHeap(Name, Params[0].Name); end; + + 'tarraybuffer': + begin + Params := Decl.Items.GetByClass(TDeclaration_Parameter, True, True); + if Length(Params) = 1 then + Parser := RunArrayBuffer(Name, Params[0].Name); + end; end; end; diff --git a/Source/ide/codetools/simba.ide_codetools_pasparser.pas b/Source/ide/codetools/simba.ide_codetools_pasparser.pas index 20cb38cad..c015571e2 100644 --- a/Source/ide/codetools/simba.ide_codetools_pasparser.pas +++ b/Source/ide/codetools/simba.ide_codetools_pasparser.pas @@ -1791,7 +1791,7 @@ procedure TPasParser.TypeKind; S: String; begin S := UpperCase(fLexer.Token); - Result := (S = 'STRINGMAP') or (S = 'MAP') or (S = 'HEAP'); + Result := (S = 'TSTRINGMAP') or (S = 'TMAP') or (S = 'THEAP') or (S = 'TARRAYBUFFER'); end; begin diff --git a/Source/ide/simba.form_main.pas b/Source/ide/simba.form_main.pas index 2d9851c8c..fd51444aa 100644 --- a/Source/ide/simba.form_main.pas +++ b/Source/ide/simba.form_main.pas @@ -801,8 +801,8 @@ procedure TSimbaMainForm.MenuGotoClick(Sender: TObject); if SimbaTabsForm.CurrentEditor <> nil then begin Value := ''; - if InputQuery('Goto line', 'Goto line:', Value) and Value.IsInteger() then - SimbaTabsForm.CurrentEditor.TopLine := StrToInt(Value) - (SimbaTabsForm.CurrentEditor.LinesInWindow div 2); + if InputQuery('Goto line', 'Goto line:', Value) and Value.IsNumeric then + SimbaTabsForm.CurrentEditor.TopLine := Value.ToInteger - (SimbaTabsForm.CurrentEditor.LinesInWindow div 2); end; end; diff --git a/Source/ide/simba.ide_package.pas b/Source/ide/simba.ide_package.pas index fa6384b13..c826125e5 100644 --- a/Source/ide/simba.ide_package.pas +++ b/Source/ide/simba.ide_package.pas @@ -156,7 +156,7 @@ procedure TSimbaPackageEndpoint.ParseTime(Str: String; out Time: TDateTime; out if (Str <> '') then begin - if Str.IsInteger() then + if Str.IsNumeric then Time := Str.ToDateTime('unix', 0) else Time := Str.ToDateTime('iso8601', 0); diff --git a/Source/script/imports/simba.import_pointbuffer.pas b/Source/script/imports/simba.import_pointbuffer.pas deleted file mode 100644 index fb159ba5f..000000000 --- a/Source/script/imports/simba.import_pointbuffer.pas +++ /dev/null @@ -1,131 +0,0 @@ -unit simba.import_pointbuffer; - -{$i simba.inc} - -interface - -uses - Classes, SysUtils, - simba.base, simba.script; - -procedure ImportPointBuffer(Script: TSimbaScript); - -implementation - -uses - Graphics, lptypes, lpvartypes, - simba.containers; - -type - PSimbaPointBuffer = ^TSimbaPointBuffer; - -procedure _LapePointBuffer_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.Init(PInteger(Params^[1])^); -end; - -procedure _LapePointBuffer_InitWith(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.InitWith(PPointArray(Params^[1])^); -end; - -procedure _LapePointBuffer_Clear(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.Clear(); -end; - -procedure _LapePointBuffer_Add1(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.Add(PPoint(Params^[1])^); -end; - -procedure _LapePointBuffer_Add2(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.Add(PInteger(Params^[1])^, PInteger(Params^[2])^); -end; - -procedure _LapePointBuffer_ToArray(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPointArray(Result)^ := PSimbaPointBuffer(Params^[0])^.ToArray(PBoolean(Params^[1])^); -end; - -procedure _LapePointBuffer_First(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.First(); -end; - -procedure _LapePointBuffer_Last(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Last(); -end; - -procedure _LapePointBuffer_Pop(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Pop(); -end; - -procedure _LapePointBuffer_Clear(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PSimbaPointBuffer(Params^[0])^.Clear(); -end; - -procedure _LapePointBuffer_Size(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PInteger(Result)^ := PSimbaPointBuffer(Params^[0])^.Size; -end; - -procedure _LapePointBuffer_Count(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PInteger(Result)^ := PSimbaPointBuffer(Params^[0])^.Count; -end; - -procedure _LapePointBuffer_Point(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Item[PInteger(Params^[1])^]; -end; - -procedure ImportPointBuffer(Script: TSimbaScript); -begin - with Script.Compiler do - begin - addGlobalType([ - 'record', - ' {%CODETOOLS OFF}', - ' __Length: Integer;', - ' __Count: Integer;', - ' __Arr: TPointArray;', - ' {%CODETOOLS ON}', - 'end;'], - 'TPointBuffer' - ); - if (getGlobalType('TPointBuffer').Size <> SizeOf(TSimbaPointBuffer)) then - SimbaException('SizeOf(TPointBuffer) is wrong'); - - addDelayedCode([ - 'function ToString(constref PointBuffer: TPointBuffer): String; override;', - 'begin', - ' Result := "TPointBuffer: Size=" + IntToStr(PointBuffer.Size()) + ", Count=" + IntToStr(PointBuffer.Count());', - 'end;' - ]); - - addGlobalFunc('procedure TPointBuffer.Init(const InitialSize: Integer = 1024);', @_LapePointBuffer_Init); - addGlobalFunc('procedure TPointBuffer.InitWith(const Values: TPointArray);', @_LapePointBuffer_InitWith); - - addGlobalFunc('procedure TPointBuffer.Clear;', @_LapePointBuffer_Clear); - - addGlobalFunc('procedure TPointBuffer.Add(Value: TPoint); overload;', @_LapePointBuffer_Add1); - addGlobalFunc('procedure TPointBuffer.Add(X, Y: Integer); overload;', @_LapePointBuffer_Add2); - addGlobalFunc('function TPointBuffer.ToArray(Copy: Boolean = True): TPointArray;', @_LapePointBuffer_ToArray); - - addGlobalFunc('function TPointBuffer.First: TPoint;', @_LapePointBuffer_First); - addGlobalFunc('function TPointBuffer.Last: TPoint;', @_LapePointBuffer_Last); - addGlobalFunc('function TPointBuffer.Pop: TPoint;', @_LapePointBuffer_Pop); - - addGlobalFunc('function TPointBuffer.Size: Integer;', @_LapePointBuffer_Size); - addGlobalFunc('function TPointBuffer.Count: Integer;', @_LapePointBuffer_Count); - addGlobalFunc('function TPointBuffer.Point(Index: Integer): TPoint;', @_LapePointBuffer_Point); - end; -end; - -end. - diff --git a/Source/script/imports/simba.import_string.pas b/Source/script/imports/simba.import_string.pas index 90be53464..f35e513e1 100644 --- a/Source/script/imports/simba.import_string.pas +++ b/Source/script/imports/simba.import_string.pas @@ -13,12 +13,75 @@ procedure ImportString(Script: TSimbaScript); implementation +uses + lpmessages; + (* String ====== String methods *) +procedure _LapeString_SetLength(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + SetLength(PString(Params^[0])^, PInteger(Params^[1])^); +end; + +procedure _LapeString_Length(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := Length(PString(Params^[0])^); +end; + +procedure _LapeString_Low(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := Low(PString(Params^[0])^); +end; + +procedure _LapeString_High(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PInteger(Result)^ := High(PString(Params^[0])^); +end; + +procedure _LapeString_Pop(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV + + function _Pop(var Str: lpString): Char; + begin + if Length(Str) < 1 then + LapeExceptionFmt(lpeIndexOutOfRange, [Length(Str), Low(Str), Length(Str)]); + Result := Str[Length(Str)]; + SetLength(Str, Length(Str) - 1); + end; + +begin + PChar(Result)^ := _Pop(PString(Params^[0])^); +end; + +procedure _LapeString_First(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV + + function _First(const Str: lpString): Char; + begin + if Length(Str) < 1 then + LapeExceptionFmt(lpeIndexOutOfRange, [Low(Str), Low(Str), Length(Str)]); + Result := Str[Low(Str)]; + end; + +begin + PChar(Result)^ := _First(PString(Params^[0])^); +end; + +procedure _LapeString_Last(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV + + function _Last(const Str: lpString): Char; + begin + if Length(Str) < 1 then + LapeExceptionFmt(lpeIndexOutOfRange, [High(Str), Low(Str), Length(Str)]); + Result := Str[High(Str)]; + end; + +begin + PChar(Result)^ := _Last(PString(Params^[0])^); +end; + (* String.Before ------------- @@ -59,24 +122,12 @@ procedure _LapeString_StartsWith(const Params: PParamArray; const Result: Pointe String.Equals ------------- ``` -function String.Equals(Other: String): Boolean; +function String.EqualsIgnoreCase(Other: String; CaseSenstive: Boolean = True): Boolean; ``` *) procedure _LapeString_Equals(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.Equals(PString(Params^[1])^); -end; - -(* -String.EqualsIgnoreCase ------------------------ -``` -function String.EqualsIgnoreCase(Other: String): Boolean; -``` -*) -procedure _LapeString_EqualsIgnoreCase(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PBoolean(Result)^ := PString(Params^[0])^.EqualsIgnoreCase(PString(Params^[1])^); + PBoolean(Result)^ := PString(Params^[0])^.Equals(PString(Params^[1])^, PBoolean(Params^[2])^); end; (* @@ -131,31 +182,31 @@ procedure _LapeString_EndsWith(const Params: PParamArray; const Result: Pointer) String.IsUpper -------------- ``` -function String.IsUpper(): Boolean; +property String.IsUpper(): Boolean; ``` *) procedure _LapeString_IsUpper(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.IsUpper(); + PBoolean(Result)^ := PString(Params^[0])^.IsUpper; end; (* String.IsLower -------------- ``` -function String.IsLower(): Boolean; +property String.IsLower: Boolean; ``` *) procedure _LapeString_IsLower(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.IsLower(); + PBoolean(Result)^ := PString(Params^[0])^.IsLower; end; (* String.ToUpper -------------- ``` -function String.ToUpper(): String; +function String.ToUpper: String; ``` *) procedure _LapeString_ToUpper(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -167,7 +218,7 @@ procedure _LapeString_ToUpper(const Params: PParamArray; const Result: Pointer); String.ToLower -------------- ``` -function String.ToLower(): String; +function String.ToLower: String; ``` *) procedure _LapeString_ToLower(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -187,6 +238,18 @@ procedure _LapeString_Capitalize(const Params: PParamArray; const Result: Pointe PString(Result)^ := PString(Params^[0])^.Capitalize(); end; +(* +String.CapitalizeWords +---------------------- +``` +function String.CapitalizeWords: String; +``` +*) +procedure _LapeString_CapitalizeWords(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PString(Result)^ := PString(Params^[0])^.CapitalizeWords(); +end; + (* String.SwapCase --------------- @@ -423,54 +486,6 @@ procedure _LapeString_RegExprExists(const Params: PParamArray; const Result: Poi PBoolean(Result)^ := PString(Params^[0])^.RegExprExists(PString(Params^[1])^); end; -(* -String.CopyRange ----------------- -``` -function String.CopyRange(StartIndex, EndIndex: Integer): String; -``` -*) -procedure _LapeString_CopyRange(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := PString(Params^[0])^.CopyRange(PInteger(Params^[1])^, PInteger(Params^[2])^); -end; - -(* -String.DeleteRange ------------------- -``` -procedure String.DeleteRange(StartIndex, EndIndex: Integer); -``` -*) -procedure _LapeString_DeleteRange(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV -begin - PString(Params^[0])^.DeleteRange(PInteger(Params^[1])^, PInteger(Params^[2])^); -end; - -(* -String.Remove -------------- -``` -function String.Remove(Value: String): Boolean; -``` -*) -procedure _LapeString_Remove(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PBoolean(Result)^ := PString(Params^[0])^.Remove(PString(Params^[1])^); -end; - -(* -String.RemoveAll ----------------- -``` -function String.RemoveAll(Value: String): Integer; -``` -*) -procedure _LapeString_RemoveAll(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PInteger(Result)^ := PString(Params^[0])^.RemoveAll(PString(Params^[1])^); -end; - (* String.IndexOf -------------- @@ -567,66 +582,6 @@ procedure _LapeString_BetweenAll(const Params: PParamArray; const Result: Pointe PStringArray(Result)^ := PString(Params^[0])^.BetweenAll(PString(Params^[1])^, PString(Params^[2])^); end; -(* -String.NumberChars ------------------- -``` -function String.NumberChars: String; static; -``` -*) -procedure _LapeString_NumberChars(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := String.NumberChars; -end; - -(* -String.LowerChars ------------------ -``` -function String.LowerChars: String; static; -``` -*) -procedure _LapeString_LowerChars(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := String.LowerChars; -end; - -(* -String.UpperChars ------------------ -``` -function String.UpperChars: String; static; -``` -*) -procedure _LapeString_UpperChars(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := String.UpperChars; -end; - -(* -String.AlphaChars ------------------ -``` -function String.AlphaChars: String; static; -``` -*) -procedure _LapeString_AlphaChars(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := String.AlphaChars; -end; - -(* -String.AlphaNumChars --------------------- -``` -function String.AlphaNumChars: String; static; -``` -*) -procedure _LapeString_AlphaNumChars(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := String.AlphaNumChars; -end; - (* String.Extract -------------- @@ -665,40 +620,89 @@ procedure _LapeString_ExtractFloat(const Params: PParamArray; const Result: Poin PDouble(Result)^ := PString(Params^[0])^.ExtractFloat(PInt64(Params^[1])^); end; +(* +String.IsAlpha +-------------- +``` +property String.IsAlpha: Boolean; +``` +*) +procedure _LapeString_IsAlpha(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PString(Params^[0])^.IsAlpha; +end; + (* String.IsAlphaNum ----------------- ``` -function String.IsAlphaNum(): Boolean; +property String.IsAlphaNum: Boolean; ``` *) procedure _LapeString_IsAlphaNum(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.IsAlphaNum(); + PBoolean(Result)^ := PString(Params^[0])^.IsAlphaNum; +end; + +(* +String.IsNumeric +---------------- +``` +property String.IsNumeric: Boolean; +``` +*) +procedure _LapeString_IsNumeric(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PBoolean(Result)^ := PString(Params^[0])^.IsNumeric; end; (* String.IsInteger ---------------- ``` -function String.IsInteger(): Boolean; +property String.IsInteger: Boolean; ``` *) procedure _LapeString_IsInteger(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.IsInteger(); + PBoolean(Result)^ := PString(Params^[0])^.IsInteger; end; (* String.IsFloat -------------- ``` -function String.IsFloat(): Boolean; +property String.IsFloat: Boolean; ``` *) procedure _LapeString_IsFloat(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PString(Params^[0])^.IsFloat(); + PBoolean(Result)^ := PString(Params^[0])^.IsFloat; +end; + +procedure _LapeString_Insert(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + Insert(PString(Params^[1])^, PString(Params^[0])^, PInteger(Params^[2])^); +end; + +procedure _LapeString_Delete(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + Delete(PString(Params^[0])^, PInteger(Params^[1])^, 1); +end; + +procedure _LapeString_DeleteRange(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + Delete(PString(Params^[0])^, PInteger(Params^[1])^, (PInteger(Params^[2])^ - PInteger(Params^[1])^) + 1); +end; + +procedure _LapeString_Copy(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PString(Result)^ := Copy(PString(Params^[0])^, 1, Length(PString(Params^[0])^)); +end; + +procedure _LapeString_CopyRange(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PString(Result)^ := Copy(PString(Params^[0])^, PInteger(Params^[1])^, (PInteger(Params^[2])^ - PInteger(Params^[1])^) + 1); end; (* @@ -713,23 +717,11 @@ procedure _LapeString_Count(const Params: PParamArray; const Result: Pointer); L PInteger(Result)^ := PString(Params^[0])^.Count(PString(Params^[1])^); end; -(* -String.CountAll ---------------- -``` -function String.CountAll(Values: TStringArray): TIntegerArray; -``` -*) -procedure _LapeString_CountAll(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PIntegerArray(Result)^ := PString(Params^[0])^.CountAll(PStringArray(Params^[1])^); -end; - (* String.Contains --------------- ``` -function String.Contains(Value: String; CaseSenstive: Boolean = True): Boolean; +function String.Contains(Value: String; CaseSenstive: Boolean): Boolean; ``` *) procedure _LapeString_Contains(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -749,30 +741,6 @@ procedure _LapeString_ContainsAny(const Params: PParamArray; const Result: Point PBoolean(Result)^ := PString(Params^[0])^.ContainsAny(PStringArray(Params^[1])^, PBoolean(Params^[2])^); end; -(* -String.IndexOfAny ------------------ -``` -function String.IndexOfAny(Values: TStringArray): Integer; -``` -*) -procedure _LapeString_IndexOfAny(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PInteger(Result)^ := PString(Params^[0])^.IndexOfAny(PStringArray(Params^[1])^); -end; - -(* -String.IndexOfAny ------------------ -``` -function String.IndexOfAny(Values: TStringArray; Offset: Integer): Integer; -``` -*) -procedure _LapeString_IndexOfAnyEx(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PInteger(Result)^ := PString(Params^[0])^.IndexOfAny(PStringArray(Params^[1])^, PInteger(Params^[2])^); -end; - (* String.Format ------------- @@ -969,75 +937,71 @@ procedure _LapeString_IN_StringArray(const Params: PParamArray; const Result: Po PBoolean(Result)^ := PString(Params^[0])^ in PStringArray(Params^[1])^; end; - -// -------------------------- -// char methods - (* -Char.IsAlphaNum ---------------- +Char.IsAlpha +------------ ``` -function Char.IsAlphaNum(): Boolean; +property Char.IsAlpha: Boolean; ``` *) -procedure _LapeChar_IsAlphaNum(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeChar_IsAlpha(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PChar(Params^[0])^.IsAlphaNum(); + PBoolean(Result)^ := PChar(Params^[0])^.IsAlpha; end; (* -Char.IsInteger --------------- +Char.IsAlphaNum +--------------- ``` -function Char.IsInteger(): Boolean; +property Char.IsAlphaNum: Boolean; ``` *) -procedure _LapeChar_IsInteger(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeChar_IsAlphaNum(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PChar(Params^[0])^.IsInteger(); + PBoolean(Result)^ := PChar(Params^[0])^.IsAlphaNum; end; (* -Char.IsFloat ------------- +Char.IsNumeric +-------------- ``` -function Char.IsFloat(): Boolean; +property Char.IsNumeric: Boolean; ``` *) -procedure _LapeChar_IsFloat(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeChar_IsNumeric(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PChar(Params^[0])^.IsFloat(); + PBoolean(Result)^ := PChar(Params^[0])^.IsNumeric; end; (* Char.IsUpper ------------ ``` -function Char.IsUpper(): Boolean; +property Char.IsUpper: Boolean; ``` *) procedure _LapeChar_IsUpper(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PChar(Params^[0])^.IsUpper(); + PBoolean(Result)^ := PChar(Params^[0])^.IsUpper; end; (* Char.IsLower ------------ ``` -function Char.IsLower(): Boolean; +property Char.IsLower: Boolean; ``` *) procedure _LapeChar_IsLower(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBoolean(Result)^ := PChar(Params^[0])^.IsLower(); + PBoolean(Result)^ := PChar(Params^[0])^.IsLower; end; (* Char.ToUpper ------------ ``` -function Char.ToUpper(): String; +function Char.ToUpper: String; ``` *) procedure _LapeChar_ToUpper(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -1049,7 +1013,7 @@ procedure _LapeChar_ToUpper(const Params: PParamArray; const Result: Pointer); L Char.ToLower ------------ ``` -function Char.ToLower(): String; +function Char.ToLower: String; ``` *) procedure _LapeChar_ToLower(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -1057,18 +1021,6 @@ procedure _LapeChar_ToLower(const Params: PParamArray; const Result: Pointer); L PString(Result)^ := PChar(Params^[0])^.ToLower(); end; -(* -Char.Capitalize ---------------- -``` -function Char.Capitalize(): String; -``` -*) -procedure _LapeChar_Capitalize(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PString(Result)^ := PChar(Params^[0])^.Capitalize(); -end; - (* Char.Join --------- @@ -1117,9 +1069,16 @@ procedure _LapeChar_IN_StringArray(const Params: PParamArray; const Result: Poin PBoolean(Result)^ := PChar(Params^[0])^ in PStringArray(Params^[1])^; end; -procedure _LapeStringArray_ToString(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +(* +TStringArray.Join +----------------- +``` +function TStringArray.Join(Glue: String): String; +``` +*) +procedure _LapeStringArray_Join(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PString(Result)^ := PStringArray(Params^[0])^.ToString(PString(Params^[1])^); + PString(Result)^ := PStringArray(Params^[0])^.Join(PString(Params^[1])^); end; procedure ImportString(Script: TSimbaScript); @@ -1149,25 +1108,38 @@ procedure ImportString(Script: TSimbaScript); ); addGlobalType('array of TRegExprMatch', 'TRegExprMatchArray'); - addGlobalFunc('function String.NumberChars: String; static;', @_LapeString_NumberChars); - addGlobalFunc('function String.AlphaChars: String; static;', @_LapeString_AlphaChars); - addGlobalFunc('function String.LowerChars: String; static;', @_LapeString_LowerChars); - addGlobalFunc('function String.UpperChars: String; static;', @_LapeString_UpperChars); - addGlobalFunc('function String.AlphaNumChars: String; static;', @_LapeString_AlphaNumChars); - - addGlobalFunc('function String.Equals(Other: String): Boolean;', @_LapeString_Equals); - addGlobalFunc('function String.EqualsIgnoreCase(Other: String): Boolean;', @_LapeString_EqualsIgnoreCase); + addGlobalFunc('procedure String.SetLength(NewLen: Int32);', @_LapeString_SetLength); + addGlobalFunc('property String.Length: Int32;', @_LapeString_Length); + addGlobalFunc('property String.Low: Int32;', @_LapeString_Low); + addGlobalFunc('property String.High: Int32;', @_LapeString_High); + addGlobalFunc('property String.Pop: Char;', @_LapeString_Pop); + addGlobalFunc('property String.First: Char;', @_LapeString_First); + addGlobalFunc('property String.Last: Char;', @_LapeString_Last); + + addGlobalFunc('property String.IsUpper: Boolean;', @_LapeString_IsUpper); + addGlobalFunc('property String.IsLower: Boolean;', @_LapeString_IsLower); + addGlobalFunc('property String.IsAlpha: Boolean;', @_LapeString_IsAlpha); + addGlobalFunc('property String.IsAlphaNum: Boolean;', @_LapeString_IsAlphaNum); + addGlobalFunc('property String.IsNumeric: Boolean;', @_LapeString_IsNumeric); + addGlobalFunc('property String.IsInteger: Boolean;', @_LapeString_IsInteger); + addGlobalFunc('property String.IsFloat: Boolean;', @_LapeString_IsFloat); + + addGlobalFunc('procedure String.Insert(Value: String; Index: Int32);', @_LapeString_Insert); + addGlobalFunc('procedure String.Delete(Value: String);', @_LapeString_Delete); + addGlobalFunc('procedure String.DeleteRange(StartIndex, EndIndex: Int32);', @_LapeString_DeleteRange); + addGlobalFunc('function String.Copy(StartIndex, EndIndex: Int32): String', @_LapeString_Copy); + addGlobalFunc('function String.CopyRange(StartIndex, EndIndex: Int32): String', @_LapeString_CopyRange); + + addGlobalFunc('function String.Equals(Other: String; CaseSenstive: Boolean = True): Boolean;', @_LapeString_Equals); addGlobalFunc('function String.Compare(Other: String): Integer;', @_LapeString_Compare); addGlobalFunc('function String.Similarity(Other: String): Double;', @_LapeString_Similarity); addGlobalFunc('function String.Hash(Seed: UInt32 = 0): UInt32;', @_LapeString_Hash); - addGlobalFunc('function String.IsUpper(): Boolean;', @_LapeString_IsUpper); - addGlobalFunc('function String.IsLower(): Boolean;', @_LapeString_IsLower); - - addGlobalFunc('function String.ToUpper(): String;', @_LapeString_ToUpper); - addGlobalFunc('function String.ToLower(): String;', @_LapeString_ToLower); - addGlobalFunc('function String.Capitalize(): String;', @_LapeString_Capitalize); - addGlobalFunc('function String.SwapCase(): String;', @_LapeString_SwapCase); + addGlobalFunc('function String.ToUpper: String;', @_LapeString_ToUpper); + addGlobalFunc('function String.ToLower: String;', @_LapeString_ToLower); + addGlobalFunc('function String.Capitalize: String;', @_LapeString_Capitalize); + addGlobalFunc('function String.CapitalizeWords: String;', @_LapeString_CapitalizeWords); + addGlobalFunc('function String.SwapCase: String;', @_LapeString_SwapCase); addGlobalFunc('function String.Before(Value: String): String;', @_LapeString_Before); addGlobalFunc('function String.After(Value: String): String;', @_LapeString_After); @@ -1180,9 +1152,6 @@ procedure ImportString(Script: TSimbaScript); addGlobalFunc('function String.RegExprFind(Pattern: String): TRegExprMatch;', @_LapeString_RegExprFind); addGlobalFunc('function String.RegExprExists(Pattern: String): Boolean;', @_LapeString_RegExprExists); - addGlobalFunc('function String.IndexOfAny(Values: TStringArray): Integer; overload;', @_LapeString_IndexOfAny); - addGlobalFunc('function String.IndexOfAny(Values: TStringArray; Offset: Integer): Integer; overload;', @_LapeString_IndexOfAnyEx); - addGlobalFunc('function String.IndexOf(Value: String): Integer; overload;', @_LapeString_IndexOf); addGlobalFunc('function String.IndexOf(Value: String; Offset: Integer): Integer; overload;', @_LapeString_IndexOfEx); addGlobalFunc('function String.LastIndexOf(Value: String): Integer; overload;', @_LapeString_LastIndexOf); @@ -1195,10 +1164,6 @@ procedure ImportString(Script: TSimbaScript); addGlobalFunc('function String.ExtractInteger(Default: Int64 = -1): Int64;', @_LapeString_ExtractInteger); addGlobalFunc('function String.ExtractFloat(Default: Double = -1): Double;', @_LapeString_ExtractFloat); - addGlobalFunc('function String.IsAlphaNum(): Boolean;', @_LapeString_IsAlphaNum); - addGlobalFunc('function String.IsInteger(): Boolean;', @_LapeString_IsInteger); - addGlobalFunc('function String.IsFloat(): Boolean;', @_LapeString_IsFloat); - addGlobalFunc('function String.Trim: String; overload;', @_LapeString_Trim); addGlobalFunc('function String.Trim(TrimChars: array of Char): String; overload;', @_LapeString_TrimEx); @@ -1212,25 +1177,16 @@ procedure ImportString(Script: TSimbaScript); addGlobalFunc('function String.EndsWith(Value: String; CaseSenstive: Boolean = True): Boolean;', @_LapeString_EndsWith); addGlobalFunc('function String.Partition(Value: String): TStringArray;', @_LapeString_Partition); - addGlobalFunc('function String.Replace(OldValue: String; NewValue: String): String; overload;', @_LapeString_Replace); - addGlobalFunc('function String.Replace(OldValue: String; NewValue: String; ReplaceFlags: TReplaceFlags): String; overload;', @_LapeString_ReplaceEx); + addGlobalFunc('function String.Replace(OldValue, NewValue: String): String; overload;', @_LapeString_Replace); + addGlobalFunc('function String.Replace(OldValue, NewValue: String; ReplaceFlags: TReplaceFlags): String; overload;', @_LapeString_ReplaceEx); - addGlobalFunc('function String.Contains(Value: String; CaseSenstive: Boolean = True): Boolean;', @_LapeString_Contains); - addGlobalFunc('function String.ContainsAny(Values: TStringArray; CaseSenstive: Boolean = True): Boolean;', @_LapeString_ContainsAny); - - addGlobalFunc('function String.Count(Value: String): Integer;', @_LapeString_Count); - addGlobalFunc('function String.CountAll(Values: TStringArray): TIntegerArray;', @_LapeString_CountAll); + addGlobalFunc('function String.Contains(Value: String; CaseSenstive: Boolean): Boolean; overload', @_LapeString_Contains); + addGlobalFunc('function String.ContainsAny(Values: TStringArray; CaseSenstive: Boolean): Boolean;', @_LapeString_ContainsAny); addGlobalFunc('function String.Join(Values: TStringArray): String;', @_LapeString_Join); addGlobalFunc('function String.Split(Seperator: String; ExcludeEmpty: Boolean = True): TStringArray;', @_LapeString_Split); addGlobalFunc('function String.SplitLines: TStringArray;', @_LapeString_SplitLines); - addGlobalFunc('function String.CopyRange(StartIndex, EndIndex: Integer): String;', @_LapeString_CopyRange); - addGlobalFunc('procedure String.DeleteRange(StartIndex, EndIndex: Integer);', @_LapeString_DeleteRange); - - addGlobalFunc('function String.Remove(Value: String): Boolean;', @_LapeString_Remove); - addGlobalFunc('function String.RemoveAll(Value: String): Integer;', @_LapeString_RemoveAll); - addGlobalFunc('function String.PadLeft(Count: Integer; PaddingChar: Char = #32): String', @_LapeString_PadLeft); addGlobalFunc('function String.PadRight(Count: Integer; PaddingChar: Char = #32): String', @_LapeString_PadRight); @@ -1249,20 +1205,17 @@ procedure ImportString(Script: TSimbaScript); addGlobalFunc('function String.ToDouble(Default: Double): Double; overload;', @_LapeString_ToDoubleDef); addGlobalFunc('function String.ToDateTime(Fmt: String; Def: TDateTime): TDateTime;', @_LapeString_ToDateTime); - addGlobalFunc('function TStringArray.ToString(Sep: String): String;', @_LapeStringArray_ToString); + addGlobalFunc('function TStringArray.Join(Glue: String): String;', @_LapeStringArray_Join); addGlobalFunc('operator *(Left: String; Right: Integer): String', @_LapeString_MUL_Integer); addGlobalFunc('operator in(Left: String; Right: String): Boolean', @_LapeString_IN_String); addGlobalFunc('operator in(Left: String; Right: TStringArray): Boolean', @_LapeString_IN_StringArray); - addGlobalFunc('function Char.IsUpper(): Boolean;', @_LapeChar_IsUpper); - addGlobalFunc('function Char.IsLower(): Boolean;', @_LapeChar_IsLower); - addGlobalFunc('function Char.ToUpper(): String;', @_LapeChar_ToUpper); - addGlobalFunc('function Char.ToLower(): String;', @_LapeChar_ToLower); - addGlobalFunc('function Char.Capitalize(): String;', @_LapeChar_Capitalize); - addGlobalFunc('function Char.IsAlphaNum(): Boolean;', @_LapeChar_IsAlphaNum); - addGlobalFunc('function Char.IsInteger(): Boolean;', @_LapeChar_IsInteger); - addGlobalFunc('function Char.IsFloat(): Boolean;', @_LapeChar_IsFloat); + addGlobalFunc('property Char.IsUpper: Boolean;', @_LapeChar_IsUpper); + addGlobalFunc('property Char.IsLower: Boolean;', @_LapeChar_IsLower); + addGlobalFunc('property Char.IsAlpha: Boolean;', @_LapeChar_IsAlpha); + addGlobalFunc('property Char.IsAlphaNum: Boolean;', @_LapeChar_IsAlphaNum); + addGlobalFunc('property Char.IsNumeric: Boolean;', @_LapeChar_IsNumeric); addGlobalFunc('function Char.Join(Values: TStringArray): String;', @_LapeChar_Join); addGlobalFunc('operator *(Left: Char; Right: Integer): String', @_LapeChar_MUL_Integer); diff --git a/Source/script/simba.script_compiler.pas b/Source/script/simba.script_compiler.pas index 8706a2b33..0016d0476 100644 --- a/Source/script/simba.script_compiler.pas +++ b/Source/script/simba.script_compiler.pas @@ -60,6 +60,7 @@ TManagedImportClosure = class(TLapeDeclaration) function addGlobalVar(Value: Pointer; AName: lpString): TLapeGlobalVar; override; function addGlobalFunc(Header: lpString; Value: Pointer): TLapeGlobalVar; override; function addGlobalType(Str: lpString; AName: lpString): TLapeType; override; + function addGlobalType(Typ: TLapeType; AName: lpString = ''; ACopy: Boolean = True): TLapeType; override; // Compiler addons procedure pushCode(Code: String); @@ -343,7 +344,7 @@ constructor TScriptCompiler.CreateDump; begin FDump := TSimbaStringPairList.Create(); - // init the dump with things not imported normally + // init the dump with things not imported by normal means for BaseType in ELapeBaseType do if (FBaseTypes[BaseType] <> nil) then DumpCode('Base', 'type %s = %s;'.Format([LapeTypeToString(BaseType), LapeTypeToString(BaseType)])); @@ -519,6 +520,14 @@ function TScriptCompiler.addGlobalType(Str: lpString; AName: lpString): TLapeTyp DumpType(AName, Str); end; +function TScriptCompiler.addGlobalType(Typ: TLapeType; AName: lpString; ACopy: Boolean): TLapeType; +begin + if (FDump <> nil) and (Typ <> nil) and (Typ.Name <> '') then + DumpType(AName, Typ.Name); + + Result := inherited; +end; + procedure TScriptCompiler.pushCode(Code: String); begin pushTokenizer(TLapeTokenizerString.Create(Code)); diff --git a/Source/script/simba.script_genericbase.pas b/Source/script/simba.script_genericbase.pas index 349799a7e..f2834a484 100644 --- a/Source/script/simba.script_genericbase.pas +++ b/Source/script/simba.script_genericbase.pas @@ -206,6 +206,7 @@ constructor TGenericMethod.Create(ACompiler: TLapeCompilerBase; ADocPos: PDocPos inherited Create(ACompiler, ADocPos); FConstant := bTrue; + FSpecialParam := spType; end; // "inherited FoldConstants()" but dont hide exception if raised diff --git a/Source/script/simba.script_genericheap.pas b/Source/script/simba.script_genericheap.pas index 2f08aec1f..03c5c3b9d 100644 --- a/Source/script/simba.script_genericheap.pas +++ b/Source/script/simba.script_genericheap.pas @@ -230,7 +230,7 @@ function TLapeTree_InternalMethod_Heap.resType: TLapeType; procedure InitializeHeap(Compiler: TLapeCompiler); begin - Compiler.InternalMethodMap['Heap'] := TLapeTree_InternalMethod_Heap; + Compiler.InternalMethodMap['THeap'] := TLapeTree_InternalMethod_Heap; end; end. diff --git a/Source/script/simba.script_genericmap.pas b/Source/script/simba.script_genericmap.pas index 7812ff977..b7181985e 100644 --- a/Source/script/simba.script_genericmap.pas +++ b/Source/script/simba.script_genericmap.pas @@ -338,7 +338,7 @@ function TLapeTree_InternalMethod_Map.resType: TLapeType; procedure InitializeMap(Compiler: TLapeCompiler); begin - Compiler.InternalMethodMap['Map'] := TLapeTree_InternalMethod_Map; + Compiler.InternalMethodMap['TMap'] := TLapeTree_InternalMethod_Map; end; end. diff --git a/Source/script/simba.script_genericstringmap.pas b/Source/script/simba.script_genericstringmap.pas index fadbcf8a3..ab42b0ac2 100644 --- a/Source/script/simba.script_genericstringmap.pas +++ b/Source/script/simba.script_genericstringmap.pas @@ -523,7 +523,7 @@ procedure InitializeStringMap(Compiler: TLapeCompiler); Compiler.addGlobalFunc('function _StringMapIndexOf(Arr: Pointer; ElSize: Int32; Hi: Int32; CaseSens: Boolean; Key: String): Int32', @_LapeStringMapIndexOf); Compiler.addGlobalFunc('function _StringMapHash(Str: String): UInt64', @_LapeStringMapHash); - Compiler.InternalMethodMap['StringMap'] := TLapeTree_InternalMethod_StringMap; + Compiler.InternalMethodMap['TStringMap'] := TLapeTree_InternalMethod_StringMap; end; end. diff --git a/Source/script/simba.script_imports.pas b/Source/script/simba.script_imports.pas index d1537adb1..e1cdd827d 100644 --- a/Source/script/simba.script_imports.pas +++ b/Source/script/simba.script_imports.pas @@ -34,7 +34,7 @@ implementation simba.import_encoding, simba.import_file, simba.import_process, simba.import_target, simba.import_math, simba.import_misc, simba.import_slacktree, simba.import_string, simba.import_random, simba.import_debugimage, simba.import_web, simba.import_threading, - simba.import_pointbuffer, simba.import_async, + simba.import_async, // Simba classes simba.import_image, simba.import_externalcanvas, simba.import_dtm, simba.import_matchtemplate, @@ -96,7 +96,6 @@ procedure AddSimbaImports(Script: TSimbaScript); ImportMisc(Script); ImportThreading(Script); ImportASync(Script); - ImportPointBuffer(Script); ImportSimbaImageBox(Script); ImportSimbaShapeBox(Script); diff --git a/Source/script/simba.script_pluginloader.pas b/Source/script/simba.script_pluginloader.pas index 8dfa261ab..631af6761 100644 --- a/Source/script/simba.script_pluginloader.pas +++ b/Source/script/simba.script_pluginloader.pas @@ -87,7 +87,7 @@ function FindLoadedPlugin(FileName: String): String; begin Result := ''; for I := 0 to High(LoadedPlugins) do - if (TSimbaPath.PathExtractNameWithoutExt(LoadedPlugins[I].OrginalFileName).EqualsIgnoreCase(TSimbaPath.PathExtractNameWithoutExt(FileName))) then + if (TSimbaPath.PathExtractNameWithoutExt(LoadedPlugins[I].OrginalFileName).Equals(TSimbaPath.PathExtractNameWithoutExt(FileName), False)) then Exit(LoadedPlugins[I].FileName); end; diff --git a/Source/simba.aca.pas b/Source/simba.aca.pas index 0a6ddc238..e458efd94 100644 --- a/Source/simba.aca.pas +++ b/Source/simba.aca.pas @@ -153,8 +153,8 @@ procedure TSimbaACAForm.MenuItemLoadHSLCircleExClick(Sender: TObject); var Value: String; begin - if InputQuery('ACA', 'HSL Circle Radius (Max 2000)', Value) and Value.IsInteger() then - LoadHSLCircle(Min(Value.ToInteger(), 2000)); + if InputQuery('ACA', 'HSL Circle Radius (Max 2000)', Value) and Value.IsNumeric then + LoadHSLCircle(Min(Value.ToInteger, 2000)); end; function TSimbaACAForm.IsShortcut(var Message: TLMKey): Boolean; diff --git a/Source/simba.containers.pas b/Source/simba.containers.pas index 74813d3a7..a4aec6d08 100644 --- a/Source/simba.containers.pas +++ b/Source/simba.containers.pas @@ -4,14 +4,13 @@ License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0) Very simple containers: - - List + - Lists - Stack - ArrayBuffer - StringBuilder } unit simba.containers; -{$DEFINE SIMBA_MAX_OPTIMIZATION} {$i simba.inc} interface diff --git a/Source/script/imports/simba.externalcanvas.pas b/Source/simba.externalcanvas.pas similarity index 100% rename from Source/script/imports/simba.externalcanvas.pas rename to Source/simba.externalcanvas.pas diff --git a/Source/simba.vartype_string.pas b/Source/simba.vartype_string.pas index 5602d5fdd..152881cb2 100644 --- a/Source/simba.vartype_string.pas +++ b/Source/simba.vartype_string.pas @@ -42,45 +42,55 @@ TRegExprMatch = record TRegExprMatchArray = array of TRegExprMatch; TSimbaCharHelper = type helper for Char + private + function GetIsUpper: Boolean; + function GetIsLower: Boolean; + function GetIsAlpha: Boolean; + function GetIsAlphaNum: Boolean; + function GetIsNumeric: Boolean; public - function IsUpper(): Boolean; - function IsLower(): Boolean; - function IsAlphaNum(): Boolean; - function IsInteger(): Boolean; - function IsFloat(): Boolean; + function ToUpper: Char; + function ToLower: Char; - function ToUpper(): Char; - function ToLower(): Char; - function Capitalize(): Char; + property IsUpper: Boolean read GetIsUpper; + property IsLower: Boolean read GetIsLower; + property IsAlpha: Boolean read GetIsAlpha; + property IsAlphaNum: Boolean read GetIsAlphaNum; + property IsNumeric: Boolean read GetIsNumeric; function Join(const Values: TStringArray): String; end; TSimbaStringHelper = type helper for String - public const - NumberChars = '0123456789'; - LowerChars = 'abcdefghijklmnopqrstuvwxyz'; - UpperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - AlphaChars = LowerChars + UpperChars; - AlphaNumChars = AlphaChars + NumberChars; + private + function IsInSet(Chars: TSysCharSet): Boolean; + + function GetIsAlpha: Boolean; + function GetIsAlphaNum: Boolean; + function GetIsFloat: Boolean; + function GetIsInteger: Boolean; + function GetIsLower: Boolean; + function GetIsNumeric: Boolean; + function GetIsUpper: Boolean; public - function Equals(Other: String): Boolean; - function EqualsIgnoreCase(Other: String): Boolean; + function Equals(Other: String; CaseSenstive: Boolean = True): Boolean; function Compare(Other: String): Integer; function Similarity(Other: String): Double; function Hash(Seed: UInt32 = 0): UInt32; - function IsUpper(): Boolean; - function IsLower(): Boolean; - function IsAlphaNum(): Boolean; - function IsInteger(): Boolean; - function IsFloat(): Boolean; + property IsUpper: Boolean read GetIsUpper; + property IsLower: Boolean read GetIsLower; + property IsAlpha: Boolean read GetIsAlpha; + property IsAlphaNum: Boolean read GetIsAlphaNum; + property IsNumeric: Boolean read GetIsNumeric; + property IsFloat: Boolean read GetIsFloat; + property IsInteger: Boolean read GetIsInteger; - function ToUpper(): String; - function ToLower(): String; - function Capitalize(): String; - function CapitalizeWords(): String; - function SwapCase(): String; + function ToUpper: String; + function ToLower: String; + function SwapCase: String; + function Capitalize: String; + function CapitalizeWords: String; function Before(const Value: String): String; function After(const Value: String): String; @@ -93,9 +103,6 @@ TRegExprMatch = record function RegExprFind(const Pattern: String): TRegExprMatch; function RegExprExists(const Pattern: String): Boolean; - function IndexOfAny(const Values: TStringArray): Integer; overload; - function IndexOfAny(const Values: TStringArray; Offset: Integer): Integer; overload; - function IndexOf(const Value: String): Integer; overload; function IndexOf(const Value: String; Offset: Integer): Integer; overload; function LastIndexOf(const Value: String): Integer; overload; @@ -104,9 +111,11 @@ TRegExprMatch = record function IndicesOf(const Value: String): TIntegerArray; overload; function IndicesOf(const Value: String; Offset: Integer): TIntegerArray; overload; + function Count(const Value: String): Integer; + function Extract(const Chars: array of Char): String; function ExtractInteger(Default: Int64 = -1): Int64; - function ExtractFloat(Default: Extended = -1): Extended; + function ExtractFloat(Default: Double = -1): Double; function Trim: String; overload; function Trim(const TrimChars: array of Char): String; overload; @@ -127,9 +136,6 @@ TRegExprMatch = record function Contains(const Value: String; CaseSenstive: Boolean = True): Boolean; function ContainsAny(const Values: TStringArray; CaseSenstive: Boolean = True): Boolean; - function Count(const Value: String): Integer; - function CountAll(const Values: TStringArray): TIntegerArray; - function Join(const Values: TStringArray): String; function Split(const Seperator: String; ExcludeEmpty: Boolean = True): TStringArray; function SplitLines: TStringArray; @@ -139,19 +145,12 @@ TRegExprMatch = record procedure DeleteRange(StartIndex, EndIndex: Integer); procedure Insert(const Value: String; Index: Integer); - procedure Extend(Value: String); - procedure Append(Value: Char); - - function Remove(Value: String): Boolean; - function RemoveAll(Value: String): Integer; - function PadLeft(ACount: Integer; PaddingChar: Char = #32): String; function PadRight(ACount: Integer; PaddingChar: Char = #32): String; function PadCenter(ACount: Integer; PaddingChar: Char = #32): String; function Format(Args: array of const): String; - function ToBytes: TByteArray; function ToBoolean: Boolean; overload; function ToBoolean(Default: Boolean): Boolean; overload; function ToInteger: Integer; overload; @@ -162,10 +161,9 @@ TRegExprMatch = record function ToSingle(Default: Single): Single; overload; function ToDouble: Double; overload; function ToDouble(Default: Double): Double; overload; - function ToExtended: Extended; overload; - function ToExtended(Default: Extended): Extended; overload; function ToDateTime(Fmt: String; Def: TDateTime): TDateTime; + function ToBytes: TByteArray; function ParseJSON: TJSONData; end; @@ -176,7 +174,7 @@ TRegExprMatch = record function IndicesOf(Value: String): TIntegerArray; function Unique: TStringArray; procedure Sort; - function ToString(Sep: String): String; + function Join(Glue: String): String; end; operator * (const Left: String; Right: Int32): String; @@ -189,55 +187,46 @@ implementation RegExpr, StrUtils, DateUtils, simba.containers, simba.hash, simba.array_algorithm; -function TSimbaCharHelper.IsUpper(): Boolean; +function TSimbaCharHelper.GetIsUpper: Boolean; begin - Result := (Byte(Self) >= Byte('A')) and (Byte(Self) <= Byte('Z')); + Result := Self in ['A'..'Z']; end; -function TSimbaCharHelper.IsLower(): Boolean; +function TSimbaCharHelper.GetIsLower: Boolean; begin - Result := (Byte(Self) >= Byte('a')) and (Byte(Self) <= Byte('z')); + Result := Self in ['a'..'z']; end; -function TSimbaCharHelper.IsAlphaNum(): Boolean; +function TSimbaCharHelper.GetIsAlpha: Boolean; begin - Result := Self in ['0'..'9', 'a'..'z', 'A'..'Z']; + Result := Self in ['a'..'z', 'A'..'Z']; end; -function TSimbaCharHelper.IsInteger(): Boolean; +function TSimbaCharHelper.GetIsAlphaNum: Boolean; begin - Result := Self in ['0'..'9']; + Result := Self in ['0'..'9', 'a'..'z', 'A'..'Z']; end; -// same as is integer for chars, here for convinience -function TSimbaCharHelper.IsFloat(): Boolean; +function TSimbaCharHelper.GetIsNumeric: Boolean; begin Result := Self in ['0'..'9']; end; -function TSimbaCharHelper.ToUpper(): Char; +function TSimbaCharHelper.ToUpper: Char; begin Result := UpCase(Self); end; -function TSimbaCharHelper.ToLower(): Char; +function TSimbaCharHelper.ToLower: Char; begin Result := LowerCase(Self); end; -function TSimbaCharHelper.Capitalize(): Char; -begin - Result := UpCase(Self); -end; - function TSimbaCharHelper.Join(const Values: TStringArray): String; begin Result := String(Self).Join(Values); end; - -(* ---- String helpers ---- *) - function TSimbaStringHelper.Before(const Value: String): String; var P: Integer; @@ -415,25 +404,6 @@ function TSimbaStringHelper.RegExprFindAll(const Pattern: String): TRegExprMatch end; end; -function TSimbaStringHelper.IndexOfAny(const Values: TStringArray): Integer; -begin - Result := IndexOfAny(Values, 1); -end; - -function TSimbaStringHelper.IndexOfAny(const Values: TStringArray; Offset: Integer): Integer; -var - I: Integer; -begin - Result := 0; - - for I := 0 to High(Values) do - begin - Result := Self.IndexOf(Values[I], Offset); - if (Result > 0) then - Exit; - end; -end; - function TSimbaStringHelper.IndexOf(const Value: String): Integer; begin Result := Pos(Value, Self); @@ -451,7 +421,7 @@ function TSimbaStringHelper.LastIndexOf(const Value: String): Integer; function TSimbaStringHelper.LastIndexOf(const Value: String; Offset: Integer): Integer; begin - Result := RPosEx(Value, Self, Offset); + Result := RPosEx(Value, Self, Length(Self)); end; function TSimbaStringHelper.IndicesOf(const Value: String): TIntegerArray; @@ -464,7 +434,7 @@ function TSimbaStringHelper.IndicesOf(const Value: String): TIntegerArray; if (Self = '') then Exit; - if Length(Value) = 1 then + if (Length(Value) = 1) then begin Buffer.Init(32); @@ -514,14 +484,67 @@ function TSimbaStringHelper.IndicesOf(const Value: String; Offset: Integer): TIn end; end; -function TSimbaStringHelper.Equals(Other: String): Boolean; +function TSimbaStringHelper.Count(const Value: String): Integer; +begin + Result := Length(IndicesOf(Value)); +end; + +function TSimbaStringHelper.IsInSet(Chars: TSysCharSet): Boolean; +var + I: Integer; begin - Result := Self = Other; + for I := 1 to Length(Self) do + if not (Self[I] in Chars) then + Exit(False); + + Result := Self <> '' end; -function TSimbaStringHelper.EqualsIgnoreCase(Other: String): Boolean; +function TSimbaStringHelper.GetIsAlpha: Boolean; begin - Result := SameText(Self, Other); + Result := IsInSet(['a'..'z', 'A'..'Z']); +end; + +function TSimbaStringHelper.GetIsAlphaNum: Boolean; +begin + Result := IsInSet(['0'..'9', 'a'..'z', 'A'..'Z']); +end; + +function TSimbaStringHelper.GetIsFloat: Boolean; +var + _: Double; +begin + Result := TryStrToFloat(Self, _); +end; + +function TSimbaStringHelper.GetIsInteger: Boolean; +var + _: Int64; +begin + Result := TryStrToInt64(Self, _) or TryStrToUInt64(Self, UInt64(_)); +end; + +function TSimbaStringHelper.GetIsLower: Boolean; +begin + Result := IsInSet(['a'..'z']); +end; + +function TSimbaStringHelper.GetIsNumeric: Boolean; +begin + Result := IsInSet(['0'..'9']); +end; + +function TSimbaStringHelper.GetIsUpper: Boolean; +begin + Result := IsInSet(['A'..'Z']); +end; + +function TSimbaStringHelper.Equals(Other: String; CaseSenstive: Boolean): Boolean; +begin + if CaseSenstive then + Result := SameStr(Self, Other) + else + Result := SameText(Self, Other); end; function TSimbaStringHelper.Compare(Other: String): Integer; @@ -633,48 +656,42 @@ function TSimbaStringHelper.Hash(Seed: UInt32 = 0): UInt32; Result := Hash32(Self, Seed); end; -function TSimbaStringHelper.IsUpper(): Boolean; -var i: Int32; +function TSimbaStringHelper.ToUpper: String; begin - for i:=1 to Length(self) do - if not self[i].IsUpper() then - Exit(False); - Result := True; -end; - -function TSimbaStringHelper.IsLower(): Boolean; -var i: Int32; -begin - for i:=1 to Length(self) do - if not self[i].IsLower() then - Exit(False); - Result := True; + Result := UpperCase(Self); end; -function TSimbaStringHelper.ToUpper(): String; +function TSimbaStringHelper.ToLower: String; begin - Result := UpperCase(Self); + Result := LowerCase(Self); end; -function TSimbaStringHelper.ToLower(): String; +function TSimbaStringHelper.SwapCase: String; +var + i: Integer; begin - Result := LowerCase(Self); + Result := Self.Copy(); + for i := 1 to Length(Result) do + if (Result[i] in ['a'..'z']) then + Result[i] := UpCase(Result[i]) + else if (Result[i] in ['A'..'Z']) then + Result[i] := LowerCase(Result[i]); end; -function TSimbaStringHelper.Capitalize(): String; +function TSimbaStringHelper.Capitalize: String; var I: Integer; begin SetLength(Result, Length(Self)); - - for I := 1 to Length(Self) do - if (I = 1) then - Result[I] := UpCase(Self[I]) - else + if (Length(Result) > 0) then + begin + Result[1] := UpCase(Self[1]); + for I := 2 to Length(Self) do Result[I] := LowerCase(Self[I]); + end; end; -function TSimbaStringHelper.CapitalizeWords(): String; +function TSimbaStringHelper.CapitalizeWords: String; var Temp: TStringArray; I: Integer; @@ -685,21 +702,6 @@ function TSimbaStringHelper.CapitalizeWords(): String; Result := ' '.Join(Temp); end; -function TSimbaStringHelper.SwapCase(): String; -var - i: Integer; -begin - SetLength(Result, Length(Self)); - - for i:=1 to Length(self) do - if Self[i].IsUpper() then - Result[i] := Self[i].ToLower() - else if Self[i].IsLower() then - Result[i] := Self[i].ToUpper() - else - Result[i] := Self[i]; -end; - function TSimbaStringHelper.Extract(const Chars: array of Char): String; type TCharMap = array[Char] of Boolean; @@ -734,68 +736,11 @@ function TSimbaStringHelper.ExtractInteger(Default: Int64): Int64; Result := StrToInt64Def(Self.Extract(['-','0','1','2','3','4','5','6','7','8','9']), Default); end; -function TSimbaStringHelper.ExtractFloat(Default: Extended): Extended; +function TSimbaStringHelper.ExtractFloat(Default: Double): Double; begin Result := StrToFloatDef(Self.Extract(['.','-','0','1','2','3','4','5','6','7','8','9']), Default); end; -function TSimbaStringHelper.IsAlphaNum: Boolean; -var - I: Integer; -begin - if (Self = '') then - Exit(False); - - Result := True; - - for I := 1 to Length(Self) do - if not (Self[I] in ['0'..'9','a'..'z','A'..'Z']) then - begin - Result := False; - Exit; - end; -end; - -function TSimbaStringHelper.IsInteger: Boolean; -var - I: Integer; -begin - if (Self = '') then - Exit(False); - - for I := 1 to Length(Self) do - if (not (Self[I] in ['0'..'9'])) then - begin - if (I = 1) and (Self[I] = '-') then - Continue; - - Result := False; - Exit; - end; - - Result := True; -end; - -function TSimbaStringHelper.IsFloat: Boolean; -var - I: Integer; -begin - if (Self = '') then - Exit(False); - - for I := 1 to Length(Self) do - if (not (Self[I] in ['0'..'9', '.'])) then - begin - if (I = 1) and (Self[I] = '-') then - Continue; - - Result := False; - Exit; - end; - - Result := True; -end; - function TSimbaStringHelper.Trim: String; begin Result := SysUtils.Trim(Self); @@ -941,20 +886,6 @@ function TSimbaStringHelper.ContainsAny(const Values: TStringArray; CaseSenstive Result := False; end; -function TSimbaStringHelper.Count(const Value: String): Integer; -begin - Result := Length(Self.IndicesOf(Value)); -end; - -function TSimbaStringHelper.CountAll(const Values: TStringArray): TIntegerArray; -var - I: Integer; -begin - SetLength(Result, Length(Values)); - for I := 0 to High(Values) do - Result[I] := Length(Self.IndicesOf(Values[I])); -end; - function TSimbaStringHelper.Join(const Values: TStringArray): String; var I, Current, Total: Integer; @@ -1148,30 +1079,6 @@ procedure TSimbaStringHelper.Insert(const Value: String; Index: Integer); System.Insert(Value, Self, Index); end; -procedure TSimbaStringHelper.Extend(Value: String); -begin - Self := Self + Value; -end; - -procedure TSimbaStringHelper.Append(Value: Char); -begin - Self := Self + Value; -end; - -function TSimbaStringHelper.Remove(Value: String): Boolean; -var - ReplaceCount: Integer; -begin - Self := StringReplace(Self, Value, '', [], ReplaceCount); - - Result := ReplaceCount > 0; -end; - -function TSimbaStringHelper.RemoveAll(Value: String): Integer; -begin - Self := StringReplace(Self, Value, '', [rfReplaceAll], Result); -end; - function TSimbaStringHelper.PadLeft(ACount: Integer; PaddingChar: Char): String; begin ACount := ACount - Length(Self); @@ -1265,16 +1172,6 @@ function TSimbaStringHelper.ToDouble(Default: Double): Double; Result := StrToFloatDef(Self, Default); end; -function TSimbaStringHelper.ToExtended: Extended; -begin - Result := StrToFloat(Self); -end; - -function TSimbaStringHelper.ToExtended(Default: Extended): Extended; -begin - Result := StrToFloatDef(Self, Default); -end; - function TSimbaStringHelper.ToDateTime(Fmt: String; Def: TDateTime): TDateTime; begin Result := Def; @@ -1287,7 +1184,7 @@ function TSimbaStringHelper.ToDateTime(Fmt: String; Def: TDateTime): TDateTime; 'iso8601': TryISO8601ToDate(Self, Result); 'unix': - if Self.IsInteger() then + if Self.IsNumeric then Result := UnixToDateTime(Self.ToInt64()); else SimbaException('String.ToDateTime: Fmt "%s" not recognized', [Fmt]); @@ -1342,9 +1239,9 @@ procedure TStringArrayHelper.Sort; specialize TArraySortFunc.QuickSort(Self, Low(Self), High(Self), @Compare); end; -function TStringArrayHelper.ToString(Sep: String): String; +function TStringArrayHelper.Join(Glue: String): String; begin - Result := Sep.Join(Self); + Result := Glue.Join(Self); end; operator *(const Left: String; Right: Int32): String; diff --git a/Tests/generic_heap.simba b/Tests/generic_heap.simba index d866e76e6..620b6d121 100644 --- a/Tests/generic_heap.simba +++ b/Tests/generic_heap.simba @@ -3,7 +3,7 @@ function MaxValues(Mat: TIntegerMatrix; count: Integer): TPointArray; var X,Y,I: Integer; - Heap: Heap(Single); + Heap: THeap(Single); Errored: Boolean; begin for Y := 0 to Mat.Height - 1 do diff --git a/Tests/generic_map.simba b/Tests/generic_map.simba index 8f512e15f..b787631a4 100644 --- a/Tests/generic_map.simba +++ b/Tests/generic_map.simba @@ -1,7 +1,7 @@ {$assertions on} var - Map: Map(Int32,String); + Map: TMap(Int32, String); begin Map.Value[123] := '123'; Map.Value[456] := '456'; diff --git a/Tests/generic_stringmap.simba b/Tests/generic_stringmap.simba index 5fb2e97b9..98940f8bd 100644 --- a/Tests/generic_stringmap.simba +++ b/Tests/generic_stringmap.simba @@ -1,7 +1,7 @@ {$assertions on} type - TStringIntMap = StringMap(Int32); + TStringIntMap = TStringMap(Int32); procedure Test_CaseSens; var @@ -65,7 +65,7 @@ end; procedure Test_Arr; var - Map: StringMap(TIntegerArray); + Map: TStringMap(TIntegerArray); begin Map.Value['a'] := [1,2,3]; Map.Value['b'] := [100,101,102]; diff --git a/Tests/string.simba b/Tests/string.simba index 07843ad08..4a831bd86 100644 --- a/Tests/string.simba +++ b/Tests/string.simba @@ -1,19 +1,10 @@ {$assertions on} var TestString: String; - begin TestString := 'abcHelloxyz'; Assert(ToString(TestString.Partition('Hello')) = '[abc, Hello, xyz]'); - TestString := 'HelloRemoveWorld'; - Assert(TestString.Remove('Remove') = True); - Assert(TestString = 'HelloWorld'); - - TestString := 'HelloRemoveRemoveWorld'; - Assert(TestString.RemoveAll('Remove') = 2); - Assert(TestString = 'HelloWorld'); - TestString := '1.23'; Assert(TestString.IsInteger = False); Assert(TestString.IsFloat = True); @@ -59,14 +50,6 @@ begin TestString := '-hello123world.456'; Assert(ToString(TestString.ExtractFloat) = '-123.456'); - Assert(String.UpperChars.IsUpper() = True); - Assert(String.UpperChars.IsLower() = False); - - Assert(String.LowerChars.IsLower() = True); - Assert(String.LowerChars.IsUpper() = False); - - Assert(String.AlphaChars.IsAlphaNum() = True); - Assert(#32.Join(['a']) = 'a'); Assert(#32.Join(['a','b']) = 'a b'); Assert(#32.Join(['a','b','c','d']) = 'a b c d'); diff --git a/Third-Party/lape b/Third-Party/lape index 0a0cf1258..da88da686 160000 --- a/Third-Party/lape +++ b/Third-Party/lape @@ -1 +1 @@ -Subproject commit 0a0cf125803d207f03e3d35c21979055b9066ff3 +Subproject commit da88da6863f1cd3f142a12eedae60e3f3b926762