Browse Source

* Bigint does not use new()

Michael Van Canneyt 2 months ago
parent
commit
db612ccef0
1 changed files with 21 additions and 1 deletions
  1. 21 1
      packages/rtl/src/js.pas

+ 21 - 1
packages/rtl/src/js.pas

@@ -16,6 +16,7 @@ unit JS;
 
 {$mode objfpc}
 {$modeswitch externalclass}
+{$modeswitch typehelpers}
 
 interface
 
@@ -1108,11 +1109,16 @@ type
   end;
 
   TJSBigInt = class external name 'BigInt' (TJSObject)
-     constructor new(aValue : JSValue);
      class function asIntN(Size : Integer;aValue : TJSBigInt) : NativeInt;
      class function asUIntN(Size : Integer;aValue : TJSBigInt) : NativeInt;
   end;
 
+  { TJSBigIntHelper }
+
+  TJSBigIntHelper = type helper for TJSBigint
+    class function new(aValue : JSValue) : TJSBigInt; static;
+  end;
+
   { TJSAtomicWaitResult }
 
   TJSAtomicWaitResult = class external name 'Object' (TJSObject)
@@ -1862,6 +1868,7 @@ Function GetValueType(JS : JSValue) : TJSValueType;
 Function HaveSharedArrayBuffer : Boolean;
 Function SharedToNonShared(aBuffer : TJSAbstractArrayBuffer) : TJSArrayBuffer;
 Function SharedToNonShared(aArray : TJSTypedArray; aWordSized : Boolean = False) : TJSTypedArray;
+Function JSBigInt(aValue : JSValue) : TJSBigInt;
 
 Const
   Null : JSValue; external name 'null';
@@ -2092,6 +2099,13 @@ begin
   FMessage:=Msg;
 end;
 
+{ TJSBigIntHelper }
+
+class function TJSBigIntHelper.new(aValue: JSValue): TJSBigInt;
+begin
+  Result:=JSBigint(aValue);
+end;
+
 
 function GetValueType(JS: JSValue): TJSValueType;
 
@@ -2173,5 +2187,11 @@ asm
   return Symbol(Description);
 end;
 
+Function JSBigInt(aValue : JSValue) : TJSBigInt; assembler;
+
+asm
+  return BigInt(aValue);
+end;
+
 end.