View Issue Details

IDProjectCategoryView StatusLast Update
0038568pas2jsrtlpublic2021-03-02 13:32
Reporterhenrique Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Fixed in Versiontrunk 
Summary0038568: AsType in TValue
DescriptionI created the AsType function in TValue for the generic conversion equal to Delphi.
TagsNo tags attached.
Fixed in Revision1091
Attached Files

Activities

henrique

2021-03-02 13:20

reporter  

0001-Criado-o-AsType.patch (1,000 bytes)   
From de24fbeedcea18295e5aa11ca17ff448367f732c Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Tue, 2 Mar 2021 09:11:51 -0300
Subject: [PATCH] Criado o AsType.

---
 packages/rtl/rtti.pas | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/packages/rtl/rtti.pas b/packages/rtl/rtti.pas
index c66e6c3..ea9e83c 100644
--- a/packages/rtl/rtti.pas
+++ b/packages/rtl/rtti.pas
@@ -41,6 +41,7 @@ type
     property TypeInfo: TTypeInfo read FTypeInfo;
 
     property IsEmpty: boolean read GetIsEmpty; // check if nil or undefined
+    generic function AsType<T>: T;
     function IsObject: boolean;
     function AsObject: TObject;
     function IsObjectInstance: boolean;
@@ -561,6 +562,11 @@ begin
     Result:=FTypeInfo.Kind;
 end;
 
+generic function TValue.AsType<T>: T;
+begin
+  Result := T(AsJSValue)
+end;
+
 generic class function TValue.From<T>(const Value: T): TValue;
 begin
   Result := Make(System.TypeInfo(T), Value);
-- 
2.30.0.windows.1

0001-Criado-o-AsType.patch (1,000 bytes)   

Michael Van Canneyt

2021-03-02 13:32

administrator   ~0129312

Applied, thank you very much !

Issue History

Date Modified Username Field Change
2021-03-02 13:20 henrique New Issue
2021-03-02 13:20 henrique File Added: 0001-Criado-o-AsType.patch
2021-03-02 13:30 Michael Van Canneyt Assigned To => Michael Van Canneyt
2021-03-02 13:30 Michael Van Canneyt Status new => assigned
2021-03-02 13:32 Michael Van Canneyt Status assigned => resolved
2021-03-02 13:32 Michael Van Canneyt Resolution open => fixed
2021-03-02 13:32 Michael Van Canneyt Fixed in Version => trunk
2021-03-02 13:32 Michael Van Canneyt Fixed in Revision => 1091
2021-03-02 13:32 Michael Van Canneyt Note Added: 0129312