ESRequestData has been renamed to ESMapWrapper.
Passing an instance of java.util.Map as argument to the invokeDirectFunction method will cause it to get wrapped in an ESMapWrapper, which exposes the elements in the Map in native JavaScript Object fashion.
This commit is contained in:
parent
1f3a94c7be
commit
23b3b8055b
1 changed files with 11 additions and 5 deletions
|
@ -46,10 +46,11 @@ public class RequestEvaluator implements Runnable {
|
||||||
Object result;
|
Object result;
|
||||||
Exception exception;
|
Exception exception;
|
||||||
protected ArrayPrototype reqPath;
|
protected ArrayPrototype reqPath;
|
||||||
private ESRequestData reqData;
|
private ESMapWrapper reqData;
|
||||||
|
|
||||||
// vars for FESI EcmaScript support
|
// vars for FESI EcmaScript support
|
||||||
public Evaluator evaluator;
|
public Evaluator evaluator;
|
||||||
|
public ObjectPrototype esObjectPrototype;
|
||||||
public ObjectPrototype esNodePrototype;
|
public ObjectPrototype esNodePrototype;
|
||||||
public ObjectPrototype esUserPrototype;
|
public ObjectPrototype esUserPrototype;
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
appnode = new ESAppNode (app.appnode, this);
|
appnode = new ESAppNode (app.appnode, this);
|
||||||
global.putHiddenProperty ("app", appnode);
|
global.putHiddenProperty ("app", appnode);
|
||||||
reqPath = new ArrayPrototype (evaluator.getArrayPrototype(), evaluator);
|
reqPath = new ArrayPrototype (evaluator.getArrayPrototype(), evaluator);
|
||||||
reqData = new ESRequestData (this);
|
reqData = new ESMapWrapper (this);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Cannot initialize interpreter");
|
System.err.println("Cannot initialize interpreter");
|
||||||
|
@ -199,7 +200,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
global.putHiddenProperty ("path", reqPath);
|
global.putHiddenProperty ("path", reqPath);
|
||||||
global.putHiddenProperty ("app", appnode);
|
global.putHiddenProperty ("app", appnode);
|
||||||
// set and mount the request data object
|
// set and mount the request data object
|
||||||
reqData.setData (req.getReqData());
|
reqData.setData (req.getRequestData());
|
||||||
req.data = reqData;
|
req.data = reqData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -662,7 +663,12 @@ public class RequestEvaluator implements Runnable {
|
||||||
eso = getElementWrapper (obj);
|
eso = getElementWrapper (obj);
|
||||||
ESValue[] esv = args == null ? new ESValue[0] : new ESValue[args.length];
|
ESValue[] esv = args == null ? new ESValue[0] : new ESValue[args.length];
|
||||||
for (int i=0; i<esv.length; i++)
|
for (int i=0; i<esv.length; i++)
|
||||||
esv[i] = ESLoader.normalizeValue (args[i], evaluator);
|
// for java.util.Map objects, we use the special "tight" wrapper
|
||||||
|
// that makes the Map look like a native object
|
||||||
|
if (args[i] instanceof Map)
|
||||||
|
esv[i] = new ESMapWrapper (this, (Map) args[i]);
|
||||||
|
else
|
||||||
|
esv[i] = ESLoader.normalizeValue (args[i], evaluator);
|
||||||
ESValue retval = eso.doIndirectCall (evaluator, eso, functionName, esv);
|
ESValue retval = eso.doIndirectCall (evaluator, eso, functionName, esv);
|
||||||
return retval == null ? null : retval.toJavaObject ();
|
return retval == null ? null : retval.toJavaObject ();
|
||||||
}
|
}
|
||||||
|
@ -899,7 +905,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
ObjectPrototype op = getPrototype (prototypeName);
|
ObjectPrototype op = getPrototype (prototypeName);
|
||||||
|
|
||||||
if (op == null)
|
if (op == null)
|
||||||
op = esNodePrototype;
|
op = esObjectPrototype;
|
||||||
|
|
||||||
return new ESGenericObject (op, evaluator, e);
|
return new ESGenericObject (op, evaluator, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue