Browse Source

* Fix compilation for avr-embedded (no unicode strings)

Michaël Van Canneyt 2 years ago
parent
commit
defc7e99d1
2 changed files with 196 additions and 166 deletions
  1. 136 129
      rtl/inc/objpas.inc
  2. 60 37
      rtl/inc/objpash.inc

+ 136 - 129
rtl/inc/objpas.inc

@@ -1346,172 +1346,79 @@ begin
   System.Move(Src.Value^, Dest.Value^, Count);
 end;
 
-class function TMarshal.AsAnsi(const S: UnicodeString): AnsiString;
-begin
-  Result := AnsiString(S);
-end;
-
-class function TMarshal.AsAnsi(S: PUnicodeChar): AnsiString;
-begin
-  result := AnsiString(S);
-end;
-
-class function TMarshal.InOutString(const S: UnicodeString): PUnicodeChar;
-begin
-  Result := PUnicodeChar(S);
-end;
-
-class function TMarshal.InString(const S: UnicodeString): PUnicodeChar;
-begin
-  Result := PUnicodeChar(S);
-end;
-
-class function TMarshal.OutString(const S: UnicodeString): PUnicodeChar;
-begin
-  Result := PUnicodeChar(S);
-end;
 
 class function TMarshal.UnsafeAddrOf(var Value): TPtrWrapper;
 begin
   Result.Value := @Value;
 end;
 
-class function TMarshal.AllocStringAsAnsi(const Str: UnicodeString): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), DefaultSystemCodePage);
-end;
-
-class function TMarshal.AllocStringAsAnsi(const Str: UnicodeString; CodePage: Word): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), CodePage);
-end;
-
-class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(S, Length(S), DefaultSystemCodePage);
-end;
-
-class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar; CodePage: Word): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(S, Length(S), CodePage);
-end;
-
-class function TMarshal.AllocStringAsUnicode(const Str: UnicodeString): TPtrWrapper;
-var
-  NBytes: SizeUint;
-begin
-  NBytes := (Length(Str) + 1) * SizeOf(UnicodeChar);
-  Result.Value := System.GetMem(NBytes);
-  System.Move(PUnicodeChar(Str)^, Result.Value^, NBytes);
-end;
-
-class function TMarshal.AllocStringAsUtf8(const Str: UnicodeString): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), CP_UTF8);
-end;
-
-class function TMarshal.AllocStringAsUtf8(S: PUnicodeChar): TPtrWrapper;
-begin
-  Result := AllocStringAsAnsi(S, Length(S), CP_UTF8);
-end;
-
-class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar; Len: SizeInt; CodePage: Word): TPtrWrapper;
-var
-  U2ARes: AnsiString;
-  NBytes: SizeInt;
-begin
-  U2ARes := ''; { Suppress warning. }
-  WideStringManager.Unicode2AnsiMoveProc(S, U2ARes, CodePage, Len);
-  if Length(U2ARes) = 0 then
-  begin
-    Result.Value := nil;
-    Exit;
-  end;
-  { Could instead avoid the second allocation, assuming U2ARes.RefCount = 1:
-    System.Move(Pointer(U2ARes)^, (Pointer(U2ARes) - AnsiStringHeaderSize)^, (Length(U2ARes) + 1) * SizeOf(AnsiChar));
-    Result.FValue := Pointer(U2ARes) - AnsiStringHeaderSize;
-    Pointer(U2ARes) := nil; }
-  NBytes := (Length(U2ARes) + 1) * SizeOf(AnsiChar);
-  Result.Value := System.GetMem(NBytes);
-  System.Move(PAnsiChar(U2ARes)^, Result.Value^, NBytes);
-end;
-
-class procedure TMarshal.Copy(const Src: specialize TArray<UnicodeChar>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
-begin
-  System.Move(PUnicodeChar(Src)[StartIndex], Dest.Value^, Count * SizeOf(UnicodeChar));
-end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<UnicodeChar>; StartIndex: SizeInt; Count: SizeInt);
-begin
-  System.Move(Src.Value^, PUnicodeChar(Dest)[StartIndex], Count * SizeOf(UnicodeChar));
-end;
-
-class procedure TMarshal.Copy(const Src: specialize TArray<UInt8>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TUint8Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PUInt8(Src)[StartIndex], Dest.Value^, Count * SizeOf(UInt8));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<UInt8>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TUint8Array; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PUInt8(Dest)[StartIndex], Count * SizeOf(UInt8));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<Int8>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TInt8Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PInt8(Src)[StartIndex], Dest.Value^, Count * SizeOf(Int8));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int8>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TInt8Array ; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PInt8(Dest)[StartIndex], Count * SizeOf(Int8));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<UInt16>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TUInt16Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PUInt16(Src)[StartIndex], Dest.Value^, Count * SizeOf(UInt16));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<UInt16>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TUint16Array; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PUInt16(Dest)[StartIndex], Count * SizeOf(UInt16));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<Int16>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TInt16Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PInt16(Src)[StartIndex], Dest.Value^, Count * SizeOf(Int16));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int16>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TInt16Array; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PInt16(Dest)[StartIndex], Count * SizeOf(Int16));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<Int32>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TInt32Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PInt32(Src)[StartIndex], Dest.Value^, Count * SizeOf(Int32));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int32>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TInt32Array; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PInt32(Dest)[StartIndex], Count * SizeOf(Int32));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<Int64>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TInt64Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PInt64(Src)[StartIndex], Dest.Value^, Count * SizeOf(Int64));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int64>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TInt64Array; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PInt64(Dest)[StartIndex], Count * SizeOf(Int64));
 end;
 
