[Pas2js] Testing generics

warleyalex warleyalex at yahoo.com.br
Sun Oct 27 21:46:34 CET 2019


//---- CODE -----
type
  generic TJSGenArray<T> = Class external name 'Array'
  private
    function GetElements(Index: NativeInt): T; external name '[]';
    procedure SetElements(Index: NativeInt; const AValue: T); external name
'[]';
  public
  type
    TSelfArray = specialize TJSGenArray<T>;

    TSelfTypeEvent = reference to function (element: T; index: NativeInt;
anArray: TSelfArray): Boolean;
    TSelfTypeEventProc = reference to procedure(element: T; index:
NativeInt; anArray: TSelfArray);
    TSelfTypeMapEvent = reference to function (element: T; index: NativeInt;
anArray: TSelfArray): T;
    TSelfTypeReduceEvent = reference to function (accumulator, currentValue:
T; currentIndex: NativeInt; anArray: TSelfArray): T;
    TSelfTypeCompareEvent = reference to function (a,b: T): NativeInt;
    TSelfTypeCallback = TSelfTypeEvent;
    TSelfTypeMapCallback = TSelfTypeMapEvent;
    TSelfTypeReduceCallBack = TSelfTypeReduceEvent;
    TSelfTypeCompareCallBack = TSelfTypeCompareEvent;
  public
    FLength: T; external name 'length';
    constructor new; overload;
    constructor new(aLength: NativeInt); overload;
    constructor new(aElement1: T); varargs; overload;
    class function &of(): TSelfArray; varargs; external name 'of';
    class function isArray(a: T): Boolean;
  {$IFDEF JAVASCRIPT2015}
    class function from(a: T): TSelfType;
    class function from(arrayLike: T; mapFunction: TJSMapFunctionCallBack):
TSelfType; overload;
    class function from(arrayLike: T; mapFunction: TJSMapFunctionCallBack;
thisArg: T): TSelfType; overload;
  {$ENDIF}
    function concat(el: T): TSelfArray; varargs;
    function copyWithin(aTarget: NativeInt): TSelfArray;overload; // not in
IE
    function copyWithin(aTarget, aStart: NativeInt): TSelfArray;overload; //
not in IE
    function copyWithin(aTarget, aStart, aEnd: NativeInt):
TSelfArray;overload; // not in IE
    function entries: TJSIterator;
    Function every(const aCallback: TSelfTypeCallBack): boolean;overload;
    Function every(const aCallback: TSelfTypeEvent; aThis: TObject):
boolean;overload;
    Function filter(const aCallBack: TSelfTypeCallBack): TSelfArray;
overload;
    Function filter(const aCallBack: TSelfTypeEvent; aThis: TObject):
TSelfArray;overload;
    Function fill(aValue: T): TSelfArray; overload;
    Function fill(aValue: T; aStartIndex: NativeInt): TSelfArray; overload;
    Function fill(aValue: T; aStartIndex,aEndIndex: NativeInt): TSelfArray;
overload;
    Function find(const aCallBack: TSelfTypeCallBack): T; overload;
    Function find(const aCallBack: TSelfTypeEvent; aThis: TObject): T;
overload;
    Function findIndex(const aCallBack: TSelfTypeCallBack): NativeInt;
overload;
    Function findIndex(const aCallBack: TSelfTypeEvent; aThis: TObject):
NativeInt; overload;
    procedure forEach(const aCallBack: TSelfTypeEventProc); overload;
    procedure forEach(const aCallBack: TSelfTypeEvent); overload;
    procedure forEach(const aCallBack: TSelfTypeEvent; aThis: TObject);
overload;
    function includes(aElement: T): Boolean; overload;
    function includes(aElement: T; FromIndex: NativeInt): Boolean; overload;
    function indexOf(aElement: T): NativeInt; overload;
    function indexOf(aElement: T; FromIndex: NativeInt): NativeInt;
overload;
    function join: String; overload;
    function join (aSeparator: string): String; overload;
    function keys: TJSIterator;
    function lastIndexOf(aElement: T): NativeInt; overload;
    function lastIndexOf(aElement: T; FromIndex: NativeInt): NativeInt;
overload;
  //    Function map(const aCallBack: TSelfTypeMapEventArray): T; overload;
    Function map(const aCallBack: TSelfTypeMapCallBack): TSelfArray;
overload;
    Function map(const aCallBack: TSelfTypeMapEvent; aThis: TObject):
TSelfArray; overload;
    function pop: T;
    function push(aElement: T): NativeInt; varargs;
    function reduce(const aCallBack: TSelfTypeReduceCallBack): T; overload;
    function reduce(const aCallBack: TSelfTypeReduceCallBack; initialValue:
T): T; overload;
    function reduceRight(const aCallBack: TSelfTypeReduceCallBack): T;
overload;
    function reduceRight(const aCallBack: TSelfTypeReduceCallBack;
initialValue: T): T; overload;
    Function reverse: TSelfArray;
    Function shift: T;
    Function slice: TSelfArray; overload;
    function slice(aBegin: NativeInt): TSelfArray; overload;
    function slice(aBegin,aEnd: NativeInt): TSelfArray; overload;
    Function some(const aCallback: TSelfTypeCallBack): boolean; overload;
    Function some(const aCallback: TSelfTypeEvent; aThis: TObject): boolean;
overload;
    Function sort(const aCallback: TSelfTypeCompareCallBack): TSelfArray;
overload;
    Function sort(): TSelfArray; overload;
    function splice(aStart: NativeInt): TSelfArray; overload;
    function splice(aStart,aDeleteCount: NativeInt): TSelfArray; varargs;
overload;
    function toLocaleString: String; overload;
    function toLocaleString(locales: string): String; overload;
    function toLocaleString(locales: string; const Options:
TLocaleCompareOptions): String; overload;
    function toString: String;
    function unshift: NativeInt; varargs;
    function values: TJSIterator;
    Property Length: T Read FLength Write FLength;
    property Elements[Index: NativeInt]: T read GetElements write
SetElements; default;
  end;

  { forward declarations }
  type
     generic TJSGenTypedArray<T> = Class;
     generic TJSGenArrayBuffer<T> = Class;
     generic TJSGenInt8Array<T> = Class;

  { TJSGenArrayBuffer<T> }
  generic TJSGenArrayBuffer<T> = Class external name 'ArrayBuffer'
  private
    fLength: NativeInt; external name 'byteLength';
  public
    constructor new(aByteLength: NativeInt);
    class function isView(aValue: T): Boolean;
    function slice(aBegin: NativeInt): TJSGenArrayBuffer; overload;
    function slice(aBegin,aEnd: NativeInt): TJSGenArrayBuffer; overload;
    Property byteLength: NativeInt Read fLength;
  end;

  { TJSGenBufferSource<T> }
  generic TJSGenBufferSource<T> = Class external name 'BufferSource'
  type
     TSelfArrayBuffer = specialize TJSGenArrayBuffer<T>;
     TSelfTypedArray = specialize TJSGenTypedArray<T>;
     TSelfInt8Array = specialize TJSGenInt8Array<T>;
  end;

  { TJSGenTypedArray<T> }
  generic TJSGenTypedArray<T> = Class external name 'TypedArray'
(TJSGenBufferSource)
  Private
    FBuffer: TSelfTypedArray; external name 'buffer';
    FByteLength: NativeInt; external name 'byteLength';
    FLength: NativeInt; external name 'length';
    FByteOffset: NativeInt; external name 'byteOffset';
    FBytesPerElement: NativeInt; external name 'BYTES_PER_ELEMENT';
    function getValue(Index: NativeInt): T; external name '[]';
    procedure setValue(Index: NativeInt;AValue: T); external name '[]';
  Public
  type
    TJSGenTypedArrayCallBack = function (element: T; index: NativeInt;
anArray: TSelfTypedArray): Boolean;
    TJSGenTypedArrayEvent = function (element: T; index: NativeInt; anArray:
TSelfTypedArray): Boolean of object;
    TJSGenTypedArrayMapCallBack = function (element: T; index: NativeInt;
anArray: TSelfTypedArray): T;
    TJSGenTypedArrayMapEvent = function (element: T; index: NativeInt;
anArray: TSelfTypedArray): T of object;
    TJSGenTypedArrayReduceCallBack = function (accumulator, currentValue: T;
currentIndex: NativeInt; anArray: TSelfTypedArray): T;
    TJSGenTypedArrayCompareCallBack = function (a,b: T): NativeInt;

    property BYTES_PER_ELEMENT: NativeInt Read FBytesPerElement;
    class var name: string;
