Author: [EMAIL PROTECTED]
Date: Sat Oct  4 12:20:45 2008
New Revision: 3711

Added:
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/close.png    
(contents, props changed)
    changes/jat/oophm-branch/plugins/xpcom/prebuilt/extension/platform/
     
changes/jat/oophm-branch/plugins/xpcom/prebuilt/extension/platform/Linux_x86-gcc3/
     
changes/jat/oophm-branch/plugins/xpcom/prebuilt/extension/platform/Linux_x86-gcc3/components/
Modified:
    changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/GWTShell.java
    changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/ModulePanel.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/BrowserChannelServer.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/OophmSessionHandler.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingLoggerPanel.java
     
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingTreeLogger.java
    changes/jat/oophm-branch/plugins/common/ByteOrder.h
    changes/jat/oophm-branch/plugins/common/DebugLevel.h
    changes/jat/oophm-branch/plugins/common/HostChannel.cpp
    changes/jat/oophm-branch/plugins/common/Makefile
    changes/jat/oophm-branch/plugins/common/Socket.h
    changes/jat/oophm-branch/plugins/xpcom/ExternalWrapper.cpp
    changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp
    changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.h
    changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp
    changes/jat/oophm-branch/plugins/xpcom/ModuleOOPHM.cpp
    changes/jat/oophm-branch/plugins/xpcom/SessionData.h

Log:
Various cleanups getting ready for use, including a close button on
disconnected tabs, alerts on mocked UI bits, debug levels cleanup, etc.


Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/GWTShell.java
==============================================================================
--- changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/GWTShell.java      
 
(original)
+++ changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/GWTShell.java      
 
Sat Oct  4 12:20:45 2008
@@ -487,7 +487,7 @@
        try {
          for (String prenormalized : startupUrls) {
            startupURL = normalizeURL(prenormalized);
-          logger.log(TreeLogger.TRACE, "Starting URL: " + startupURL,  
null);
+          logger.log(TreeLogger.INFO, "Starting URL: " + startupURL, null);
            launchURL(startupURL);
          }
        } catch (UnableToCompleteException e) {

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/ModulePanel.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/ModulePanel.java       
 
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/ModulePanel.java       
 
Sat Oct  4 12:20:45 2008
@@ -19,13 +19,18 @@
  import com.google.gwt.core.ext.TreeLogger.Type;
  import com.google.gwt.dev.util.log.AbstractTreeLogger;
  import com.google.gwt.dev.util.log.SwingLoggerPanel;
-import com.google.gwt.dev.util.log.SwingLoggerPanel.CloseListener;

  import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;

+import javax.swing.BorderFactory;
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.JLabel;
+import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JTabbedPane;

@@ -33,12 +38,41 @@
   */
  public class ModulePanel extends JPanel {

+  /**
+   * A tab component with a close button, derived from Swing
+   * TabComponentsDemoProject.
+   */
+  private class ClosedTabComponent extends JPanel {
+
+    public ClosedTabComponent() {
+      super(new FlowLayout(FlowLayout.LEFT, 0, 0));
+      setOpaque(false);
+      JLabel label = new JLabel("Disconnected");
+      add(label);
+      label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
+      JButton button = new JButton(closeIcon);
+      button.setBorderPainted(false);
+      button.setPreferredSize(new Dimension(closeIcon.getIconWidth(),
+          closeIcon.getIconHeight()));
+      add(button);
+      button.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          synchronized (tabs) {
+            tabs.remove(ModulePanel.this);
+          }
+        }
+      });
+    }
+  }
+
    private static ImageIcon firefoxIcon =  
GWTShell.loadImageIcon("firefox24.png");

    private static ImageIcon ieIcon = GWTShell.loadImageIcon("ie24.png");

    private static ImageIcon safariIcon =  
GWTShell.loadImageIcon("safari24.png");

+  private static ImageIcon closeIcon = GWTShell.loadImageIcon("close.png");
+
    private SwingLoggerPanel loggerPanel;

    private final JTabbedPane tabs;
@@ -50,15 +84,15 @@
      JPanel topPanel = new JPanel();
      topPanel.add(new JLabel(moduleName));
      JButton compileButton = new JButton("Compile");
