зеркало из https://github.com/mozilla/pluotsorbet.git
Override ResourceInputStream::read() and ResourceInputStream::available() instead of implementing the natives they call
This commit is contained in:
Родитель
62ec354597
Коммит
9a7e55135c
20
native.js
20
native.js
|
@ -573,13 +573,25 @@ Native["com/sun/cldc/io/ResourceInputStream.open.(Ljava/lang/String;)Ljava/lang/
|
|||
stack.push(obj);
|
||||
};
|
||||
|
||||
Native["com/sun/cldc/io/ResourceInputStream.bytesRemain.(Ljava/lang/Object;)I"] = function(ctx, stack) {
|
||||
var handle = stack.pop();
|
||||
Override["com/sun/cldc/io/ResourceInputStream.available.()I"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
var handle = _this.class.getField("fileDecoder", "Ljava/lang/Object;").get(_this);
|
||||
|
||||
if (!handle) {
|
||||
ctx.raiseExceptionAndYield("java/io/IOException");
|
||||
}
|
||||
|
||||
stack.push(handle.data.length - handle.pos);
|
||||
}
|
||||
|
||||
Native["com/sun/cldc/io/ResourceInputStream.readByte.(Ljava/lang/Object;)I"] = function(ctx, stack) {
|
||||
var handle = stack.pop();
|
||||
Override["com/sun/cldc/io/ResourceInputStream.read.()I"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
var handle = _this.class.getField("fileDecoder", "Ljava/lang/Object;").get(_this);
|
||||
|
||||
if (!handle) {
|
||||
ctx.raiseExceptionAndYield("java/io/IOException");
|
||||
}
|
||||
|
||||
stack.push((handle.data.length - handle.pos > 0) ? handle.data[handle.pos++] : -1);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче