@live-codes/pascal-wasm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +501 -0
  2. package/README.md +278 -0
  3. package/THIRD-PARTY-NOTICES.md +48 -0
  4. package/assets/pas2js.wasm +0 -0
  5. package/assets/rtl/Rtl.BrowserLoadHelper.pas +179 -0
  6. package/assets/rtl/browserconsole.pas +190 -0
  7. package/assets/rtl/classes.pas +11371 -0
  8. package/assets/rtl/js.pas +2211 -0
  9. package/assets/rtl/manifest.json +19 -0
  10. package/assets/rtl/math.pas +903 -0
  11. package/assets/rtl/p2jsres.pp +334 -0
  12. package/assets/rtl/rtl.js +1563 -0
  13. package/assets/rtl/rtlconsts.pas +97 -0
  14. package/assets/rtl/simplelinkedlist.pas +152 -0
  15. package/assets/rtl/system.pas +1166 -0
  16. package/assets/rtl/sysutils.pas +8959 -0
  17. package/assets/rtl/types.pas +2296 -0
  18. package/assets/rtl/typinfo.pas +1680 -0
  19. package/assets/rtl/web.pas +3586 -0
  20. package/assets/rtl/weborworker.pas +2101 -0
  21. package/dist/pascal-wasm.iife.min.js +6 -0
  22. package/dist/pascal-wasm.iife.min.js.map +7 -0
  23. package/package.json +54 -0
  24. package/src/assets.js +119 -0
  25. package/src/compiler.js +142 -0
  26. package/src/config.js +24 -0
  27. package/src/iife.js +27 -0
  28. package/src/index.js +130 -0
  29. package/src/vendor/browser_wasi_shim/debug.js +1 -0
  30. package/src/vendor/browser_wasi_shim/fd.js +1 -0
  31. package/src/vendor/browser_wasi_shim/fs_mem.js +1 -0
  32. package/src/vendor/browser_wasi_shim/fs_opfs.js +1 -0
  33. package/src/vendor/browser_wasi_shim/index.js +1 -0
  34. package/src/vendor/browser_wasi_shim/strace.js +1 -0
  35. package/src/vendor/browser_wasi_shim/wasi.js +1 -0
  36. package/src/vendor/browser_wasi_shim/wasi_defs.js +1 -0
  37. package/types/index.d.ts +89 -0
@@ -0,0 +1,2211 @@
1
+ {
2
+ This file is part of the Pas2JS run time library.
3
+ Copyright (c) 2017-2020 by the Pas2JS development team.
4
+
5
+ See the file COPYING.FPC, included in this distribution,
6
+ for details about the copyright.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
+
12
+ **********************************************************************}
13
+ {$IFNDEF FPC_DOTTEDUNITS}
14
+ unit JS;
15
+ {$ENDIF}
16
+
17
+ {$mode objfpc}
18
+ {$modeswitch externalclass}
19
+ {$modeswitch typehelpers}
20
+
21
+ interface
22
+
23
+ uses
24
+ {$IFDEF FPC_DOTTEDUNITS}
25
+ System.Types;
26
+ {$ELSE}
27
+ Types;
28
+ {$ENDIF}
29
+
30
+ type
31
+ // We cannot use EConvertError or Exception, this would result in a circular dependency.
32
+ TJSArray = class;
33
+ TJSMap = class;
34
+ TJSBigInt = Class;
35
+ { EJS }
36
+
37
+ EJS = class(TObject)
38
+ private
39
+ FMessage: string;
40
+ Public
41
+ constructor Create(const Msg: String); reintroduce;
42
+ property Message : string Read FMessage Write FMessage;
43
+ end;
44
+
45
+ TJSObjectPropertyDescriptor = JSValue;
46
+ Float32 = Double;
47
+ Float64 = Double;
48
+
49
+ { TJSObject }
50
+
51
+ TJSObject = class external name 'Object'
52
+ private
53
+ function GetProperties(Name: String): JSValue; external name '[]';
54
+ procedure SetProperties(Name: String; const AValue: JSValue); external name '[]';
55
+ public
56
+ constructor new;
57
+ class function create(const proto: TJSObject): TJSObject;
58
+ class function create(const proto, propertiesObject: TJSObject): TJSObject;
59
+ class function assign(const Target, Source1: TJSObject): TJSObject; varargs;
60
+ class procedure defineProperty(const obj: TJSObject; propname: String; const descriptor: TJSObjectPropertyDescriptor);
61
+ //class procedure defineProperties
62
+ class function freeze(const obj: TJSObject): TJSObject;
63
+ class function getOwnPropertyDescriptor(const obj: TJSObject; propname: String): TJSObjectPropertyDescriptor;
64
+ //class function getOwnPropertyDescriptors
65
+ class function getOwnPropertyNames(const obj: TJSObject): TStringDynArray;
66
+ class function values(const obj: JSValue): TJSObject;
67
+ {$IFDEF FIREFOX}
68
+ class function getOwnPropertySymbols(const obj: TJSObject): TJSValueDynArray;
69
+ {$ENDIF}
70
+ class function getPrototypeOf(const obj: TJSObject): TJSObject;
71
+ {$IFDEF FIREFOX}
72
+ class function _is(const value1, value2: JSValue): boolean;
73
+ {$ENDIF}
74
+ class function fromEntries(const obj: TJSObject): TJSObject;
75
+ class function fromEntries(const obj: TJSArray): TJSObject;
76
+ class function fromEntries(const obj: TJSMap): TJSObject;
77
+ class function isExtensible(const obj: TJSObject): boolean;
78
+ class function isFrozen(const obj: TJSObject): boolean;
79
+ class function isSealed(const obj: TJSObject): boolean;
80
+ class function keys(const obj: TJSObject): TStringDynArray;
81
+ class function preventExtensions(const obj: TJSObject): TJSObject;
82
+ class function seal(const obj: TJSObject): TJSObject;
83
+ class function setPrototypeOf(const obj, prototype: TJSObject): TJSObject;
84
+ function hasOwnProperty(prop: String): boolean;
85
+ function isPrototypeOf(const obj: TJSObject): boolean;
86
+ function propertyIsEnumerable(propname: String): boolean;
87
+ function toLocaleString: String;
88
+ function toString: String;
89
+ function valueOf: JSValue;
90
+ property Properties[Name: String]: JSValue read GetProperties write SetProperties; default;
91
+ end;
92
+ TJSObjectClass = class of TJSObject;
93
+
94
+ TJSObjectDynArray = Array of TJSObject;
95
+ TJSObjectDynArrayArray = Array of TJSObjectDynArray;
96
+ TJSStringDynArray = Array of String;
97
+
98
+
99
+ { TJSIteratorValue }
100
+ TJSIteratorValue = class external name 'IteratorValue'
101
+ public
102
+ value : JSValue; external name 'value';
103
+ done : boolean; external name 'done';
104
+ end;
105
+
106
+ { TJSIterator }
107
+ TJSIterator = class external name 'Iterator'
108
+ Public
109
+ function next: TJSIteratorValue;
110
+ end;
111
+
112
+
113
+ TJSSet = class;
114
+
115
+ TJSSetEventProc = reference to procedure(value : JSValue; key: NativeInt; set_: TJSSet);
116
+ TJSSetProcCallBack = reference to procedure(value: JSValue; key: JSValue);
117
+
118
+ { TJSSet }
119
+ TJSSet = class external name 'Set'
120
+ private
121
+ FSize : NativeInt; external name 'size';
122
+ public
123
+ constructor new; overload;
124
+ constructor new(aElement1 : JSValue); varargs; overload;
125
+ function add(value: JSValue): TJSSet;
126
+ function has(value: JSValue): Boolean;
127
+ function delete(value: JSValue): Boolean;
128
+ procedure clear;
129
+ function values: TJSIterator;
130
+ procedure forEach(const aCallBack: TJSSetEventProc); overload;
131
+ procedure forEach(const aCallBack: TJSSetProcCallBack); overload;
132
+ procedure forEach(const aCallBack: TJSSetEventProc; thisArg: JSValue); overload;
133
+ function entries: TJSIterator;
134
+ function keys: TJSIterator;
135
+ Property size : NativeInt Read FSize;
136
+ end;
137
+
138
+ TJSMapFunctionCallBack = reference to function(arg : JSValue): JSValue;
139
+ TJSMapProcCallBack = reference to procedure(value: JSValue; key: JSValue);
140
+
141
+ { TJSMap }
142
+
143
+ TJSMap = class external name 'Map'
144
+ Private
145
+ FSize : NativeInt; external name 'size';
146
+ public
147
+ constructor new; varargs; overload;
148
+ constructor new(aElement1 : JSValue); varargs; overload;
149
+ function &set(key: JSValue; value: JSValue) :TJSMap;
150
+ function get(key : JSValue): JSValue;
151
+ function has(key: JSValue): Boolean;
152
+ function delete(key: JSValue): Boolean;
153
+ procedure clear;
154
+ function entries: TJSIterator;
155
+ procedure forEach(const aCallBack: TJSMapFunctionCallBack); overload;
156
+ procedure forEach(const aCallBack: TJSMapFunctionCallBack; thisArg: JSValue); overload;
157
+ procedure forEach(const aCallBack: TJSMapProcCallBack); overload;
158
+ function keys: TJSIterator;
159
+ function values: TJSIterator;
160
+ property size : NativeInt Read FSize;
161
+ end;
162
+
163
+ { TJSFunction }
164
+
165
+ TJSFunction = class external name 'Function'(TJSObject)
166
+ private
167
+ Flength: NativeInt external name 'length';
168
+ Fprototyp: TJSFunction external name 'prototyp';
169
+ public
170
+ name: String;
171
+ property prototyp: TJSFunction read Fprototyp;
172
+ property length: NativeInt read Flength;
173
+ function apply(thisArg: TJSObject; const ArgArray: TJSValueDynArray): JSValue; varargs;
174
+ function bind(thisArg: TJSObject): JSValue; varargs;
175
+ function call(thisArg: TJSObject): JSValue; varargs;
176
+ end;
177
+
178
+ { TJSDate - wrapper for JavaScript Date }
179
+
180
+ TJSDate = class external name 'Date'(TJSFunction)
181
+ private
182
+ function getDate: NativeInt;
183
+ function getFullYear: NativeInt;
184
+ function getHours: NativeInt;
185
+ function getMilliseconds: NativeInt;
186
+ function getMinutes: NativeInt;
187
+ function getMonth: NativeInt;
188
+ function getSeconds: NativeInt;
189
+ function getYear: NativeInt;
190
+ function getTime: NativeInt;
191
+ function getUTCDate: NativeInt;
192
+ function getUTCFullYear: NativeInt;
193
+ function getUTCHours: NativeInt;
194
+ function getUTCMilliseconds: NativeInt;
195
+ function getUTCMinutes: NativeInt;
196
+ function getUTCMonth: NativeInt;
197
+ function getUTCSeconds: NativeInt;
198
+ procedure setDate(const AValue: NativeInt);
199
+ procedure setFullYear(const AValue: NativeInt);
200
+ procedure setHours(const AValue: NativeInt);
201
+ procedure setMilliseconds(const AValue: NativeInt);
202
+ procedure setMinutes(const AValue: NativeInt);
203
+ procedure setMonth(const AValue: NativeInt);
204
+ procedure setSeconds(const AValue: NativeInt);
205
+ procedure setYear(const AValue: NativeInt);
206
+ procedure setTime(const AValue: NativeInt);
207
+ procedure setUTCDate(const AValue: NativeInt);
208
+ procedure setUTCFullYear(const AValue: NativeInt);
209
+ procedure setUTCHours(const AValue: NativeInt);
210
+ procedure setUTCMilliseconds(const AValue: NativeInt);
211
+ procedure setUTCMinutes(const AValue: NativeInt);
212
+ procedure setUTCMonth(const AValue: NativeInt);
213
+ procedure setUTCSeconds(const AValue: NativeInt);
214
+ public
215
+ constructor New; reintroduce;
216
+ constructor New(const MilliSecsSince1970: NativeInt); // milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored
217
+ constructor New(const aDateString: String); // RFC 2822, ISO8601
218
+ constructor New(aYear: NativeInt; aMonth: NativeInt; aDayOfMonth: NativeInt = 1;
219
+ TheHours: NativeInt = 0; TheMinutes: NativeInt = 0; TheSeconds: NativeInt = 0;
220
+ TheMilliseconds: NativeInt = 0);
221
+ class function now: NativeInt; // current date and time in milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored
222
+ class function parse(const aDateString: string): NativeInt; // format depends on browser
223
+ class function UTC(aYear: NativeInt; aMonth: NativeInt = 0; aDayOfMonth: NativeInt = 1;
224
+ TheHours: NativeInt = 0; TheMinutes: NativeInt = 0; TheSeconds: NativeInt = 0;
225
+ TheMilliseconds: NativeInt = 0): NativeInt;
226
+ function getDay: NativeInt;
227
+ function getTimezoneOffset: NativeInt;
228
+ function getUTCDay: NativeInt; // day of the week
229
+ function toDateString: string; // human readable date, without time
230
+ function toISOString: string; // ISO 8601 Extended Format
231
+ function toJSON: string;
232
+ function toGMTString: string; // in GMT timezone
233
+ function toLocaleDateString: string; overload; // date in locale timezone, no time
234
+ function toLocaleDateString(const aLocale : string) : string; overload; // date in locale timezone, no time
235
+ function toLocaleDateString(const aLocale : string; aOptions : TJSObject) : string; overload; // date in locale timezone, no time
236
+ function toLocaleString: string; reintroduce; // date and time in locale timezone
237
+ function toLocaleTimeString: string; // time in locale timezone, no date
238
+ function toTimeString: string; // time human readable, no date
239
+ function toUTCString: string; // date and time using UTC timezone
240
+ property Year: NativeInt read getYear write setYear;
241
+ property Time: NativeInt read getTime write setTime; // milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored
242
+ property FullYear: NativeInt read getFullYear write setFullYear;
243
+ property UTCDate: NativeInt read getUTCDate write setUTCDate; // day of month
244
+ property UTCFullYear: NativeInt read getUTCFullYear write setUTCFullYear;
245
+ property UTCHours: NativeInt read getUTCHours write setUTCHours;
246
+ property UTCMilliseconds: NativeInt read getUTCMilliseconds write setUTCMilliseconds;
247
+ property UTCMinutes: NativeInt read getUTCMinutes write setUTCMinutes;
248
+ property UTCMonth: NativeInt read getUTCMonth write setUTCMonth;
249
+ property UTCSeconds: NativeInt read getUTCSeconds write setUTCSeconds;
250
+ property Month: NativeInt read getMonth write setMonth;
251
+ property Date: NativeInt read getDate write setDate; // day of the month, starting at 1
252
+ property Hours: NativeInt read getHours write setHours;
253
+ property Minutes: NativeInt read getMinutes write setMinutes;
254
+ property Seconds: NativeInt read getSeconds write setSeconds;
255
+ property Milliseconds: NativeInt read getMilliseconds write setMilliseconds;
256
+ end;
257
+
258
+ { TJSSymbol }
259
+
260
+ TJSSymbol = class external name 'Symbol' (TJSFunction)
261
+ private
262
+ Private
263
+ FDescription: String; external name 'description';
264
+ Public
265
+ constructor new (aValue : JSValue);
266
+ class function for_ (key : string) : TJSSymbol;
267
+ class function keyFor (aSymbol : TJSSymbol) : string;
268
+ property Description : String Read FDescription;
269
+ end;
270
+
271
+ TLocaleCompareOptions = record
272
+ localematched : string;
273
+ usage: string;
274
+ sensitivity : string;
275
+ ignorePunctuation : Boolean;
276
+ numeric : boolean;
277
+ caseFirst : string;
278
+ end;
279
+
280
+ TJSRegexp = class external name 'RegExp'
281
+ private
282
+ FDotAll : boolean; external name 'dotall';
283
+ FFlags : string; external name 'flags';
284
+ FSticky : boolean; external name 'sticky';
285
+ fglobal: boolean; external name 'global';
286
+ fhasIndices: boolean; external name 'hasIndices';
287
+ fignoreCase : boolean; external name 'ignoreCase';
288
+ fmultiline : boolean; external name 'multiline';
289
+ fsource : string; external name 'source';
290
+ funicode : boolean; external name 'unicode';
291
+ funicodeSets : boolean; external name 'unicodeSets';
292
+ public
293
+ Constructor New(Pattern : string);
294
+ Constructor New(Pattern, Flags : string);
295
+ lastIndex: NativeInt;
296
+ function exec(aString : string): TStringDynArray;
297
+ function execFull(aString : string): TJSObject; external name 'exec';
298
+ function test(aString : string) : boolean;
299
+ function toString : String;
300
+ property dotAll : Boolean Read FDotAll;
301
+ property Global : boolean read fglobal;
302
+ property IgnoreCase : Boolean read FIgnoreCase;
303
+ property Multiline : Boolean Read FMultiLine;
304
+ Property Source : string Read FSource;
305
+ Property Unicode : boolean Read FUnicode;
306
+ Property UnicodeSets : boolean Read FUnicodeSets;
307
+ Property HasIndices : Boolean Read FHasIndices;
308
+ property Flags : string read FFlags;
309
+ property Sticky : boolean read FSticky;
310
+ end;
311
+
312
+
313
+ TReplaceCallBack = reference to Function (Const match : string) : string; varargs;
314
+ TReplaceCallBack0 = reference to Function (Const match : string; offset : Integer; AString : String) : string;
315
+ TReplaceCallBack1 = reference to Function (Const match,p1 : string; offset : Integer; AString : String) : string;
316
+ TReplaceCallBack2 = reference to Function (Const match,p1,p2 : string; offset : Integer; AString : String) : string;
317
+
318
+ TJSString = class external name 'String'
319
+ private
320
+ flength : NativeInt; external name 'length';
321
+ public
322
+ constructor New(Const S : String);
323
+ constructor New(Const I : NativeInt);
324
+ constructor New(Const D : double);
325
+ property length : NativeInt read flength;
326
+ class function fromCharCode() : string; varargs;
327
+ class function fromCodePoint() : string; varargs;
328
+ function anchor(const aName : string) : string; deprecated;
329
+ function at(const index: Integer): String;
330
+ function charAt(aIndex : NativeInt) : string;
331
+ function charCodeAt(aIndex : NativeInt) : NativeInt;
332
+ function codePointAt(aIndex : NativeInt) : NativeInt;
333
+ function concat(s : string) : string; varargs;
334
+ function endsWith(aSearchString : string) : boolean; overload;
335
+ function endsWith(aSearchString : string; Pos : NativeInt) : boolean; overload;
336
+ function includes(aSearchString : string; Pos : NativeInt = 0) : boolean;
337
+ function indexOf(aSearchString : String; Pos : NativeInt = 0) : Integer;
338
+ function isWellFormed: Boolean;
339
+ function lastIndexOf(aSearchString : String) : NativeInt;overload;
340
+ function lastIndexOf(aSearchString : String; Pos : NativeInt) : Integer;overload;
341
+ function link(aUrl : string) : String; deprecated;
342
+ function localeCompare(aCompareString : string) : NativeInt; overload;
343
+ function localeCompare(aCompareString : string; aLocales: string) : integer; overload;
344
+ function localeCompare(compareString : string; locales: string; Options : TlocaleCompareOptions) : integer; overload;
345
+ function match(aRegexp : TJSRegexp) : TStringDynArray; overload;
346
+ function match(aRegexp : String) : TStringDynArray; overload;
347
+ function matchAll(aRegexp : TJSRegexp) : TJSIterator; overload;
348
+ function matchAll(aRegexp : String) : TJSIterator; overload;
349
+ {$IFDEF ECMAScript6}
350
+ function normalize : string;
351
+ function normalize(aForm : string) : string;
352
+ {$ENDIF}
353
+ function padEnd(targetLength: Integer): String; overload;
354
+ function padEnd(targetLength: Integer; padString: String): String; overload;
355
+ function padStart(targetLength: Integer): String; overload;
356
+ function padStart(targetLength: Integer; padString: String): String; overload;
357
+ function _repeat(aCount : NativeInt) : Integer; external name 'repeat';
358
+ function replace(aRegexp : String; NewString : String) : String; overload;
359
+ function replace(aRegexp : TJSRegexp; NewString : String) : String; overload;
360
+ function replace(Regexp : String; aCallback : TReplaceCallBack) : String; overload;
361
+ function replace(Regexp : TJSRegexp; aCallback : TReplaceCallBack) : String; overload;
362
+ function replace(Regexp : String; aCallback : TReplaceCallBack0) : String; overload;
363
+ function replace(Regexp : TJSRegexp; aCallback : TReplaceCallBack0) : String; overload;
364
+ function replace(Regexp : String; aCallback : TReplaceCallBack1) : String; overload;
365
+ function replace(Regexp : TJSRegexp; aCallback : TReplaceCallBack1) : String; overload;
366
+ function replace(Regexp : String; aCallback : TReplaceCallBack2) : String; overload;
367
+ function replace(Regexp : TJSRegexp; aCallback : TReplaceCallBack2) : String; overload;
368
+ function replaceAll(aRegexp : String; NewString : String) : String; overload;
369
+ function replaceAll(aRegexp : TJSRegexp; NewString : String) : String; overload;
370
+ function replaceAll(Regexp : String; aCallback : TReplaceCallBack) : String; overload;
371
+ function replaceAll(Regexp : TJSRegexp; aCallback : TReplaceCallBack) : String; overload;
372
+ function replaceAll(Regexp : String; aCallback : TReplaceCallBack0) : String; overload;
373
+ function replaceAll(Regexp : TJSRegexp; aCallback : TReplaceCallBack0) : String; overload;
374
+ function replaceAll(Regexp : String; aCallback : TReplaceCallBack1) : String; overload;
375
+ function replaceAll(Regexp : TJSRegexp; aCallback : TReplaceCallBack1) : String; overload;
376
+ function replaceAll(Regexp : String; aCallback : TReplaceCallBack2) : String; overload;
377
+ function replaceAll(Regexp : TJSRegexp; aCallback : TReplaceCallBack2) : String; overload;
378
+ function search(Regexp : TJSRegexp) : NativeInt; overload;
379
+ function search(Regexp : JSValue) : NativeInt; overload;
380
+ function slice(aBeginIndex : NativeInt) : String; overload;
381
+ function slice(aBeginIndex, aEndIndex : NativeInt) : String; overload;
382
+ function split : TStringDynArray; overload;
383
+ function split(aRegexp : TJSRegexp) : TStringDynArray; overload;
384
+ function split(aSeparator : string) : TStringDynArray; overload;
385
+ function split(aSeparator : string; aLimit : NativeInt) : TStringDynArray; overload;
386
+ function split(aSeparator : array of string) : TStringDynArray; overload;
387
+ function split(aSeparator : array of string; aLimit : NativeInt) : TStringDynArray; overload;
388
+ function startsWith(aSearchString : String) : Boolean; overload;
389
+ function startsWith(aSearchString : String; aPosition : NativeInt) : Boolean; overload;
390
+ function substr(aStartIndex : NativeInt) : String; overload; deprecated;
391
+ function substr(aStartIndex,aLength : NativeInt) : String; overload; deprecated;
392
+ function substring(aStartIndex : NativeInt) : String; overload;
393
+ function substring(aStartIndex,aEndIndex : NativeInt) : String; overload;
394
+ function toLocaleLowerCase : String;
395
+ function toLocaleUpperCase : String;
396
+ function toLowerCase : String;
397
+ function toString : string;
398
+ function toUpperCase : String;
399
+ function toWellFormed: String;
400
+ function trim : string;
401
+ function trimEnd: String;
402
+ function trimStart: String;
403
+ function valueOf : string;
404
+ end;
405
+
406
+
407
+ TJSArrayEventProc = reference to procedure(element : JSValue; index: NativeInt; anArray : TJSArray);
408
+ TJSArrayEvent = reference to function (element : JSValue; index: NativeInt; anArray : TJSArray) : Boolean;
409
+ TJSArrayMapEvent = reference to function (element : JSValue; index: NativeInt; anArray : TJSArray) : JSValue;
410
+ TJSArrayReduceEvent = reference to function (accumulator, currentValue : JSValue; currentIndex : NativeInt; anArray : TJSArray) : JSValue;
411
+ TJSArrayCompareEvent = reference to function (a,b : JSValue) : NativeInt;
412
+ TJSArrayCallback = TJSArrayEvent;
413
+ TJSArrayMapCallback = TJSArrayMapEvent;
414
+ TJSArrayReduceCallBack = TJSArrayReduceEvent;
415
+ TJSArrayCompareCallBack = TJSArrayCompareEvent;
416
+
417
+ { TJSArray }
418
+
419
+ TJSArray = Class external name 'Array'
420
+ private
421
+ function GetElements(Index: NativeInt): JSValue; external name '[]';
422
+ procedure SetElements(Index: NativeInt; const AValue: JSValue); external name '[]';
423
+ public
424
+ FLength : NativeInt; external name 'length';
425
+ constructor new; overload;
426
+ constructor new(aLength : NativeInt); overload;
427
+ constructor new(aElement1 : JSValue); varargs; overload;
428
+ class function _of() : TJSArray; varargs; external name 'of';
429
+ class function isArray(a: JSValue) : Boolean;
430
+ class function from(a : JSValue) : TJSArray;
431
+ class function from(arrayLike : JSValue; mapFunction : TJSMapFunctionCallBack): TJSArray; overload;
432
+ class function from(arrayLike : JSValue; mapFunction : TJSMapFunctionCallBack; thisArg : JSValue): TJSArray; overload;
433
+
434
+ function concat(el : JSValue) : TJSArray; varargs;
435
+ function copyWithin(aTarget : NativeInt) : TJSArray;overload; // not in IE
436
+ function copyWithin(aTarget, aStart : NativeInt) : TJSArray;overload; // not in IE
437
+ function copyWithin(aTarget, aStart, aEnd : NativeInt) : TJSArray;overload; // not in IE
438
+ function entries: TJSIterator;
439
+ Function every(const aCallback : TJSArrayCallBack) : boolean;overload;
440
+ Function every(const aCallback : TJSArrayEvent; aThis : TObject) : boolean;overload;
441
+ Function filter(const aCallBack : TJSArrayCallBack) : TJSArray; overload;
442
+ Function filter(const aCallBack : TJSArrayEvent; aThis : TObject) : TJSArray;overload;
443
+ Function fill(aValue : JSValue) : TJSArray; overload;
444
+ Function fill(aValue : JSValue; aStartIndex : NativeInt) : TJSArray; overload;
445
+ Function fill(aValue : JSValue; aStartIndex,aEndIndex : NativeInt) : TJSArray; overload;
446
+ Function find(const aCallBack : TJSArrayCallBack) : JSValue; overload;
447
+ Function find(const aCallBack : TJSArrayEvent; aThis : TObject) : JSValue; overload;
448
+ Function findIndex(const aCallBack : TJSArrayCallBack) : NativeInt; overload;
449
+ Function findIndex(const aCallBack : TJSArrayEvent; aThis : TObject) : NativeInt; overload;
450
+ procedure forEach(const aCallBack : TJSArrayEventProc); overload;
451
+ procedure forEach(const aCallBack : TJSArrayEvent); overload;
452
+ procedure forEach(const aCallBack : TJSArrayEvent; aThis : TObject); overload;
453
+ function includes(aElement : JSValue) : Boolean; overload;
454
+ function includes(aElement : JSValue; FromIndex : NativeInt) : Boolean; overload;
455
+ function indexOf(aElement : JSValue) : NativeInt; overload;
456
+ function indexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;
457
+ function join : String; overload;
458
+ function join (aSeparator : string) : String; overload;
459
+ function keys: TJSIterator;
460
+ function lastIndexOf(aElement : JSValue) : NativeInt; overload;
461
+ function lastIndexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;
462
+ // Function map(const aCallBack : TJSArrayMapEventArray) : JSValue; overload;
463
+ Function map(const aCallBack : TJSArrayMapCallBack) : TJSArray; overload;
464
+ Function map(const aCallBack : TJSArrayMapEvent; aThis : TObject) : TJSArray; overload;
465
+ function pop : JSValue;
466
+ function push(aElement : JSValue) : NativeInt; varargs;
467
+ function reduce(const aCallBack : TJSArrayReduceCallBack) : JSValue; overload;
468
+ function reduce(const aCallBack : TJSArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;
469
+ function reduceRight(const aCallBack : TJSArrayReduceCallBack) : JSValue; overload;
470
+ function reduceRight(const aCallBack : TJSArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;
471
+ Function reverse : TJSArray;
472
+ Function shift : JSValue;
473
+ Function slice : TJSArray; overload;
474
+ function slice(aBegin : NativeInt) : TJSArray; overload;
475
+ function slice(aBegin,aEnd : NativeInt) : TJSArray; overload;
476
+ Function some(const aCallback : TJSArrayCallBack) : boolean; overload;
477
+ Function some(const aCallback : TJSArrayEvent; aThis : TObject) : boolean; overload;
478
+ Function sort(const aCallback : TJSArrayCompareCallBack) : TJSArray; overload;
479
+ Function sort() : TJSArray; overload;
480
+ function splice(aStart : NativeInt) : TJSArray; overload;
481
+ function splice(aStart,aDeleteCount : NativeInt) : TJSArray; varargs; overload;
482
+ function toLocaleString: String; overload;
483
+ function toLocaleString(locales : string) : String; overload;
484
+ function toLocaleString(locales : string; const Options : TLocaleCompareOptions) : String; overload;
485
+ function toString : String;
486
+ function unshift : NativeInt; varargs;
487
+ function values: TJSIterator;
488
+ Property Length : NativeInt Read FLength Write FLength;
489
+ property Elements[Index: NativeInt]: JSValue read GetElements write SetElements; default;
490
+ end;
491
+
492
+ TJSAbstractArrayBuffer = Class external name 'Object' (TJSObject)
493
+ private
494
+ fLength : NativeInt; external name 'byteLength';
495
+ fmaxByteLength: NativeInt; external name 'maxByteLength';
496
+ Public
497
+ constructor new(aByteLength : NativeInt);
498
+ Property byteLength : NativeInt Read fLength;
499
+ property maxByteLength : NativeInt Read fmaxByteLength;
500
+ end;
501
+
502
+ { TJSArrayBuffer }
503
+
504
+ TJSArrayBuffer = Class external name 'ArrayBuffer' (TJSAbstractArrayBuffer)
505
+ private
506
+ fResizable: Boolean; external name 'resizable';
507
+ public
508
+ class function isView(aValue : JSValue) : Boolean;
509
+ function slice(aBegin : NativeInt) : TJSArrayBuffer; overload;
510
+ function slice(aBegin,aEnd : NativeInt) : TJSArrayBuffer; overload;
511
+ property resizable : Boolean Read fResizable;
512
+ end;
513
+
514
+ TJSSharedArrayBuffer = Class external name 'SharedArrayBuffer' (TJSAbstractArrayBuffer)
515
+ private
516
+ fGrowable : boolean; external name 'growable';
517
+ public
518
+ procedure grow(aNewLength : nativeInt);
519
+ function slice(aBegin : NativeInt) : TJSSharedArrayBuffer; overload;
520
+ function slice(aBegin,aEnd : NativeInt) : TJSSharedArrayBuffer; overload;
521
+ property growable : Boolean Read fGrowable;
522
+ end;
523
+
524
+
525
+ TJSBufferSource = class external name 'BufferSource' (TJSObject)
526
+ end;
527
+
528
+ { TJSTypedArray }
529
+ TJSTypedArray = Class;
530
+
531
+ TJSTypedArrayCallBack = reference to function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : Boolean;
532
+ TJSTypedArrayEvent = TJSTypedArrayCallBack; // function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : Boolean of object;
533
+ TJSTypedArrayMapCallBack = reference to function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : JSValue;
534
+ TJSTypedArrayMapEvent = TJSTypedArrayMapCallBack; // reference to function (element : JSValue; index: NativeInt; anArray : TJSTypedArray) : JSValue of object;
535
+ TJSTypedArrayReduceCallBack = reference to function (accumulator, currentValue : JSValue; currentIndex : NativeInt; anArray : TJSTypedArray) : JSValue;
536
+ TJSTypedArrayCompareCallBack = reference to function (a,b : JSValue) : NativeInt;
537
+
538
+ TJSTypedArray = class external name 'TypedArray' (TJSBufferSource)
539
+ Private
540
+ FBuffer: TJSArrayBuffer; external name 'buffer';
541
+ FBufferObj: TJSAbstractArrayBuffer; external name 'buffer';
542
+ FByteLength: NativeInt; external name 'byteLength';
543
+ FLength: NativeInt; external name 'length';
544
+ FByteOffset: NativeInt; external name 'byteOffset';
545
+ FBytesPerElement : NativeInt; external name 'BYTES_PER_ELEMENT';
546
+ function getValue(Index : NativeInt) : JSValue; external name '[]';
547
+ procedure setValue(Index : NativeInt;AValue : JSValue); external name '[]';
548
+ Public
549
+ property BYTES_PER_ELEMENT : NativeInt Read FBytesPerElement;
550
+ class var name : string;
551
+ // class function from(aValue : jsValue) : TJSTypedArray;
552
+ // class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSTypedArray;
553
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSTypedArray;
554
+ class function _of(aValue : jsValue) : TJSTypedArray; varargs; external name 'of';
555
+ function copyWithin(aTarget : NativeInt) : TJSTypedArray;overload;
556
+ function copyWithin(aTarget, aStart : NativeInt) : TJSTypedArray;overload;
557
+ function copyWithin(aTarget, aStart, aEnd : NativeInt) : TJSTypedArray;overload;
558
+ Function every(const aCallback : TJSTypedArrayCallBack) : boolean;overload;
559
+ Function every(const aCallback : TJSTypedArrayEvent; aThis : TObject) : boolean;overload;
560
+ Function fill(aValue : JSValue) : TJSTypedArray; overload;
561
+ Function fill(aValue : JSValue; aStartIndex : NativeInt) : TJSTypedArray; overload;
562
+ Function fill(aValue : JSValue; aStartIndex,aEndIndex : NativeInt) : TJSTypedArray; overload;
563
+ Function filter(const aCallBack : TJSTypedArrayCallBack) : TJSTypedArray; overload;
564
+ Function filter(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : TJSTypedArray;overload;
565
+ Function find(const aCallBack : TJSTypedArrayCallBack) : JSValue; overload;
566
+ Function find(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : JSValue; overload;
567
+ Function findIndex(const aCallBack : TJSTypedArrayCallBack) : NativeInt; overload;
568
+ Function findIndex(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : NativeInt; overload;
569
+ procedure forEach(const aCallBack : TJSTypedArrayCallBack); overload;
570
+ procedure forEach(const aCallBack : TJSTypedArrayEvent; aThis : TObject); overload;
571
+ function includes(aElement : JSValue) : Boolean; overload;
572
+ function includes(aElement : JSValue; FromIndex : NativeInt) : Boolean; overload;
573
+ function indexOf(aElement : JSValue) : NativeInt; overload;
574
+ function indexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;
575
+ function join : String; overload;
576
+ function join (aSeparator : string) : String; overload;
577
+ function lastIndexOf(aElement : JSValue) : NativeInt; overload;
578
+ function lastIndexOf(aElement : JSValue; FromIndex : NativeInt) : NativeInt; overload;
579
+ Function map(const aCallBack : TJSTypedArrayCallBack) : TJSTypedArray; overload;
580
+ Function map(const aCallBack : TJSTypedArrayEvent; aThis : TObject) : TJSTypedArray; overload;
581
+ function reduce(const aCallBack : TJSTypedArrayReduceCallBack) : JSValue; overload;
582
+ function reduce(const aCallBack : TJSTypedArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;
583
+ function reduceRight(const aCallBack : TJSTypedArrayReduceCallBack) : JSValue; overload;
584
+ function reduceRight(const aCallBack : TJSTypedArrayReduceCallBack; initialValue : JSValue) : JSValue; overload;
585
+ Function reverse : TJSTypedArray;
586
+ procedure _set(anArray : TJSArray); external name 'set';
587
+ procedure _set(anArray : TJSArray; anOffset : NativeInt); external name 'set';
588
+ procedure _set(anArray : TJSTypedArray); external name 'set';
589
+ procedure _set(anArray : TJSTypedArray; anOffset : NativeInt); external name 'set';
590
+ Function slice : TJSTypedArray; overload;
591
+ function slice(aBegin : NativeInt) : TJSTypedArray; overload;
592
+ function slice(aBegin,aEnd : NativeInt) : TJSTypedArray; overload;
593
+ Function some(const aCallback : TJSTypedArrayCallBack) : boolean; overload;
594
+ Function some(const aCallback : TJSTypedArrayEvent; aThis : TObject) : boolean; overload;
595
+ Function sort(const aCallback : TJSTypedArrayCompareCallBack) : TJSTypedArray; overload;
596
+ Function sort() : TJSTypedArray; overload;
597
+ function splice(aStart : NativeInt) : TJSTypedArray; overload;
598
+ function splice(aStart,aDeleteCount : NativeInt) : TJSTypedArray; varargs; overload;
599
+ function toLocaleString: String; overload;
600
+ function toLocaleString(locales : string) : String; overload;
601
+ function toLocaleString(locales : string; const Options : TLocaleCompareOptions) : String; overload;
602
+ function unshift : NativeInt; varargs;
603
+ property buffer : TJSArrayBuffer read FBuffer;
604
+ property bufferObj : TJSAbstractArrayBuffer read FBufferObj;
605
+ property byteLength : NativeInt Read FByteLength;
606
+ property byteOffset : NativeInt Read FByteOffset;
607
+ property length : NativeInt Read FLength;
608
+ property values[Index : NativeInt] : JSValue Read getValue Write SetValue; default;
609
+ end;
610
+ TJSTypedArrayClass = Class of TJSTypedArray;
611
+
612
+ { TJSInt8Array }
613
+
614
+ TJSInt8Array = class external name 'Int8Array' (TJSTypedArray)
615
+ private
616
+ function getTypedValue(Index : NativeInt): Shortint; external name '[]';
617
+ procedure setTypedValue(Index : NativeInt; AValue: Shortint);external name '[]';
618
+ public
619
+ {$IFDEF JAVASCRIPT2017}
620
+ constructor new; // new in ES2017
621
+ {$ENDIF}
622
+ constructor new (length : NativeInt);
623
+ constructor new (atypedArray : TJSTypedArray);
624
+ constructor new (aObject : TJSObject);
625
+ constructor new (buffer : TJSAbstractArrayBuffer);
626
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
627
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
628
+ class function from(aValue : jsValue) : TJSInt8Array; reintroduce;
629
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt8Array; reintroduce;
630
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt8Array; reintroduce;
631
+ class function _of(aValue : jsValue) : TJSInt8Array; varargs; external name 'of'; reintroduce;overload;
632
+ class function _of(aValue : TJSValueDynArray) : TJSInt8Array; varargs; external name 'of'; reintroduce; overload;
633
+ function subarray(aBegin, aEnd: Integer): TJSInt8Array; overload;
634
+ function subarray(aBegin: Integer): TJSInt8Array; overload;
635
+ function toBase64: String;
636
+ function toBase64(options: TJSObject): String;
637
+ procedure _set(anArray : Array of ShortInt); external name 'set'; reintroduce; overload;
638
+ procedure _set(anArray : Array of ShortInt; anOffset : NativeInt); external name 'set';
639
+ property values[Index : NativeInt] : Shortint Read getTypedValue Write setTypedValue; default;
640
+ end;
641
+
642
+ TJSUint8Array = class external name 'Uint8Array' (TJSTypedArray)
643
+ private
644
+ function getTypedValue(Index : NativeInt): Byte; external name '[]';
645
+ procedure setTypedValue(Index : NativeInt; AValue: Byte);external name '[]';
646
+ public
647
+ constructor new (length : NativeInt);
648
+ constructor new (atypedArray : TJSTypedArray);
649
+ constructor new (aArray : TJSValueDynArray);
650
+ constructor new (aArray : TJSArray);
651
+ constructor new (aObject : TJSObject);
652
+ constructor new (buffer : TJSAbstractArrayBuffer);
653
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
654
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
655
+ class function from(aValue : jsValue) : TJSUInt8Array; reintroduce; overload;
656
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt8Array; reintroduce;overload;
657
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt8Array; reintroduce;overload;
658
+ class function _of(aValue : jsValue) : TJSUInt8Array; varargs; external name 'of'; reintroduce; overload;
659
+ function subarray(aBegin, aEnd: Integer): TJSUInt8Array; overload;
660
+ function subarray(aBegin: Integer): TJSUInt8Array; overload;
661
+ procedure _set(anArray : Array of Byte); external name 'set'; reintroduce; overload;
662
+ procedure _set(anArray : Array of Byte; anOffset : NativeInt); external name 'set'; overload;
663
+ Property values[Index : NativeInt] : Byte Read getTypedValue Write setTypedValue; default;
664
+ end;
665
+
666
+ TJSUint8ClampedArray = class external name 'Uint8ClampedArray' (TJSTypedArray)
667
+ private
668
+ function getTypedValue(Index : NativeInt): Byte; external name '[]';
669
+ procedure setTypedValue(Index : NativeInt; AValue: Byte);external name '[]';
670
+ public
671
+ constructor new (length : NativeInt);
672
+ constructor new (atypedArray : TJSTypedArray);
673
+ constructor new (aArray : TJSValueDynArray);
674
+ constructor new (aArray : TJSArray);
675
+ constructor new (aObject : TJSObject);
676
+ constructor new (buffer : TJSAbstractArrayBuffer);
677
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
678
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
679
+ class function from(aValue : jsValue) : TJSUInt8ClampedArray; reintroduce;
680
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt8ClampedArray; reintroduce;overload;
681
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt8ClampedArray; reintroduce;overload;
682
+ class function _of(aValue : jsValue) : TJSUInt8ClampedArray; varargs; external name 'of'; reintroduce;
683
+ procedure _set(anArray : Array of Byte); external name 'set'; reintroduce;overload;
684
+ procedure _set(anArray : Array of Byte; anOffset : NativeInt); external name 'set';overload;
685
+ function subarray(aBegin, aEnd: Integer): TJSUInt8ClampedArray; overload;
686
+ function subarray(aBegin: Integer): TJSUInt8ClampedArray; overload;
687
+ Property values[Index : NativeInt] : Byte Read getTypedValue Write setTypedValue; default;
688
+ end;
689
+
690
+ TJSInt16Array = class external name 'Int16Array' (TJSTypedArray)
691
+ private
692
+ function getTypedValue(Index : NativeInt): smallint; external name '[]';
693
+ procedure setTypedValue(Index : NativeInt; AValue: Smallint);external name '[]';
694
+ public
695
+ constructor new (length : NativeInt);
696
+ constructor new (atypedArray : TJSTypedArray);
697
+ constructor new (aArray : TJSValueDynArray);
698
+ constructor new (aArray : TJSArray);
699
+ constructor new (aObject : TJSObject);
700
+ constructor new (buffer : TJSAbstractArrayBuffer);
701
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
702
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
703
+ class function from(aValue : jsValue) : TJSInt16Array; reintroduce;
704
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt16Array; reintroduce;overload;
705
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt16Array; reintroduce;overload;
706
+ class function _of(aValue : jsValue) : TJSInt16Array; varargs; external name 'of'; reintroduce;overload;
707
+ procedure _set(anArray : Array of SmallInt); external name 'set'; reintroduce;overload;
708
+ procedure _set(anArray : Array of SmallInt; anOffset : NativeInt); external name 'set';overload;
709
+ function subarray(aBegin, aEnd: Integer): TJSInt16Array; overload;
710
+ function subarray(aBegin: Integer): TJSInt16Array; overload;
711
+ Property values[Index : NativeInt] : SmallInt Read getTypedValue Write setTypedValue; default;
712
+ end;
713
+
714
+ TJSUint16Array = class external name 'Uint16Array' (TJSTypedArray)
715
+ private
716
+ function getTypedValue(Index : NativeInt): Word; external name '[]';
717
+ procedure setTypedValue(Index : NativeInt; AValue: Word);external name '[]';
718
+ public
719
+ constructor new (length : NativeInt);
720
+ constructor new (atypedArray : TJSTypedArray);
721
+ constructor new (aArray : TJSValueDynArray);
722
+ constructor new (aArray : TJSArray);
723
+ constructor new (aObject : TJSObject);
724
+ constructor new (buffer : TJSAbstractArrayBuffer);
725
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
726
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
727
+ class function from(aValue : jsValue) : TJSUInt16Array; reintroduce;
728
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt16Array; reintroduce;
729
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt16Array; reintroduce;
730
+ class function _of(aValue : jsValue) : TJSUInt16Array; varargs; external name 'of'; reintroduce;
731
+ procedure _set(anArray : Array of Word); external name 'set'; reintroduce; overload;
732
+ procedure _set(anArray : Array of Word; anOffset : NativeInt); external name 'set'; overload;
733
+ function subarray(aBegin, aEnd: Integer): TJSUInt16Array; overload;
734
+ function subarray(aBegin: Integer): TJSUInt16Array; overload;
735
+ Property values[Index : NativeInt] : Word Read getTypedValue Write setTypedValue; default;
736
+ end;
737
+
738
+ TJSInt32Array = class external name 'Int32Array' (TJSTypedArray)
739
+ private
740
+ function getTypedValue(Index : NativeInt): longint; external name '[]';
741
+ procedure setTypedValue(Index : NativeInt; AValue: longint);external name '[]';
742
+ public
743
+ constructor new (length : NativeInt);
744
+ constructor new (atypedArray : TJSTypedArray);
745
+ constructor new (aArray : TJSValueDynArray);
746
+ constructor new (aArray : TJSArray);
747
+ constructor new (aObject : TJSObject);
748
+ constructor new (buffer : TJSAbstractArrayBuffer);
749
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
750
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
751
+ class function from(aValue : jsValue) : TJSInt32Array; reintroduce;
752
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSInt32Array; reintroduce;
753
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSInt32Array; reintroduce;
754
+ class function _of(aValue : jsValue) : TJSInt32Array; varargs;external name 'of'; reintroduce;
755
+ procedure _set(anArray : Array of LongInt); external name 'set'; reintroduce; overload;
756
+ procedure _set(anArray : Array of LongInt; anOffset : NativeInt); external name 'set'; overload;
757
+ function subarray(aBegin, aEnd: Integer): TJSInt32Array; overload;
758
+ function subarray(aBegin: Integer): TJSInt32Array; overload;
759
+ Property values[Index : NativeInt] : longint Read getTypedValue Write setTypedValue; default;
760
+ end;
761
+
762
+ TJSUint32Array = class external name 'Uint32Array' (TJSTypedArray)
763
+ private
764
+ function getTypedValue(Index : NativeInt): LongWord; external name '[]';
765
+ procedure setTypedValue(Index : NativeInt; AValue: LongWord);external name '[]';
766
+ public
767
+ constructor new (length : NativeInt);
768
+ constructor new (atypedArray : TJSTypedArray);
769
+ constructor new (aArray : TJSValueDynArray);
770
+ constructor new (aArray : TJSArray);
771
+ constructor new (aObject : TJSObject);
772
+ constructor new (buffer : TJSAbstractArrayBuffer);
773
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
774
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
775
+ class function from(aValue : jsValue) : TJSUInt32Array; reintroduce;
776
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSUInt32Array; reintroduce;
777
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSUInt32Array; reintroduce;
778
+ class function _of(aValue : jsValue) : TJSUInt32Array; varargs; external name 'of'; reintroduce;
779
+ procedure _set(anArray : Array of Cardinal); external name 'set'; reintroduce; overload;
780
+ procedure _set(anArray : Array of Cardinal; anOffset : NativeInt); external name 'set'; overload;
781
+ function subarray(aBegin, aEnd: Integer): TJSUInt32Array; overload;
782
+ function subarray(aBegin: Integer): TJSUInt32Array; overload;
783
+ Property values[Index : NativeInt] : LongWord Read getTypedValue Write setTypedValue; default;
784
+ end;
785
+
786
+ TJSFloat32Array = class external name 'Float32Array' (TJSTypedArray)
787
+ private
788
+ function getTypedValue(Index : NativeInt): Float32; external name '[]';
789
+ procedure setTypedValue(Index : NativeInt; AValue: Float32);external name '[]';
790
+ public
791
+ constructor new (length : NativeInt);
792
+ constructor new (atypedArray : TJSTypedArray);
793
+ constructor new (aArray : TJSValueDynArray);
794
+ constructor new (aArray : TJSArray);
795
+ constructor new (aObject : TJSObject);
796
+ constructor new (buffer : TJSAbstractArrayBuffer);
797
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
798
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
799
+ class function from(aValue : jsValue) : TJSFloat32Array; reintroduce;
800
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSFloat32Array; reintroduce;
801
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSFloat32Array; reintroduce;
802
+ class function _of(aValue : jsValue) : TJSFloat32Array; varargs; reintroduce;
803
+ procedure _set(anArray : Array of Double); external name 'set'; reintroduce; overload;
804
+ procedure _set(anArray : Array of Double; anOffset : NativeInt); external name 'set'; reintroduce; overload;
805
+ function subarray(aBegin, aEnd: Integer): TJSFloat32Array; overload;
806
+ function subarray(aBegin: Integer): TJSFloat32Array; overload;
807
+ Property values[Index : NativeInt] : Float32 Read getTypedValue Write setTypedValue; default;
808
+ end;
809
+
810
+ TJSFloat64Array = class external name 'Float64Array' (TJSTypedArray)
811
+ private
812
+ function getTypedValue(Index : NativeInt): Float64; external name '[]';
813
+ procedure setTypedValue(Index : NativeInt; AValue: Float64);external name '[]';
814
+ public
815
+ constructor new (length : NativeInt);
816
+ constructor new (atypedArray : TJSTypedArray);
817
+ constructor new (aArray : TJSValueDynArray);
818
+ constructor new (aArray : TJSArray);
819
+ constructor new (aObject : TJSObject);
820
+ constructor new (buffer : TJSAbstractArrayBuffer);
821
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset: NativeInt);
822
+ constructor new (buffer : TJSAbstractArrayBuffer; aByteOffset, aElementLength: NativeInt);
823
+ class function from(aValue : jsValue) : TJSFloat64Array; reintroduce;
824
+ class function from(aValue : jsValue; Map : TJSTypedArrayMapCallBack) : TJSFloat64Array; reintroduce;
825
+ // class function from(aValue : jsValue; aMap : TJSTypedArrayMapEvent) : TJSFloat64Array; reintroduce;
826
+ class function _of(aValue : jsValue) : TJSFloat64Array; varargs; reintroduce;
827
+ procedure _set(anArray : Array of Double); external name 'set'; reintroduce; overload;
828
+ procedure _set(anArray : Array of Double; anOffset : NativeInt); external name 'set'; reintroduce; overload;
829
+ function subarray(aBegin, aEnd: Integer): TJSFloat64Array; overload;
830
+ function subarray(aBegin: Integer): TJSFloat64Array; overload;
831
+ Property values[Index : NativeInt] : Float64 Read getTypedValue Write setTypedValue; default;
832
+ end;
833
+
834
+ { TJSDataView }
835
+
836
+ TJSDataView = Class external name 'DataView' (TJSBufferSource)
837
+ private
838
+ fBuffer : TJSArrayBuffer; external name 'buffer';
839
+ fBufferObj: TJSAbstractArrayBuffer; external name 'buffer';
840
+ fLength : NativeInt; external name 'byteLength';
841
+ fOffset : NativeInt; external name 'byteOffset';
842
+
843
+ public
844
+ constructor new(aBuffer : TJSAbstractArrayBuffer); overload;
845
+ constructor new(aBuffer : TJSAbstractArrayBuffer; aOffset : NativeInt); overload;
846
+ constructor new(aBuffer : TJSAbstractArrayBuffer; aOffset,aByteLength : NativeInt); overload;
847
+ function getFloat32(aByteOffset : NativeInt) : double; overload;
848
+ function getFloat32(aByteOffset : NativeInt; aLittleEndian: Boolean) : double; overload;
849
+ function getFloat64(aByteOffset : NativeInt) : double; overload;
850
+ function getFloat64(aByteOffset : NativeInt; aLittleEndian: Boolean) : double; overload;
851
+ function getInt8(aByteOffset : NativeInt) : ShortInt;
852
+ function getInt16(aByteOffset : NativeInt) : SmallInt; overload;
853
+ function getInt16(aByteOffset : NativeInt; aLittleEndian : Boolean) : SmallInt; overload;
854
+ function getInt32(aByteOffset : NativeInt) : Longint; overload;
855
+ function getInt32(aByteOffset : NativeInt; aLittleEndian : Boolean) : Longint; overload;
856
+ function getUint8(aByteOffset : NativeInt) : Byte; overload;
857
+ function getUint16(aByteOffset : NativeInt) : Word; overload;
858
+ function getUint16(aByteOffset : NativeInt; aLittleEndian : Boolean) : Word; overload;
859
+ function getUint32(aByteOffset : NativeInt) : LongWord; overload;
860
+ function getUint32(aByteOffset : NativeInt; aLittleEndian : Boolean) : LongWord; overload;
861
+ function getBigInt64(aByteOffset : NativeInt) : TJSBigInt; overload;
862
+ function getBigInt64(aByteOffset : NativeInt; aLittleEndian : Boolean) : TJSBigInt; overload;
863
+ function getBigUInt64(aByteOffset : NativeInt) : TJSBigInt; overload;
864
+ function getBigUInt64(aByteOffset : NativeInt; aLittleEndian : Boolean) : TJSBigInt; overload;
865
+
866
+ procedure setFloat32(aByteOffset : NativeInt; aValue : double); overload;
867
+ procedure setFloat32(aByteOffset : NativeInt; aValue : double; aLittleEndian: Boolean); overload;
868
+ procedure setFloat64(aByteOffset : NativeInt; aValue : double); overload;
869
+ procedure setFloat64(aByteOffset : NativeInt; aValue : double; aLittleEndian: Boolean); overload;
870
+ procedure setInt8(aByteOffset : NativeInt; aValue : ShortInt);
871
+ procedure setInt16(aByteOffset : NativeInt; aValue : SmallInt); overload;
872
+ procedure setInt16(aByteOffset : NativeInt; aValue : SmallInt; aLittleEndian : Boolean); overload;
873
+ procedure setInt32(aByteOffset : NativeInt; aValue : Longint); overload;
874
+ procedure setInt32(aByteOffset : NativeInt; aValue : Longint; aLittleEndian : Boolean); overload;
875
+ procedure setUint8(aByteOffset : NativeInt; aValue : Byte); overload;
876
+ procedure setUint16(aByteOffset : NativeInt; aValue : Word); overload;
877
+ procedure setUint16(aByteOffset : NativeInt; aValue : Word; aLittleEndian : Boolean); overload;
878
+ procedure setUint32(aByteOffset : NativeInt; aValue : LongWord); overload;
879
+ procedure setUint32(aByteOffset : NativeInt; aValue: LongWord; aLittleEndian : Boolean); overload;
880
+ procedure setBigInt64(aByteOffset : NativeInt; aValue : TJSBigInt); overload;
881
+ procedure setBigInt64(aByteOffset : NativeInt; aValue: TJSBigInt;aLittleEndian : Boolean) overload;
882
+ procedure setBigUInt64(aByteOffset : NativeInt; aValue : TJSBigInt); overload;
883
+ procedure setBigUInt64(aByteOffset : NativeInt; aValue : TJSBigInt; aLittleEndian : Boolean) ; overload;
884
+ Property byteLength : NativeInt Read fLength;
885
+ Property byteOffset : NativeInt read fOffset;
886
+ property buffer : TJSArrayBuffer Read fBuffer;
887
+ property bufferObj : TJSAbstractArrayBuffer Read fBufferObj;
888
+ end;
889
+
890
+ TJSJSON = class external name 'JSON' (TJSObject)
891
+ Public
892
+ class function parse(aJSON : String) : JSValue;
893
+ // Use this only when you are sure you will get an object, no checking is done.
894
+ class function parseObject(aJSON : String) : TJSObject; external name 'parse';
895
+ class function stringify(aValue : JSValue) : string;
896
+ class function stringify(aValue,aReplacer : JSValue) : string;
897
+ class function stringify(aValue,aReplacer : JSValue; space: NativeInt) : string;
898
+ class function stringify(aValue,aReplacer : JSValue; space: String) : string;
899
+ end;
900
+
901
+ { TJSError }
902
+
903
+ TJSError = Class external name 'Error' (TJSObject)
904
+ private
905
+ FMessage: String; external name 'message';
906
+ FStack: JSValue; external name 'stack';
907
+ Public
908
+ Constructor new;
909
+ Constructor new(Const aMessage : string);
910
+ Constructor new(Const aMessage,aFileName : string);
911
+ Constructor new(Const aMessage,aFileName : string; aLineNumber : NativeInt);
912
+ Property Message : String Read FMessage;
913
+ Property Stack: JSValue read FStack;
914
+ end;
915
+
916
+ TJSPromise = class;
917
+
918
+ TJSPromiseResolvers = class external name 'Object'
919
+ private
920
+ FPromise: TJSPromise; external name 'promise';
921
+ public
922
+ procedure Resolve; overload; external name 'resolve';
923
+ procedure Resolve(const Value: JSValue); overload; external name 'resolve';
924
+ procedure Reject; overload; external name 'reject';
925
+ procedure Reject(const Value: JSValue); overload; external name 'reject';
926
+
927
+ property Promise: TJSPromise read FPromise;
928
+ end;
929
+
930
+ TJSPromiseResolver = reference to function (aValue : JSValue) : JSValue;
931
+ TJSPromiseExecutor = reference to procedure (resolve,reject : TJSPromiseResolver);
932
+ TJSPromiseFinallyHandler = reference to procedure;
933
+ TJSPromiseArray = array of TJSPromise;
934
+
935
+ TJSPromise = class external name 'Promise'
936
+ public
937
+ constructor new(Executor : TJSPromiseExecutor);
938
+
939
+ class function all(arg : Array of JSValue) : TJSPromise; overload;
940
+ class function all(arg : JSValue) : TJSPromise; overload;
941
+ class function all(arg : TJSPromiseArray) : TJSPromise; overload;
942
+ class function allSettled(arg : Array of JSValue) : TJSPromise; overload;
943
+ class function allSettled(arg : JSValue) : TJSPromise; overload;
944
+ class function allSettled(arg : TJSPromiseArray) : TJSPromise; overload;
945
+ class function race(arg : Array of JSValue) : TJSPromise; overload;
946
+ class function race(arg : JSValue) : TJSPromise; overload;
947
+ class function race(arg : TJSPromiseArray) : TJSPromise; overload;
948
+ class function reject(reason : JSValue) : TJSPromise;
949
+ class function resolve(value : JSValue): TJSPromise; overload;
950
+ class function resolve : TJSPromise; overload;
951
+ class function withResolvers: TJSPromiseResolvers;
952
+ function _then (onAccepted : TJSPromiseResolver) : TJSPromise; external name 'then';
953
+ function _then (onAccepted,OnRejected: TJSPromiseResolver) : TJSPromise; external name 'then';
954
+ function catch (onRejected : TJSPromiseResolver) : TJSPromise;
955
+ function _finally(value : TJSPromiseFinallyHandler): TJSPromise; external name 'finally';
956
+ end;
957
+
958
+ generic TGPromise<T> = class external name 'Promise'
959
+ Type
960
+ TResolve = reference to function (aValue : T) : JSValue;
961
+ TReject = reference to function (aValue : JSValue) : JSValue;
962
+ TExecute = reference to procedure (resolve: TResolve; reject : TReject);
963
+ TFinallyHandler = reference to procedure;
964
+ Public
965
+ constructor new(Executor : TExecute);
966
+ function then_ (onAccepted : TResolve) : TJSPromise; external name 'then';
967
+ function then_ (onAccepted : TResolve; onRejected : TReject) : TJSPromise; external name 'then';
968
+ function finally_(value : TFinallyHandler): TJSPromise; external name 'finally';
969
+ function catch (onRejected : TReject) : TJSPromise;
970
+ end;
971
+
972
+ generic TGPromiseEx<T,E> = class external name 'Promise'
973
+ Type
974
+ TResolve = reference to function (aValue : T) : JSValue;
975
+ TReject = reference to function (aValue : E) : JSValue;
976
+ TExecute = reference to procedure (resolve: TResolve; reject : TReject);
977
+ TFinallyHandler = reference to procedure;
978
+ Public
979
+ constructor new(Executor : TExecute);
980
+ function then_ (onAccepted : TResolve) : TJSPromise; external name 'then';
981
+ function then_ (onAccepted : TResolve; onRejected : TReject) : TJSPromise; external name 'then';
982
+ function catch (onRejected : TReject) : TJSPromise;
983
+ function finally_(value : TFinallyHandler): TJSPromise; external name 'finally';
984
+ end;
985
+
986
+ TJSFunctionArguments = class external name 'arguments'
987
+ private
988
+ FLength: NativeInt; external name 'length';
989
+ function GetElements(Index: NativeInt): JSValue; external name '[]';
990
+ procedure SetElements(Index: NativeInt; const AValue: JSValue); external name '[]';
991
+ public
992
+ property Length: NativeInt read FLength;
993
+ property Elements[Index: NativeInt]: JSValue read GetElements write SetElements; default;
994
+ end;
995
+
996
+ TJSIteratorResult = Class external name 'IteratorResult' (TJSObject)
997
+ Private
998
+ fDone : Boolean; external name 'done';
999
+ fValue : JSValue; external name 'value';
1000
+ Public
1001
+ property done : boolean Read FDone;
1002
+ property value : JSValue read FValue;
1003
+ end;
1004
+
1005
+ TJSAsyncIterator = Class external name 'AsyncIterator' (TJSObject)
1006
+ function next: TJSIteratorResult;
1007
+ end;
1008
+
1009
+ TJSSyntaxError = class external name 'SyntaxError' (TJSError);
1010
+
1011
+ TJSTextDecoderOptions = class external name 'Object' (TJSObject)
1012
+ fatal : Boolean;
1013
+ ignoreBOM : Boolean;
1014
+ end;
1015
+
1016
+ TJSTextDecodeOptions = class external name 'Object' (TJSObject)
1017
+ stream : Boolean;
1018
+ end;
1019
+
1020
+ TJSTextDecoder = class external name 'TextDecoder' (TJSObject)
1021
+ Private
1022
+ FEncoding : String; external name 'encoding';
1023
+ FFatal : Boolean; external name 'fatal';
1024
+ FIgnoreBOM : Boolean; external name 'ignoreBOM';
1025
+ Public
1026
+ Constructor New(utfLabel : String); overload;
1027
+ Constructor New(utfLabel : String; Options : TJSTextDecoderOptions); overload;
1028
+ Function decode(arr : TJSTypedArray) : String; overload;
1029
+ Function decode(arr : TJSArrayBuffer) : String; overload;
1030
+ Function decode(arr : TJSTypedArray; opts : TJSTextDecodeOptions) : String; overload;
1031
+ Function decode(arr : TJSArrayBuffer; opts : TJSTextDecodeOptions) : String; overload;
1032
+ property Encoding : string Read FEncoding;
1033
+ Property Fatal : Boolean Read FFatal;
1034
+ Property IgnoreBOM : Boolean Read FIgnoreBOM;
1035
+ end;
1036
+
1037
+ TJSTextEncoderEncodeIntoResult = class external name 'Object' (TJSObject)
1038
+ read : Nativeint;
1039
+ written : NativeInt;
1040
+ end;
1041
+
1042
+ TJSTextEncoder = class external name 'TextEncoder' (TJSObject)
1043
+ Private
1044
+ FEncoding : String; external name 'encoding';
1045
+ Public
1046
+ Constructor New;
1047
+ function encode(aString : String) : TJSUInt8Array;
1048
+ Function encodeInto(aString : String; aArray : TJSUInt8Array) : TJSTextEncoderEncodeIntoResult;
1049
+ Property Encoding : string Read FEncoding;
1050
+ end;
1051
+
1052
+ generic TGGenerator<T> = class external name 'Generator' (TJSObject)
1053
+ public type
1054
+ TGGeneratorValue = class external name 'Generator' (TJSObject)
1055
+ public
1056
+ done: Boolean;
1057
+ value: T;
1058
+ end;
1059
+ public
1060
+ function next: TGGeneratorValue; overload;
1061
+ function next(Value: T): TGGeneratorValue; overload;
1062
+ function return: TGGeneratorValue; overload;
1063
+ function return(Value: T): TGGeneratorValue; overload;
1064
+ function throw(Error: TJSError): TGGeneratorValue;
1065
+ end;
1066
+
1067
+ TJSGenerator = specialize TGGenerator<JSValue>;
1068
+
1069
+ TJSProxy = class external name 'Proxy' (TJSObject)
1070
+ public
1071
+ constructor New(Target, Handler: TJSObject);
1072
+ end;
1073
+
1074
+ TJSNumber = class external name 'Number' (TJSFunction)
1075
+ private
1076
+ class var FEPSILON: Double; external name 'EPSILON';
1077
+ class var {%H-}FMAX_SAFE_INTEGER: NativeInt; external name 'MAX_SAFE_INTEGER';
1078
+ class var FMAX_VALUE: Double; external name 'MAX_VALUE';
1079
+ class var {%H-}FMIN_SAFE_INTEGER: NativeInt; external name 'MIN_SAFE_INTEGER';
1080
+ class var FMIN_VALUE: Double; external name 'MIN_VALUE';
1081
+ class var FNaN: Double; external name 'NaN';
1082
+ class var FNEGATIVE_INFINITY: TJSNumber; external name 'NEGATIVE_INFINITY';
1083
+ class var FPOSITIVE_INFINITY: TJSNumber; external name 'POSITIVE_INFINITY';
1084
+ public
1085
+ constructor New(const value: Double);
1086
+
1087
+ class function isFinite(const value: Double): Boolean; overload;
1088
+ class function isFinite(const value: Integer): Boolean; overload;
1089
+ class function isFinite(const value: TJSNumber): Boolean; overload;
1090
+ class function isInteger(const value: Double): Boolean; overload;
1091
+ class function isInteger(const value: Integer): Boolean; overload;
1092
+ class function isInteger(const value: TJSNumber): Boolean; overload;
1093
+ class function isNaN(const value: Double): Boolean; overload;
1094
+ class function isNaN(const value: Integer): Boolean; overload;
1095
+ class function isNaN(const value: TJSNumber): Boolean; overload;
1096
+ class function isSafeInteger(const value: Double): Boolean; overload;
1097
+ class function isSafeInteger(const value: Integer): Boolean; overload;
1098
+ class function isSafeInteger(const value: TJSNumber): Boolean; overload;
1099
+ class function parseFloat(const value: String): TJSNumber; overload;
1100
+ class function parseInt(const value: String): TJSNumber; overload;
1101
+
1102
+ function toExponential: TJSString; overload;
1103
+ function toExponential(const fractionDigits: Integer): TJSString; overload;
1104
+ function toFixed: TJSString; overload;
1105
+ function toFixed(const digits: Integer): TJSString; overload;
1106
+ function toLocaleString: TJSString; overload;
1107
+ function toLocaleString(const locale: String): TJSString; overload;
1108
+ function toPrecision: TJSString; overload;
1109
+ function toPrecision(const precision: Integer): TJSString; overload;
1110
+ function toString: TJSString; overload;
1111
+ function toString(const radix: Integer): TJSString; overload;
1112
+ function valueOf: Double; reintroduce;
1113
+
1114
+ class property EPSILON: Double read FEPSILON;
1115
+ class property MAX_SAFE_INTEGER{%H-}: NativeInt read FMAX_SAFE_INTEGER;
1116
+ class property MAX_VALUE: Double read FMAX_VALUE;
1117
+ class property MIN_SAFE_INTEGER{%H-}: NativeInt read FMIN_SAFE_INTEGER;
1118
+ class property MIN_VALUE: Double read FMIN_VALUE;
1119
+ class property NaN: Double read FNaN;
1120
+ class property NEGATIVE_INFINITY: TJSNumber read FNEGATIVE_INFINITY;
1121
+ class property POSITIVE_INFINITY: TJSNumber read FPOSITIVE_INFINITY;
1122
+ end;
1123
+
1124
+ TJSBigInt = class external name 'BigInt' (TJSObject)
1125
+ class function asIntN(Size : Integer;aValue : TJSBigInt) : NativeInt;
1126
+ class function asUIntN(Size : Integer;aValue : TJSBigInt) : NativeInt;
1127
+ end;
1128
+
1129
+ { TJSBigIntHelper }
1130
+
1131
+ TJSBigIntHelper = type helper for TJSBigint
1132
+ class function new(aValue : JSValue) : TJSBigInt; overload; static;
1133
+ end;
1134
+
1135
+ { TJSAtomicWaitResult }
1136
+
1137
+ TJSAtomicWaitResult = class external name 'Object' (TJSObject)
1138
+ private
1139
+ FAsync: boolean; external name 'async';
1140
+ FValue: JSValue; external name 'value';
1141
+ FValueAsPromise: TJSPromise; external name 'value';
1142
+ FValueAsString: String; external name 'value';
1143
+ Public
1144
+ property async : boolean Read FAsync;
1145
+ property value : JSValue Read FValue;
1146
+ property valueAsPromise : TJSPromise Read FValueAsPromise;
1147
+ property valueAsString : String Read FValueAsString;
1148
+ end;
1149
+
1150
+ TJSAtomics = class external name 'Atomics' (TJSObject)
1151
+ class function add(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer;
1152
+ class function and_(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer; external name 'and';
1153
+ class function compareExchange(aTypedArray : TJSTypedArray; index: integer; ExpectedValue, ReplacementValue : Integer) : integer;
1154
+ class function exchange(aTypedArray : TJSTypedArray; index: integer; ReplacementValue : Integer) : integer;
1155
+ class function isLockFree(size : integer) : integer;
1156
+ class function load(aTypedArray : TJSTypedArray; Index : integer) : integer;
1157
+ class function notify(aTypedArray : TJSTypedArray; Index : integer; count : integer) : integer;
1158
+ class function notify(aTypedArray : TJSTypedArray; Index : integer) : integer;
1159
+ class function or_(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer; external name 'or';
1160
+ class function store(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer;
1161
+ class function sub(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer;
1162
+ class function wait(aTypedArray : TJSTypedArray; index: integer; value : Integer) : string;
1163
+ class function wait(aTypedArray : TJSTypedArray; index: integer; value : Integer; TimeOut : integer) : string;
1164
+ class function waitAsync(aTypedArray : TJSTypedArray; index: integer; value : Integer) : TJSAtomicWaitResult;
1165
+ class function waitAsync(aTypedArray : TJSTypedArray; index: integer; value : Integer; TimeOut : integer) : TJSAtomicWaitResult;
1166
+
1167
+ class function xor_(aTypedArray : TJSTypedArray; index: integer; value : Integer) : integer; external name 'xor';
1168
+ end;
1169
+
1170
+ TJSLocalesOfOptions = class external name 'Object' (TJSObject)
1171
+ public
1172
+ localeMatcher : string;
1173
+ end;
1174
+
1175
+ TJSFormatRangePart = class external name 'Object' (TJSObject)
1176
+ private
1177
+ FType : string; external name 'type';
1178
+ FValue : string; external name 'value';
1179
+ FSource : string; external name 'source';
1180
+ Public
1181
+ property type_ : string read FType;
1182
+ property value : string read FValue;
1183
+ property source : string read FSource;
1184
+ end;
1185
+ TJSFormatRangePartArray = array of TJSFormatRangePart;
1186
+
1187
+ TJSFormatDatePart = class external name 'Object' (TJSObject)
1188
+ private
1189
+ FType : string; external name 'type';
1190
+ FValue : string; external name 'value';
1191
+ Public
1192
+ property type_ : string read FType;
1193
+ property value : string read FValue;
1194
+ end;
1195
+ TJSFormatDatePartArray = array of TJSFormatDatePart;
1196
+
1197
+ { TJSDateTimeResolvedOptions }
1198
+
1199
+ TJSDateTimeResolvedOptions = class external name 'Object' (TJSObject)
1200
+ private
1201
+ FCalendar: string; external name 'calendar';
1202
+ FDateStyle: String; external name 'dateStyle';
1203
+ FDay: string; external name 'day';
1204
+ FDayPeriod: string; external name 'dayPeriod';
1205
+ FEra: string; external name 'era';
1206
+ FfractionalSecondDigits: Integer; external name 'fractionalSecondDigits';
1207
+ FHour: string; external name 'hour';
1208
+ FHour12: string; external name 'hour12';
1209
+ FHourCycle: string; external name 'hourCycle';
1210
+ FLocale: string; external name 'locale';
1211
+ FMinute: string; external name 'minute';
1212
+ FMonth: string; external name 'month';
1213
+ FNumberingSystem: string; external name 'numberingSystem';
1214
+ FSecond: string; external name 'second';
1215
+ FTimeStyle: string; external name 'timeStyle';
1216
+ FTimeZone: string; external name 'timeZone';
1217
+ FtimeZoneName: string; external name 'timeZoneName';
1218
+ FWeekday: string; external name 'weekday';
1219
+ FYear: string; external name 'year';
1220
+ Public
1221
+ property locale : string read FLocale;
1222
+ property calendar : string read FCalendar;
1223
+ property numberingSystem : string read FNumberingSystem;
1224
+ property timeZone : string read FTimeZone;
1225
+ property hourCycle : string read FHourCycle;
1226
+ property hour12 : string read FHour12;
1227
+ property weekday : string read FWeekday;
1228
+ property era : string read FEra;
1229
+ property year : string read FYear;
1230
+ property month : string read FMonth;
1231
+ property day : string read FDay;
1232
+ property hour : string read FHour;
1233
+ property dayPeriod : string read FDayPeriod;
1234
+ property minute : string Read FMinute;
1235
+ property second : string read FSecond;
1236
+ property fractionalSecondDigits : Integer read FfractionalSecondDigits;
1237
+ property timeZoneName : string read FtimeZoneName;
1238
+ property dateStyle : String Read FDateStyle;
1239
+ property timeStyle : string read FTimeStyle;
1240
+ end;
1241
+
1242
+ TJSDateLocaleOptions = class external name 'Object' (TJSObject)
1243
+ Public
1244
+ localeMatcher : string;
1245
+ locale : string;
1246
+ calendar : string;
1247
+ numberingSystem : string;
1248
+ timeZone : string;
1249
+ hourCycle : string;
1250
+ hour12 : boolean;
1251
+ weekday : string;
1252
+ era : string;
1253
+ year : string;
1254
+ month : string;
1255
+ day : string;
1256
+ hour : string;
1257
+ dayPeriod : string;
1258
+ minute : string;
1259
+ second : string;
1260
+ fractionalSecondDigits : Integer;
1261
+ timeZoneName : string;
1262
+ dateStyle : String;
1263
+ timeStyle : string;
1264
+ end;
1265
+
1266
+ TJSIntlDateTimeFormat = class external name 'Intl.DateTimeFormat' (TJSObject)
1267
+ Public
1268
+ constructor new ();
1269
+ constructor new (locales : string);
1270
+ constructor new (locales : string; Options : TJSDateLocaleOptions);
1271
+ constructor new (locales : Array of string);
1272
+ constructor new (locales : array of string; Options : TJSDateLocaleOptions);
1273
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1274
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1275
+ function format(aDate : TJSDate) : string;
1276
+ function formatRange(aStartDate, aEndDate : TJSDate) : string;
1277
+ function formatRangeToParts(aStartDate, aEndDate : TJSDate) : TJSFormatRangePartArray;
1278
+ function formatToParts(aDate : TJSDate) : TJSFormatDatePartArray;
1279
+ function resolvedOptions : TJSDateTimeResolvedOptions;
1280
+ end;
1281
+
1282
+ { TJSDisplayNamesOptions }
1283
+
1284
+ TJSDisplayNamesOptions = class external name 'Object' (TJSObject)
1285
+ Public
1286
+ locale : string ;
1287
+ style : string ;
1288
+ type_ : string ; external name 'type';
1289
+ fallback : string ;
1290
+ languageDisplay : string ;
1291
+ end;
1292
+
1293
+ TJSIntlDisplayNamesResolvedOptions = class external name 'Object' (TJSObject)
1294
+ private
1295
+ FFallback: string; external name 'fallback';
1296
+ FLanguageDisplay: string; external name 'languageDisplay';
1297
+ FLocale: string; external name 'locale';
1298
+ FStyle: string; external name 'style';
1299
+ FType: string; external name 'type';
1300
+ Public
1301
+ property locale : string read FLocale;
1302
+ property style : string read FStyle;
1303
+ property type_ : string read FType;
1304
+ property fallback : string read FFallback;
1305
+ property languageDisplay : string read FLanguageDisplay;
1306
+ end;
1307
+
1308
+ TJSIntlDisplayNames = class external name 'Intl.DisplayNames' (TJSObject)
1309
+ Public
1310
+ constructor new (locales : string; Options : TJSDisplayNamesOptions);
1311
+ class function supportedLocalesOf(locales : string) : TStringDynArray;
1312
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TStringDynArray;
1313
+ function of_ : string; external name 'of';
1314
+ function resolvedOptions : TJSIntlDisplayNamesResolvedOptions;
1315
+ end;
1316
+
1317
+ TJSDurationLocaleOptions = class external name 'Object' (TJSObject)
1318
+ Public
1319
+ localeMatcher : string;
1320
+ style : string;
1321
+ numberingSystem : string;
1322
+ timeZone : string;
1323
+ years : string;
1324
+ yearsDisplay : string;
1325
+ months : string;
1326
+ monthsDisplay : string;
1327
+ weeks : string;
1328
+ weeksDisplay : string;
1329
+ days : string;
1330
+ daysDisplay : string;
1331
+ hours : string;
1332
+ hoursDisplay : string;
1333
+ minutes : string;
1334
+ minutesDisplay : string;
1335
+ seconds : string;
1336
+ secondsDisplay : string;
1337
+ milliseconds : string;
1338
+ millisecondsDisplay : string;
1339
+ microseconds : string;
1340
+ microsecondsDisplay : string;
1341
+ nanoseconds : string;
1342
+ nanosecondsDisplay : string;
1343
+ fractionalDigits : byte;
1344
+ end;
1345
+
1346
+ TJSFormatDurationPart = class external name 'Object' (TJSObject)
1347
+ private
1348
+ FType : string; external name 'string';
1349
+ FValue : string; external name 'value';
1350
+ FUnits : string; external name 'units';
1351
+ Public
1352
+ property type_ : string read FType;
1353
+ property value : string read FValue;
1354
+ property units : string read FUnits;
1355
+ end;
1356
+ TJSFormatDurationPartArray = array of TJSFormatDurationPart;
1357
+
1358
+ { TJSDurationResolvedOptions }
1359
+
1360
+ TJSDurationResolvedOptions = class external name 'Object' (TJSObject)
1361
+ private
1362
+ Fdays : string; external name 'days';
1363
+ FdaysDisplay : string; external name 'daysDisplay';
1364
+ FfractionalDigits : byte; external name 'fractionalDigits';
1365
+ Fhours : string; external name 'hours';
1366
+ FhoursDisplay : string; external name 'hoursDisplay';
1367
+ FlocaleMatcher : string; external name 'localeMatcher';
1368
+ Fmicroseconds : string; external name 'microseconds';
1369
+ FmicrosecondsDisplay : string; external name 'microsecondsDisplay';
1370
+ Fmilliseconds : string; external name 'milliseconds';
1371
+ FmillisecondsDisplay : string; external name 'millisecondsDisplay';
1372
+ Fminutes : string; external name 'minutes';
1373
+ FminutesDisplay : string; external name 'minutesDisplay';
1374
+ Fmonths : string; external name 'months';
1375
+ FmonthsDisplay : string; external name 'monthsDisplay';
1376
+ Fnanoseconds : string; external name 'nanoseconds';
1377
+ FnanosecondsDisplay : string; external name 'nanosecondsDisplay';
1378
+ FnumberingSystem : string; external name 'numberingSystem';
1379
+ Fseconds : string; external name 'seconds';
1380
+ FsecondsDisplay : string; external name 'secondsDisplay';
1381
+ Fstyle : string; external name 'style';
1382
+ FtimeZone : string; external name 'timeZone';
1383
+ Fweeks : string; external name 'weeks';
1384
+ FweeksDisplay : string; external name 'weeksDisplay';
1385
+ Fyears : string; external name 'years';
1386
+ FyearsDisplay : string; external name 'yearsDisplay';
1387
+ Public
1388
+ property localeMatcher : string read FlocaleMatcher;
1389
+ property style : string read Fstyle;
1390
+ property numberingSystem : string read FnumberingSystem;
1391
+ property timeZone : string read FtimeZone;
1392
+ property years : string read Fyears;
1393
+ property yearsDisplay : string read FyearsDisplay;
1394
+ property months : string read Fmonths;
1395
+ property monthsDisplay : string read FmonthsDisplay;
1396
+ property weeks : string read Fweeks;
1397
+ property weeksDisplay : string read FweeksDisplay;
1398
+ property days : string read Fdays;
1399
+ property daysDisplay : string read FdaysDisplay;
1400
+ property hours : string read Fhours;
1401
+ property hoursDisplay : string read FhoursDisplay;
1402
+ property minutes : string read Fminutes;
1403
+ property minutesDisplay : string read FminutesDisplay;
1404
+ property seconds : string read Fseconds;
1405
+ property secondsDisplay : string read FsecondsDisplay;
1406
+ property milliseconds : string read Fmilliseconds;
1407
+ property millisecondsDisplay : string read FmillisecondsDisplay;
1408
+ property microseconds : string read Fmicroseconds;
1409
+ property microsecondsDisplay : string read FmicrosecondsDisplay;
1410
+ property nanoseconds : string read Fnanoseconds;
1411
+ property nanosecondsDisplay : string read FnanosecondsDisplay;
1412
+ property fractionalDigits : byte read FfractionalDigits;
1413
+ end;
1414
+
1415
+ TJSDuration = class external name 'Object' (TJSObject)
1416
+ Public
1417
+ years : integer;
1418
+ months : integer;
1419
+ weeks : integer;
1420
+ days : integer;
1421
+ hours : integer;
1422
+ minutes : integer;
1423
+ seconds : integer;
1424
+ milliseconds : integer;
1425
+ microseconds : integer;
1426
+ nanoseconds : integer;
1427
+ end;
1428
+
1429
+ TJSIntlDurationFormat = class external name 'Intl.DurationFormat' (TJSObject)
1430
+ Public
1431
+ constructor new ();
1432
+ constructor new (locales : string);
1433
+ constructor new (locales : string; Options : TJSDurationLocaleOptions);
1434
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1435
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1436
+ function format(duration : TJSDuration) : String;
1437
+ function formatToParts(duration : TJSDuration) : TJSFormatDurationPartArray;
1438
+ function resolvedOptions : TJSDurationResolvedOptions;
1439
+ end;
1440
+
1441
+ TJSListFormatOptions = class external name 'Object' (TJSObject)
1442
+ localeMatcher : string;
1443
+ type_ : string; external name 'type';
1444
+ style : string; external name 'style';
1445
+ end;
1446
+
1447
+ TJSListFormatResolvedOptions = class external name 'Object' (TJSObject)
1448
+ Private
1449
+ FlocaleMatcher : string; external name 'localeMatched';
1450
+ Ftype : string; external name 'type';
1451
+ Fstyle : string; external name 'style';
1452
+ Public
1453
+ property localeMatcher : string read FlocaleMatcher;
1454
+ property type_ : string read FType;
1455
+ property style : string read FStyle;
1456
+ end;
1457
+
1458
+ TJSFormatListPart = class external name 'Object' (TJSObject)
1459
+ Public
1460
+ type_ : string; external name 'type';
1461
+ value : string;
1462
+ end;
1463
+ TJSFormatListPartArray = Array of TJSFormatListPart;
1464
+
1465
+ TJSIntlListFormat = class external name 'Intl.ListFormat' (TJSObject)
1466
+ Public
1467
+ constructor new ();
1468
+ constructor new (locales : string);
1469
+ constructor new (locales : string; Options : TJSListFormatOptions);
1470
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1471
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1472
+ function format(aList : Array of string) : String;
1473
+ function formatToParts(aList : array of string) : TJSFormatListPartArray;
1474
+ function resolvedOptions : TJSListFormatResolvedOptions;
1475
+ end;
1476
+
1477
+ TJSIntlLocaleOptions = class external name 'Object' (TJSObject)
1478
+ public
1479
+ language : string;
1480
+ script : string;
1481
+ region : string;
1482
+ calendar : string;
1483
+ collation : string;
1484
+ numberingSystem : string;
1485
+ caseFirst : string;
1486
+ hourCycle : string;
1487
+ numeric : boolean;
1488
+ end;
1489
+
1490
+ { TJSIntlTextInfo }
1491
+
1492
+ TJSIntlTextInfo = class external name 'Object' (TJSObject)
1493
+ private
1494
+ FDirection: string; external name 'direction';
1495
+ Public
1496
+ property direction : string read FDirection;
1497
+ end;
1498
+
1499
+ { TJSIntlWeekInfo }
1500
+
1501
+ TJSIntlWeekInfo = class external name 'Object' (TJSObject)
1502
+ private
1503
+ FFirstDay: integer; external name 'firstDay';
1504
+ FMInimalDays: Integer; external name 'minimalDays';
1505
+ FWeekend: TIntegerDynArray; external name 'weekend';
1506
+ Public
1507
+ property firstDay : integer read FFirstDay;
1508
+ property weekend : TIntegerDynArray read FWeekend;
1509
+ property minimalDays : Integer Read FMInimalDays;
1510
+ end;
1511
+
1512
+ { TJSIntlLocale }
1513
+
1514
+ TJSIntlLocale = class external name 'Intl.Locale' (TJSObject)
1515
+ private
1516
+ FBaseName: string; external name 'baseName';
1517
+ FCalendar: string; external name 'calendar';
1518
+ FCaseFirst: string; external name 'caseFirst';
1519
+ FCollation: string; external name 'collation';
1520
+ FHourCycle: string; external name 'hourCycle';
1521
+ FLanguage: string; external name 'language';
1522
+ FNumberingSystem: string; external name 'numberingSystem';
1523
+ FNumeric: boolean; external name 'numeric';
1524
+ FRegion: string; external name 'region';
1525
+ FScript: string; external name 'script';
1526
+ public
1527
+ constructor new(aLocale : string);
1528
+ constructor new(aLocale : string; Options : TJSIntlLocaleOptions);
1529
+ function getCalendars : TStringDynArray;
1530
+ function getCollations : TStringDynArray;
1531
+ function getHourCycles : TStringDynArray;
1532
+ function getNumberingSystems : TStringDynArray;
1533
+ function getTextInfo : TJSIntlTextInfo;
1534
+ function getTimeZones : TStringDynArray;
1535
+ function getWeekInfo : TJSIntlWeekInfo;
1536
+ function maximize : TJSIntlLocale;
1537
+ function minimize : TJSIntlLocale;
1538
+ property baseName : string read FBaseName;
1539
+ property calendar : string read FCalendar;
1540
+ property caseFirst : string read FCaseFirst;
1541
+ property collation : string read FCollation;
1542
+ property hourCycle : string read FHourCycle;
1543
+ property language : string read FLanguage;
1544
+ property numberingSystem : string read FNumberingSystem;
1545
+ property numeric : boolean Read FNumeric;
1546
+ property region : string read FRegion;
1547
+ property script : string read FScript;
1548
+ end;
1549
+
1550
+ TJSNumberFormatOptions = class external name 'Object' (TJSObject)
1551
+ localeMatcher : string;
1552
+ numberingSystem : string;
1553
+ style : string;
1554
+ currency_ : string; external name 'currency';
1555
+ currencyDisplay : string;
1556
+ currencySign : string;
1557
+ unit_ : string; external name 'unit';
1558
+ unitDisplay : string;
1559
+ minimumIntegerDigits : Byte;
1560
+ minimumFractionDigits : Byte;
1561
+ maximumFractionDigits : Byte;
1562
+ minimumSignificantDigits : Byte;
1563
+ maximumSignificantDigits : Byte;
1564
+ roundingpriority : string;
1565
+ roundingIncrement : word;
1566
+ roundingMode : string;
1567
+ trailingZeroDisplay : string;
1568
+ notation : string;
1569
+ compactDisplay : string;
1570
+ useGrouping : string;
1571
+ signDisplay : string;
1572
+ end;
1573
+
1574
+ TJSNumberFormatResolvedOptions = class external name 'Object' (TJSObject)
1575
+ Private
1576
+ FlocaleMatcher : string; external name 'localeMatcher';
1577
+ FnumberingSystem : string; external name 'numberingSystem';
1578
+ Fstyle : string; external name 'style';
1579
+ Fcurrency_ : string; external name 'currency';
1580
+ FcurrencyDisplay : string; external name 'currencyDisplay';
1581
+ FcurrencySign : string; external name 'currencySign';
1582
+ Funit_ : string; external name 'unit';
1583
+ FunitDisplay : string; external name 'unitDisplay';
1584
+ FminimumIntegerDigits : Byte; external name 'minimumIntegerDigits';
1585
+ FminimumFractionDigits : Byte; external name 'minimumFractionDigits';
1586
+ FmaximumFractionDigits : Byte; external name 'maximumFractionDigits';
1587
+ FminimumSignificantDigits : Byte; external name 'minimumSignificantDigits';
1588
+ FmaximumSignificantDigits : Byte; external name 'maximumSignificantDigits';
1589
+ Froundingpriority : string; external name 'roundingpriority';
1590
+ FroundingIncrement : word; external name 'roundingIncrement';
1591
+ FroundingMode : string; external name 'roundingMode';
1592
+ FtrailingZeroDisplay : string; external name 'trailingZeroDisplay';
1593
+ Fnotation : string; external name 'notation';
1594
+ FcompactDisplay : string; external name 'compactDisplay';
1595
+ FuseGrouping : string; external name 'useGrouping';
1596
+ FsignDisplay : string; external name 'signDisplay';
1597
+ Public
1598
+ property localeMatcher : string read FlocaleMatcher;
1599
+ property numberingSystem : string read FnumberingSystem;
1600
+ property style : string read Fstyle;
1601
+ property currency_ : string read Fcurrency_;
1602
+ property currencyDisplay : string read FcurrencyDisplay;
1603
+ property currencySign : string read FcurrencySign;
1604
+ property unit_ : string read Funit_;
1605
+ property unitDisplay : string read FunitDisplay;
1606
+ property minimumIntegerDigits : Byte read FminimumIntegerDigits;
1607
+ property minimumFractionDigits : Byte read FminimumFractionDigits;
1608
+ property maximumFractionDigits : Byte read FmaximumFractionDigits;
1609
+ property minimumSignificantDigits : Byte read FminimumSignificantDigits;
1610
+ property maximumSignificantDigits : Byte read FmaximumSignificantDigits;
1611
+ property roundingpriority : string read Froundingpriority;
1612
+ property roundingIncrement : word read FroundingIncrement;
1613
+ property roundingMode : string read FroundingMode;
1614
+ property trailingZeroDisplay : string read FtrailingZeroDisplay;
1615
+ property notation : string read Fnotation;
1616
+ property compactDisplay : string read FcompactDisplay;
1617
+ property useGrouping : string read FuseGrouping;
1618
+ property signDisplay : string read FsignDisplay;
1619
+ end;
1620
+
1621
+ { TJSNumberPart }
1622
+
1623
+ TJSIntlNumberPart = class external name 'Object' (TJSObject)
1624
+ private
1625
+ FType: String; external name 'type';
1626
+ FValue: string; external name 'value';
1627
+ Public
1628
+ Property Type_ : String read FType;
1629
+ property Value : string read FValue;
1630
+ end;
1631
+ TJSIntlNumberPartArray = array of TJSIntlNumberPart;
1632
+
1633
+ TJSIntlNumberFormat = class external name 'Intl.NumberFormat' (TJSObject)
1634
+ Public
1635
+ constructor new ();
1636
+ constructor new (locales : string);
1637
+ constructor new (locales : string; Options : TJSNumberFormatOptions);
1638
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1639
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1640
+ function format(aDate : TJSDate) : string;
1641
+ function formatRange(aStart, aEnd: Double) : string;
1642
+ function formatRange(aStart, aEnd: TJSBigint) : string;
1643
+ function formatRange(aStart, aEnd: String) : string;
1644
+ function formatRange(aStart: TJSBigint; aEnd : Double) : string;
1645
+ function formatRange(aStart: Double; aEnd : TJSBigint) : string;
1646
+ function formatRange(aStart: string; aEnd : Double) : string;
1647
+ function formatRange(aStart: Double; aEnd : string) : string;
1648
+ function formatRange(aStart: TJSBigint; aEnd : string) : string;
1649
+ function formatRange(aStart: string; aEnd : TJSBigint) : TJSIntlNumberPartArray;
1650
+ function formatRangeToParts(aStart, aEnd: Double) : TJSIntlNumberPartArray;
1651
+ function formatRangeToParts(aStart, aEnd: TJSBigint) : TJSIntlNumberPartArray;
1652
+ function formatRangeToParts(aStart, aEnd: String) : TJSIntlNumberPartArray;
1653
+ function formatRangeToParts(aStart: TJSBigint; aEnd : Double) : TJSIntlNumberPartArray;
1654
+ function formatRangeToParts(aStart: Double; aEnd : TJSBigint) : TJSIntlNumberPartArray;
1655
+ function formatRangeToParts(aStart: string; aEnd : Double) : TJSIntlNumberPartArray;
1656
+ function formatRangeToParts(aStart: Double; aEnd : string) : TJSIntlNumberPartArray;
1657
+ function formatRangeToParts(aStart: TJSBigint; aEnd : string) : TJSIntlNumberPartArray;
1658
+ function formatRangeToParts(aStart: string; aEnd : TJSBigint) : TJSIntlNumberPartArray;
1659
+ function formatToParts(aValue : Double) : TJSIntlNumberPartArray;
1660
+ function formatToParts(aValue : TJSBigint) : TJSIntlNumberPartArray;
1661
+ function formatToParts(aValue : String) : TJSIntlNumberPartArray;
1662
+ function resolvedOptions : TJSNumberFormatResolvedOptions;
1663
+ end;
1664
+
1665
+ TJSIntlCollatorOptions = class external name 'Object' (TJSObject)
1666
+ Public
1667
+ usage : string;
1668
+ localeMatcher : string;
1669
+ collation : string;
1670
+ numeric : boolean;
1671
+ caseFirst : string;
1672
+ sensitivity : string;
1673
+ ignorePunctuation : boolean;
1674
+ end;
1675
+
1676
+ { TJSIntlCollatorResolvedOptions }
1677
+
1678
+ TJSIntlCollatorResolvedOptions = class external name 'Object' (TJSObject)
1679
+ private
1680
+ FCaseFirst: string; external name 'caseFirst';
1681
+ FCollation: string; external name 'collation';
1682
+ FIgnorePunctuation: boolean; external name 'ignorePunctuation';
1683
+ FLocale: string; external name 'locale';
1684
+ FNumeric: boolean; external name 'numeric';
1685
+ FSensitivity: string; external name 'sensitivity';
1686
+ FUsage: string; external name 'usage';
1687
+ Public
1688
+ Property usage : string read FUsage;
1689
+ Property locale : string read FLocale;
1690
+ Property collation : string read FCollation;
1691
+ Property numeric : boolean read FNumeric;
1692
+ Property caseFirst : string read FCaseFirst;
1693
+ Property sensitivity : string read FSensitivity;
1694
+ Property ignorePunctuation : boolean read FIgnorePunctuation;
1695
+ end;
1696
+
1697
+ TJSIntlCollator = class external name 'Intl.Collator' (TJSObject)
1698
+ constructor new ();
1699
+ constructor new (locales : string);
1700
+ constructor new (locales : string; Options : TJSIntlCollatorOptions);
1701
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1702
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1703
+ function compare (aString1, aString2 : string) : Integer;
1704
+ function resolvedOptions : TJSIntlCollatorResolvedOptions;
1705
+ end;
1706
+
1707
+ TJSIntlPluralRuleOptions = class external name 'Object' (TJSObject)
1708
+ Public
1709
+ localeMatcher : string;
1710
+ type_ : string; external name 'type';
1711
+ minimumIntegerDigits : Byte;
1712
+ minimumFractionDigits : Byte;
1713
+ maximumFractionDigits : Byte;
1714
+ minimumSignificantDigits : Byte;
1715
+ maximumSignificantDigits : Byte;
1716
+ roundingpriority : string;
1717
+ roundingIncrement : word;
1718
+ roundingMode : string;
1719
+ end;
1720
+
1721
+ { TJSIntlPluralRuleResolvedOptions }
1722
+
1723
+ TJSIntlPluralRuleResolvedOptions = class external name 'Object' (TJSObject)
1724
+ private
1725
+ FLocale: string; external name 'locale';
1726
+ FmaximumFractionDigits: Byte; external name 'maximumFractionDigits';
1727
+ FmaximumSignificantDigits: Byte; external name 'maximumSignificantDigits';
1728
+ FminimumFractionDigits: Byte; external name 'minimumFractionDigits';
1729
+ FminimumIntegerDigits: Byte; external name 'minimumIntegerDigits';
1730
+ FminimumSignificantDigits: Byte; external name 'minimumSignificantDigits';
1731
+ FroundingIncrement: word; external name 'roundingIncrement';
1732
+ FroundingMode: string; external name 'roundingMode';
1733
+ Froundingpriority: string; external name 'roundingPriority';
1734
+ FType: string; external name 'type';
1735
+ Public
1736
+ property locale : string read FLocale;
1737
+ property type_ : string read FType;
1738
+ property minimumIntegerDigits : Byte read FminimumIntegerDigits;
1739
+ property minimumFractionDigits : Byte read FminimumFractionDigits;
1740
+ property maximumFractionDigits : Byte read FmaximumFractionDigits;
1741
+ property minimumSignificantDigits : Byte read FminimumSignificantDigits;
1742
+ property maximumSignificantDigits : Byte read FmaximumSignificantDigits;
1743
+ property roundingpriority : string read Froundingpriority;
1744
+ property roundingIncrement : word read FroundingIncrement;
1745
+ property roundingMode : string read FroundingMode;
1746
+ end;
1747
+
1748
+ TJSIntlPluralRules = class external name 'Intl.PluralRules' (TJSObject)
1749
+ constructor new ();
1750
+ constructor new (locales : string);
1751
+ constructor new (locales : string; Options : TJSIntlPluralRuleOptions);
1752
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1753
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1754
+ function select (aValue : Double) : string;
1755
+ function selectRange (aValue1, aValue2: Double) : string;
1756
+ function resolvedOptions : TJSIntlPluralRuleResolvedOptions;
1757
+ end;
1758
+
1759
+ { TJSRelativeTimeParts }
1760
+
1761
+ TJSRelativeTimeParts = class external name 'Object' (TJSObject)
1762
+ private
1763
+ FType: string; external name 'type';
1764
+ FUnits: string; external name 'units';
1765
+ Fvalue: string; external name 'value';
1766
+ Public
1767
+ Property type_ : string read FType;
1768
+ Property value : string read Fvalue;
1769
+ Property units : string read FUnits;
1770
+ end;
1771
+ TJSRelativeTimePartsArray = array of TJSRelativeTimeParts;
1772
+
1773
+ TJSIntlRelativeTimeFormatOptions = class external name 'Object' (TJSObject)
1774
+ localeMatcher : string;
1775
+ numberingSystem :string;
1776
+ style : string;
1777
+ numeric : string;
1778
+ end;
1779
+
1780
+ TJSIntlRelativeTimeFormatResolvedOptions = class external name 'Object' (TJSObject)
1781
+ Private
1782
+ Flocale : string; external name 'locale';
1783
+ FnumberingSystem : string; external name 'numberingSystem';
1784
+ Fstyle : string; external name 'style';
1785
+ Fnumeric : string; external name 'numeric';
1786
+ Public
1787
+ property locale : string read Flocale;
1788
+ property numberingSystem : string read FnumberingSystem;
1789
+ property style : string read Fstyle;
1790
+ property numeric : string read Fnumeric;
1791
+ end;
1792
+
1793
+ TJSIntlRelativeTimeFormat = class external name 'Intl.RelativeTimeFormat' (TJSObject)
1794
+ constructor new ();
1795
+ constructor new (locales : string);
1796
+ constructor new (locales : string; Options : TJSIntlRelativeTimeFormatOptions);
1797
+ class function supportedLocalesOf(locales : string) : TJSStringDynArray;
1798
+ class function supportedLocalesOf(locales : string; Options: TJSLocalesOfOptions) : TJSStringDynArray;
1799
+ function format (aValue : Double; aUnits: string) : string;
1800
+ function formatToParts (aValue : Double; aUnits: string) : TJSRelativeTimePartsArray;
1801
+ function resolvedOptions : TJSIntlRelativeTimeFormatResolvedOptions;
1802
+ end;
1803
+
1804
+ TJSIntl = class external name 'Intl' (TJSObject)
1805
+ Public
1806
+ class function DateTimeFormat() : TJSIntlDateTimeFormat;
1807
+ class function DateTimeFormat(locales : string) : TJSIntlDateTimeFormat;
1808
+ class function DateTimeFormat(locales : string; Options : TJSDateLocaleOptions) : TJSIntlDateTimeFormat;
1809
+ class function UndefinedDateTimeFormat(locales : JSValue; Options : TJSDateLocaleOptions) : TJSIntlDateTimeFormat; external name 'DateTimeFormat';
1810
+ class function UndefinedDateTimeFormat(locales : JSValue) : TJSIntlDateTimeFormat; external name 'DateTimeFormat';
1811
+ class function DisplayNames(locales : string; Options : TJSDisplayNamesOptions) : TJSIntlDisplayNames;
1812
+ class function NumberFormat() : TJSIntlNumberFormat;
1813
+ class function NumberFormat(locales : string) : TJSIntlNumberFormat;
1814
+ class function NumberFormat(locales : string; Options : TJSNumberFormatOptions) : TJSIntlNumberFormat;
1815
+ class function UndefinedNumberFormat(locales : JSValue; Options : TJSNumberFormatOptions) : TJSIntlNumberFormat; external name 'NumberFormat';
1816
+ class function UndefinedNumberFormat(locales : JSValue) : TJSIntlNumberFormat; external name 'NumberFormat';
1817
+ class function Collator() : TJSIntlCollator;
1818
+ class function Collator(locales : string) : TJSIntlCollator;
1819
+ class function Collator(locales : string; Options : TJSIntlCollatorOptions) : TJSIntlCollator;
1820
+ end;
1821
+
1822
+
1823
+ var
1824
+ // JSArguments can be used in procedures/functions to provide access to the 'arguments' array.
1825
+ JSArguments: TJSFunctionArguments; external name 'arguments';
1826
+ // JSThis can be used in all code to access the javascript 'this' object.
1827
+ JSThis: TJSObject; external name 'this';
1828
+ // JSExceptValue can be used in catch blocks to access the JS throw value
1829
+ JSExceptValue: JSValue; external name '$e';
1830
+
1831
+ function Symbol : TJSSymbol;
1832
+ function Symbol(Description : String) : TJSSymbol;
1833
+ function AsNumber(v : JSValue) : Double; assembler;
1834
+ function AsIntNumber(v : JSValue) : NativeInt; assembler;
1835
+ Function JSValueArrayOf(Args : Array of const) : TJSValueDynArray;
1836
+ function new(aElements: TJSValueDynArray) : TJSObject; overload;
1837
+ function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler; overload;
1838
+
1839
+ function decodeURIComponent(encodedURI : String) : String; external name 'decodeURIComponent';
1840
+ function encodeURIComponent(str : String) : String; external name 'encodeURIComponent';
1841
+
1842
+ function parseInt(s: String; Radix: NativeInt): NativeInt; overload; external name 'parseInt'; // may result NaN
1843
+ function parseInt(s: String): NativeInt; overload; external name 'parseInt'; // may result NaN
1844
+ function parseFloat(s: String): double; overload; external name 'parseFloat'; // may result NaN
1845
+
1846
+ function hasString(const v: JSValue): boolean; external name 'rtl.hasString';// isString(v) and v<>''
1847
+ function hasValue(const v: JSValue): boolean; assembler; // returns the JS definition of if(v): v is not false, undefined, null, 0, NaN, or the empty string. Note: JS if(new Boolean(false)) returns true.
1848
+ function jsIn(const keyName: String; const &object: TJSObject): Boolean; assembler;
1849
+ function isArray(const v: JSValue): boolean; external name 'rtl.isArray';
1850
+ function isBoolean(const v: JSValue): boolean; assembler;
1851
+ function isDate(const v: JSValue): boolean; assembler;
1852
+ function isCallback(const v: JSValue): boolean; assembler;
1853
+ function isChar(const v: JSValue): boolean; assembler;
1854
+ function isClass(const v: JSValue): boolean; assembler; // is a Pascal class, e.g. a TClass
1855
+ function isClassInstance(const v: JSValue): boolean; assembler;// is a Pascal class instance, e.g. a TObject
1856
+ function isFunction(const v: JSValue): boolean; external name 'rtl.isFunction';
1857
+ function isInteger(const v: JSValue): boolean; assembler;
1858
+ function isModule(const v: JSValue): boolean; external name 'rtl.isModule';
1859
+ function isNull(const v: JSValue): boolean; assembler;
1860
+ function isNumber(const v: JSValue): boolean; external name 'rtl.isNumber';
1861
+ function isObject(const v: JSValue): boolean; external name 'rtl.isObject'; // true if not null and a JS Object
1862
+ function isRecord(const v: JSValue): boolean; assembler;
1863
+ function isBigint(const v: JSValue): boolean; assembler;
1864
+ function isString(const v: JSValue): boolean; external name 'rtl.isString';
1865
+ function isUndefined(const v: JSValue): boolean; assembler;
1866
+ function isDefined(const v: JSValue): boolean; assembler;
1867
+ function isUTF16Char(const v: JSValue): boolean; assembler;
1868
+ function isExt(const InstanceOrClass, aClass: JSValue): boolean; external name 'rtl.isExt'; // aClass can be a JS object or function
1869
+ function jsInstanceOf(const aFunction, aFunctionWithPrototype: JSValue): Boolean; assembler;
1870
+ function jsTypeOf(const v: JSValue): String; external name 'typeof';
1871
+ function jsIsNaN(const v: JSValue): boolean; external name 'isNaN';// true if value cannot be converted to a number. e.g. True on NaN, undefined, {}, '123'. False on true, null, '', ' ', '1A'
1872
+ function jsIsFinite(const v: JSValue): boolean; external name 'isFinite';// true if value is a Finite number
1873
+ function toNumber(const v: JSValue): double; assembler; // if not possible, returns NaN
1874
+ function toInteger(const v: JSValue): NativeInt; // if v is not an integer, returns 0
1875
+ function toObject(Value: JSValue): TJSObject; // If Value is not a Javascript object, returns Nil
1876
+ function toArray(Value: JSValue): TJSArray; // If Value is not a Javascript array, returns Nil
1877
+ function toBoolean(Value: JSValue): Boolean; // If Value is not a Boolean, returns False
1878
+ function toString(Value: JSValue): String; // If Value is not a string, returns ''
1879
+ function JSClassName(aObj : TJSObject) : string;
1880
+
1881
+ Type
1882
+ TJSValueType = (jvtNull,jvtBoolean,jvtInteger,jvtFloat,jvtString,jvtObject,jvtArray);
1883
+
1884
+ Function GetValueType(JS : JSValue) : TJSValueType;
1885
+
1886
+ Function HaveSharedArrayBuffer : Boolean;
1887
+ Function SharedToNonShared(aBuffer : TJSAbstractArrayBuffer) : TJSArrayBuffer;
1888
+ Function SharedToNonShared(aArray : TJSTypedArray; aWordSized : Boolean = False) : TJSTypedArray;
1889
+ Function JSBigInt(aValue : JSValue) : TJSBigInt external name 'BigInt';
1890
+
1891
+ Const
1892
+ Null : JSValue; external name 'null';
1893
+ Undefined : JSValue; external name 'undefined';
1894
+
1895
+ implementation
1896
+
1897
+ function JSClassName(aObj : TJSObject) : string;
1898
+
1899
+ begin
1900
+ Result:='';
1901
+ if aObj=Nil then exit;
1902
+ asm
1903
+ return aObj.constructor.name;
1904
+ end;
1905
+ end;
1906
+
1907
+ function AsNumber(v: JSValue): Double; assembler;
1908
+ asm
1909
+ return Number(v);
1910
+ end;
1911
+
1912
+ function AsIntNumber(v: JSValue): NativeInt;
1913
+ asm
1914
+ return Number(v);
1915
+ end;
1916
+
1917
+ function JSValueArrayOf(Args: array of const): TJSValueDynArray;
1918
+
1919
+ var
1920
+ I : Integer;
1921
+
1922
+ begin
1923
+ SetLength(Result,Length(Args));
1924
+ for I:=0 to Length(Args)-1 do
1925
+ Result[i]:=Args[i].VJSValue
1926
+ end;
1927
+
1928
+
1929
+ function new(aElements: TJSValueDynArray): TJSObject;
1930
+
1931
+ function toString(I : Integer): string; external name 'String';
1932
+
1933
+ Var
1934
+ L,I : integer;
1935
+ S : String;
1936
+
1937
+ begin
1938
+ L:=length(aElements);
1939
+ if (L mod 2)=1 then
1940
+ raise EJS.Create('Number of arguments must be even');
1941
+ I:=0;
1942
+ // Check all arguments;
1943
+ While (i<L) do
1944
+ begin
1945
+ if Not isString(aElements[i]) then
1946
+ begin
1947
+ S:=ToString(I);
1948
+ raise EJS.Create('Argument '+S+' must be a string.');
1949
+ end;
1950
+ inc(I,2);
1951
+ end;
1952
+ I:=0;
1953
+ Result:=TJSObject.New;
1954
+ While (i<L) do
1955
+ begin
1956
+ S:=String(aElements[i]);
1957
+ Result.Properties[S]:=aElements[i+1];
1958
+ inc(I,2);
1959
+ end;
1960
+ end;
1961
+
1962
+ function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler;
1963
+ asm
1964
+ return delete Obj[PropName];
1965
+ end;
1966
+
1967
+ function hasValue(const v: JSValue): boolean; assembler;
1968
+ asm
1969
+ if(v){ return true; } else { return false; };
1970
+ end;
1971
+
1972
+ function jsIn(const keyName: String; const &object: TJSObject): Boolean; assembler;
1973
+ asm
1974
+ return keyName in object;
1975
+ end;
1976
+
1977
+ function isBoolean(const v: JSValue): boolean; assembler;
1978
+ asm
1979
+ return typeof(v) == 'boolean';
1980
+ end;
1981
+
1982
+ function isDate(const v: JSValue): boolean; assembler;
1983
+ asm
1984
+ return (v instanceof Date);
1985
+ end;
1986
+
1987
+ function isCallback(const v: JSValue): boolean; assembler;
1988
+ asm
1989
+ return rtl.isObject(v) && rtl.isObject(v.scope) && (rtl.isString(v.fn) || rtl.isFunction(v.fn));
1990
+ end;
1991
+
1992
+ function isChar(const v: JSValue): boolean; assembler;
1993
+ asm
1994
+ return (typeof(v)!="string") && (v.length==1);
1995
+ end;
1996
+
1997
+ function isClass(const v: JSValue): boolean; assembler;
1998
+ asm
1999
+ return (typeof(v)=="object") && (v!=null) && (v.$class == v);
2000
+ end;
2001
+
2002
+ function isClassInstance(const v: JSValue): boolean; assembler;
2003
+ asm
2004
+ return (typeof(v)=="object") && (v!=null) && (v.$class == Object.getPrototypeOf(v));
2005
+ end;
2006
+
2007
+ function isInteger(const v: JSValue): boolean; assembler;
2008
+ asm
2009
+ return Math.floor(v)===v;
2010
+ end;
2011
+
2012
+ function isNull(const v: JSValue): boolean; assembler;
2013
+ // Note: use identity, "==" would fit undefined
2014
+ asm
2015
+ return v === null;
2016
+ end;
2017
+
2018
+ function isRecord(const v: JSValue): boolean; assembler;
2019
+ asm
2020
+ return (typeof(v)==="object")
2021
+ && (typeof(v.$new)==="function")
2022
+ && (typeof(v.$clone)==="function")
2023
+ && (typeof(v.$eq)==="function")
2024
+ && (typeof(v.$assign)==="function");
2025
+ end;
2026
+
2027
+ function isBigint(const v: JSValue): boolean; assembler;
2028
+ asm
2029
+ return typeof(v) === 'bigint';
2030
+ end;
2031
+
2032
+ function isUndefined(const v: JSValue): boolean; assembler;
2033
+ asm
2034
+ return v == undefined;
2035
+ end;
2036
+
2037
+ function isDefined(const v: JSValue): boolean; assembler;
2038
+ asm
2039
+ return !(v == undefined);
2040
+ end;
2041
+
2042
+ function isUTF16Char(const v: JSValue): boolean; assembler;
2043
+ asm
2044
+ if (typeof(v)!="string") return false;
2045
+ if ((v.length==0) || (v.length>2)) return false;
2046
+ var code = v.charCodeAt(0);
2047
+ if (code < 0xD800){
2048
+ if (v.length == 1) return true;
2049
+ } else if (code <= 0xDBFF){
2050
+ if (v.length==2){
2051
+ code = v.charCodeAt(1);
2052
+ if (code >= 0xDC00 && code <= 0xDFFF) return true;
2053
+ };
2054
+ };
2055
+ return false;
2056
+ end;
2057
+
2058
+ function jsInstanceOf(const aFunction, aFunctionWithPrototype: JSValue
2059
+ ): Boolean; assembler;
2060
+ asm
2061
+ return aFunction instanceof aFunctionWithPrototype;
2062
+ end;
2063
+
2064
+ function toNumber(const v: JSValue): double; assembler;
2065
+ asm
2066
+ return v-0;
2067
+ end;
2068
+
2069
+ function toInteger(const v: JSValue): NativeInt;
2070
+ begin
2071
+ if IsInteger(v) then
2072
+ Result:=NativeInt(v)
2073
+ else
2074
+ Result:=0;
2075
+ end;
2076
+
2077
+ function toObject(Value: JSValue): TJSObject;
2078
+
2079
+ begin
2080
+ if IsObject(Value) then
2081
+ Result:=TJSObject(Value)
2082
+ else
2083
+ Result:=Nil;
2084
+ end;
2085
+
2086
+ function toArray(Value: JSValue): TJSArray; // If not possible, returns Nil
2087
+
2088
+ begin
2089
+ if IsArray(Value) then
2090
+ Result:=TJSArray(Value)
2091
+ else
2092
+ Result:=Nil;
2093
+ end;
2094
+
2095
+ function toBoolean(Value: JSValue): Boolean; // If not possible, returns False
2096
+
2097
+ begin
2098
+ if isBoolean(Value) then
2099
+ Result:=Boolean(Value)
2100
+ else
2101
+ Result:=False;
2102
+ end;
2103
+
2104
+ function toString(Value: JSValue): String; // If not possible, returns ''
2105
+
2106
+ begin
2107
+ if IsString(Value) then
2108
+ Result:=String(Value)
2109
+ else
2110
+ Result:='';
2111
+ end;
2112
+
2113
+ { EJS }
2114
+
2115
+ constructor EJS.Create(const Msg: String);
2116
+ begin
2117
+ FMessage:=Msg;
2118
+ end;
2119
+
2120
+ { TJSBigIntHelper }
2121
+
2122
+ class function TJSBigIntHelper.new(aValue: JSValue): TJSBigInt;
2123
+ begin
2124
+ Result:=JSBigint(aValue);
2125
+ end;
2126
+
2127
+ { TJSIntlHelper }
2128
+
2129
+ function GetValueType(JS: JSValue): TJSValueType;
2130
+
2131
+ Var
2132
+ t : string;
2133
+
2134
+ begin
2135
+ if isNull(js) then // null reported as object
2136
+ result:=jvtNull
2137
+ else
2138
+ begin
2139
+ t:=jsTypeOf(js);
2140
+ if (t='string') then
2141
+ Result:=jvtString
2142
+ else if (t='boolean') then
2143
+ Result:=jvtBoolean
2144
+ else if (t='object') then
2145
+ begin
2146
+ if IsArray(JS) then
2147
+ Result:=jvtArray
2148
+ else
2149
+ Result:=jvtObject;
2150
+ end
2151
+ else if (t='number') then
2152
+ if isInteger(JS) then
2153
+ result:=jvtInteger
2154
+ else
2155
+ result:=jvtFloat
2156
+ end;
2157
+ end;
2158
+
2159
+ Function HaveSharedArrayBuffer : Boolean; assembler;
2160
+
2161
+ asm
2162
+ return (typeof SharedArrayBuffer !== 'undefined');
2163
+ end;
2164
+
2165
+
2166
+ function SharedToNonShared(aBuffer: TJSAbstractArrayBuffer): TJSArrayBuffer;
2167
+ var
2168
+ Src,Dest : TJSUint8Array;
2169
+ begin
2170
+ if HaveSharedArrayBuffer and (aBuffer is TJSSharedArrayBuffer) then
2171
+ begin
2172
+ Result:=TJSArrayBuffer.new(aBuffer.byteLength);
2173
+ Src:=TJSUint8Array.New(aBuffer);
2174
+ Dest:=TJSUint8Array.New(Result);
2175
+ Dest._set(Src);
2176
+ end
2177
+ else
2178
+ Result:=TJSArrayBuffer(aBuffer);
2179
+ end;
2180
+
2181
+ function SharedToNonShared(aArray : TJSTypedArray; aWordSized : Boolean = False): TJSTypedArray;
2182
+ var
2183
+ Buf : TJSSharedArrayBuffer;
2184
+
2185
+ begin
2186
+ if HaveSharedArrayBuffer and (aArray.bufferObj is TJSSharedArrayBuffer) then
2187
+ begin
2188
+ Buf:=TJSSharedArrayBuffer(aArray.bufferObj).slice(aArray.byteOffset,aArray.byteOffset+aArray.ByteLength);
2189
+ if aWordSized then
2190
+ Result:=TJSUInt16Array.New(SharedToNonShared(Buf))
2191
+ else
2192
+ Result:=TJSUInt8Array.New(SharedToNonShared(Buf))
2193
+ end
2194
+ else
2195
+ Result:=aArray;
2196
+ end;
2197
+
2198
+ function Symbol : TJSSymbol; assembler;
2199
+ asm
2200
+ return Symbol();
2201
+ end;
2202
+
2203
+ function Symbol(Description : String) : TJSSymbol; assembler;
2204
+
2205
+ asm
2206
+ return Symbol(Description);
2207
+ end;
2208
+
2209
+
2210
+ end.
2211
+