You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2009/08/06 07:33:28 UTC

svn commit: r801512 - in /xmlgraphics/batik/trunk: ./ sources/org/apache/batik/bridge/ sources/org/apache/batik/script/ sources/org/apache/batik/script/jacl/ sources/org/apache/batik/script/jpython/ sources/org/apache/batik/script/rhino/

Author: cam
Date: Thu Aug  6 05:33:28 2009
New Revision: 801512

URL: http://svn.apache.org/viewvc?rev=801512&view=rev
Log:
Use the same script interpreter instance for all four JavaScript MIME types
that are supported.  Otherwise, script fragments in the same document using
different types are executed in separated script environments.

Modified:
    xmlgraphics/batik/trunk/CHANGES
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BridgeContext.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/Interpreter.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreter.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreter.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java

Modified: xmlgraphics/batik/trunk/CHANGES
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/CHANGES?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/CHANGES (original)
+++ xmlgraphics/batik/trunk/CHANGES Thu Aug  6 05:33:28 2009
@@ -52,6 +52,9 @@
   * DocumentType.getName() now returns the correct value.
   * Fixed SVGLocatable.farthestViewportElement to return null when
     called on the outermost <svg> element.
+  * JavaScript fragments using different types within the one document
+    (such as text/javascript and application/ecmascript) now share the
+    same script interpreter.
 
 1.7beta1 -> 1.7
 ---------------

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BridgeContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BridgeContext.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BridgeContext.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BridgeContext.java Thu Aug  6 05:33:28 2009
@@ -563,7 +563,10 @@
                 interpreter = interpreterPool.createInterpreter(document, 
                                                                 language,
                                                                 null);
-                interpreterMap.put(language, interpreter);
+                String[] mimeTypes = interpreter.getMimeTypes();
+                for (int i = 0; i < mimeTypes.length; i++) {
+                    interpreterMap.put(mimeTypes[i], interpreter);
+                }
             } catch (Exception e) {
                 if (userAgent != null) {
                     userAgent.displayError(e);

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/Interpreter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/Interpreter.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/Interpreter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/Interpreter.java Thu Aug  6 05:33:28 2009
@@ -32,6 +32,12 @@
 public interface Interpreter extends org.apache.batik.i18n.Localizable {
 
     /**
+     * Returns the content types of the scripting languages this interpreter
+     * handles.
+     */
+    String[] getMimeTypes();
+
+    /**
      * This method should evaluate a piece of script associated to a given 
      * description.
      *

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreter.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreter.java Thu Aug  6 05:33:28 2009
@@ -48,6 +48,14 @@
 
     // org.apache.batik.script.Intepreter implementation
 
+    /**
+     * Returns the content types of the scripting languages this interpreter
+     * handles.
+     */
+    public String[] getMimeTypes() {
+        return JaclInterpreterFactory.JACL_MIMETYPES;
+    }
+
     public Object evaluate(Reader scriptreader) throws IOException {
         return evaluate(scriptreader, "");
     }

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java Thu Aug  6 05:33:28 2009
@@ -33,7 +33,7 @@
     /**
      * The MIME types that jacl can handle.
      */
-    private static final String[] JACL_MIMETYPES = { "text/tcl" };
+    public static final String[] JACL_MIMETYPES = { "text/tcl" };
 
     /**
      * Builds a <code>JaclInterpreterFactory</code>.

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreter.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreter.java Thu Aug  6 05:33:28 2009
@@ -41,6 +41,14 @@
 
     // org.apache.batik.script.Intepreter implementation
 
+    /**
+     * Returns the content types of the scripting languages this interpreter
+     * handles.
+     */
+    public String[] getMimeTypes() {
+        return JPythonInterpreterFactory.JPYTHON_MIMETYPES;
+    }
+
     public Object evaluate(Reader scriptreader)
         throws IOException {
         return evaluate(scriptreader, "");

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java Thu Aug  6 05:33:28 2009
@@ -33,7 +33,7 @@
     /**
      * The MIME types that JPython can handle.
      */
-    private static final String[] JPYTHON_MIMETYPES =  { "text/python" };
+    public static final String[] JPYTHON_MIMETYPES =  { "text/python" };
 
     /**
      * Builds a <code>JPythonInterpreterFactory</code>.

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java Thu Aug  6 05:33:28 2009
@@ -205,6 +205,14 @@
     }
 
     /**
+     * Returns the content types of the scripting languages this interpreter
+     * handles.
+     */
+    public String[] getMimeTypes() {
+        return RhinoInterpreterFactory.RHINO_MIMETYPES;
+    }
+
+    /**
      * Returns the window object for this interpreter.
      */
     public Window getWindow() {

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java?rev=801512&r1=801511&r2=801512&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java Thu Aug  6 05:33:28 2009
@@ -37,7 +37,7 @@
     /**
      * The MIME types that Rhino can handle.
      */
-    private static final String[] RHINO_MIMETYPES = {
+    public static final String[] RHINO_MIMETYPES = {
         "application/ecmascript",
         "application/javascript",
         "text/ecmascript",