Skip to content
This repository was archived by the owner on Mar 25, 2019. It is now read-only.

Commit 8ee2aec

Browse files
author
ericwlange
committed
Updated JavaDoc documentation
1 parent 3eeb248 commit 8ee2aec

13 files changed

Lines changed: 862 additions & 31 deletions

File tree

AndroidJSCore/AndroidJSCore/src/main/java/org/liquidplayer/webkit/javascriptcore/JSArrayBuffer.java

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,131 @@
1+
//
2+
// JSArrayBuffer.java
3+
// AndroidJSCore project
4+
//
5+
// https://github.com/ericwlange/AndroidJSCore/
6+
//
7+
// Created by Eric Lange
8+
//
9+
/*
10+
Copyright (c) 2014-2016 Eric Lange. All rights reserved.
11+
12+
Redistribution and use in source and binary forms, with or without
13+
modification, are permitted provided that the following conditions are met:
14+
15+
- Redistributions of source code must retain the above copyright notice, this
16+
list of conditions and the following disclaimer.
17+
18+
- Redistributions in binary form must reproduce the above copyright notice,
19+
this list of conditions and the following disclaimer in the documentation
20+
and/or other materials provided with the distribution.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
133
package org.liquidplayer.webkit.javascriptcore;
234

335
/**
4-
* Created by Eric on 6/20/16.
36+
* A wrapper class for a JavaScript ArrayBuffer
537
*/
638
public class JSArrayBuffer {
39+
/**
40+
* Creates a new array buffer of 'length' bytes
41+
* @param ctx the JSContext in which to create the ArrayBuffer
42+
* @param length the length in bytes of the ArrayBuffer
43+
*/
744
public JSArrayBuffer(JSContext ctx, int length) {
845
JSFunction constructor = new JSFunction(ctx,"_ArrayBuffer",new String[] {"length"},
946
"return new ArrayBuffer(length);",
1047
null, 0);
1148
mArrayBuffer = constructor.call(null,length).toObject();
1249
}
50+
51+
/**
52+
* Treats an existing JSObject as an ArrayBuffer. It is up to the user to ensure the
53+
* underlying JSObject is actually an ArrayBuffer.
54+
* @param buffer The ArrayBuffer JSObject to wrap
55+
*/
1356
public JSArrayBuffer(JSObject buffer) {
1457
mArrayBuffer = buffer;
1558
}
1659
private final JSObject mArrayBuffer;
1760

61+
/**
62+
* Gets underlying JSObject
63+
* @return JSObject representing the ArrayBuffer
64+
*/
1865
public JSObject getJSObject() {
1966
return mArrayBuffer;
2067
}
2168

22-
public int length() {
23-
return mArrayBuffer.property("length").toNumber().intValue();
69+
/**
70+
* JavaScript: ArrayBuffer.prototype.byteLength, see:
71+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength
72+
* @return length of ArrayBuffer in bytes
73+
*/
74+
public int byteLength() {
75+
return mArrayBuffer.property("byteLength").toNumber().intValue();
2476
}
2577

78+
/**
79+
* JavaScript: ArrayBuffer.isView(), see:
80+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
81+
* @param arg the argument to be checked
82+
* @return true if arg is one of the ArrayBuffer views, such as typed array objects or
83+
* a DataView; false otherwise
84+
*/
2685
public static boolean isView(JSValue arg) {
2786
return arg.getContext().property("ArrayBuffer").toObject().property("isView").toFunction()
2887
.call(null,arg).toBoolean();
2988
}
3089

90+
/**
91+
* JavaScript: ArrayBuffer.transfer(), see:
92+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer
93+
* @param oldBuffer An ArrayBuffer object from which to transfer from
94+
* @param newByteLength The byte length of the new ArrayBuffer object
95+
* @return a new ArrayBuffer
96+
*/
3197
public static JSArrayBuffer transfer(JSArrayBuffer oldBuffer, int newByteLength) {
3298
return new JSArrayBuffer(oldBuffer.getJSObject().getContext().property("ArrayBuffer").toObject()
3399
.property("transfer").toFunction().call(null,oldBuffer,newByteLength).toObject());
34100
}
101+
/**
102+
* JavaScript: ArrayBuffer.transfer(), see:
103+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer
104+
* @param oldBuffer An ArrayBuffer object from which to transfer from
105+
* @return a new ArrayBuffer
106+
*/
35107
public static JSArrayBuffer transfer(JSArrayBuffer oldBuffer) {
36108
return new JSArrayBuffer(oldBuffer.getJSObject().getContext().property("ArrayBuffer").toObject()
37109
.property("transfer").toFunction().call(null,oldBuffer).toObject());
38110
}
39111

112+
/**
113+
* JavaScript: ArrayBuffer.prototype.slice(), see:
114+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
115+
* @param begin Zero-based byte index at which to begin slicing
116+
* @param end Byte index to end slicing
117+
* @return new ArrayBuffer with sliced contents copied
118+
*/
40119
public JSArrayBuffer slice(int begin, int end) {
41120
return new JSArrayBuffer(
42121
mArrayBuffer.property("slice").toFunction().call(null,begin,end).toObject());
43122
}
123+
/**
124+
* JavaScript: ArrayBuffer.prototype.slice(), see:
125+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
126+
* @param begin Zero-based byte index at which to begin slicing
127+
* @return new ArrayBuffer with sliced contents copied
128+
*/
44129
public JSArrayBuffer slice(int begin) {
45130
return new JSArrayBuffer(
46131
mArrayBuffer.property("slice").toFunction().call(null,begin).toObject());

AndroidJSCore/AndroidJSCore/src/main/java/org/liquidplayer/webkit/javascriptcore/JSBaseArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4848
* simple integration with Java methods.
4949
*
5050
*/
51-
public class JSBaseArray<T> extends JSFunction implements List<T> {
51+
public abstract class JSBaseArray<T> extends JSFunction implements List<T> {
5252

5353
protected Class<T> mType;
5454
protected int mLeftBuffer = 0;

AndroidJSCore/AndroidJSCore/src/main/java/org/liquidplayer/webkit/javascriptcore/JSFloat32Array.java

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,105 @@
1+
//
2+
// JSFloat32Array.java
3+
// AndroidJSCore project
4+
//
5+
// https://github.com/ericwlange/AndroidJSCore/
6+
//
7+
// Created by Eric Lange
8+
//
9+
/*
10+
Copyright (c) 2014-2016 Eric Lange. All rights reserved.
11+
12+
Redistribution and use in source and binary forms, with or without
13+
modification, are permitted provided that the following conditions are met:
14+
15+
- Redistributions of source code must retain the above copyright notice, this
16+
list of conditions and the following disclaimer.
17+
18+
- Redistributions in binary form must reproduce the above copyright notice,
19+
this list of conditions and the following disclaimer in the documentation
20+
and/or other materials provided with the distribution.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
133
package org.liquidplayer.webkit.javascriptcore;
234

335
/**
4-
* Created by Eric on 6/26/16.
36+
* A convenience class for handling JavaScript's Float32Array
37+
* @since 3.0
538
*/
639
public class JSFloat32Array extends JSTypedArray<Float> {
40+
/**
41+
* Creates a typed array of length 'length' in JSContext 'context'
42+
* @param ctx the JSContext in which to create the typed array
43+
* @param length the length of the array in elements
44+
* @since 3.0
45+
*/
746
public JSFloat32Array(JSContext ctx, int length) {
847
super(ctx,length,"Float32Array",Float.class);
948
}
49+
50+
/**
51+
* Creates a new JSFloat32Array from the contents of another typed array
52+
* @param tarr the typed array from which to create the new array
53+
* @since 3.0
54+
*/
1055
public JSFloat32Array(JSTypedArray tarr) {
1156
super(tarr,"Float32Array",Float.class);
1257
}
58+
59+
/**
60+
* Creates new typed array as if by TypedArray.from()
61+
* @param ctx The context in which to create the typed array
62+
* @param object The object to create the array from
63+
* @since 3.0
64+
*/
1365
public JSFloat32Array(JSContext ctx, Object object) {
1466
super(ctx,object,"Float32Array",Float.class);
1567
}
68+
69+
/**
70+
* Creates a typed array from a JSArrayBuffer
71+
* @param buffer The JSArrayBuffer to create the typed array from
72+
* @param byteOffset The byte offset in the ArrayBuffer to start from
73+
* @param length The number of bytes from 'byteOffset' to include in the array
74+
* @since 3.0
75+
*/
1676
public JSFloat32Array(JSArrayBuffer buffer, int byteOffset, int length) {
1777
super(buffer,byteOffset,length,"Float32Array",Float.class);
1878
}
79+
/**
80+
* Creates a typed array from a JSArrayBuffer
81+
* @param buffer The JSArrayBuffer to create the typed array from
82+
* @param byteOffset The byte offset in the ArrayBuffer to start from
83+
* @since 3.0
84+
*/
1985
public JSFloat32Array(JSArrayBuffer buffer, int byteOffset) {
2086
super(buffer,byteOffset,"Float32Array",Float.class);
2187
}
88+
/**
89+
* Creates a typed array from a JSArrayBuffer
90+
* @param buffer The JSArrayBuffer to create the typed array from
91+
* @since 3.0
92+
*/
2293
public JSFloat32Array(JSArrayBuffer buffer) {
2394
super(buffer,"Float32Array",Float.class);
2495
}
96+
97+
/**
98+
* Treats an existing value as a typed array
99+
* @param valueRef the JavaScriptCore value reference
100+
* @param ctx The JSContext of the value
101+
* @since 3.0
102+
*/
25103
public JSFloat32Array(long valueRef, JSContext ctx) {
26104
super(valueRef,ctx,Float.class);
27105
}

AndroidJSCore/AndroidJSCore/src/main/java/org/liquidplayer/webkit/javascriptcore/JSFloat64Array.java

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,104 @@
1+
//
2+
// JSFloat64Array.java
3+
// AndroidJSCore project
4+
//
5+
// https://github.com/ericwlange/AndroidJSCore/
6+
//
7+
// Created by Eric Lange
8+
//
9+
/*
10+
Copyright (c) 2014-2016 Eric Lange. All rights reserved.
11+
12+
Redistribution and use in source and binary forms, with or without
13+
modification, are permitted provided that the following conditions are met:
14+
15+
- Redistributions of source code must retain the above copyright notice, this
16+
list of conditions and the following disclaimer.
17+
18+
- Redistributions in binary form must reproduce the above copyright notice,
19+
this list of conditions and the following disclaimer in the documentation
20+
and/or other materials provided with the distribution.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
133
package org.liquidplayer.webkit.javascriptcore;
234

335
/**
4-
* Created by Eric on 6/26/16.
36+
* A convenience class for handling JavaScript's Float64Array
37+
* @since 3.0
538
*/
639
public class JSFloat64Array extends JSTypedArray<Double> {
40+
/**
41+
* Creates a typed array of length 'length' in JSContext 'context'
42+
* @param ctx the JSContext in which to create the typed array
43+
* @param length the length of the array in elements
44+
* @since 3.0
45+
*/
746
public JSFloat64Array(JSContext ctx, int length) {
847
super(ctx,length,"Float64Array",Double.class);
948
}
49+
/**
50+
* Creates a new JSFloat64Array from the contents of another typed array
51+
* @param tarr the typed array from which to create the new array
52+
* @since 3.0
53+
*/
1054
public JSFloat64Array(JSTypedArray tarr) {
1155
super(tarr,"Float64Array",Double.class);
1256
}
57+
58+
/**
59+
* Creates new typed array as if by TypedArray.from()
60+
* @param ctx The context in which to create the typed array
61+
* @param object The object to create the array from
62+
* @since 3.0
63+
*/
1364
public JSFloat64Array(JSContext ctx, Object object) {
1465
super(ctx,object,"Float64Array",Double.class);
1566
}
67+
68+
/**
69+
* Creates a typed array from a JSArrayBuffer
70+
* @param buffer The JSArrayBuffer to create the typed array from
71+
* @param byteOffset The byte offset in the ArrayBuffer to start from
72+
* @param length The number of bytes from 'byteOffset' to include in the array
73+
* @since 3.0
74+
*/
1675
public JSFloat64Array(JSArrayBuffer buffer, int byteOffset, int length) {
1776
super(buffer,byteOffset,length,"Float64Array",Double.class);
1877
}
78+
/**
79+
* Creates a typed array from a JSArrayBuffer
80+
* @param buffer The JSArrayBuffer to create the typed array from
81+
* @param byteOffset The byte offset in the ArrayBuffer to start from
82+
* @since 3.0
83+
*/
1984
public JSFloat64Array(JSArrayBuffer buffer, int byteOffset) {
2085
super(buffer,byteOffset,"Float64Array",Double.class);
2186
}
87+
/**
88+
* Creates a typed array from a JSArrayBuffer
89+
* @param buffer The JSArrayBuffer to create the typed array from
90+
* @since 3.0
91+
*/
2292
public JSFloat64Array(JSArrayBuffer buffer) {
2393
super(buffer,"Float64Array",Double.class);
2494
}
95+
96+
/**
97+
* Treats an existing value as a typed array
98+
* @param valueRef the JavaScriptCore value reference
99+
* @param ctx The JSContext of the value
100+
* @since 3.0
101+
*/
25102
public JSFloat64Array(long valueRef, JSContext ctx) {
26103
super(valueRef,ctx,Double.class);
27104
}

0 commit comments

Comments
 (0)