2014-09-24 10:50:23 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Override = {};
|
|
|
|
|
2014-09-24 10:56:54 +04:00
|
|
|
Override.getKey = function(methodInfo) {
|
|
|
|
return methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
Override.hasMethod = function(methodInfo) {
|
2014-09-24 20:14:49 +04:00
|
|
|
return ("override" in methodInfo || Override.getKey(methodInfo) in Override);
|
2014-09-24 10:56:54 +04:00
|
|
|
}
|
|
|
|
|
2014-09-24 10:50:23 +04:00
|
|
|
Override.invoke = function(ctx, methodInfo) {
|
2014-09-24 11:32:43 +04:00
|
|
|
if (!methodInfo.override) {
|
|
|
|
var key = Override.getKey(methodInfo);
|
|
|
|
methodInfo.override = Override[key];
|
2014-09-24 10:50:23 +04:00
|
|
|
if (!methodInfo.override) {
|
2014-09-24 11:32:43 +04:00
|
|
|
console.error("Missing override: " + key);
|
|
|
|
ctx.raiseExceptionAndYield("java/lang/RuntimeException", key + " not found");
|
2014-09-24 10:50:23 +04:00
|
|
|
}
|
2014-09-24 11:32:43 +04:00
|
|
|
}
|
|
|
|
methodInfo.override.call(null, ctx, ctx.current().stack);
|
2014-09-24 10:50:23 +04:00
|
|
|
}
|
2014-09-24 12:10:39 +04:00
|
|
|
|
|
|
|
Override["com/ibm/oti/connection/file/Connection.decode.(Ljava/lang/String;)Ljava/lang/String;"] = function(ctx, stack) {
|
2014-09-24 23:55:17 +04:00
|
|
|
var string = util.fromJavaString(stack.pop());
|
|
|
|
stack.push(ctx.newString(decodeURIComponent(string)));
|
|
|
|
}
|
|
|
|
|
|
|
|
Override["com/ibm/oti/connection/file/Connection.encode.(Ljava/lang/String;)Ljava/lang/String;"] = function(ctx, stack) {
|
|
|
|
var string = util.fromJavaString(stack.pop());
|
2014-09-25 04:44:06 +04:00
|
|
|
stack.push(ctx.newString(string.replace(/[^a-zA-Z0-9-_\.!~\*\\'()/:]/g, encodeURIComponent)));
|
2014-09-24 12:10:39 +04:00
|
|
|
}
|
2014-09-25 23:14:32 +04:00
|
|
|
|
|
|
|
Override["java/lang/Math.min.(II)I"] = function(ctx, stack) {
|
|
|
|
var b = stack.pop(), a = stack.pop();
|
|
|
|
stack.push(a <= b ? a : b);
|
|
|
|
}
|