зеркало из https://github.com/mozilla/pluotsorbet.git
move MIDP-related natives into midp.js
This commit is contained in:
Родитель
9c991cc0ba
Коммит
d8c7ca9555
117
midp.js
117
midp.js
|
@ -1248,3 +1248,120 @@ Native["javax/microedition/lcdui/game/GameCanvas.setSuppressKeyEvents.(Ljavax/mi
|
||||||
MIDP.suppressKeyEvents = suppressKeyEvents;
|
MIDP.suppressKeyEvents = suppressKeyEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Native["com/sun/midp/main/MIDletProxyList.resetForegroundInNativeState.()V"] = function(ctx, stack) {
|
||||||
|
var _this = stack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/sun/midp/main/MIDletProxyList.setForegroundInNativeState.(II)V"] = function(ctx, stack) {
|
||||||
|
var displayId = stack.pop(), isolateId = stack.pop(), _this = stack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/sun/midp/io/j2me/push/ConnectionRegistry.poll0.(J)I"] = function(ctx, stack) {
|
||||||
|
var time = stack.pop(), _this = stack.pop();
|
||||||
|
// Wait for incoming connections
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/nokia/mid/ui/gestures/GestureRegistrationManager.setListener.(Ljava/lang/Object;Lcom/nokia/mid/ui/gestures/GestureListener;)V"] = function(ctx, stack) {
|
||||||
|
var listener = stack.pop(), container = stack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/nokia/mid/ui/gestures/GestureRegistrationManager.register.(Ljava/lang/Object;Lcom/nokia/mid/ui/gestures/GestureInteractiveZone;)Z"] = function(ctx, stack) {
|
||||||
|
var gestureInteractiveZone = stack.pop(), container = stack.pop();
|
||||||
|
stack.push(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/nokia/mid/ui/gestures/GestureInteractiveZone.isSupported.(I)Z"] = function(ctx, stack) {
|
||||||
|
var gestureEventIdentity = stack.pop();
|
||||||
|
stack.push(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.isValidFilenameImpl.([B)Z"] = function(ctx, stack) {
|
||||||
|
var byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
stack.push(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.existsImpl.([B)Z"] = function(ctx, stack) {
|
||||||
|
var byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
|
||||||
|
var path = "/" + new TextDecoder().decode(byteArray);
|
||||||
|
|
||||||
|
fs.exists(path, function(exists) {
|
||||||
|
stack.push(exists ? 1 : 0);
|
||||||
|
ctx.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.fileSizeImpl.([B)J"] = function(ctx, stack) {
|
||||||
|
var byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
|
||||||
|
var path = "/" + new TextDecoder().decode(byteArray);
|
||||||
|
|
||||||
|
fs.size(path, function(size) {
|
||||||
|
stack.push2(Long.fromNumber(size));
|
||||||
|
ctx.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.isDirectoryImpl.([B)Z"] = function(ctx, stack) {
|
||||||
|
var byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
|
||||||
|
var path = "/" + new TextDecoder().decode(byteArray);
|
||||||
|
|
||||||
|
fs.list(path, function(files) {
|
||||||
|
stack.push(files ? 1 : 0);
|
||||||
|
ctx.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.listImpl.([B[BZ)[[B"] = function(ctx, stack) {
|
||||||
|
// TODO: FILTER
|
||||||
|
|
||||||
|
var includeHidden = stack.pop(), filterArray = stack.pop(), byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
|
||||||
|
var path = "/" + new TextDecoder().decode(byteArray);
|
||||||
|
|
||||||
|
var filter = "";
|
||||||
|
if (filterArray) {
|
||||||
|
filter = new TextDecoder().decode(filterArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.list(path, function(files) {
|
||||||
|
var pathsArray = CLASSES.newArray("[B", files.length);
|
||||||
|
for (var i = 0; i < files.length; i++) {
|
||||||
|
var curPath = path + files[i];
|
||||||
|
var bytesCurPath = new TextEncoder.encode(curPath);
|
||||||
|
var pathArray = CLASSES.newPrimitiveArray("B", bytesCurPath.byteLength);
|
||||||
|
for (var j = 0; j < bytesCurPath.byteLength; j++) {
|
||||||
|
pathArray[j] = bytesCurPath[j];
|
||||||
|
}
|
||||||
|
pathsArray[i] = pathArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.push(pathsArray);
|
||||||
|
ctx.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
Native["com/ibm/oti/connection/file/Connection.mkdirImpl.([B)I"] = function(ctx, stack) {
|
||||||
|
var byteArray = stack.pop(), _this = stack.pop();
|
||||||
|
|
||||||
|
var path = "/" + new TextDecoder().decode(byteArray);
|
||||||
|
|
||||||
|
// IBM's implementation returns different error numbers, we don't care
|
||||||
|
|
||||||
|
fs.mkdir(path, function(created) {
|
||||||
|
stack.push(created ? 0 : 42);
|
||||||
|
ctx.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
throw VM.Pause;
|
||||||
|
}
|
||||||
|
|
117
native.js
117
native.js
|
@ -504,20 +504,6 @@ Native["com/sun/cldc/i18n/uclc/DefaultCaseConverter.toUpperCase.(C)C"] = functio
|
||||||
stack.push(String.fromCharCode(stack.pop()).toUpperCase().charCodeAt(0));
|
stack.push(String.fromCharCode(stack.pop()).toUpperCase().charCodeAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletProxyList.resetForegroundInNativeState.()V"] = function(ctx, stack) {
|
|
||||||
var _this = stack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletProxyList.setForegroundInNativeState.(II)V"] = function(ctx, stack) {
|
|
||||||
var displayId = stack.pop(), isolateId = stack.pop(), _this = stack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/sun/midp/io/j2me/push/ConnectionRegistry.poll0.(J)I"] = function(ctx, stack) {
|
|
||||||
var time = stack.pop(), _this = stack.pop();
|
|
||||||
// Wait for incoming connections
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["java/lang/ref/WeakReference.initializeWeakReference.(Ljava/lang/Object;)V"] = function(ctx, stack) {
|
Native["java/lang/ref/WeakReference.initializeWeakReference.(Ljava/lang/Object;)V"] = function(ctx, stack) {
|
||||||
var target = stack.pop(), _this = stack.pop();
|
var target = stack.pop(), _this = stack.pop();
|
||||||
_this.target = target;
|
_this.target = target;
|
||||||
|
@ -534,106 +520,3 @@ Native["java/lang/ref/WeakReference.clear.()V"] = function(ctx, stack) {
|
||||||
_this.target = null;
|
_this.target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Native["com/nokia/mid/ui/gestures/GestureRegistrationManager.setListener.(Ljava/lang/Object;Lcom/nokia/mid/ui/gestures/GestureListener;)V"] = function(ctx, stack) {
|
|
||||||
var listener = stack.pop(), container = stack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/nokia/mid/ui/gestures/GestureRegistrationManager.register.(Ljava/lang/Object;Lcom/nokia/mid/ui/gestures/GestureInteractiveZone;)Z"] = function(ctx, stack) {
|
|
||||||
var gestureInteractiveZone = stack.pop(), container = stack.pop();
|
|
||||||
stack.push(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/nokia/mid/ui/gestures/GestureInteractiveZone.isSupported.(I)Z"] = function(ctx, stack) {
|
|
||||||
var gestureEventIdentity = stack.pop();
|
|
||||||
stack.push(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.isValidFilenameImpl.([B)Z"] = function(ctx, stack) {
|
|
||||||
var byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
stack.push(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.existsImpl.([B)Z"] = function(ctx, stack) {
|
|
||||||
var byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
|
|
||||||
var path = "/" + new TextDecoder().decode(byteArray);
|
|
||||||
|
|
||||||
fs.exists(path, function(exists) {
|
|
||||||
stack.push(exists ? 1 : 0);
|
|
||||||
ctx.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.fileSizeImpl.([B)J"] = function(ctx, stack) {
|
|
||||||
var byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
|
|
||||||
var path = "/" + new TextDecoder().decode(byteArray);
|
|
||||||
|
|
||||||
fs.size(path, function(size) {
|
|
||||||
stack.push2(Long.fromNumber(size));
|
|
||||||
ctx.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.isDirectoryImpl.([B)Z"] = function(ctx, stack) {
|
|
||||||
var byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
|
|
||||||
var path = "/" + new TextDecoder().decode(byteArray);
|
|
||||||
|
|
||||||
fs.list(path, function(files) {
|
|
||||||
stack.push(files ? 1 : 0);
|
|
||||||
ctx.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.listImpl.([B[BZ)[[B"] = function(ctx, stack) {
|
|
||||||
// TODO: FILTER
|
|
||||||
|
|
||||||
var includeHidden = stack.pop(), filterArray = stack.pop(), byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
|
|
||||||
var path = "/" + new TextDecoder().decode(byteArray);
|
|
||||||
|
|
||||||
var filter = "";
|
|
||||||
if (filterArray) {
|
|
||||||
filter = new TextDecoder().decode(filterArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.list(path, function(files) {
|
|
||||||
var pathsArray = CLASSES.newArray("[B", files.length);
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
var curPath = path + files[i];
|
|
||||||
var bytesCurPath = new TextEncoder.encode(curPath);
|
|
||||||
var pathArray = CLASSES.newPrimitiveArray("B", bytesCurPath.byteLength);
|
|
||||||
for (var j = 0; j < bytesCurPath.byteLength; j++) {
|
|
||||||
pathArray[j] = bytesCurPath[j];
|
|
||||||
}
|
|
||||||
pathsArray[i] = pathArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
stack.push(pathsArray);
|
|
||||||
ctx.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
||||||
Native["com/ibm/oti/connection/file/Connection.mkdirImpl.([B)I"] = function(ctx, stack) {
|
|
||||||
var byteArray = stack.pop(), _this = stack.pop();
|
|
||||||
|
|
||||||
var path = "/" + new TextDecoder().decode(byteArray);
|
|
||||||
|
|
||||||
// IBM's implementation returns different error numbers, we don't care
|
|
||||||
|
|
||||||
fs.mkdir(path, function(created) {
|
|
||||||
stack.push(created ? 0 : 42);
|
|
||||||
ctx.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
throw VM.Pause;
|
|
||||||
}
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче