зеркало из https://github.com/mozilla/pluotsorbet.git
Implement getBoolean native
This commit is contained in:
Родитель
6fe0ae7292
Коммит
4da71d84eb
|
@ -29,9 +29,7 @@ public class DataDecoder {
|
|||
throw new RuntimeException("DataDecoder::getName(int) not implemented");
|
||||
}
|
||||
|
||||
public boolean getBoolean() throws IOException {
|
||||
throw new RuntimeException("DataDecoder::getBoolean() not implemented");
|
||||
}
|
||||
public native boolean getBoolean() throws IOException;
|
||||
|
||||
public byte[] getByteArray() throws IOException {
|
||||
throw new RuntimeException("DataDecoder::getByteArray() not implemented");
|
||||
|
|
|
@ -74,6 +74,11 @@ DataDecoder.prototype.getValue = function(tag) {
|
|||
return this.find(tag);
|
||||
}
|
||||
|
||||
DataDecoder.prototype.getNextValue = function() {
|
||||
var elem = this.data.shift();
|
||||
return (elem) ? elem.value : undefined;
|
||||
}
|
||||
|
||||
DataDecoder.prototype.getName = function() {
|
||||
return this.data[0].name;
|
||||
}
|
||||
|
@ -103,7 +108,7 @@ Native["com/nokia/mid/s40/codec/DataEncoder.put.(ILjava/lang/String;J)V"] = func
|
|||
}
|
||||
|
||||
Native["com/nokia/mid/s40/codec/DataEncoder.put.(ILjava/lang/String;Z)V"] = function(ctx, stack) {
|
||||
var value = stack.pop(), name = stack.pop(), tag = stack.pop(), _this = stack.pop();
|
||||
var value = stack.pop(), name = util.fromJavaString(stack.pop()), tag = stack.pop(), _this = stack.pop();
|
||||
_this.encoder.put(tag, name, value);
|
||||
}
|
||||
|
||||
|
@ -148,7 +153,6 @@ Native["com/nokia/mid/s40/codec/DataDecoder.getString.(I)Ljava/lang/String;"] =
|
|||
stack.push(ctx.newString(str));
|
||||
}
|
||||
|
||||
// Throw IOException if not found
|
||||
Native["com/nokia/mid/s40/codec/DataDecoder.getInteger.(I)J"] = function(ctx, stack) {
|
||||
var tag = stack.pop(), _this = stack.pop();
|
||||
var num = _this.decoder.getValue(tag);
|
||||
|
@ -158,6 +162,15 @@ Native["com/nokia/mid/s40/codec/DataDecoder.getInteger.(I)J"] = function(ctx, st
|
|||
stack.push2(Long.fromNumber(num));
|
||||
}
|
||||
|
||||
Native["com/nokia/mid/s40/codec/DataDecoder.getBoolean.()Z"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
var val = _this.decoder.getNextValue();
|
||||
if (val === undefined) {
|
||||
ctx.raiseExceptionAndYield("java/io/IOException");
|
||||
}
|
||||
stack.push(val);
|
||||
}
|
||||
|
||||
Native["com/nokia/mid/s40/codec/DataDecoder.getName.()Ljava/lang/String;"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
var name = _this.decoder.getName();
|
||||
|
|
Загрузка…
Ссылка в новой задаче