Author: ptw
Date: 2007-12-05 10:52:32 -0800 (Wed, 05 Dec 2007)
New Revision: 7459

Added:
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
   openlaszlo/branches/4.0.5.1/test/lpp-5088.lzx
Modified:
   openlaszlo/branches/4.0.5.1/
   openlaszlo/branches/4.0.5.1/WEB-INF/lps/schema/lzx.rnc
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/util/Tag.java
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFFile.java
   
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
Log:
Change 20071205-ptw-1 by [EMAIL PROTECTED] on 2007-12-05 13:39:29 EST
    in /Users/ptw/OpenLaszlo/4.0.5.1
    for http://svn.openlaszlo.org/openlaszlo/branches/4.0.5.1

Summary: Implement scriptlimits for SWF runtime

New Features: The canvas tag has a new attribute, swflimits which is
of type css, which can be used to override the default recursion (256)
and timeout (15s) limits.  To do so you say:
  <canvas scriptlimits="timeout: 30">
or to override both limits
  <canvas scriptlimits="recursion: 300; timeout: 30">

Bugs Fixed:
LPP-5088 'Enable scriptLimits override in Flash'

Technical Reviewer: [EMAIL PROTECTED] (message://<[EMAIL PROTECTED]>)
QA Reviewer: [EMAIL PROTECTED] (pending)
Doc Reviewer: [EMAIL PROTECTED] (pending)

Documentation:
See "New Features".  For complete example demonstration, see the test
case attached to the bug.

Details:
    Merged revisions 7413,7448 via svnmerge from 
    http://svn.openlaszlo.org/openlaszlo/trunk

    Added test/lpp-5088 to demonstrate the use of the feature

Tests:
    smokecheck, test case




Property changes on: openlaszlo/branches/4.0.5.1
___________________________________________________________________
Name: svnmerge-integrated
   - 
/openlaszlo/branches/legals:1-5746,5748-5756,5758-5770,5772-5819,5821-5860,5862-5890,5892-6065,6068-6177,6179-6228,6230-6236,6241-6266
 
/openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334
   + 
/openlaszlo/branches/legals:1-5746,5748-5756,5758-5770,5772-5819,5821-5860,5862-5890,5892-6065,6068-6177,6179-6228,6230-6236,6241-6266
 
/openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334,7413,7418,7420,7422-7425,7427-7430,7432-7436,7438-7439,7441,7443,7446-7448

Modified: openlaszlo/branches/4.0.5.1/WEB-INF/lps/schema/lzx.rnc
===================================================================
--- openlaszlo/branches/4.0.5.1/WEB-INF/lps/schema/lzx.rnc      2007-12-05 
18:45:12 UTC (rev 7458)
+++ openlaszlo/branches/4.0.5.1/WEB-INF/lps/schema/lzx.rnc      2007-12-05 
18:52:32 UTC (rev 7459)
@@ -93,6 +93,7 @@
   & toplevelElements
   & [a:defaultValue="1.1"] attribute version {string}?
   & [a:defaultValue="false"] attribute accessible {booleanLiteral}?
+  & attribute scriptlimits {css}?
 }
 
 library =

Copied: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
 (from rev 7413, 
openlaszlo/trunk/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java)

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/util/Tag.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/util/Tag.java
     2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/util/Tag.java
     2007-12-05 18:52:32 UTC (rev 7459)
@@ -124,6 +124,7 @@
     public static final int DEFINEVIDEOSTEAM     = 60; // Flash 6
     //public static final int                      = 61;
     public static final int DEFINEFONTINFO2      = 62;  // Flash 6
+    public static final int SCRIPTLIMITS         = 65;  // Flash 8
     public static final int IMPORTASSETS2        = 71;  // Flash 8
 
 
@@ -193,12 +194,12 @@
         "DefineFontInfo2",
         "Unknown",
         "Unknown",
+        "ScriptLimits",
         "Unknown",
         "Unknown",
         "Unknown",
         "Unknown",
         "Unknown",
-        "Unknown",
         "ImportAssets2"
     };
 

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
      2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
      2007-12-05 18:52:32 UTC (rev 7459)
@@ -19,6 +19,7 @@
 import org.openlaszlo.utils.*;
 import org.jdom.*;
 import org.apache.log4j.*;
+import org.openlaszlo.css.CSSParser;
 
 /** Compiler for the <code>canvas</code> element. */
 class CanvasCompiler extends ToplevelCompiler {
@@ -96,6 +97,24 @@
                 mEnv.warn(msg, element);
         }
 
+        String scriptLimits = element.getAttributeValue("scriptlimits");
+        if (scriptLimits != null) {
+          try {
+            Map properties = new CSSParser(new AttributeStream(element, 
"scriptlimits")).Parse();
+            int recursion =
+              properties.containsKey("recursion") ?
+              ((Integer)properties.get("recursion")).intValue() : 0;
+            int timeout =
+              properties.containsKey("timeout") ?
+              ((Integer)properties.get("timeout")).intValue() : 0;
+            mEnv.setScriptLimits(recursion, timeout);
+          } catch (org.openlaszlo.css.ParseException e) {
+            throw new CompilationError(e);
+          } catch (org.openlaszlo.css.TokenMgrError e) {
+            throw new CompilationError(e);
+          }
+        }
+
         if (mEnv.isSWF()) {
           String baseLibraryName = getBaseLibraryName(mEnv);
           String baseLibraryBecause = "Required for all applications";

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
      2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
      2007-12-05 18:52:32 UTC (rev 7459)
@@ -276,6 +276,12 @@
         this.mMainObjectWriter = writer;
     }
     
+    public void setScriptLimits(int recursion, int timeout) {
+        if (this.mMainObjectWriter != null) {
+            this.mMainObjectWriter.setScriptLimits(recursion, timeout);
+        }
+    }
+
     public ViewSchema getSchema() {
         return mSchema;
     }

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
        2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
        2007-12-05 18:52:32 UTC (rev 7459)
@@ -94,6 +94,9 @@
     /** Canvas Width */
     protected int mWidth = 0;
 
+    protected int mRecursionLimit   = 0;
+    protected int mExecutionTimeout = 0;
+
     /**
      * Initialize jgenerator
      */
@@ -530,5 +533,12 @@
     abstract void importFontStyle(String fileName, String face, String style,
                                   CompilationEnvironment env)
       throws FileNotFoundException, CompilationError;
+
+
+    public void setScriptLimits(int recursion, int timeout) { 
+        this.mRecursionLimit = recursion;
+        this.mExecutionTimeout = timeout;
+    }
+
 }
 

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFFile.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFFile.java
     2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFFile.java
     2007-12-05 18:52:32 UTC (rev 7459)
@@ -117,6 +117,7 @@
             Frame frame = getMainScript().getFrameAt(0);
             Shape rectShape = rectangle();
 
+
             // 1. Button moved offscreen so that it's not vis. rectangle with 
actions
             but = new Button2();
             states = ButtonRecord.HitTest;

Modified: 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
===================================================================
--- 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
   2007-12-05 18:45:12 UTC (rev 7458)
+++ 
openlaszlo/branches/4.0.5.1/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
   2007-12-05 18:52:32 UTC (rev 7459)
@@ -267,6 +267,14 @@
         SetBackgroundColor setbgc = new SetBackgroundColor(c);
         mFlashFile.getMainScript().setBackgroundColor(setbgc);
         
+        // Write scriptlimits tag if requested
+        if ((this.mRecursionLimit != 0) || (this.mExecutionTimeout != 0)) {
+          // ScriptLimits tag, to set max recursion depth and timeout
+          Frame frame = mFlashFile.getMainScript().getFrameAt(mLastFrame);
+          ScriptLimits slimit = new ScriptLimits(this.mRecursionLimit, 
this.mExecutionTimeout);
+          frame.addFlashObject(slimit);
+        }
+
         // NOTE: disable constant pool when compiling canvas constructor
         // so that build id etc... are easy for qa to pick out.
         Properties props = (Properties)mProperties.clone();
@@ -853,7 +861,7 @@
         if (mCloseCalled) {
             throw new IllegalStateException("SWFWriter.close() called twice");
         }
-        
+
         // Add font information
         addFontTable();
 

Added: openlaszlo/branches/4.0.5.1/test/lpp-5088.lzx


Property changes on: openlaszlo/branches/4.0.5.1/test/lpp-5088.lzx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to