xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vha...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/script/rhino RhinoInterpreter.java
Date Tue, 18 Jun 2002 08:27:22 GMT
vhardy      2002/06/18 01:27:22

  Modified:    sources/org/apache/batik/script InterpreterPool.java
               sources/org/apache/batik/script/rhino RhinoInterpreter.java
  Log:
  Clean-up: Fixed bug #8404 and removed hard coded constants from scripting module
  
  Revision  Changes    Path
  1.13      +7 -2      xml-batik/sources/org/apache/batik/script/InterpreterPool.java
  
  Index: InterpreterPool.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/script/InterpreterPool.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- InterpreterPool.java	14 May 2002 08:57:32 -0000	1.12
  +++ InterpreterPool.java	18 Jun 2002 08:27:22 -0000	1.13
  @@ -44,6 +44,11 @@
           "org.apache.batik.script.jacl.JaclInterpreterFactory";
   
       /**
  +     * Name of the "document" object when referenced by scripts
  +     */
  +    public static final String BIND_NAME_DOCUMENT = "document";
  +
  +    /**
        * The default InterpreterFactory map.
        */
       protected static Map defaultFactories = new HashMap(7);
  @@ -102,7 +107,7 @@
                   interpreter = factory.createInterpreter
                       (((SVGOMDocument)document).getURLObject());
                   if (document != null) {
  -                    interpreter.bindObject("document", document);
  +                    interpreter.bindObject(BIND_NAME_DOCUMENT, document);
                   }
               } catch (Exception t) {
                   // may happen if the batik interpreters class is here but
  
  
  
  1.19      +24 -7     xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java
  
  Index: RhinoInterpreter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- RhinoInterpreter.java	6 Jun 2002 08:33:46 -0000	1.18
  +++ RhinoInterpreter.java	18 Jun 2002 08:27:22 -0000	1.19
  @@ -69,9 +69,26 @@
           }
       };
   
  -    // store last 32 precompiled objects.
  +    /**
  +     * store last 32 precompiled objects.
  +     */
       private static final int MAX_CACHED_SCRIPTS = 32;
   
  +    /**
  +     * Constant used to describe an SVG source
  +     */
  +    public static final String SOURCE_NAME_SVG = "<SVG>";
  +
  +    /**
  +     * Name of the "window" object when referenced by scripts
  +     */
  +    public static final String BIND_NAME_WINDOW = "window";
  +
  +    /**
  +     * Instantiate the "window" object
  +     */
  +    public static final String ECMA_WINDOW_INSTANTIATION = "window = new Window(window)";
  +
       private ScriptableObject globalObject = null;
       private LinkedList compiledScripts = new LinkedList();
       private WrapHandler wrapHandler =
  @@ -193,7 +210,7 @@
           try {
               rv = ctx.evaluateReader(globalObject,
                                       scriptreader,
  -                                    "<SVG>",
  +                                    SOURCE_NAME_SVG,
                                       1, rhinoClassLoader);
           } catch (JavaScriptException e) {
               // exception from JavaScript (possibly wrapping a Java Ex)
  @@ -258,7 +275,7 @@
                           try {
                               return ctx.compileReader(globalObject,
                                                        new StringReader(scriptstr),
  -                                                     "<SVG>",
  +                                                     SOURCE_NAME_SVG,
                                                        1, rhinoClassLoader);
                           } catch(IOException io) {
                               // Should never happen: we are using a string
  @@ -327,18 +344,18 @@
               Context.exit();
           }
   
  -        if (name.equals("window") && object instanceof Window) {
  +        if (name.equals(BIND_NAME_WINDOW) && object instanceof Window) {
               try {
                   // Defines the 'Window' class.
                   ScriptableObject.defineClass(globalObject,
                                                WindowWrapper.class);
   
                   // Wrap the given window object.
  -                evaluate(new StringReader("window = new Window(window)"));
  +                evaluate(new StringReader(ECMA_WINDOW_INSTANTIATION));
   
                   // The window becomes the global object.
                   globalObject =
  -                    (ScriptableObject)globalObject.get("window", globalObject);
  +                    (ScriptableObject)globalObject.get(BIND_NAME_WINDOW, globalObject);
               } catch (Exception e) {
                   // Cannot happen.
               }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Mime
View raw message