coliver 2003/03/02 15:38:35
Modified: src/java/org/apache/cocoon/components/flow/javascript
JavaScriptInterpreter.java
Log:
register ScriptablePropertyHandler with JXPath and fixed parameter conversion
Revision Changes Path
1.21 +10 -6
xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java
Index: JavaScriptInterpreter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- JavaScriptInterpreter.java 28 Feb 2003 03:23:34 -0000 1.20
+++ JavaScriptInterpreter.java 2 Mar 2003 23:38:35 -0000 1.21
@@ -77,7 +77,10 @@
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.tools.debugger.ScopeProvider;
import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
+import org.apache.commons.jxpath.JXPathIntrospector;
+
import org.apache.excalibur.source.Source;
+
/**
* Interface with the JavaScript interpreter.
*
@@ -153,7 +156,10 @@
Context context = Context.enter();
context.setOptimizationLevel(OPTIMIZATION_LEVEL);
+ context.setGeneratingDebug(true);
// add support for Rhino objects to JXPath
+ JXPathIntrospector.registerDynamicClass(org.mozilla.javascript.Scriptable.class,
+ ScriptablePropertyHandler.class);
JXPathContextReferenceImpl.addNodePointerFactory(new
ScriptablePointerFactory());
try {
@@ -284,8 +290,8 @@
throws Exception
{
Context context = Context.enter();
- context.setGeneratingDebug(true);
context.setOptimizationLevel(OPTIMIZATION_LEVEL);
+ context.setGeneratingDebug(true);
context.setCompileFunctionsWithDynamicScope(true);
context.setErrorReporter(errorReporter);
Scriptable thrScope = null;
@@ -511,18 +517,16 @@
int size = (params != null ? params.size() : 0);
Object[] funArgs = new Object[size];
- NativeArray funArgsArray = new NativeArray(funArgs);
NativeArray parameters = new NativeArray(size);
-
if (size != 0) {
for (int i = 0; i < size; i++) {
Interpreter.Argument arg = (Interpreter.Argument)params.get(i);
- funArgs[i] = ScriptRuntime.toObject(context, thrScope, arg.value);
+ funArgs[i] = arg.value;
parameters.put(arg.name, parameters, arg.value);
}
}
-
cocoon.setParameters(parameters);
+ NativeArray funArgsArray = new NativeArray(funArgs);
Object callFunArgs[] = { fun, funArgsArray };
((Function) callFunction).call(context, thrScope, thrScope, callFunArgs);
}
@@ -563,8 +567,8 @@
}
Context context = Context.enter();
- context.setGeneratingDebug(true);
context.setOptimizationLevel(OPTIMIZATION_LEVEL);
+ context.setGeneratingDebug(true);
context.setCompileFunctionsWithDynamicScope(true);
// Obtain the JS continuation object from it, and setup the