From dcf63357f755b4bb69c1e6ea68f37647ce134459 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 12 Jan 2006 16:01:11 +0000 Subject: [PATCH] * Simplify getValidPrototype() and hasFunction() a bit. * No need to catch exceptions in hasFunction(). --- src/helma/scripting/rhino/RhinoCore.java | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java index be864b46..0731b7ad 100644 --- a/src/helma/scripting/rhino/RhinoCore.java +++ b/src/helma/scripting/rhino/RhinoCore.java @@ -382,10 +382,13 @@ public final class RhinoCore implements ScopeProvider { throw new EvaluatorException(globalError); } TypeInfo type = getPrototypeInfo(protoName); - if (type != null && type.hasError()) { - throw new EvaluatorException(type.getError()); + if (type != null) { + if (type.hasError()) { + throw new EvaluatorException(type.getError()); + } + return type.objProto; } - return type == null ? null : type.objProto; + return null; } /** @@ -458,27 +461,15 @@ public final class RhinoCore implements ScopeProvider { * is a java object) with that name. */ public boolean hasFunction(String protoname, String fname) { - // System.err.println ("HAS_FUNC: "+fname); // throws EvaluatorException if type has a syntax error Scriptable op = getValidPrototype(protoname); - try { - // if this is an untyped object return false - if (op == null) { - return false; - } - - Object func = ScriptableObject.getProperty(op, fname); - - if ((func != null) && func instanceof Function) { - return true; - } - } catch (Exception esx) { - // System.err.println ("Error in hasFunction: "+esx); + // if this is an untyped object return false + if (op == null) { return false; } - return false; + return ScriptableObject.getProperty(op, fname) instanceof Function; } /**