//    class function from(aValue: T): TJSGenTypedArray;
//    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenTypedArray;
//    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenTypedArray;
    class function _of(aValue: T): TJSGenTypedArray; varargs; external name
'of';
    function copyWithin(aTarget: NativeInt): TJSGenTypedArray;overload;
    function copyWithin(aTarget, aStart: NativeInt):
TJSGenTypedArray;overload;
    function copyWithin(aTarget, aStart, aEnd: NativeInt):
TJSGenTypedArray;overload;
    Function every(const aCallback: TJSGenTypedArrayCallBack):
boolean;overload;
    Function every(const aCallback: TJSGenTypedArrayEvent; aThis: TObject):
boolean;overload;
    Function fill(aValue: T): TJSGenTypedArray; overload;
    Function fill(aValue: T; aStartIndex: NativeInt): TJSGenTypedArray;
overload;
    Function fill(aValue: T; aStartIndex,aEndIndex: NativeInt):
TJSGenTypedArray; overload;
    Function filter(const aCallBack: TJSGenTypedArrayCallBack):
TJSGenTypedArray; overload;
    Function filter(const aCallBack: TJSGenTypedArrayEvent; aThis: TObject):
TJSGenTypedArray;overload;
    Function find(const aCallBack: TJSGenTypedArrayCallBack): T; overload;
    Function find(const aCallBack: TJSGenTypedArrayEvent; aThis: TObject):
T; overload;
    Function findIndex(const aCallBack: TJSGenTypedArrayCallBack):
NativeInt; overload;
    Function findIndex(const aCallBack: TJSGenTypedArrayEvent; aThis:
TObject): NativeInt; overload;
    procedure forEach(const aCallBack: TJSGenTypedArrayCallBack); overload;
    procedure forEach(const aCallBack: TJSGenTypedArrayEvent; aThis:
TObject); overload;
    function includes(aElement: T): Boolean; overload;
    function includes(aElement: T; FromIndex: NativeInt): Boolean; overload;
    function indexOf(aElement: T): NativeInt; overload;
    function indexOf(aElement: T; FromIndex: NativeInt): NativeInt;
overload;
    function join: String; overload;
    function join (aSeparator: string): String; overload;
    function lastIndexOf(aElement: T): NativeInt; overload;
    function lastIndexOf(aElement: T; FromIndex: NativeInt): NativeInt;
overload;
    Function map(const aCallBack: TJSGenTypedArrayCallBack):
TJSGenTypedArray; overload;
    Function map(const aCallBack: TJSGenTypedArrayEvent; aThis: TObject):
TJSGenTypedArray; overload;
    function reduce(const aCallBack: TJSGenTypedArrayReduceCallBack): T;
overload;
    function reduce(const aCallBack: TJSGenTypedArrayReduceCallBack;
initialValue: T): T; overload;
    function reduceRight(const aCallBack: TJSGenTypedArrayReduceCallBack):
T; overload;
    function reduceRight(const aCallBack: TJSGenTypedArrayReduceCallBack;
initialValue: T): T; overload;
    Function reverse: TJSGenTypedArray;
    procedure _set(anArray: TJSArray); external name 'set';
    procedure _set(anArray: TJSArray; anOffset: NativeInt); external name
'set';
    procedure _set(anArray: TJSGenTypedArray); external name 'set';
    procedure _set(anArray: TJSGenTypedArray; anOffset: NativeInt); external
name 'set';
    Function slice: TJSGenTypedArray; overload;
    function slice(aBegin: NativeInt): TJSGenTypedArray; overload;
    function slice(aBegin,aEnd: NativeInt): TJSGenTypedArray; overload;
    Function some(const aCallback: TJSGenTypedArrayCallBack): boolean;
