Browse Source

* TValue.From with buffer and typeinfo. Patch from Lipinast Lekrisov

Michaël Van Canneyt 8 months ago
parent
commit
98a7fe6204
1 changed files with 7 additions and 0 deletions
  1. 7 0
      packages/rtl-objpas/src/inc/rtti.pp

+ 7 - 0
packages/rtl-objpas/src/inc/rtti.pp

@@ -208,6 +208,7 @@ type
     { Note: a TValue based on an open array is only valid until the routine having the open array parameter is left! }
     { Note: a TValue based on an open array is only valid until the routine having the open array parameter is left! }
     generic class function FromOpenArray<T>(constref aValue: array of T): TValue; static; inline;
     generic class function FromOpenArray<T>(constref aValue: array of T): TValue; static; inline;
 {$endif}
 {$endif}
+    class function From(aTypeInfo: PTypeInfo; ABuffer: Pointer): TValue; static;
     class function FromOrdinal(aTypeInfo: PTypeInfo; aValue: Int64): TValue; static; {inline;}
     class function FromOrdinal(aTypeInfo: PTypeInfo; aValue: Int64): TValue; static; {inline;}
     class function FromArray(aArrayTypeInfo: PTypeInfo; const aValues: array of TValue): TValue; static;
     class function FromArray(aArrayTypeInfo: PTypeInfo; const aValues: array of TValue): TValue; static;
     class function FromVarRec(const aValue: TVarRec): TValue; static;
     class function FromVarRec(const aValue: TVarRec): TValue; static;
@@ -3675,6 +3676,12 @@ begin
   Result.FData.FElSize := el.DataSize;
   Result.FData.FElSize := el.DataSize;
 end;
 end;
 
 
+class function TValue.From(aTypeInfo: PTypeInfo; ABuffer: Pointer): TValue;
+
+begin
+  TValue.Make(ABuffer, PTypeInfo(aTypeInfo), Result);
+end;
+
 class function TValue.FromOrdinal(aTypeInfo: PTypeInfo; aValue: Int64): TValue;
 class function TValue.FromOrdinal(aTypeInfo: PTypeInfo; aValue: Int64): TValue;
 {$ifdef ENDIAN_BIG}
 {$ifdef ENDIAN_BIG}
 var
 var