mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 21:38:18 +02:00
* Add length
This commit is contained in:
parent
f584c559fd
commit
50370ff56d
@ -706,9 +706,11 @@ type
|
||||
IJSTypedArray = interface(IJSObject)
|
||||
['{6A76602B-9555-4136-A7B7-2E683265EA82}']
|
||||
function GetBuffer: IJSArrayBuffer;
|
||||
function _GetLength: NativeInt;
|
||||
procedure set_(aArray : IJSTypedArray; TargetOffset : Integer);
|
||||
procedure set_(aArray : IJSTypedArray);
|
||||
property Buffer : IJSArrayBuffer read GetBuffer;
|
||||
Property Length: NativeInt Read _GetLength;
|
||||
end;
|
||||
|
||||
{ TJSTypedArray }
|
||||
@ -716,6 +718,7 @@ type
|
||||
TJSTypedArray = class(TJSObject,IJSTypedArray)
|
||||
private
|
||||
function GetBuffer: IJSArrayBuffer;
|
||||
function _GetLength: NativeInt;
|
||||
public
|
||||
constructor Create(aBytes : PByte; aLen : NativeUInt);
|
||||
constructor Create(aBytes : TBytes);
|
||||
@ -723,6 +726,7 @@ type
|
||||
procedure set_(aArray : IJSTypedArray; TargetOffset : Integer);
|
||||
procedure set_(aArray : IJSTypedArray);
|
||||
property Buffer : IJSArrayBuffer read GetBuffer;
|
||||
Property Length: NativeInt Read _GetLength;
|
||||
end;
|
||||
|
||||
{ IJSInt8Array }
|
||||
@ -935,7 +939,7 @@ type
|
||||
|
||||
TJSPromise = class(TJSObject,IJSPromise)
|
||||
public
|
||||
//class function Create(const Executor: TJSPromiseExecutor): IJSPromise; overload;
|
||||
constructor Create(const Executor: TJSPromiseExecutor); overload;
|
||||
function all(const arg: Variant): IJSPromise; overload;
|
||||
function allSettled(const arg: Variant): IJSPromise; overload;
|
||||
function race(const arg: Variant): IJSPromise; overload;
|
||||
@ -947,6 +951,7 @@ type
|
||||
function catch(const OnRejected: TJSPromiseResolver): IJSPromise; overload;
|
||||
function _finally(const Handler: TJSPromiseFinallyHandler): IJSPromise; overload;
|
||||
class function Cast(const Intf: IJSObject): IJSPromise; overload;
|
||||
class function JSClassName: UnicodeString; override;
|
||||
end;
|
||||
|
||||
{ IJSTextDecoder }
|
||||
@ -1229,6 +1234,19 @@ begin
|
||||
TJSPromiseFinallyHandler(aMethod)();
|
||||
end;
|
||||
|
||||
function JOBCallTJSPromiseExecutor(const aMethod: TMethod; var H: TJOBCallbackHelper): PByte;
|
||||
|
||||
var
|
||||
Resolve,Reject : TMethod;
|
||||
|
||||
begin
|
||||
// Resolve:=TJSPromiseResolver(H.GetMethod);
|
||||
// Reject:=TJSPromiseResolver(H.GetMethod);
|
||||
// TJSPromiseExecutor(aMethod)(Resolve, Reject);
|
||||
Result:=H.AllocUndefined;
|
||||
end;
|
||||
|
||||
|
||||
{ TJSTextEncoder }
|
||||
|
||||
class function TJSTextEncoder.Cast(const Intf: IJSObject): IJSTextEncoder;
|
||||
@ -1245,6 +1263,19 @@ end;
|
||||
|
||||
{ TJSPromise }
|
||||
|
||||
constructor TJSPromise.Create(const Executor: TJSPromiseExecutor);
|
||||
|
||||
var
|
||||
m: TJOB_Method;
|
||||
begin
|
||||
m:=TJOB_Method.Create(TMethod(Executor),@JobCallTJSPromiseExecutor);
|
||||
try
|
||||
JOBCreate([m]);
|
||||
finally
|
||||
m.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TJSPromise.all(const arg: Variant): IJSPromise;
|
||||
begin
|
||||
Result:=InvokeJSObjectResult('all',[arg],TJSPromise) as IJSPromise;
|
||||
@ -1332,6 +1363,11 @@ begin
|
||||
Result:=TJSPromise.Cast(Intf);
|
||||
end;
|
||||
|
||||
class function TJSPromise.JSClassName: UnicodeString;
|
||||
begin
|
||||
Result:='Promise';
|
||||
end;
|
||||
|
||||
{ TJSError }
|
||||
|
||||
class function TJSError.Cast(const Intf: IJSObject): IJSError;
|
||||
@ -1478,6 +1514,12 @@ begin
|
||||
Result:=ReadJSPropertyObject('buffer',TJSArrayBuffer) as IJSArrayBuffer;
|
||||
end;
|
||||
|
||||
function TJSTypedArray._GetLength: NativeInt;
|
||||
begin
|
||||
// For the time being
|
||||
Result:=ReadJSPropertyLongInt('length');
|
||||
end;
|
||||
|
||||
constructor TJSTypedArray.Create(aBytes: PByte; aLen: NativeUInt);
|
||||
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user