overload;
    Function some(const aCallback: TJSGenTypedArrayEvent; aThis: TObject):
boolean; overload;
    Function sort(const aCallback: TJSGenTypedArrayCompareCallBack):
TJSGenTypedArray; overload;
    Function sort(): TJSGenTypedArray; overload;
    function splice(aStart: NativeInt): TJSGenTypedArray; overload;
    function splice(aStart,aDeleteCount: NativeInt): TJSGenTypedArray;
varargs; overload;
    function toLocaleString: String; overload;
    function toLocaleString(locales: string): String; overload;
    function toLocaleString(locales: string; const Options:
TLocaleCompareOptions): String; overload;
    function toString: String;
    function unshift: NativeInt; varargs;
    property buffer: TSelfTypedArray read FBuffer;
    property byteLength: NativeInt Read FByteLength;
    property byteOffset: NativeInt Read FByteOffset;
    property length: NativeInt Read FLength;
    property values[Index: NativeInt]: T Read getValue Write SetValue;
default;
  end;

  { TJSGenInt8Array<T> }
  generic TJSGenInt8Array<T> = Class external name 'Int8Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Shortint; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Shortint);external
name '[]';
  public
{$IFDEF JAVASCRIPT2017}
    constructor new; // new in ES2017
{$ENDIF}
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TSelfInt8Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TSelfInt8Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TSelfInt8Array; reintroduce;
    class function _of(aValue: T): TSelfInt8Array; varargs; external name
'of'; reintroduce;overload;
    class function _of(aValue: TJSValueDynArray): TSelfInt8Array; varargs;
external name 'of'; reintroduce; overload;
    function subarray(aBegin, aEnd: Integer): TSelfInt8Array;  overload;
    function subarray(aBegin: Integer): TSelfInt8Array; overload;
    procedure _set(anArray: Array of ShortInt); external name 'set';
reintroduce; overload;
    procedure _set(anArray: Array of ShortInt; anOffset: NativeInt);
external name 'set';
    property values[Index: NativeInt]: Shortint Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenUint8Array<T> }
  generic TJSGenUint8Array <T> = Class external name 'Uint8Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Byte; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Byte);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenUint8Array; reintroduce; overload;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenUint8Array; reintroduce;overload;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenUint8Array; reintroduce;overload;
    class function _of(aValue: T): TJSGenUint8Array; varargs; external name
'of'; reintroduce; overload;
    function subarray(aBegin, aEnd: Integer): TJSGenUint8Array;  overload;
    function subarray(aBegin: Integer): TJSGenUint8Array; overload;
    procedure _set(anArray: Array of Byte); external name 'set';
reintroduce; overload;
    procedure _set(anArray: Array of Byte; anOffset: NativeInt); external
name 'set'; overload;
    Property values[Index: NativeInt]: Byte Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenUint8ClampedArray<T> }
  generic TJSGenUint8ClampedArray <T> = Class external name
'Uint8ClampedArray' (TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Byte; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Byte);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenUint8ClampedArray; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenUint8ClampedArray; reintroduce;overload;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenUint8ClampedArray; reintroduce;overload;
    class function _of(aValue: T): TJSGenUint8ClampedArray; varargs;
external name 'of'; reintroduce;overload;
    procedure _set(anArray: Array of Byte); external name 'set';
reintroduce;overload;
    procedure _set(anArray: Array of Byte; anOffset: NativeInt); external
name 'set';overload;
    function subarray(aBegin, aEnd: Integer): TJSGenUint8ClampedArray; 
overload;
    function subarray(aBegin: Integer): TJSGenUint8ClampedArray; overload;
    Property values[Index: NativeInt]: Byte Read getTypedValue Write
setTypedValue; default;
  end;

  { TJGenSInt16Array<T> }
  generic TJGenSInt16Array<T> = Class external name 'Int16Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): smallint; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Smallint);external
name '[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJGenSInt16Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJGenSInt16Array; reintroduce;overload;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJGenSInt16Array; reintroduce;overload;
    class function _of(aValue: T): TJGenSInt16Array; varargs; external name
