This commit is contained in:
nboyd%atg.com 2000-08-21 15:56:15 +00:00
Родитель d55dd0cde5
Коммит c1c435731a
2 изменённых файлов: 36 добавлений и 30 удалений

Просмотреть файл

@ -288,18 +288,22 @@ public class JavaAdapter extends ScriptableObject {
public static Object callMethod(Scriptable object, String methodId, public static Object callMethod(Scriptable object, String methodId,
Object[] args) Object[] args)
{ {
if (object.has(methodId, object)) { try {
try { Context cx = Context.enter();
Context cx = Context.enter(); Object fun = ScriptableObject.getProperty(object,methodId);
Object fun = object.get(methodId, object); if (fun == Scriptable.NOT_FOUND) {
return ScriptRuntime.call(cx, fun, object, args, object); // It is an error that this function doesn't exist.
} catch (JavaScriptException ex) { // Easiest thing to do is just pass the undefined value
// TODO: could occur // along and ScriptRuntime will take care of reporting
} finally { // the error.
Context.exit(); fun = Undefined.instance;
} }
} return ScriptRuntime.call(cx, fun, object, args, object);
return Context.getUndefinedValue(); } catch (JavaScriptException ex) {
throw WrappedException.wrapException(ex);
} finally {
Context.exit();
}
} }
public static Scriptable toObject(Object value, Scriptable scope, public static Scriptable toObject(Object value, Scriptable scope,
@ -609,12 +613,11 @@ public class JavaAdapter extends ScriptableObject {
"Ljava/lang/String;[Ljava/lang/Object;)", "Ljava/lang/String;[Ljava/lang/Object;)",
"Ljava/lang/Object;"); "Ljava/lang/Object;");
Class retType = returnType; if (returnType.equals(Void.TYPE)) {
if (retType.equals(Void.TYPE)) {
cfw.add(ByteCode.POP); cfw.add(ByteCode.POP);
cfw.add(ByteCode.RETURN); cfw.add(ByteCode.RETURN);
} else { } else {
generateReturnResult(cfw, retType); generateReturnResult(cfw, returnType);
} }
cfw.stopMethod((short)(scopeLocal + 1), null); cfw.stopMethod((short)(scopeLocal + 1), null);
} }

Просмотреть файл

@ -288,18 +288,22 @@ public class JavaAdapter extends ScriptableObject {
public static Object callMethod(Scriptable object, String methodId, public static Object callMethod(Scriptable object, String methodId,
Object[] args) Object[] args)
{ {
if (object.has(methodId, object)) { try {
try { Context cx = Context.enter();
Context cx = Context.enter(); Object fun = ScriptableObject.getProperty(object,methodId);
Object fun = object.get(methodId, object); if (fun == Scriptable.NOT_FOUND) {
return ScriptRuntime.call(cx, fun, object, args, object); // It is an error that this function doesn't exist.
} catch (JavaScriptException ex) { // Easiest thing to do is just pass the undefined value
// TODO: could occur // along and ScriptRuntime will take care of reporting
} finally { // the error.
Context.exit(); fun = Undefined.instance;
} }
} return ScriptRuntime.call(cx, fun, object, args, object);
return Context.getUndefinedValue(); } catch (JavaScriptException ex) {
throw WrappedException.wrapException(ex);
} finally {
Context.exit();
}
} }
public static Scriptable toObject(Object value, Scriptable scope, public static Scriptable toObject(Object value, Scriptable scope,
@ -609,12 +613,11 @@ public class JavaAdapter extends ScriptableObject {
"Ljava/lang/String;[Ljava/lang/Object;)", "Ljava/lang/String;[Ljava/lang/Object;)",
"Ljava/lang/Object;"); "Ljava/lang/Object;");
Class retType = returnType; if (returnType.equals(Void.TYPE)) {
if (retType.equals(Void.TYPE)) {
cfw.add(ByteCode.POP); cfw.add(ByteCode.POP);
cfw.add(ByteCode.RETURN); cfw.add(ByteCode.RETURN);
} else { } else {
generateReturnResult(cfw, retType); generateReturnResult(cfw, returnType);
} }
cfw.stopMethod((short)(scopeLocal + 1), null); cfw.stopMethod((short)(scopeLocal + 1), null);
} }