[Laszlo-checkins] r11895 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler

hqm@openlaszlo.org hqm at openlaszlo.org
Wed Nov 26 05:58:04 PST 2008


Author: hqm
Date: 2008-11-26 05:57:59 -0800 (Wed, 26 Nov 2008)
New Revision: 11895

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
Log:
Change 20081125-hqm-x by hqm at badtzmaru.home on 2008-11-25 22:44:53 EST
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: fix for "Including the <debug/> tag defers the initialization of the debug console window"

New Features:

Bugs Fixed: LPP-7394

Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    
+ make special case for compiling <debug> tag, emit javascript to create the window
immediately rather than queueing for instantation on the canvas.

This turned out to be messy because there was no clean API for getting
a hold of the potentially anonymous <debug> window classname from the NodeModel,
so I ended up inlining code out of ViewCompiler. Not so clean...

Tests:

test from bug report works




Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java	2008-11-26 09:00:08 UTC (rev 11894)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java	2008-11-26 13:57:59 UTC (rev 11895)
@@ -56,6 +56,7 @@
     // Flag used internally, to mark whether the user instantiated a <debug>
     // tag manually. If they didn't, we need to add a call to instantiate one.
     public static final String USER_DEBUG_WINDOW     = "userdebugwindow";
+    public static final String DEBUGGER_WINDOW_SCRIPT = "userdebuggerwindowscript";
 
     // Internal flag signals when the schema parser is parsing an
     // external library (for library compiling)

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java	2008-11-26 09:00:08 UTC (rev 11894)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java	2008-11-26 13:57:59 UTC (rev 11895)
@@ -12,6 +12,8 @@
 import org.jdom.Element;
 import java.io.File;
 import java.io.FileNotFoundException;
+import org.openlaszlo.sc.ScriptCompiler;
+import org.openlaszlo.utils.ChainedException;
 import java.util.*;
 
 /** 
@@ -49,7 +51,23 @@
             return;
         } else {
             mEnv.setProperty(mEnv.USER_DEBUG_WINDOW, true);
-            super.compile(element);
+            // inlined from ViewCompiler.compile()
+            preprocess(element, mEnv);
+            NodeModel model = NodeModel.elementAsModel(element, mEnv.getSchema(), mEnv);
+            model = model.expandClassDefinitions();
+            Map map = model.asMap();
+            String classname = (String) map.get("class");
+            try {
+                java.io.Writer writer = new java.io.StringWriter();
+                ScriptCompiler.writeObject(map, writer);
+                String nodejs = writer.toString();
+                String script = "new "+classname + "(canvas, " + nodejs +".attrs" + ");\n";
+                // Store the script to construct the debugger window
+                mEnv.setProperty(CompilationEnvironment.DEBUGGER_WINDOW_SCRIPT, script);
+            } catch (java.io.IOException e) {
+                throw new ChainedException(e);
+            }
+
         }
     }
 }

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java	2008-11-26 09:00:08 UTC (rev 11894)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java	2008-11-26 13:57:59 UTC (rev 11895)
@@ -360,14 +360,18 @@
         
         boolean debug = mProperties.getProperty("debug", "false").equals("true");
 
-        // This indicates whether the user's source code already manually invoked
-        // <debug> to create a debug window. If they didn't explicitly call for
-        // a debugger window, instantiate one now by passing 'true' to __LzDebug.startDebugWindow()
-        boolean makedebugwindow =  !mEnv.getBooleanProperty(mEnv.USER_DEBUG_WINDOW);
-
         // Bring up a debug window if needed.
-        if (debug && makedebugwindow) {
-            addScript("Debug.makeDebugWindow()");
+        if (debug) {
+            boolean userSpecifiedDebugger = mEnv.getBooleanProperty(mEnv.USER_DEBUG_WINDOW);
+            // This indicates whether the user's source code already manually invoked
+            // <debug> to create a debug window. If they didn't explicitly call for
+            // a debugger window, instantiate one now by calling _LZDebug.makeDebugWindow()
+            if (userSpecifiedDebugger) {
+                addScript(mEnv.getProperty(mEnv.DEBUGGER_WINDOW_SCRIPT));
+            } else {
+                // Create debugger window with default init options
+                addScript("__LzDebug.makeDebugWindow()");
+            }
         }
 
         // Put the canvas sprite on the 'stage'.

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java	2008-11-26 09:00:08 UTC (rev 11894)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java	2008-11-26 13:57:59 UTC (rev 11895)
@@ -876,14 +876,18 @@
 
         boolean debug = mProperties.getProperty("debug", "false").equals("true");
 
-        // This indicates whether the user's source code already manually invoked
-        // <debug> to create a debug window. If they didn't explicitly call for
-        // a debugger window, instantiate one now by passing 'true' to __LzDebug.startDebugWindow()
-        boolean makedebugwindow =  !mEnv.getBooleanProperty(mEnv.USER_DEBUG_WINDOW);
-
         // Bring up a debug window if needed.
-        if (debug && makedebugwindow) {
-            addScript("__LzDebug.makeDebugWindow()");
+        if (debug) {
+            boolean userSpecifiedDebugger = mEnv.getBooleanProperty(mEnv.USER_DEBUG_WINDOW);
+            // This indicates whether the user's source code already manually invoked
+            // <debug> to create a debug window. If they didn't explicitly call for
+            // a debugger window, instantiate one now by calling _LZDebug.makeDebugWindow()
+            if (userSpecifiedDebugger) {
+                addScript(mEnv.getProperty(mEnv.DEBUGGER_WINDOW_SCRIPT));
+            } else {
+                // Create debugger window with default init options
+                addScript("__LzDebug.makeDebugWindow()");
+            }
         }
 
         // Tell the canvas we're done loading.



More information about the Laszlo-checkins mailing list