'of'; reintroduce;overload;
    procedure _set(anArray: Array of SmallInt); external name 'set';
reintroduce;overload;
    procedure _set(anArray: Array of SmallInt; anOffset: NativeInt);
external name 'set';overload;
    function subarray(aBegin, aEnd: Integer): TJGenSInt16Array;  overload;
    function subarray(aBegin: Integer): TJGenSInt16Array; overload;
    Property values[Index: NativeInt]: SmallInt Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenUint16Array<T> }
  generic TJSGenUint16Array<T> = Class external name 'Uint16Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Word; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Word);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenUint16Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenUint16Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenUint16Array; reintroduce;
    class function _of(aValue: T): TJSGenUint16Array; varargs; external name
'of'; reintroduce;
    procedure _set(anArray: Array of Word); external name 'set';
reintroduce;
    procedure _set(anArray: Array of Word; anOffset: NativeInt); external
name 'set';
    function subarray(aBegin, aEnd: Integer): TJSGenUint16Array;  overload;
    function subarray(aBegin: Integer): TJSGenUint16Array; overload;
    Property values[Index: NativeInt]: Word Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenInt32Array<T> }
  generic TJSGenInt32Array<T> = Class external name 'Int32Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): longint; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: longint);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenInt32Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenInt32Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenInt32Array; reintroduce;
    class function _of(aValue: T): TJSGenInt32Array; varargs;external name
'of'; reintroduce;
    procedure _set(anArray: Array of LongInt); external name 'set';
reintroduce;
    procedure _set(anArray: Array of LongInt; anOffset: NativeInt); external
name 'set';
    function subarray(aBegin, aEnd: Integer): TJSGenInt32Array;  overload;
    function subarray(aBegin: Integer): TJSGenInt32Array; overload;
    Property values[Index: NativeInt]: longint Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenUint32Array<T> }
  generic TJSGenUint32Array<T> = Class external name 'Uint32Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): LongWord; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: LongWord);external
name '[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenUint32Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenUint32Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenUint32Array; reintroduce;
    class function _of(aValue: T): TJSGenUint32Array; varargs; external name
'of'; reintroduce;
    procedure _set(anArray: Array of Cardinal); external name 'set';
reintroduce;
    procedure _set(anArray: Array of Cardinal; anOffset: NativeInt);
external name 'set';
    function subarray(aBegin, aEnd: Integer): TJSGenUint32Array;  overload;
    function subarray(aBegin: Integer): TJSGenUint32Array; overload;
    Property values[Index: NativeInt]: LongWord Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenFloat32Array<T> }
  generic TJSGenFloat32Array<T> = Class external name 'Float32Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Float32; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Float32);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenFloat32Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenFloat32Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenFloat32Array; reintroduce;
    class function _of(aValue: T): TJSGenFloat32Array; varargs; reintroduce;
    procedure _set(anArray: Array of Double); external name 'set';
reintroduce;
    procedure _set(anArray: Array of Double; anOffset: NativeInt); external
name 'set'; reintroduce;
    function subarray(aBegin, aEnd: Integer): TJSGenFloat32Array;  overload;
    function subarray(aBegin: Integer): TJSGenFloat32Array; overload;
    Property values[Index: NativeInt]: Float32 Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenFloat64Array<T> }
  generic TJSGenFloat64Array<T> = Class external name 'Float64Array'
(TJSGenTypedArray)
  private
    function getTypedValue(Index: NativeInt): Float64; external name '[]';
    procedure setTypedValue(Index: NativeInt; AValue: Float64);external name
'[]';
  public
    constructor new (length: NativeInt);
    constructor new (atypedArray: TSelfTypedArray);
    constructor new (aObject: TJSObject);
    constructor new (buffer: TSelfArrayBuffer);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset: NativeInt);
    constructor new (buffer: TSelfArrayBuffer; aByteOffset, aLength:
NativeInt);
    class function from(aValue: T): TJSGenFloat64Array; reintroduce;
    class function from(aValue: T; Map: TJSGenTypedArrayMapCallBack):
TJSGenFloat64Array; reintroduce;
    class function from(aValue: T; aMap: TJSGenTypedArrayMapEvent):
