Skip to content

Commit

Permalink
Change some of the natives to not expect null slots.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbebenita committed Dec 9, 2014
1 parent 3440fcb commit 2b5bf72
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion midp/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Native.create("com/nokia/mid/s40/codec/DataEncoder.put.(ILjava/lang/String;Ljava
this.encoder.put(tag, util.fromJavaString(name), util.fromJavaString(value));
});

Native.create("com/nokia/mid/s40/codec/DataEncoder.put.(ILjava/lang/String;J)V", function(tag, name, value, _) {
Native.create("com/nokia/mid/s40/codec/DataEncoder.put.(ILjava/lang/String;J)V", function(tag, name, value) {
this.encoder.put(tag, util.fromJavaString(name), value.toNumber());
});

Expand Down
2 changes: 1 addition & 1 deletion midp/device_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

Native.create("com/nokia/mid/ui/DeviceControl.startVibra.(IJ)V", function(freq, longDuration, _) {
Native.create("com/nokia/mid/ui/DeviceControl.startVibra.(IJ)V", function(freq, longDuration) {
// If method is called during a previously called vibration that has been
// activated from this method, the previous vibration is stopped and the new
// one is activated using the new set of parameters.
Expand Down
6 changes: 3 additions & 3 deletions midp/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ Native.create("com/ibm/oti/connection/file/Connection.renameImpl.([B[B)V", funct
});
}, true);

Native.create("com/ibm/oti/connection/file/Connection.truncateImpl.([BJ)V", function(path, newLength, _) {
Native.create("com/ibm/oti/connection/file/Connection.truncateImpl.([BJ)V", function(path, newLength) {
return new Promise(function(resolve, reject) {
fs.open(util.decodeUtf8(path), function(fd) {
if (fd == -1) {
Expand All @@ -450,7 +450,7 @@ Native.create("com/ibm/oti/connection/file/FCInputStream.availableImpl.(I)I", fu
return fs.getsize(fd) - fs.getpos(fd);
});

Native.create("com/ibm/oti/connection/file/FCInputStream.skipImpl.(JI)J", function(count, _, fd) {
Native.create("com/ibm/oti/connection/file/FCInputStream.skipImpl.(JI)J", function(count, fd) {
var curpos = fs.getpos(fd);
var size = fs.getsize(fd);
if (curpos + count.toNumber() > size) {
Expand Down Expand Up @@ -522,7 +522,7 @@ Native.create("com/ibm/oti/connection/file/FCOutputStream.openImpl.([B)I", funct
});
}, true);

Native.create("com/ibm/oti/connection/file/FCOutputStream.openOffsetImpl.([BJ)I", function(jPath, offset, _) {
Native.create("com/ibm/oti/connection/file/FCOutputStream.openOffsetImpl.([BJ)I", function(jPath, offset) {
var path = util.decodeUtf8(jPath);

return new Promise(function(resolve, reject) {
Expand Down
2 changes: 1 addition & 1 deletion midp/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ Native.create("com/sun/mmedia/MediaDownload.nNeedMoreDataImmediatelly.(I)Z", fun
return true;
});

Native.create("com/sun/mmedia/MediaDownload.nSetWholeContentSize.(IJ)V", function(handle, contentSize, _) {
Native.create("com/sun/mmedia/MediaDownload.nSetWholeContentSize.(IJ)V", function(handle, contentSize) {
var player = Media.PlayerCache[handle];
player.wholeContentSize = contentSize.toNumber();
});
Expand Down
4 changes: 2 additions & 2 deletions midp/midp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ MIDP.ConnectionRegistry = {
}
};
Native.create("com/sun/midp/io/j2me/push/ConnectionRegistry.poll0.(J)I", function(time, _) {
Native.create("com/sun/midp/io/j2me/push/ConnectionRegistry.poll0.(J)I", function(time) {
return new Promise(function(resolve, reject) {
MIDP.ConnectionRegistry.waitForRegistration(function(id) {
resolve(id);
Expand All @@ -1186,7 +1186,7 @@ Native.create("com/sun/midp/io/j2me/push/ConnectionRegistry.add0.(Ljava/lang/Str
return 0;
});

Native.create("com/sun/midp/io/j2me/push/ConnectionRegistry.addAlarm0.([BJ)J", function(jMidlet, jTime, _) {
Native.create("com/sun/midp/io/j2me/push/ConnectionRegistry.addAlarm0.([BJ)J", function(jMidlet, jTime) {
var time = jTime.toNumber(), midlet = util.decodeUtf8(jMidlet);

var lastAlarm = 0;
Expand Down
30 changes: 15 additions & 15 deletions native.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Native.create("java/lang/Object.hashCode.()I", function() {
return hashCode;
});

Native.create("java/lang/Object.wait.(J)V", function(timeout, _, ctx) {
Native.create("java/lang/Object.wait.(J)V", function(timeout, ctx) {
ctx.wait(this, timeout.toNumber());
});

Expand Down Expand Up @@ -371,7 +371,7 @@ Native.create("java/lang/Float.floatToIntBits.(F)I", (function() {
Native.create("java/lang/Double.doubleToLongBits.(D)J", (function() {
var da = new Float64Array(1);
var ia = new Int32Array(da.buffer);
return function(val, _) {
return function(val) {
da[0] = val;
return Long.fromBits(ia[0], ia[1]);
}
Expand All @@ -389,7 +389,7 @@ Native.create("java/lang/Float.intBitsToFloat.(I)F", (function() {
Native.create("java/lang/Double.longBitsToDouble.(J)D", (function() {
var da = new Float64Array(1);
var ia = new Int32Array(da.buffer);
return function(l, _) {
return function(l) {
ia[0] = l.low_;
ia[1] = l.high_;
return da[0];
Expand Down Expand Up @@ -442,47 +442,47 @@ Native.create("java/lang/Runtime.totalMemory.()J", function() {
Native.create("java/lang/Runtime.gc.()V", function() {
});
Native.create("java/lang/Math.floor.(D)D", function(val, _) {
Native.create("java/lang/Math.floor.(D)D", function(val) {
return Math.floor(val);
});
Native.create("java/lang/Math.asin.(D)D", function(val, _) {
Native.create("java/lang/Math.asin.(D)D", function(val) {
return Math.asin(val);
});
Native.create("java/lang/Math.acos.(D)D", function(val, _) {
Native.create("java/lang/Math.acos.(D)D", function(val) {
return Math.acos(val);
});
Native.create("java/lang/Math.atan.(D)D", function(val, _) {
Native.create("java/lang/Math.atan.(D)D", function(val) {
return Math.atan(val);
});
Native.create("java/lang/Math.atan2.(DD)D", function(x, _1, y, _2) {
Native.create("java/lang/Math.atan2.(DD)D", function(x, y) {
return Math.atan2(x, y);
});
Native.create("java/lang/Math.sin.(D)D", function(val, _) {
Native.create("java/lang/Math.sin.(D)D", function(val) {
return Math.sin(val);
});
Native.create("java/lang/Math.cos.(D)D", function(val, _) {
Native.create("java/lang/Math.cos.(D)D", function(val) {
return Math.cos(val);
});
Native.create("java/lang/Math.tan.(D)D", function(val, _) {
Native.create("java/lang/Math.tan.(D)D", function(val) {
return Math.tan(val);
});
Native.create("java/lang/Math.sqrt.(D)D", function(val, _) {
Native.create("java/lang/Math.sqrt.(D)D", function(val) {
return Math.sqrt(val);
});
Native.create("java/lang/Math.ceil.(D)D", function(val, _) {
Native.create("java/lang/Math.ceil.(D)D", function(val) {
return Math.ceil(val);
});
Native.create("java/lang/Math.floor.(D)D", function(val, _) {
Native.create("java/lang/Math.floor.(D)D", function(val) {
return Math.floor(val);
});
Expand Down Expand Up @@ -547,7 +547,7 @@ Native.create("java/lang/Thread.isAlive.()Z", function() {
return !!this.alive;
});
Native.create("java/lang/Thread.sleep.(J)V", function(delay, _) {
Native.create("java/lang/Thread.sleep.(J)V", function(delay) {
return new Promise(function(resolve, reject) {
window.setTimeout(resolve, delay.toNumber());
})
Expand Down
2 changes: 1 addition & 1 deletion override.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Override.create("java/io/ByteArrayInputStream.read.([BII)I", function(b, off, le
return len;
});

Override.create("java/io/ByteArrayInputStream.skip.(J)J", function(long, _) {
Override.create("java/io/ByteArrayInputStream.skip.(J)J", function(long) {
var n = long.toNumber();

if (this.pos + n > this.count) {
Expand Down
6 changes: 3 additions & 3 deletions string.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Override.create("java/lang/String.valueOf.(I)Ljava/lang/String;", function(n) {
return n.toString();
});

Override.create("java/lang/String.valueOf.(J)Ljava/lang/String;", function(n, _) {
Override.create("java/lang/String.valueOf.(J)Ljava/lang/String;", function(n) {
// This function takes a dummy second argument, since we're taking a
// Long and need to pop two items off the stack.
return n.toString();
Expand Down Expand Up @@ -498,7 +498,7 @@ Override.create("java/lang/StringBuffer.append.(I)Ljava/lang/StringBuffer;", fun
return stringBufferAppend.call(this, n + "");
});

Override.create("java/lang/StringBuffer.append.(J)Ljava/lang/StringBuffer;", function(n, _) {
Override.create("java/lang/StringBuffer.append.(J)Ljava/lang/StringBuffer;", function(n) {
return stringBufferAppend.call(this, n + "");
});

Expand Down Expand Up @@ -595,7 +595,7 @@ Override.create("java/lang/StringBuffer.insert.(II)Ljava/lang/StringBuffer;", fu
return stringBufferInsert.call(this, offset, n + "");
});

Override.create("java/lang/StringBuffer.insert.(IJ)Ljava/lang/StringBuffer;", function(offset, n, _) {
Override.create("java/lang/StringBuffer.insert.(IJ)Ljava/lang/StringBuffer;", function(offset, n) {
return stringBufferInsert.call(this, offset, n + "");
});

Expand Down
4 changes: 2 additions & 2 deletions tests/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Native.create("gnu/testlet/vm/NativeTest.getInt.()I", function() {
return 0xFFFFFFFF;
});

Native.create("gnu/testlet/vm/NativeTest.getLongReturnLong.(J)J", function(val, _) {
Native.create("gnu/testlet/vm/NativeTest.getLongReturnLong.(J)J", function(val) {
return Long.fromNumber(40 + val.toNumber());
});

Native.create("gnu/testlet/vm/NativeTest.getLongReturnInt.(J)I", function(val, _) {
Native.create("gnu/testlet/vm/NativeTest.getLongReturnInt.(J)I", function(val) {
return 40 + val.toNumber();
});

Expand Down

0 comments on commit 2b5bf72

Please sign in to comment.