String script = argument[0].evaluateAsString(context).toString();
return evaluateJsFunction(script, context);
} else if (localName.equals("call")) {
ValueRepresentation itemVal = (ValueRepresentation)argument[0].evaluateItem(context);
JavaScriptObject target = (JavaScriptObject)convertToJavaScript(itemVal);
if (target != null) {
String method = argument[1].evaluateAsString(context).toString();
JavaScriptObject jsArgs = jsArray(argument.length - 2);
for (int i=2; i<argument.length; i++) {
ValueRepresentation val = SequenceExtent.makeSequenceExtent(argument[i].iterate(context));
jsSetArrayItem(jsArgs, i-2, convertToJavaScript(val));
}
// Issue: if following throws an exception - GWT doesn't always allow it to be caught - it's rethrown
// as a GWT unhandled exception
try {
JavaScriptObject jsObj = jsCall(target, method, jsArgs);
Object result = getValueFromTypeValuePair(jsObj);
return convertFromJavaScript(result, context.getConfiguration());
} catch(Exception e) {
boolean doRetry = false;
// try again setting any null values to zero-length arrays
for (int i = 0; i < argument.length - 2; i++) {
if (jsGetArrayItem(jsArgs, i) == null) {
jsSetArrayItem(jsArgs, i, jsArray(0));
doRetry = true;
}
}
if (doRetry) {
try {
Object result = getValueFromTypeValuePair(jsCall(target, method, jsArgs));
return convertFromJavaScript(result, context.getConfiguration());
} catch(Exception e2) {}
}
// if we get this far then throw exception - recovery failed
throw(new XPathException("JavaScriptException in ixsl:call(): Object does not support property or method '" +
method + "' with " + (argument.length - 2) + " argument(s)."));
}
} else {
throw(new XPathException("JavaScriptException in ixsl:call(): Call target object is null or undefined"));
}
} else if (localName.equals("get")) {
ValueRepresentation itemVal = (ValueRepresentation)argument[0].evaluateItem(context);
JavaScriptObject target = (JavaScriptObject)convertToJavaScript(itemVal);
if (target != null) {
String property = argument[1].evaluateAsString(context).toString();
Object result;
try {
result = getValueFromTypeValuePair(jsSplitPropertyTypeAndValue(target, property));