You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
This is another requirement coming to us from the world of Node.js -- the need to allocate "external storage" that is specified as a separate JavaScript array which replaces the various slots inside an object with the array data.
We will add the following methods to ScriptableObject:
each takes an appropriate Java array type and implements JavaScript getters and setters to support signed or unsigned values, as appropriate.
The "clamped" array, like the V8 equivalent, coerces bytes inserted to the range [0,255].
Once an array is set, all indexes between 0 and the array size are handled directly by the array.
Access to other object properties, and array indices higher than the array size, behave as normal.
The array may be set at any time, or removed by setting it to null. However, if it is set after data has already been loaded, then the result will be undefined.
For instance, assume that an object "o" is in scope, that the Java code already set it up by calling "setExternalArray()" with the type "ExternalIntArray" of size 10, and that each element is initialized to 0:
…thod:
ScriptableObject.setExternalArray()
and the new "ExternalArray" class and its subclasses.
This feature lets you set the contents of the "array" portion of an
object to a Java array of various types. This makes it easier to
write code that efficiently shares code between Java and Node.js
See here for more:
#17
This is another requirement coming to us from the world of Node.js -- the need to allocate "external storage" that is specified as a separate JavaScript array which replaces the various slots inside an object with the array data.
We will add the following methods to ScriptableObject:
void setExternalArray(ExternalArray array);
ExternalArray getExternalArray();
boolean hasExternalArray();
The external array is represented as an abstract class, which has the following subclasses (to match the array types supported by Rhino):
ExternalByteArray
ExternalUnsignedByteArray
ExternalClampedByteArray
ExternalShortArray
ExternalUnsignedShortArray
ExternalIntArray
ExternalUnsignedIntArray
ExternalFloatArray
ExternalDoubleArray
each takes an appropriate Java array type and implements JavaScript getters and setters to support signed or unsigned values, as appropriate.
The "clamped" array, like the V8 equivalent, coerces bytes inserted to the range [0,255].
Once an array is set, all indexes between 0 and the array size are handled directly by the array.
Access to other object properties, and array indices higher than the array size, behave as normal.
The array may be set at any time, or removed by setting it to null. However, if it is set after data has already been loaded, then the result will be undefined.
For instance, assume that an object "o" is in scope, that the Java code already set it up by calling "setExternalArray()" with the type "ExternalIntArray" of size 10, and that each element is initialized to 0:
The text was updated successfully, but these errors were encountered: