throw new UnsupportedOperationException("loadModule must not be called");
}
public Value makeValueFromJsval(Context jsContext, Object value) {
if (value == Undefined.instance) {
return new Value();
}
if (value instanceof JavaObject) {
Value returnVal = new Value();
int refId = ((JavaObject) value).getRefId();
returnVal.setJavaObject(new JavaObjectRef(refId));
return returnVal;
}
if (value instanceof Scriptable) {
if (value instanceof ScriptableObject) {
/*
* HACK: check for native types like NativeString. NativeString is
* package-protected. What other types do we need to check?
*/
ScriptableObject scriptableValue = (ScriptableObject) value;
String className = scriptableValue.getClassName();
if (className.equals("String")) {
return new Value(scriptableValue.toString());
}
}
Integer refId = jsObjectToRef.get(value);
if (refId == null) {
refId = nextRefId++;
jsObjectToRef.put((Scriptable) value, refId);
refToJsObject.put(refId, (Scriptable) value);
}
Value returnVal = new Value();
returnVal.setJsObject(new JsObjectRef(refId));
return returnVal;
}
return new Value(value);
}