TJSGenFloat64Array; reintroduce;
    class function _of(aValue: T): TJSGenFloat64Array; varargs; reintroduce;
    procedure _set(anArray: Array of Double); external name 'set';
reintroduce;
    procedure _set(anArray: Array of Double; anOffset: NativeInt); external
name 'set'; reintroduce;
    function subarray(aBegin, aEnd: Integer): TJSGenFloat64Array;  overload;
    function subarray(aBegin: Integer): TJSGenFloat64Array; overload;
    Property values[Index: NativeInt]: Float64 Read getTypedValue Write
setTypedValue; default;
  end;

  { TJSGenDataView<T> }
  generic TJSGenDataView<T> = Class external name 'DataView'
(TJSGenBufferSource)
  private
    fBuffer: TSelfArrayBuffer; external name 'buffer';
    fLength: NativeInt; external name 'byteLength';
    fOffset: NativeInt; external name 'byteOffset';
  public
    constructor new(aBuffer: TSelfArrayBuffer); overload;
    constructor new(aBuffer: TSelfArrayBuffer; aOffset: NativeInt);
overload;
    constructor new(aBuffer: TSelfArrayBuffer; aOffset,aByteLength:
NativeInt); overload;
    function getFloat32(aByteOffset: NativeInt): double; overload;
    function getFloat32(aByteOffset: NativeInt; aLittleEndian: Boolean):
double; overload;
    function getFloat64(aByteOffset: NativeInt): double; overload;
    function getFloat64(aByteOffset: NativeInt; aLittleEndian: Boolean):
double; overload;
    function getInt8(aByteOffset: NativeInt): ShortInt;
    function getInt16(aByteOffset: NativeInt): SmallInt; overload;
    function getInt16(aByteOffset: NativeInt; aLittleEndian: Boolean):
SmallInt; overload;
    function getInt32(aByteOffset: NativeInt): Longint; overload;
    function getInt32(aByteOffset: NativeInt; aLittleEndian: Boolean):
Longint; overload;
    function getUint8(aByteOffset: NativeInt): Byte; overload;
    function getUint16(aByteOffset: NativeInt): Word; overload;
    function getUint16(aByteOffset: NativeInt; aLittleEndian: Boolean):
Word; overload;
    function getUint32(aByteOffset: NativeInt): LongWord; overload;
    function getUint32(aByteOffset: NativeInt; aLittleEndian: Boolean):
LongWord; overload;

    procedure setFloat32(aByteOffset: NativeInt; aValue: double); overload;
    procedure setFloat32(aByteOffset: NativeInt; aValue: double;
aLittleEndian: Boolean); overload;
    procedure setFloat64(aByteOffset: NativeInt; aValue: double); overload;
    procedure setFloat64(aByteOffset: NativeInt; aValue: double;
aLittleEndian: Boolean); overload;
    procedure setInt8(aByteOffset: NativeInt; aValue: ShortInt);
    procedure setInt16(aByteOffset: NativeInt; aValue: SmallInt); overload;
    procedure setInt16(aByteOffset: NativeInt; aValue: SmallInt;
aLittleEndian: Boolean); overload;
    procedure setInt32(aByteOffset: NativeInt; aValue: Longint); overload;
    procedure setInt32(aByteOffset: NativeInt; aValue: Longint;
aLittleEndian: Boolean); overload;
    procedure setUint8(aByteOffset: NativeInt; aValue: Byte); overload;
    procedure setUint16(aByteOffset: NativeInt; aValue: Word); overload;
    procedure setUint16(aByteOffset: NativeInt; aValue: Word; aLittleEndian:
Boolean); overload;
    procedure setUint32(aByteOffset: NativeInt; aValue: LongWord); overload;
    procedure setUint32(aByteOffset: NativeInt; aValue: LongWord;
aLittleEndian: Boolean); overload;
    Property byteLength: NativeInt Read fLength;
    Property byteOffset: NativeInt read fOffset;
    property buffer: TSelfArrayBuffer Read fBuffer;
  end;        
//---- END ------

I sincerely don't see the pros, if it's worthy to implement generic external
classes like this one.



--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list