Skip to content

Commit 7b75ea8

Browse files
committed
ByteBuffer/Bits options for JavaScript; adds JSHashMap (preliminary)
1 parent e9c9ea1 commit 7b75ea8

File tree

12 files changed

+733
-21
lines changed

12 files changed

+733
-21
lines changed
3.59 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191126232346
1+
20191130151509
3.59 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191126232346
1+
20191130151509
3.59 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/nio/Bits.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,4 +819,53 @@ public static ByteOrder byteOrder() {
819819
// static native void copyToLongArray(long srcAddr, Object dst, long dstPos,
820820
// long length);
821821

822+
static int[] _ia = new int[0];
823+
static short[] _ha = new short[0];
824+
static float[] _fa = new float[0];
825+
static double[] _da = new double[0];
826+
827+
public static int[] _toInt32(byte[] b) {
828+
/**
829+
* @j2sNative
830+
*
831+
* return Clazz.array(new Int32Array(b.buffer), C$._ia);
832+
*/
833+
{
834+
return null;
835+
}
836+
}
837+
838+
public static short[] _toInt16(byte[] b) {
839+
/**
840+
* @j2sNative
841+
*
842+
* return Clazz.array(new Int16Array(b.buffer), C$._ha);
843+
*/
844+
{
845+
return null;
846+
}
847+
}
848+
849+
public static float[] _toFloat32(byte[] b) {
850+
/**
851+
* @j2sNative
852+
*
853+
* return Clazz.array(new Float32Array(b.buffer), C$._fa);
854+
*/
855+
{
856+
return null;
857+
}
858+
}
859+
860+
public static double[] _toFloat64(byte[] b) {
861+
/**
862+
* @j2sNative
863+
*
864+
* return Clazz.array(new Float64Array(b.buffer), C$._da);
865+
*/
866+
{
867+
return null;
868+
}
869+
}
870+
822871
}

sources/net.sf.j2s.java.core/src/java/nio/ByteBuffer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,5 @@ public final ByteBuffer order(ByteOrder bo) {
10441044
public abstract byte _get(int i); // package-private SwingJS -- NOT
10451045
public abstract void _put(int i, byte b); // package-private SwingJS -- NOT
10461046

1047-
// #BIN
1048-
//
1049-
// Binary-data access methods for short, char, int, long, float,
1050-
// and double will be inserted here
1051-
1047+
10521048
}

sources/net.sf.j2s.java.core/src/java/util/HashMap.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public HashMap(Map<? extends K, ? extends V> m) {
498498
* @param evict false when initially constructing this map, else
499499
* true (relayed to method afterNodeInsertion).
500500
*/
501-
final void putMapEntries(Map<? extends K, ? extends V> m, boolean evict) {
501+
void putMapEntries(Map<? extends K, ? extends V> m, boolean evict) {
502502
int s = m.size();
503503
if (s > 0) {
504504
if (table == null) { // pre-size
@@ -623,7 +623,7 @@ public V put(K key, V value) {
623623
* @param evict if false, the table is in creation mode.
624624
* @return previous value, or null if none
625625
*/
626-
final V putVal(int hash, K key, V value, boolean onlyIfAbsent,
626+
V putVal(int hash, K key, V value, boolean onlyIfAbsent,
627627
boolean evict) {
628628
Node<K,V>[] tab; Node<K,V> p; int n, i;
629629
if ((tab = table) == null || (n = tab.length) == 0)
@@ -1437,7 +1437,7 @@ final Node<K,V> nextNode() {
14371437
return e;
14381438
}
14391439

1440-
public final void remove() {
1440+
public void remove() {
14411441
Node<K,V> p = current;
14421442
if (p == null)
14431443
throw new IllegalStateException();

0 commit comments

Comments
 (0)