-    topPanel.add(compileButton);
-    add(topPanel, BorderLayout.NORTH);
-    loggerPanel = new SwingLoggerPanel(maxLevel, new CloseListener() {
-      public void onClose() {
-        synchronized (tabs) {
-          tabs.remove(ModulePanel.this);
-        }
+    compileButton.addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent e) {
+        JOptionPane.showMessageDialog(null, "Compiling not implemented  
yet",
+            "Alert: Not Implemented", JOptionPane.INFORMATION_MESSAGE);
        }
      });
+    topPanel.add(compileButton);
+    add(topPanel, BorderLayout.NORTH);
+    loggerPanel = new SwingLoggerPanel(maxLevel);
      add(loggerPanel);
      AbstractTreeLogger logger = loggerPanel.getLogger();
      ImageIcon browserIcon = null;
@@ -87,9 +121,7 @@
      synchronized (tabs) {
        int index = tabs.indexOfComponent(this);
        if (index > -1) {
-        tabs.setTitleAt(index, "Disconnected");
-        // TODO(jat): closed icon?
-        tabs.setIconAt(index, null);
+        tabs.setTabComponentAt(index, new ClosedTabComponent());
        }
      }
      loggerPanel.disconnected();

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/BrowserChannelServer.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/BrowserChannelServer.java
         
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/BrowserChannelServer.java
         
Sat Oct  4 12:20:45 2008
@@ -18,9 +18,7 @@
  import com.google.gwt.core.ext.TreeLogger;
  import com.google.gwt.dev.shell.JsValue.DispatchObject;

-import java.io.BufferedReader;
  import java.io.IOException;
-import java.io.InputStreamReader;
  import java.net.Socket;

  /**
@@ -107,11 +105,11 @@
            if (target instanceof Throwable) {
              throw (Throwable) (target);
            } else {
-            // JS throwing random Objects, which we'll wrap is JSException
+            // JS throwing random Java Objects, which we'll wrap is  
JSException
              throw ModuleSpaceOOPHM.createJavaScriptException(ccl, target);
            }
          }
-        // JS throwing random primitive objects, which we'll wrap is  
JSException
+        // JS throwing random primitives, which we'll wrap is JSException
          throw ModuleSpaceOOPHM.createJavaScriptException(ccl,
              returnValue.getValue().toString());
        }
@@ -156,9 +154,9 @@
          handler.unloadModule(this, moduleName);
        }
      } catch (IOException e) {
-      logger.log(TreeLogger.TRACE, "Client connection lost", e);
+      logger.log(TreeLogger.WARN, "Client connection lost", e);
      } catch (BrowserChannelException e) {
-      logger.log(TreeLogger.WARN,
+      logger.log(TreeLogger.ERROR,
            "Unrecognized command for client; closing connection", e);
      } finally {
        try {
@@ -264,23 +262,6 @@
          jsval.setWrappedJavaObject(ccl,
              localObjects.get(val.getJavaObject().getRefid()));
          break;
-    }
-  }
-
-  /**
-   * @return true if an http request was processed
-   */
-  private boolean processHttpRequest() {
-    try {
-      BufferedReader reader = new BufferedReader(new InputStreamReader(
-          getStreamFromOtherSide()));
-      String line = reader.readLine();
-      if (!line.substring(0, 3).equalsIgnoreCase("get ")) {
-        return false;
-      }
-      return true;
-    } catch (IOException ioe) {
-      return false;
      }
    }
  }

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
         
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
         
Sat Oct  4 12:20:45 2008
@@ -748,7 +748,7 @@
        jsni.append(body);
        jsni.append(";\n\n");
      }
-    logger.log(TreeLogger.TRACE, "Defining JSNI for " + sourceName);
+    logger.log(TreeLogger.DEBUG, "Defining JSNI for " + sourceName);
      shellJavaScriptHost.createNativeMethods(sourceName, jsni.toString());
    }


Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
     
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
     
Sat Oct  4 12:20:45 2008
@@ -30,7 +30,7 @@
        BrowserChannelServer channel) {
      super(msh, moduleName, moduleName);
      this.channel = channel;
-    msh.getLogger().log(TreeLogger.INFO,
+    msh.getLogger().log(TreeLogger.DEBUG,
          "Created ModuleSpaceOOPHM for " + moduleName, null);
    }

@@ -64,7 +64,7 @@
    @Override
    protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
        Object[] args) throws Throwable {
-    TreeLogger branch = host.getLogger().branch(TreeLogger.TRACE,
+    TreeLogger branch = host.getLogger().branch(TreeLogger.DEBUG,
          "Invoke native method " + name, null);
      CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
      JsValueOOPHM jsthis = new JsValueOOPHM();
@@ -85,7 +85,7 @@
            returnVal);
        branch.log(TreeLogger.SPAM, "  returned " + returnVal);
      } catch (Throwable t) {
-      branch.log(TreeLogger.TRACE, "exception thrown", t);
+      branch.log(TreeLogger.DEBUG, "exception thrown", t);
        throw t;
      }
      return returnVal;

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/OophmSessionHandler.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/OophmSessionHandler.java
  
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/OophmSessionHandler.java
  