-class procedure TMarshal.Copy(const Src: specialize TArray<TPtrWrapper>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+class procedure TMarshal.Copy(const Src: TPtrWrapperArray; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
 begin
   System.Move(PPointer(Src)[StartIndex], Dest.Value^, Count * SizeOf(TPtrWrapper));
 end;
 
-class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: specialize TArray<TPtrWrapper>; StartIndex: SizeInt; Count: SizeInt);
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TPtrWrapperArray; StartIndex: SizeInt; Count: SizeInt);
 begin
   System.Move(Src.Value^, PPointer(Dest)[StartIndex], Count * SizeOf(TPtrWrapper));
 end;
@@ -1527,28 +1434,6 @@ begin
   Finalize(specialize TArray<T>(ArrPtr));
 end;
 
-class function TMarshal.FixString(var Str: UnicodeString): TPtrWrapper;
-begin
-  UniqueString(Str);
-  Result := UnsafeFixString(Str);
-end;
-
-class procedure TMarshal.UnfixString(Ptr: TPtrWrapper);
-begin
-  if Ptr.Value <> PUnicodeChar('') then
-    Finalize(UnicodeString(Ptr));
-end;
-
-class function TMarshal.UnsafeFixString(const Str: UnicodeString): TPtrWrapper;
-begin
-  if Length(Str) = 0 then
-  begin
-    Result.Value := PUnicodeChar('');
-    Exit;
-  end;
-  Result.Value := nil;
-  UnicodeString(Result) := Str;
-end;
 
 class function TMarshal.ReadByte(Ptr: TPtrWrapper; Ofs: SizeInt = 0): Byte;
 begin
@@ -1625,6 +1510,126 @@ begin
   PPointer(Ptr.Value)^ := Value.Value;
 end;
 
+{$IFDEF FPC_HAS_FEATURE_UNICODESTRINGS}
+
+class function TMarshal.AsAnsi(const S: UnicodeString): AnsiString;
+begin
+  Result := AnsiString(S);
+end;
+
+class function TMarshal.AsAnsi(S: PUnicodeChar): AnsiString;
+begin
+  result := AnsiString(S);
+end;
+
+class function TMarshal.InOutString(const S: UnicodeString): PUnicodeChar;
+begin
+  Result := PUnicodeChar(S);
+end;
+
+class function TMarshal.InString(const S: UnicodeString): PUnicodeChar;
+begin
+  Result := PUnicodeChar(S);
+end;
+
+class function TMarshal.OutString(const S: UnicodeString): PUnicodeChar;
+begin
+  Result := PUnicodeChar(S);
+end;
+
+class function TMarshal.FixString(var Str: UnicodeString): TPtrWrapper;
+begin
+  UniqueString(Str);
+  Result := UnsafeFixString(Str);
+end;
+
+class procedure TMarshal.UnfixString(Ptr: TPtrWrapper);
+begin
+  if Ptr.Value <> PUnicodeChar('') then
+    Finalize(UnicodeString(Ptr));
+end;
+
+class function TMarshal.UnsafeFixString(const Str: UnicodeString): TPtrWrapper;
+begin
+  if Length(Str) = 0 then
+  begin
+    Result.Value := PUnicodeChar('');
+    Exit;
+  end;
+  Result.Value := nil;
+  UnicodeString(Result) := Str;
+end;
+
+class function TMarshal.AllocStringAsAnsi(const Str: UnicodeString): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), DefaultSystemCodePage);
+end;
+
+class function TMarshal.AllocStringAsAnsi(const Str: UnicodeString; CodePage: Word): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), CodePage);
+end;
+
+class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(S, Length(S), DefaultSystemCodePage);
+end;
+
+class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar; CodePage: Word): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(S, Length(S), CodePage);
+end;
+
+class function TMarshal.AllocStringAsUnicode(const Str: UnicodeString): TPtrWrapper;
+var
+  NBytes: SizeUint;
+begin
+  NBytes := (Length(Str) + 1) * SizeOf(UnicodeChar);
+  Result.Value := System.GetMem(NBytes);
+  System.Move(PUnicodeChar(Str)^, Result.Value^, NBytes);
+end;
+
+class function TMarshal.AllocStringAsUtf8(const Str: UnicodeString): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(PUnicodeChar(Pointer(Str)), Length(Str), CP_UTF8);
+end;
+
+class function TMarshal.AllocStringAsUtf8(S: PUnicodeChar): TPtrWrapper;
+begin
+  Result := AllocStringAsAnsi(S, Length(S), CP_UTF8);
+end;
+
+class function TMarshal.AllocStringAsAnsi(S: PUnicodeChar; Len: SizeInt; CodePage: Word): TPtrWrapper;
+var
+  U2ARes: AnsiString;
+  NBytes: SizeInt;
+begin
+  U2ARes := ''; { Suppress warning. }
+  WideStringManager.Unicode2AnsiMoveProc(S, U2ARes, CodePage, Len);
+  if Length(U2ARes) = 0 then
+  begin
+    Result.Value := nil;
+    Exit;
+  end;
+  { Could instead avoid the second allocation, assuming U2ARes.RefCount = 1:
+    System.Move(Pointer(U2ARes)^, (Pointer(U2ARes) - AnsiStringHeaderSize)^, (Length(U2ARes) + 1) * SizeOf(AnsiChar));
+    Result.FValue := Pointer(U2ARes) - AnsiStringHeaderSize;
+    Pointer(U2ARes) := nil; }
+  NBytes := (Length(U2ARes) + 1) * SizeOf(AnsiChar);
+  Result.Value := System.GetMem(NBytes);
+  System.Move(PAnsiChar(U2ARes)^, Result.Value^, NBytes);
+end;
+
+class procedure TMarshal.Copy(const Src: TUnicodeCharArray; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt);
+begin
+  System.Move(PUnicodeChar(Src)[StartIndex], Dest.Value^, Count * SizeOf(UnicodeChar));
+end;
+
+class procedure TMarshal.Copy(Src: TPtrWrapper; var Dest: TUnicodeCharArray; StartIndex: SizeInt; Count: SizeInt);
+begin
+  System.Move(Src.Value^, PUnicodeChar(Dest)[StartIndex], Count * SizeOf(UnicodeChar));
+end;
+
 class function TMarshal.ReadStringAsAnsi(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString;
 begin
   Result := ReadStringAsAnsi(DefaultSystemCodePage, Ptr, Len);
@@ -1742,3 +1747,5 @@ class procedure TMarshal.WriteStringAsUtf8(Ptr: TPtrWrapper; Ofs: SizeInt; const
 begin
   WriteStringAsAnsi(Ptr, Ofs, Value, MaxCharsIncNull, CP_UTF8);
 end;
+
+{$ENDIF}

+ 60 - 37
rtl/inc/objpash.inc

@@ -638,13 +638,29 @@ Type
     { ...to allow convenient and direct reading without relying on inline... and convenient writing from SysUtils until TMarshal is moved here... }
     property Value: Pointer read FValue write FValue;
   end;
+  TPtrWrapperArray = Array of TPtrWrapper;
 
   { Generic array type. 
     Slightly Less useful in FPC, since dyn array compatibility is at the element level. 
     But still useful for generic methods and of course Delphi compatibility}
   generic TArray<T> = array of T;
   
+  
+  
   TMarshal = class sealed
+  public
+    Type 
+      TUnicodeCharArray = Array of UnicodeChar;
+      Tint8Array = Array of int8;
+      Tint16Array = Array of int16;
+      Tint32Array = Array of int32;
+      Tint64Array = Array of int64;
+      TUint8Array = Array of Uint8;
+      TUint16Array = Array of Uint16;
+      TUint32Array = Array of Uint32;
+      TUint64Array = Array of Uint64;
+      
+  Public
     constructor Create;
 
     class function AllocMem(Size: SizeInt): TPtrWrapper; static; inline;
@@ -652,6 +668,9 @@ Type
     class procedure FreeMem(Ptr: TPtrWrapper); static; inline;
     class procedure Move(Src, Dest: TPtrWrapper; Count: SizeInt); static; inline;
 
+    class function UnsafeAddrOf(var Value): TPtrWrapper; static; inline;
+
+{$IFDEF FPC_HAS_FEATURE_UNICODESTRINGS}
     class function AsAnsi(const S: UnicodeString): AnsiString; static; inline;
     class function AsAnsi(S: PUnicodeChar): AnsiString; static; inline;
 
@@ -659,8 +678,6 @@ Type
     class function InString(const S: UnicodeString): PUnicodeChar; static; inline;
     class function OutString(const S: UnicodeString): PUnicodeChar; static; inline;
 
-    class function UnsafeAddrOf(var Value): TPtrWrapper; static; inline;
-
     class function AllocStringAsAnsi(const Str: UnicodeString): TPtrWrapper; static; inline;
     class function AllocStringAsAnsi(const Str: UnicodeString; CodePage: Word): TPtrWrapper; static; inline;
     class function AllocStringAsAnsi(S: PUnicodeChar): TPtrWrapper; static; inline;
@@ -672,29 +689,51 @@ Type
     { Generalization of all AllocStringAsAnsi* above, public because used in TMarshaller. }
     class function AllocStringAsAnsi(S: PUnicodeChar; Len: SizeInt; CodePage: Word): TPtrWrapper; static;
 
-    class procedure Copy(const Src: specialize TArray<UnicodeChar>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<UnicodeChar>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<UInt8>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<UInt8>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<Int8>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int8>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<UInt16>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<UInt16>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<Int16>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int16>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<Int32>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int32>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<Int64>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<Int64>; StartIndex: SizeInt; Count: SizeInt); static; inline;
-    class procedure Copy(const Src: specialize TArray<TPtrWrapper>; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
-    class procedure Copy(Src: TPtrWrapper; var Dest: specialize TArray<TPtrWrapper>; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TUnicodeCharArray; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class function FixString(var Str: UnicodeString): TPtrWrapper; static;
+    class function UnsafeFixString(const Str: UnicodeString): TPtrWrapper; static;
+    class procedure UnfixString(Ptr: TPtrWrapper); static;
+
+    class function ReadStringAsAnsi(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static; inline;
+    class function ReadStringAsAnsi(CodePage: Word; Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static;
+    class function ReadStringAsAnsiUpTo(CodePage: Word; Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static;
+
+    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
+    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt; CodePage: Word); static; inline;
+    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
+    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt; CodePage: Word); static;
+
+    class function ReadStringAsUnicode(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static;
+    class function ReadStringAsUnicodeUpTo(Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static;
+    class procedure WriteStringAsUnicode(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static;
+    class procedure WriteStringAsUnicode(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static;
+
+    class function ReadStringAsUtf8(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static; inline;
+    class function ReadStringAsUtf8UpTo(Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static; inline;
+    class procedure WriteStringAsUtf8(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
+    class procedure WriteStringAsUtf8(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TUnicodeCharArray; StartIndex: SizeInt; Count: SizeInt); static; inline;
+{$ENDIF}
+
+    class procedure Copy(const Src: TUint8Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TUint8Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TInt8Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TInt8Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TUInt16Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TUInt16Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TInt16Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TInt16Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TInt32Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TInt32Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TInt64Array; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TInt64Array; StartIndex: SizeInt; Count: SizeInt); static; inline;
+    class procedure Copy(const Src: TPtrWrapperArray; StartIndex: SizeInt; Dest: TPtrWrapper; Count: SizeInt); static; inline;
+    class procedure Copy(Src: TPtrWrapper; var Dest: TPtrWrapperArray; StartIndex: SizeInt; Count: SizeInt); static; inline;
 
     generic class function FixArray<T>(const Arr: specialize TArray<T>): TPtrWrapper; static;
     generic class procedure UnfixArray<T>(ArrPtr: TPtrWrapper); static;
 
-    class function FixString(var Str: UnicodeString): TPtrWrapper; static;
-    class procedure UnfixString(Ptr: TPtrWrapper); static;
-    class function UnsafeFixString(const Str: UnicodeString): TPtrWrapper; static;
+
 
     class function ReadByte(Ptr: TPtrWrapper; Ofs: SizeInt = 0): Byte; static; inline;
     class procedure WriteByte(Ptr: TPtrWrapper; Ofs: SizeInt; Value: Byte); static; inline;
@@ -716,21 +755,5 @@ Type
     class procedure WritePtr(Ptr: TPtrWrapper; Ofs: SizeInt; Value: TPtrWrapper); static; inline;
     class procedure WritePtr(Ptr, Value: TPtrWrapper); static; inline;
 
-    class function ReadStringAsAnsi(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static; inline;
-    class function ReadStringAsAnsi(CodePage: Word; Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static;
-    class function ReadStringAsAnsiUpTo(CodePage: Word; Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static;
-    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
-    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt; CodePage: Word); static; inline;
-    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
-    class procedure WriteStringAsAnsi(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt; CodePage: Word); static;
-
-    class function ReadStringAsUnicode(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static;
-    class function ReadStringAsUnicodeUpTo(Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static;
-    class procedure WriteStringAsUnicode(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static;
-    class procedure WriteStringAsUnicode(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static;
 
-    class function ReadStringAsUtf8(Ptr: TPtrWrapper; Len: SizeInt = -1): UnicodeString; static; inline;
-    class function ReadStringAsUtf8UpTo(Ptr: TPtrWrapper; MaxLen: SizeInt): UnicodeString; static; inline;
-    class procedure WriteStringAsUtf8(Ptr: TPtrWrapper; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
-    class procedure WriteStringAsUtf8(Ptr: TPtrWrapper; Ofs: SizeInt; const Value: UnicodeString; MaxCharsIncNull: SizeInt); static; inline;
   end;