* Simplify getValidPrototype() and hasFunction() a bit.

* No need to catch exceptions in hasFunction().
This commit is contained in:
hns 2006-01-12 16:01:11 +00:00
parent 63b6b2843d
commit dcf63357f7

View file

@ -382,10 +382,13 @@ public final class RhinoCore implements ScopeProvider {
throw new EvaluatorException(globalError);
}
TypeInfo type = getPrototypeInfo(protoName);
if (type != null && type.hasError()) {
if (type != null) {
if (type.hasError()) {
throw new EvaluatorException(type.getError());
}
return type == null ? null : type.objProto;
return 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);
return false;
}
return false;
return ScriptableObject.getProperty(op, fname) instanceof Function;
}
/**