From 3ee7505984e8ad39e3bc2f3f22365b3e158a651e Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Fri, 22 Mar 2024 20:40:57 +0100 Subject: [PATCH 1/3] Tester: Don't output #13 --- Testing/Testing.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Testing/Testing.pas b/Testing/Testing.pas index 3ace4ae6..0461dc99 100644 --- a/Testing/Testing.pas +++ b/Testing/Testing.pas @@ -66,8 +66,8 @@ if paused then p.StandardInput.WriteLine; var t_otp := p.StandardOutput.ReadToEndAsync; var t_err := p.StandardError.ReadToEndAsync; - var otp := t_otp.Result.Remove(#13).Trim(#10); - var err := t_err.Result.Remove(#13).Trim(#10).Split(|#10|,2); + var otp := t_otp.Result.Replace(#13#10,#10).Trim(#10); + var err := t_err.Result.Replace(#13#10,#10).Trim(#10).Split(|#10|,2); p.WaitForExit; DeleteFile(executor); case err[0] of From dad07f661981136550e542da7e81a6492cf6b068 Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Sat, 23 Mar 2024 12:32:21 +0100 Subject: [PATCH 2/3] cleanup TODO's --- ATask.pas | 2 -- Fixers.pas | 2 +- Patterns/MergedStrings.pas | 21 +++++++-------------- Testing/Testing.pas | 3 --- ThoroughXML.pas | 4 ++-- Timers.pas | 6 ++---- 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/ATask.pas b/ATask.pas index 65057895..694a1cab 100644 --- a/ATask.pas +++ b/ATask.pas @@ -5,8 +5,6 @@ uses AOtp; uses SubExecuters; -uses AQueue; //TODO #2543 - type AsyncTask = abstract class public own_otp: AsyncProcOtp; diff --git a/Fixers.pas b/Fixers.pas index d5d72cd4..b96fae5d 100644 --- a/Fixers.pas +++ b/Fixers.pas @@ -137,7 +137,7 @@ interface Fixer = abstract class where TSelf: Fixer; -// where TFixable: class; //TODO #2736 +// where TFixable: class, IFixable; //TODO #2640: Доделать для классов, чтобы можно было в наследниках указывать более точно where TName: System.IEquatable; private _name: TName; private used: boolean; diff --git a/Patterns/MergedStrings.pas b/Patterns/MergedStrings.pas index fcc0d00f..acab1d7c 100644 --- a/Patterns/MergedStrings.pas +++ b/Patterns/MergedStrings.pas @@ -95,7 +95,7 @@ MergedStringLength = record if max.IsValid and (c>integer(max)) then exit; Result := true; end; - public static function operator in(c: integer; l: MergedStringLength) := c in l; + public static function operator in(c: integer; l: MergedStringLength) := l.Contains(c); public static function operator+(c1, c2: MergedStringLength): MergedStringLength; begin @@ -454,8 +454,7 @@ implementation public procedure WriteTo(b: ColoredStringBuilderBase; escape_sym: char); override := b.AddSubRange('wild', b-> begin - //TODO #???? - b += MergedStringPartWild.wild_beg; + b += wild_beg; b.AddSubRange('count', b-> begin @@ -465,15 +464,13 @@ implementation b += c_min_s; if c_max_s<>c_min_s then begin - //TODO #???? - b += MergedStringPartWild.range_sep; + b += range_sep; b += c_max_s; end; end); - //TODO #???? - b += MergedStringPartWild.count_chs_sep; + b += count_chs_sep; if not ReferenceEquals(allowed, allowed_anything) then b.AddSubRange('chars', b-> @@ -497,8 +494,7 @@ implementation if ch1<>ch2 then begin if ch2.Code-ch1.Code <> 1 then - //TODO #????: Need "MergedStringPart." - b += MergedStringPartWild.range_sep; + b += range_sep; AddEscaped(ch2); end; @@ -519,8 +515,7 @@ implementation FlushPrev; end); - //TODO #???? - b += MergedStringPartWild.wild_end; + b += wild_end; end); end; @@ -680,7 +675,7 @@ implementation function MergedStringPointer.IsOut := data.part_i = s.parts.Length; static function MergedString.Literal(s: string) := -//TODO #????: adding params breaks case where array is passed to "new MergedString" +//TODO #3064: adding params breaks case where array is passed to "new MergedString" new MergedString(new MergedStringPart[](new MergedStringPartSolid(s))); static function MergedString.Parse(s: StringSection; escape_sym: char) := @@ -871,7 +866,6 @@ function NextZeroJumpPoint(p: MergedStringPoint2): MergedStringPoint2; begin var ep1 := p.Edge1; var ep2 := p.Edge2; - var s := ep1.s; while true do begin @@ -1178,7 +1172,6 @@ function MergedStringInMakeJumps(p: MergedStringPoint2): sequence of MergedStrin end; exit; end; - var s := ep1.s; var part2 := EdgePart(ep2); if part2 is MergedStringPartSolid then diff --git a/Testing/Testing.pas b/Testing/Testing.pas index 0461dc99..85042e1f 100644 --- a/Testing/Testing.pas +++ b/Testing/Testing.pas @@ -1,8 +1,5 @@ unit Testing; -//TODO #2897 -{$savepcu false} - uses System.Diagnostics; uses '../PathUtils'; diff --git a/ThoroughXML.pas b/ThoroughXML.pas index 3b12928a..b47501d2 100644 --- a/ThoroughXML.pas +++ b/ThoroughXML.pas @@ -137,7 +137,7 @@ interface attribs_cache := Result; end; - //TODO #????: self. + //TODO #3065: self. public property Attrib[name: string]: XmlAttrib read GetContent(()->self.GetAllAttribs.Get(name)); //TODO #2461: string(...) public property AttribData[name: string]: string read string(Attrib[name]?.Data); default; @@ -172,7 +172,7 @@ interface sub_nodes_cache := Result.ToArray; end; - //TODO #????: self. + //TODO #3065: self. public property SubNodes[tag: string]: sequence of XmlNode read GetContent(()->self.GetAllSubNodes.Where(n->n.Tag=tag)); public function TryDiscardSubNodes(tag: string) := SubNodes[tag].Count(n->n.TryDiscard); diff --git a/Timers.pas b/Timers.pas index 246edd18..2da130b6 100644 --- a/Timers.pas +++ b/Timers.pas @@ -153,8 +153,7 @@ interface public function MakeLogLines(lvl: integer; header: string): sequence of (integer,string,string); override; begin - //TODO #2896 - yield (lvl, header, Timer.TimeToText(self.OuterTime)); + yield (lvl, header, TimeToText(self.OuterTime)); foreach var nick in sub_timers.Keys.Order do begin @@ -166,8 +165,7 @@ interface continue; end; - //TODO #2896 - yield (lvl+1, $'♦ {nick} x{l.Count}', Timer.TimeToText(time_per_nick[nick])); + yield (lvl+1, $'♦ {nick} x{l.Count}', TimeToText(time_per_nick[nick])); var common_name_parts := l.First[0].Split('/')[:^1]; foreach var (full_name, t) in l.Skip(1) do From 4490dee19d22ed4a984f0c2f3f228c004942313b Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Thu, 28 Mar 2024 11:56:42 +0100 Subject: [PATCH 3/3] cleanup TODO's --- TypeMagic.pas | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 TypeMagic.pas diff --git a/TypeMagic.pas b/TypeMagic.pas new file mode 100644 index 00000000..fc72491a --- /dev/null +++ b/TypeMagic.pas @@ -0,0 +1,68 @@ +unit TypeMagic; + +interface + +type + + {$region Convert} + + ConvertTo = sealed class + + private constructor := raise new System.InvalidOperationException; + + public static function FromChecked(o: T2): T; + public static function FromUnchecked(o: T2): T; + public static function From(o: T2; checked: boolean := true) := + if checked then FromChecked(o) else FromUnchecked(o); + + end; + + {$endregion Convert} + +implementation + +uses System.Linq.Expressions; + +{$region Convert} + +type ConvertCache = sealed class + + private constructor := raise new System.InvalidOperationException; + + public static checked, unchecked: T2->T1; + private static function MakeFunc(conv: (Expression,System.Type)->Expression): T2->T1; + begin + try + var p := Expression.Parameter(typeof(T2)); + var c := conv(p, typeof(T1)); + var l := Expression.Lambda&>(c, p); + Result := l.Compile(); + except + on e: Exception do + begin + Result := o-> + begin + Result := default(T1); + raise new System.InvalidCastException($'Failed to make [{TypeToTypeName(typeof(T2))}]=>[{TypeToTypeName(typeof(T1))}] conversion', e); + end; + exit; + end; + end; + + end; + static constructor; + begin + checked := MakeFunc(Expression.ConvertChecked); + unchecked := MakeFunc(Expression.Convert); + end; + +end; + +static function ConvertTo.FromChecked(o: T2) := + ConvertCache&.checked(o); +static function ConvertTo.FromUnchecked(o: T2) := + ConvertCache&.unchecked(o); + +{$endregion Convert} + +end. \ No newline at end of file