[Pas2js] missing definitions
warleyalex
warleyalex at yahoo.com.br
Wed Aug 28 15:24:49 CEST 2019
I remember I had to include some missing definitions at the external classses
(JS unit) to compile my test project.
-------------------
{ TJSObject }
TJSObject = class external name 'Object'
public
(..)
class function values(const obj: JSValue): TJSObject; external name
'values';
end;
-------------------
TJSArrayEventProc = reference to procedure(element : JSValue; index:
NativeInt; anArray : TJSArray);
{ TJSIteratorValue }
TJSIteratorValue = class external name 'IteratorValue'
public
value : JSValue; external name 'value';
done : boolean; external name 'done';
end;
{ TJSIterator }
TJSIterator = class external name 'Iterator'
Public
function next: TJSIteratorValue;
end;
TJSSet = class;
type
TJSMapFunctionCallBack = reference to function(arg : JSValue): JSValue;
TJSMapProcCallBack = reference to procedure(value: JSValue; key:
JSValue);
TJSSetyEventProc = reference to procedure(value : JSValue; key:
NativeInt; &set: TJSSet);
TJSSetProcCallBack = reference to procedure(value: JSValue; key:
JSValue);
{ TJSSet }
TJSSet = class external name 'Set'
public
constructor new; overload;
constructor new(aElement1 : JSValue); varargs; overload;
function add(value: JSValue): TJSSet;
function has(value: JSValue): Boolean;
function delete(value: JSValue): Boolean;
function size: Integer; external name 'size.valueOf';
procedure clear;
function values: TJSIterator;
procedure forEach(const aCallBack: TJSSetyEventProc); overload;
procedure forEach(const aCallBack: TJSSetProcCallBack); overload;
procedure forEach(const aCallBack: TJSSetyEventProc; thisArg: JSValue);
overload;
function entries: TJSIterator;
function keys: TJSIterator;
end;
{ TJSMap }
TJSMap = class external name 'Map'
public
constructor new; varargs; overload;
constructor new(aElement1 : JSValue); varargs; overload;
function &set(key: JSValue; value: JSValue) :TJSMap;
function get(key : JSValue): JSValue;
function has(key: JSValue): Boolean;
function delete(key: JSValue): Boolean;
procedure clear;
function entries: TJSIterator;
procedure forEach(const aCallBack: TJSMapFunctionCallBack); overload;
procedure forEach(const aCallBack: TJSMapFunctionCallBack; thisArg:
JSValue); overload;
procedure forEach(const aCallBack: TJSMapProcCallBack); overload;
function keys: TJSIterator;
function values: TJSIterator;
function size: Integer; external name 'size.valueOf';
end;
{ TJSArray }
TJSArray = Class external name 'Array'
public
(...)
//ES2015
class function from(arrayLike : JSValue) : TJSArray; overload;
class function from(arrayLike : JSValue; mapFunction :
TJSMapFunctionCallBack): TJSArray; overload;
class function from(arrayLike : JSValue; mapFunction :
TJSMapFunctionCallBack; thisArg : JSValue): TJSArray; overload;
function entries: TJSIterator;
procedure forEach(const aCallBack : TJSArrayEventProc); overload;
function keys: TJSIterator;
Function map(const aCallBack : TJSArrayMapEventArray) : JSValue;
overload;
function values: TJSIterator;
end;
-------------------
TJSTypedArray = class external name 'TypedArray' (TJSBufferSource)
Public
(...)
//class var BYTES_PER_ELEMENT : NativeInt; // I think it is not a class
var definition
BYTES_PER_ELEMENT : NativeInt; // this works for me
end;
-------------------
TJSInt8Array = class external name 'Int8Array' (TJSTypedArray)
public
constructor new; // new in ES2017
constructor new (buffer : TJSValueDynArray);
(...)
class function _of(aValue : TJSValueDynArray) : TJSInt8Array; varargs;
external name 'of'; reintroduce;
function subarray(aBegin, aEnd: Integer): TJSInt8Array; external name
'subarray'; overload;
function subarray(aBegin: Integer): TJSInt8Array; external name
'subarray'; overload;
end;
-------------------
and the same, a slight modification for the method subarray (return type)
for the TJSUint8Array | TJSUint8ClampedArray | TJSInt16Array |
TJSUint16Array | TJSInt32Array | TJSUint32Array | TJSFloat32Array |
TJSFloat64Array
-------------------
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list