Browse Source

* Patch from Henrique Werlang to add Delphi compatible From<>

michael 4 years ago
parent
commit
219a749aa3
1 changed files with 6 additions and 0 deletions
  1. 6 0
      packages/rtl/rtti.pas

+ 6 - 0
packages/rtl/rtti.pas

@@ -34,6 +34,7 @@ type
     function GetIsEmpty: boolean;
     function GetTypeKind: TTypeKind;
   public
+    generic class function From<T>(const Value: T): TValue; static;
     class function FromJSValue(v: JSValue): TValue; static;
 
     property Kind: TTypeKind read GetTypeKind;
@@ -502,6 +503,11 @@ begin
     Result:=FTypeInfo.Kind;
 end;
 
+generic class function TValue.From<T>(const Value: T): TValue;
+begin
+  Result := FromJSValue(Value);
+end;
+
 class function TValue.FromJSValue(v: JSValue): TValue;
 var
   i: NativeInt;