Sat Oct  4 12:20:45 2008
@@ -156,8 +156,6 @@
    @Override
    public TreeLogger loadModule(TreeLogger logger, BrowserChannel channel,
        String moduleName, String userAgent) {
-    logger.log(TreeLogger.INFO, "Hosted mode connection from "
-        + channel.getRemoteEndpoint());
      try {
        // Attach a new ModuleSpace to make it programmable.
        //

Added:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/shell/close.png
==============================================================================
Binary file. No diff available.

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingLoggerPanel.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingLoggerPanel.java
  
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingLoggerPanel.java
  
Sat Oct  4 12:20:45 2008
@@ -31,6 +31,7 @@
  import javax.swing.JComboBox;
  import javax.swing.JEditorPane;
  import javax.swing.JLabel;
+import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JSplitPane;
@@ -49,12 +50,7 @@
   */
  public class SwingLoggerPanel extends JPanel implements  
TreeSelectionListener {

-  /**
-   * Interface for notification when this panel is requested to close.
-   */
-  public interface CloseListener {
-    void onClose();
-  }
+  private static final Color DISCONNECTED_COLOR = Color.decode("0xFFDDDD");

    private static class TreeRenderer extends DefaultTreeCellRenderer {
      @Override
@@ -72,7 +68,7 @@
        return this;
      }
    }
-
+
    // package protected for SwingTreeLogger to access

    final JTree tree;
@@ -97,17 +93,12 @@

    private JPanel topPanel;

-  private CloseListener closeListener;
-
    public SwingLoggerPanel(TreeLogger.Type maxLevel) {
-    this(maxLevel, null);
-  }
-
-  public SwingLoggerPanel(TreeLogger.Type maxLevel, CloseListener  
closeListener) {
      super(new BorderLayout());
-    this.closeListener = closeListener;
      regexFilter = "";
      levelFilter = maxLevel;
+    // TODO(jat): how to make the topPanel properly layout items
+    // when the window is resized
      topPanel = new JPanel();
      JButton expandButton = new JButton("Expand All");
      expandButton.addActionListener(new ActionListener() {
@@ -191,6 +182,11 @@
      logger.setMaxDetail(maxLevel);
    }

+  protected void alert(String msg) {
+    JOptionPane.showMessageDialog(null, "Alert", msg,
+        JOptionPane.INFORMATION_MESSAGE);
+  }
+
    @SuppressWarnings("unchecked")
    public void collapseAll() {
      Enumeration<DefaultMutableTreeNode> children =  
root.postorderEnumeration();
@@ -204,17 +200,10 @@
    }

    public void disconnected() {
-    tree.setBackground(Color.decode("0xFFDDDD"));
+    // TODO(jat): better way to do this, as this doesn't change all the
+    // background colors.
+    tree.setBackground(DISCONNECTED_COLOR);
      tree.repaint();
-    if (closeListener != null) {
-      JButton closeButton = new JButton("Close");
-      closeButton.addActionListener(new ActionListener() {
-        public void actionPerformed(ActionEvent e) {
-          closeListener.onClose();
-        }
-      });
-      topPanel.add(closeButton);
-    }
    }

    @SuppressWarnings("unchecked")
@@ -267,10 +256,14 @@
    protected void setLevelFilter(Type selectedLevel) {
      levelFilter = selectedLevel;
      // TODO(jat): filter current tree
+    JOptionPane.showMessageDialog(null, "Filtering not implemented yet",
+        "Alert: Not Implemented", JOptionPane.INFORMATION_MESSAGE);
    }

    protected void setRegexFilter(String regex) {
      regexFilter = regex;
      // TODO(jat): filter current tree
+    JOptionPane.showMessageDialog(null, "Regex filtering not implemented  
yet",
+        "Alert: Not Implemented", JOptionPane.INFORMATION_MESSAGE);
    }
  }

Modified:  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingTreeLogger.java
==============================================================================
---  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingTreeLogger.java
   
(original)
+++  
changes/jat/oophm-branch/dev/core/src/com/google/gwt/dev/util/log/SwingTreeLogger.java
   
Sat Oct  4 12:20:45 2008
@@ -41,6 +41,10 @@
     */
    public static class LogEvent {

+    private static final Color DEBUG_COLOR = Color.decode("0x007777");
+    private static final Color SPAM_COLOR = Color.decode("0x005500");
+    private static final Color WARN_COLOR = Color.decode("0x888800");
+
      private static final Date firstLog = new Date();
      private static NumberFormat minHr = NumberFormat.getIntegerInstance();
      private static NumberFormat seconds = NumberFormat.getNumberInstance();
@@ -132,7 +136,7 @@
          treeLabel.setForeground(Color.RED);
          image = imageError;
        } else if (type == TreeLogger.WARN) {
-        treeLabel.setForeground(Color.decode("0x888800"));
+        treeLabel.setForeground(WARN_COLOR);
          image = imageWarning;
        } else if (type == TreeLogger.INFO) {
          treeLabel.setForeground(Color.BLACK);
@@ -141,10 +145,10 @@
          treeLabel.setForeground(Color.DARK_GRAY);
          image = imageTrace;
        } else if (type == TreeLogger.DEBUG) {
-        treeLabel.setForeground(Color.decode("0x007777"));
+        treeLabel.setForeground(DEBUG_COLOR);
          image = imageDebug;
        } else if (type == TreeLogger.SPAM) {
-        treeLabel.setForeground(Color.decode("0x005500"));
+        treeLabel.setForeground(SPAM_COLOR);
          image = imageSpam;
        } else {
          // Messages without icons, ie ALL
@@ -214,7 +218,9 @@
    private static final ImageIcon imageTrace =  
tryLoadImage("log-item-trace.gif");
    private static final ImageIcon imageWarning =  
tryLoadImage("log-item-warning.gif");

-  private static ImageIcon tryLoadImage(String simpleName) {
+  // package protected to allow SwingLoggerPanel access
+  // TODO(jat): reorganize
+  static ImageIcon tryLoadImage(String simpleName) {
      URL url = SwingTreeLogger.class.getResource(simpleName);
      if (url != null) {
        try {

Modified: changes/jat/oophm-branch/plugins/common/ByteOrder.h
==============================================================================
--- changes/jat/oophm-branch/plugins/common/ByteOrder.h (original)
+++ changes/jat/oophm-branch/plugins/common/ByteOrder.h Sat Oct  4 12:20:45  
2008
@@ -71,8 +71,8 @@
             str = "big-endian";
             break;
        }
-      Debug::log(Debug::Debugging) << "Detected float byte order: " << str
-          << Debug::flush;
+      Debug::log(Debug::Debugging) << "Dynamically detected float byte  
order: "
+          << str << Debug::flush;
      }
  #endif
    }

Modified: changes/jat/oophm-branch/plugins/common/DebugLevel.h
==============================================================================
--- changes/jat/oophm-branch/plugins/common/DebugLevel.h        (original)
+++ changes/jat/oophm-branch/plugins/common/DebugLevel.h        Sat Oct  4  
12:20:45 2008
@@ -18,6 +18,7 @@

  // Defines the default debug level if not defined -- see Debug.h
  // Can also define GWT_DEBUGDISABLE to remove all traces of the debug code.
+//#define GWT_DEBUGLEVEL Debugging
  #define GWT_DEBUGLEVEL Info
  //#define GWT_DEBUGDISABLE


Modified: changes/jat/oophm-branch/plugins/common/HostChannel.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/common/HostChannel.cpp     (original)
+++ changes/jat/oophm-branch/plugins/common/HostChannel.cpp     Sat Oct  4  
12:20:45 2008
@@ -52,8 +52,8 @@
  ByteOrder HostChannel::byteOrder;

  bool HostChannel::connectToHost(const char* host, unsigned port) {
-  Debug::log(Debug::Info) << "HostChannel::connectToHost(host=" << host  
<< ",port=" << port
-      << ")" << Debug::flush;
+  Debug::log(Debug::Info) << "Initiating GWT hosted mode connection to  
host "
+      << host << ", port " << port << Debug::flush;
    if (!port) {
      port = 9997;
    }
@@ -66,7 +66,7 @@
  }

  bool HostChannel::disconnectFromHost() {
-  Debug::log(Debug::Info) << "Disconnecting channel" << Debug::flush;
+  Debug::log(Debug::Debugging) << "Disconnecting channel" << Debug::flush;
    if (!isConnected()) {
      Debug::log(Debug::Error) << "Disconnecting already disconnected  
channel" << Debug::flush;
      return false;
@@ -162,14 +162,16 @@
  bool HostChannel::readString(std::string& strRef) {
    uint32_t len;
    if (!readStringLength(len)) {
-    printf("readString: failed to read length\n");
+    Debug::log(Debug::Error) << "readString: failed to read length"
+        << Debug::flush;
      return false;
    }
    // Allocating variable-length arrays on the stack is a GCC feature,
    // and is vulnerable to stack overflow attacks, so we allocate on the  
heap.
    scoped_array<char> buf(new char[len]);
    if (!readStringBytes(buf.get(), len)) {
-    printf("readString: failed to read %d bytes\n", len);
+    Debug::log(Debug::Error) << "readString: failed to read " << len
+        << " bytes" << Debug::flush;
      return false;
    }
    strRef.assign(buf.get(), len);
@@ -359,6 +361,7 @@
    switch (type) {
      case Value::NULL_TYPE:
      case Value::UNDEFINED:
+      // Null and Undefined only have the tag byte, no data
        return true;
      case Value::BOOLEAN:
        return sendByte(value.getBoolean() ? 1 : 0);

Modified: changes/jat/oophm-branch/plugins/common/Makefile
==============================================================================
--- changes/jat/oophm-branch/plugins/common/Makefile    (original)
+++ changes/jat/oophm-branch/plugins/common/Makefile    Sat Oct  4 12:20:45  
2008
@@ -25,7 +25,8 @@
  OBJ32= $(patsubst %.cpp,obj32/%.o,$(SRCS))
  OBJ64= $(patsubst %.cpp,obj64/%.o,$(SRCS))

-all:: libcommon32.a libcommon64.a
+#all:: libcommon32.a libcommon64.a
+all:: libcommon32.a

  libcommon32.a: $(OBJ32) obj32.dir
        ar -rv $@ $(OBJ32)

Modified: changes/jat/oophm-branch/plugins/common/Socket.h
==============================================================================
--- changes/jat/oophm-branch/plugins/common/Socket.h    (original)
+++ changes/jat/oophm-branch/plugins/common/Socket.h    Sat Oct  4 12:20:45  
2008
@@ -93,7 +93,7 @@
      // TODO(jat): LEAK LEAK LEAK
      // delete[] readBuf;
      // delete[] writeBuf;
-    Debug::log(Debug::Info) << "Socket: #r=" << numReads << ", bytes/read="
+    Debug::log(Debug::Debugging) << "Socket: #r=" << numReads << ",  
bytes/read="
          << (numReads ? totReadBytes / numReads : 0) << ", maxr=" <<  
maxReadBytes << "; #w="
          << numWrites << ", bytes/write=" << (numWrites ? totWriteBytes /  
numWrites : 0) << ", maxw="
          << maxWriteBytes << Debug::flush;

Modified: changes/jat/oophm-branch/plugins/xpcom/ExternalWrapper.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/ExternalWrapper.cpp  (original)
+++ changes/jat/oophm-branch/plugins/xpcom/ExternalWrapper.cpp  Sat Oct  4  
12:20:45 2008
@@ -75,7 +75,7 @@

    HostChannel* channel = new HostChannel();

-  Debug::log(Debug::Info) << "Connecting..." << Debug::flush;
+  Debug::log(Debug::Debugging) << "Connecting..." << Debug::flush;

    if (!channel->connectToHost(
        const_cast<char*>(hostPart.c_str()),
@@ -84,7 +84,7 @@
      return NS_OK;
    }

-  Debug::log(Debug::Info) << "...Connected" << Debug::flush;
+  Debug::log(Debug::Debugging) << "...Connected" << Debug::flush;

    sessionHandler.reset(new FFSessionHandler(channel/*, ctx*/));
    std::string moduleName(moduleAutoStr.get());

Modified: changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp (original)
+++ changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp Sat Oct  4  
12:20:45 2008
@@ -106,14 +106,13 @@
  }

  void FFSessionHandler::freeValue(HostChannel& channel, int idCount, const  
int* ids) {
-  Debug::log(Debug::Spam) << "FFSessionHandler::freeValue [ ";
-
+  Debug::DebugStream& dbg = Debug::log(Debug::Spam)
+      << "FFSessionHandler::freeValue [ ";
    JSContext* ctx = getJSContext();

    for (int i = 0; i < idCount; ++i) {
      int objId = ids[i];
-    Debug::log(Debug::Spam) << objId << " ";
-
+    dbg << objId << " ";
      jsval toRemove;
      if (JS_GetElement(ctx, jsObjectsById, objId, &toRemove) &&  
JSVAL_IS_OBJECT(toRemove)) {
        jsIdsByObject.erase(JSVAL_TO_OBJECT(toRemove));
@@ -123,7 +122,7 @@
      }
    }

-  Debug::log(Debug::Spam) << "]" << Debug::flush;
+  dbg << "]" << Debug::flush;
  }

  void FFSessionHandler::loadJsni(HostChannel& channel, const std::string&  
js) {
@@ -173,7 +172,7 @@
      jsThis = OBJECT_TO_JSVAL(global);
      Debug::log(Debug::Spam) << "  using global object for this" <<  
Debug::flush;
    } else {
-    makeValueRef(jsThis, ctx, thisObj);
+    makeJsvalFromValue(jsThis, ctx, thisObj);
      if (Debug::level(Debug::Spam)) {
        Debug::log(Debug::Spam) << "  obj=" << dumpJsVal(ctx, jsThis)
            << Debug::flush;
@@ -194,7 +193,7 @@

    scoped_array<jsval> jsargs(new jsval[numArgs]);
    for (int i = 0; i < numArgs; ++i) {
-    makeValueRef(jsargs[i], ctx, args[i]);
+    makeJsvalFromValue(jsargs[i], ctx, args[i]);
      if (Debug::level(Debug::Spam)) {
        Debug::log(Debug::Spam) << "  arg[" << i << "] = " << dumpJsVal(ctx,
            jsargs[i]) << Debug::flush;
@@ -221,7 +220,7 @@

    if (!ok) {
      if (JS_GetPendingException(ctx, &rval)) {
-      makeValue(*returnValue, ctx, rval);
+      makeValueFromJsval(*returnValue, ctx, rval);
        Debug::log(Debug::Debugging) << "FFSessionHandler::invoke "
            << thisObj.toString() << "::" << methodName << " threw  
exception "
            << dumpJsVal(ctx, rval) << Debug::flush;
@@ -231,7 +230,7 @@
        returnValue->setUndefined();
      }
    } else {
-    makeValue(*returnValue, ctx, rval);
+    makeValueFromJsval(*returnValue, ctx, rval);
    }
    Debug::log(Debug::Spam) << "  return= " << *returnValue << Debug::flush;
    return !ok;
@@ -289,7 +288,7 @@
   */
  static JSString* stringUtf8(JSContext* ctx, const std::string& utf8str) {
    unsigned len = 0;
-  for (int i = 0; i < utf8str.length(); ++i) {
+  for (unsigned i = 0; i < utf8str.length(); ++i) {
      char ch = utf8str[i];
      switch (ch & 0xF8) {
        // continuation & invalid chars
@@ -310,7 +309,8 @@
          break;
      }
    }
-  // account for null terminator even if it isn't included in the string  
length
+  // Account for null terminator even if it isn't included in the string  
length
+  // Note that buf becomes owned by the JSString and must not be freed  
here.
    jschar* buf = static_cast<jschar*>(JS_malloc(ctx, (len + 1) *  
sizeof(jschar)));
    if (!buf) {
      return NULL;
@@ -318,7 +318,7 @@
    jschar* p = buf;
    unsigned codePoint;
    int charsLeft = -1;
-  for (int i = 0; i < utf8str.length(); ++i) {
+  for (unsigned i = 0; i < utf8str.length(); ++i) {
      char ch = utf8str[i];
      if (charsLeft >= 0) {
        if ((ch & 0xC0) != 0x80) {
@@ -340,6 +340,7 @@
        }
        continue;
      }
+    // Look at the top 5 bits to determine how many bytes are in this  
character.
      switch (ch & 0xF8) {
        default: // skip invalid and continuation chars
          break;
@@ -365,12 +366,13 @@
    }
    // null terminator, apparently some code expects a terminator even though
    // the strings are counted.  Note that this null word should not be  
included
-  // in the length.
+  // in the length, and that the buffer becomes owned by the JSString  
object.
    *p = 0;
    return JS_NewUCString(ctx, buf, p - buf);
  }

-void FFSessionHandler::makeValue(Value& retVal, JSContext* ctx, const  
jsval& value) {
+void FFSessionHandler::makeValueFromJsval(Value& retVal, JSContext* ctx,
+    const jsval& value) {
    if (JSVAL_IS_VOID(value)) {
      retVal.setUndefined();
    } else if (JSVAL_IS_NULL(value)) {
@@ -414,7 +416,8 @@
    }
  }

-void FFSessionHandler::makeValueRef(jsval& retVal, JSContext* ctx, const  
Value& value) {
+void FFSessionHandler::makeJsvalFromValue(jsval& retVal, JSContext* ctx,
+    const Value& value) {
    switch (value.getType()) {
      case Value::NULL_TYPE:
        retVal = JSVAL_NULL;
@@ -440,6 +443,7 @@
        }
        break;
      }
+    // TODO(jat): do we still need long support in the wire format and  
Value?
  //    case Value::LONG:
  //      retVal = value.getLong();
  //      break;
@@ -458,17 +462,13 @@
      case Value::JAVA_OBJECT:
        {
          int javaId = value.getJavaObjectId();
-
          std::map<int, JSObject*>::iterator i =  
javaObjectsById.find(javaId);
          if (i == javaObjectsById.end()) {
            JSObject* obj = JavaObject::construct(ctx, this, javaId);
-
            javaObjectsById[javaId] = obj;
-
            // We may have previously released the proxy for the same object  
id,
            // but have not yet sent a free message back to the server.
            javaObjectsToFree.erase(javaId);
-
            retVal = OBJECT_TO_JSVAL(obj);
          } else {
            retVal = OBJECT_TO_JSVAL(i->second);

Modified: changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.h
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.h   (original)
+++ changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.h   Sat Oct  4  
12:20:45 2008
@@ -27,17 +27,15 @@
  class HostChannel;
  class Value;

-class FFSessionHandler :
-  public SessionData,
-  public SessionHandler
-{
+class FFSessionHandler : public SessionData, public SessionHandler {
    friend class JavaObject;
  public:
    FFSessionHandler(HostChannel* channel);
    ~FFSessionHandler(void);
-//  virtual void freeJavaObject(unsigned int objId);
-  virtual void makeValue(Value& retVal, JSContext* ctx, const jsval&  
value);
-  virtual void makeValueRef(jsval& retVal, JSContext* ctx, const Value&  
value);
+  virtual void makeValueFromJsval(Value& retVal, JSContext* ctx,
+      const jsval& value);
+  virtual void makeJsvalFromValue(jsval& retVal, JSContext* ctx,
+      const Value& value);
    virtual void freeJavaObject(int objectId);
    void disconnect();

@@ -65,21 +63,6 @@
    JSClass* stringObjectClass;

    std::map<JSObject*, int> jsIdsByObject;
-//
-//  /*
-//  * Send freed Java ids back to the server.
-//  */
-//  void IESessionHandler::freeJavaObjects();
-//
-//  /*
-//  * Create a JavaScript Error object with the given message.
-//  */
-//  void makeException(_variant_t& value, const char* message);
-//
-//  /*
-//  * Create a exception Value that contains the given message.
-//  */
-//  void makeExceptionValue(Value& value, const char* message);
  };

  inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, JSString*  
str) {

Modified: changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp       (original)
+++ changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp       Sat Oct  4  
12:20:45 2008
@@ -151,7 +151,7 @@
    SessionHandler* handler = data->getSessionHandler();

    Value value = ServerMethods::getProperty(*channel, handler, objectRef,  
dispId);
-  data->makeValueRef(*rval, ctx, value);
+  data->makeJsvalFromValue(*rval, ctx, value);
    return JS_TRUE;
  }

@@ -172,7 +172,7 @@
    int dispId = JSVAL_TO_INT(id);

    Value value;
-  data->makeValue(value, ctx, *vp);
+  data->makeValueFromJsval(value, ctx, *vp);

    HostChannel* channel = data->getHostChannel();
    SessionHandler* handler = data->getSessionHandler();
@@ -320,7 +320,7 @@
      if (isJavaObject(ctx, thisObj)) {
        javaThis.setJavaObject(getObjectId(ctx, thisObj));
      } else {
-      data->makeValue(javaThis, ctx, argv[1]);
+      data->makeValueFromJsval(javaThis, ctx, argv[1]);
      }
  #if 0
      if (!dispId) {
@@ -354,7 +354,7 @@
    for (int i = 0; i < numArgs; ++i) {
      // Debug::log(Debug::Spam) << "making argv[" << i << + "]" <<  
Debug::flush;
      // Debug::log(Debug::Spam) << "   " << dumpJsVal(ctx, jsargs[i]) <<  
Debug::flush;
-    data->makeValue(args[i], ctx, jsargs[i]);
+    data->makeValueFromJsval(args[i], ctx, jsargs[i]);
    }
  //  static_cast<FFSessionHandler*>(handler)->sendFreeValues(*channel);
    if (!InvokeMessage::send(*channel, javaThis, dispId, numArgs,  
args.get())) {
@@ -375,7 +375,7 @@
    *rval = OBJECT_TO_JSVAL(retval);
    jsval retJsVal;
    Debug::log(Debug::Spam) << "  result is " << returnValue << Debug::flush;
-  data->makeValueRef(retJsVal, ctx, returnValue);
+  data->makeJsvalFromValue(retJsVal, ctx, returnValue);
    if (retMsg->isException()) {
      JS_SetPendingException(ctx, retJsVal);
      return false;

Modified: changes/jat/oophm-branch/plugins/xpcom/ModuleOOPHM.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/ModuleOOPHM.cpp      (original)
+++ changes/jat/oophm-branch/plugins/xpcom/ModuleOOPHM.cpp      Sat Oct  4  
12:20:45 2008
@@ -14,7 +14,9 @@
   * the License.
   */

+#include "Debug.h"
  #include "ExternalWrapper.h"
+
  #include "nsCOMPtr.h"
  #include "nsIGenericFactory.h"
  #include "nsICategoryManager.h"
@@ -48,7 +50,8 @@
      const char *aLoaderStr, const char *aType,
      const nsModuleComponentInfo *aInfo) {

-  printf("registering self\n");
+  Debug::log(Debug::Info) << "Registered GWT hosted mode plugin"
+      << Debug::flush;
    nsresult rv;
    nsCOMPtr<nsICategoryManager> categoryManager =
        do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
@@ -58,21 +61,24 @@
    rv = categoryManager->AddCategoryEntry("JavaScript global property",
        "__gwt_HostedModePlugin", OOPHM_CONTRACTID, true, true, nsnull);

-  printf("return value: %d\n", (int) rv);
-
+  if (rv != NS_OK) {
+    Debug::log(Debug::Error) << "ModuleOOPHM registerSelf returned " << rv
+        << Debug::flush;
+  }
    return rv;
  }

  static NS_IMETHODIMP factoryDestructor(void) {
-  printf("factoryDestructor\n");
+  Debug::log(Debug::Debugging) << "ModuleOOPHM factoryDestructor()"
+      << Debug::flush;
    return NS_OK;
  }

  static NS_IMETHODIMP unregisterSelf(nsIComponentManager *aCompMgr,
-                                             nsIFile *aPath,
-                                             const char *aLoaderStr,
-                                             const nsModuleComponentInfo  
*aInfo) {
-  printf("unregisterSelf\n");
+    nsIFile *aPath, const char *aLoaderStr,
+    const nsModuleComponentInfo *aInfo) {
+  Debug::log(Debug::Debugging) << "ModuleOOPHM unRegisterSelf()"
+      << Debug::flush;
    return NS_OK;
  }


Modified: changes/jat/oophm-branch/plugins/xpcom/SessionData.h
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/SessionData.h        (original)
+++ changes/jat/oophm-branch/plugins/xpcom/SessionData.h        Sat Oct  4  
12:20:45 2008
@@ -51,13 +51,13 @@
    * Convert a value from the JavaScript into something that can be sent  
back
    * to the OOPHM host.
    */
-  virtual void makeValue(Value& retVal, JSContext* ctx, const jsval&  
value)=0;
+  virtual void makeValueFromJsval(Value& retVal, JSContext* ctx, const  
jsval& value)=0;

    /*
    * Convert a value from the OOPHM host into something that can be passed  
into
    * the JavaScript execution environment.
    */
-  virtual void makeValueRef(jsval& retVal, JSContext* ctx, const Value&  
value)=0;
+  virtual void makeJsvalFromValue(jsval& retVal, JSContext* ctx, const  
Value& value)=0;

    /*
    * Removes the JavaObject wrapper with the given id and notifies the host.

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to