From 76813916631c591fe314db4aa46447d7fcaf33ac Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Mon, 6 May 2024 22:30:41 +0300 Subject: [PATCH] =?UTF-8?q?TypeName=20-=20=D0=BE=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B2=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=D0=B5=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- Localization/DefaultLang.resources | Bin 103102 -> 103263 bytes Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- bin/Lib/PABCSystem.pas | 74 ++++++++++----------- bin/Lib/PABCSystem.xml | 16 +---- 7 files changed, 41 insertions(+), 59 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index aff56f085..70d5c51ea 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "9"; public const string Build = "0"; - public const string Revision = "3473"; + public const string Revision = "3474"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 14b94ce30..472ec20c1 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=9 -%REVISION%=3473 %COREVERSION%=0 +%REVISION%=3474 +%MINOR%=9 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index bce1542d9e1089f89a15120b81569ca22f50266f..c66ba23b4bfa0d7af7199eb3a95c235e060b498f 100644 GIT binary patch delta 452 zcmZ9IJ4*vW6ot_u5+6T6u()7gD&wOJq}XIPxN1g8RImzSHV_CQpcWE>g@uI(>h|fh zmwf_8B|XCOEF#{aP3~>aZ9!6*nNNk2I+k-mS&UED_9LTxA(St! z6*jX5ihxV)_eKXi(d2K^_(Gm+K;?-FGDl)4_$xGLW05{&6tnppGWTMkS(MLZjT{1I zGmv}n>ll-N{8ksEMFsrGhx(T=*5X<^t)x~UWE9qo=oM?b>`5x*flU8!v^E^y9oSa& zL?WYV2_0)0tR%JQr6bXvIjvKhx~wC~rYZ=m-{$Byt4tv)u%1a>76(2shq~1H=bV&I e*7#FZ>*JL^cwPD~{5Z-7zGLiE@p%>ZfcgndkoEWg delta 248 zcmcb=jBVdiwh0fIZcW_yD3Oy69z1{W_MO6uH~+y}A51oI zQs;mvnVjHc#io*)my($_d7+bvx=LnRN@|+Ii`Op{fXqA)TNh~a$IqWWetPuz=_duK d+V@VT^k(var p: ^T); /// Выделяет динамическую память размера sizeof(T) и возвращает в переменной p указатель на нее. Тип T должен быть размерным @@ -4178,6 +4170,8 @@ function operator implicit(s: string): StringBuilder; extensionmethod := new Str // _ObjectToString //------------------------------------------------------------------------------ +procedure TypeToTypeNameHelper(t: System.Type; res: TextWriter); forward; + type ObjectToStringUtils = static class @@ -4219,7 +4213,7 @@ type res.Write( name ); res.Write(': '); end; - TypeToTypeName(par.ParameterType, res); + TypeToTypeNameHelper(par.ParameterType, res); end; res.Write(')'); end; @@ -4227,14 +4221,15 @@ type if rt<>nil then begin res.Write(': '); - TypeToTypeName(rt, res); + TypeToTypeNameHelper(rt, res); end; end; private static empty_obj_arr := new object[0]; + public static procedure ContentsToString(o: Object; prev: Stack; res: TextWriter); - const val_sep = '; '; + const val_sep = '; '; begin res.Write('('); var any_vals := false; @@ -4299,10 +4294,10 @@ type prev.Push(o); AppendImpl(o, prev, res); if prev.Pop<>o then raise new InvalidOperationException; - end; + public static procedure AppendImpl(o: Object; prev: Stack; res: TextWriter); - const max_seq_len = 100; + const max_seq_len = 100; begin if o = nil then begin @@ -4484,9 +4479,7 @@ type {$endregion IEnumerable} ContentsToString(o, prev, res); - end; - end; function TryWriteFromTypeCode(t: System.Type; res: TextWriter): boolean; @@ -4522,7 +4515,7 @@ begin end; end; -procedure TypeToTypeName(t: System.Type; res: TextWriter); +procedure TypeToTypeNameHelper(t: System.Type; res: TextWriter); begin if t=nil then begin @@ -4546,7 +4539,7 @@ begin if rank<1 then raise new NotImplementedException; res.Write(' of '); - TypeToTypeName(t.GetElementType, res); + TypeToTypeNameHelper(t.GetElementType, res); exit; end; @@ -4562,7 +4555,7 @@ begin ) then begin res.Write('sequence of '); - TypeToTypeName(typed.GetGenericArguments.Single, res); + TypeToTypeNameHelper(typed.GetGenericArguments.Single, res); exit; end; end; @@ -4579,7 +4572,7 @@ begin if any_gen_arg then res.Write(', ') else any_gen_arg := true; - TypeToTypeName(arg, res); + TypeToTypeNameHelper(arg, res); end; res.Write(')'); exit; @@ -4627,7 +4620,7 @@ begin gen_args := own_args; end; - TypeToTypeName(parent, res); + TypeToTypeNameHelper(parent, res); res.Write('+'); end; @@ -4641,7 +4634,7 @@ begin if any_gen_arg then res.Write(', ') else any_gen_arg := true; - TypeToTypeName(arg, res); + TypeToTypeNameHelper(arg, res); end; res.Write('>'); exit; @@ -4653,12 +4646,13 @@ begin if t.IsGenericParameter then res.Write(']'); end; -procedure TypeToTypeName(t: System.Type; res: StringBuilder) := - TypeToTypeName(t, new StringWriter(res)); -procedure TypeName(o: object; res: TextWriter); +procedure TypeToTypeNameHelper(t: System.Type; res: StringBuilder) := + TypeToTypeNameHelper(t, new StringWriter(res)); + +procedure TypeNameHelper(obj: object; res: TextWriter); begin - var t := o?.GetType; + var t := obj?.GetType; // Зачем? TypeName(@a) не работает // Можно сделать TypeName волшебной функцией, вызывая @@ -4672,26 +4666,26 @@ begin var static_arr_field := t?.GetField('NullBasedArray'); if static_arr_field<>nil then begin - TypeName(static_arr_field.GetValue(o), res); + TypeNameHelper(static_arr_field.GetValue(obj), res); exit; end; - TypeToTypeName(t, res); + TypeToTypeNameHelper(t, res); +end; + +procedure TypeNameHelper(obj: object; res: StringBuilder) := TypeNameHelper(obj, new StringWriter(res)); + +function TypeName(obj: object): string; +begin + var res := new StringBuilder; + TypeNameHelper(obj, res); + Result := res.ToString; end; -procedure TypeName(o: object; res: StringBuilder) := - TypeName(o, new StringWriter(res)); function TypeToTypeName(t: System.Type): string; begin var res := new StringBuilder; - TypeToTypeName(t, res); - Result := res.ToString; -end; - -function TypeName(o: object): string; -begin - var res := new StringBuilder; - TypeName(o, res); + TypeToTypeNameHelper(t, res); Result := res.ToString; end; diff --git a/bin/Lib/PABCSystem.xml b/bin/Lib/PABCSystem.xml index 90b2518e6..764aee00c 100644 --- a/bin/Lib/PABCSystem.xml +++ b/bin/Lib/PABCSystem.xml @@ -1267,22 +1267,10 @@ Возвращает последовательность имен каталогов по заданному пути, включая подкаталоги - Возвращает имя отражённого типа "t" - - - Добавляет в res имя отражённого типа "t" - - - Записывает в res имя отражённого типа "t" + Возвращает строку с именем данного типа - Возвращает имя типа объекта "o" - - - Добавляет в res имя типа объекта "o" - - - Записывает в res имя типа объекта "o" + Возвращает строку с именем типа объекта Выделяет имя файла из полного имени файла fileName