in rhino/src/main/java/org/mozilla/javascript/typedarrays/NativeTypedArrayView.java [153:478]
static void init(
Context cx, Scriptable scope, LambdaConstructor constructor, RealThis realThis) {
constructor.definePrototypeProperty(
cx,
"buffer",
(Scriptable thisObj) -> js_buffer(thisObj, realThis),
DONTENUM | READONLY);
constructor.definePrototypeProperty(
cx,
"byteLength",
(Scriptable thisObj) -> js_byteLength(thisObj, realThis),
DONTENUM | READONLY);
constructor.definePrototypeProperty(
cx,
"byteOffset",
(Scriptable thisObj) -> js_byteOffset(thisObj, realThis),
DONTENUM | READONLY);
constructor.definePrototypeProperty(
cx,
"length",
(Scriptable thisObj) -> js_length(thisObj, realThis),
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"at",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_at(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"copyWithin",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_copyWithin(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"entries",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return new NativeArrayIterator(lscope, self, ARRAY_ITERATOR_TYPE.ENTRIES);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"every",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.EVERY, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"fill",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_fill(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"filter",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
Object array =
ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FILTER, lscope, self, args);
return self.typedArraySpeciesCreate(
lcx, lscope, new Object[] {array}, "filter");
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"find",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FIND, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"findIndex",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FIND_INDEX, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"findLast",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FIND_LAST, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"findLastIndex",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FIND_LAST_INDEX, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"forEach",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.FOR_EACH, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"includes",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_includes(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"indexOf",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_indexOf(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"join",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_join(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"keys",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return new NativeArrayIterator(lscope, self, ARRAY_ITERATOR_TYPE.KEYS);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"lastIndexOf",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_lastIndexOf(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"map",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
Object array =
ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.MAP, lscope, thisObj, args);
return self.typedArraySpeciesCreate(lcx, lscope, new Object[] {array}, "map");
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"reduce",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.reduceMethod(
lcx, ReduceOperation.REDUCE, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"reduceRight",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.reduceMethod(
lcx, ReduceOperation.REDUCE_RIGHT, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"reverse",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_reverse(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"set",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_set(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"slice",
2,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_slice(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"some",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return ArrayLikeAbstractOperations.iterativeMethod(
lcx, IterativeOperation.SOME, lscope, self, args);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"sort",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_sort(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"subarray",
2,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_subarray(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"toLocaleString",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_toString(lcx, lscope, thisObj, args, realThis, true),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"toReversed",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_toReversed(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"toSorted",
1,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_toSorted(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"toString",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_toString(lcx, lscope, thisObj, args, realThis, false),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"values",
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return new NativeArrayIterator(lscope, self, ARRAY_ITERATOR_TYPE.VALUES);
},
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
"with",
2,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) ->
js_with(lcx, lscope, thisObj, args, realThis),
DONTENUM,
DONTENUM | READONLY);
constructor.definePrototypeMethod(
scope,
SymbolKey.ITERATOR,
0,
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> {
NativeTypedArrayView<?> self = realThis.realThis(thisObj);
return new NativeArrayIterator(lscope, self, ARRAY_ITERATOR_TYPE.VALUES);
},
DONTENUM,
DONTENUM | READONLY);
}