Author: [EMAIL PROTECTED]
Date: Wed Sep 24 12:42:55 2008
New Revision: 3679

Modified:
    changes/jat/oophm-branch/plugins/common/ByteOrder.h
    changes/jat/oophm-branch/plugins/common/HostChannel.h
    changes/jat/oophm-branch/plugins/common/Socket.cpp
    changes/jat/oophm-branch/plugins/common/Socket.h
    changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.h
    changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp

Log:
Checkpoint XPCOM back working except for toString.


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 Wed Sep 24 12:42:55  
2008
@@ -17,6 +17,7 @@
   */

  #include "Platform.h"
+#include <cstring>

  class ByteOrder {
  private:

Modified: changes/jat/oophm-branch/plugins/common/HostChannel.h
==============================================================================
--- changes/jat/oophm-branch/plugins/common/HostChannel.h       (original)
+++ changes/jat/oophm-branch/plugins/common/HostChannel.h       Wed Sep 24  
12:42:55 2008
@@ -46,7 +46,7 @@

    bool connectToHost(const char* host, unsigned port);
    bool disconnectFromHost();
-
+
    bool isConnected() const {
      return sock.isConnected();
    }
@@ -90,6 +90,9 @@
    bool sendDouble(const double data);

    bool readByte(char& data) {
+    if (!isConnected()) {
+      return false;
+    }
      int c = sock.readByte();
      if (c < 0) {
        return false;
@@ -99,6 +102,9 @@
    }

    bool sendByte(const char data) {
+    if (!isConnected()) {
+      return false;
+    }
      return sock.writeByte(data);
    }


Modified: changes/jat/oophm-branch/plugins/common/Socket.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/common/Socket.cpp  (original)
+++ changes/jat/oophm-branch/plugins/common/Socket.cpp  Wed Sep 24 12:42:55  
2008
@@ -95,14 +95,20 @@
    connected = true;
    readBufPtr = readValid = readBuf;
    writeBufPtr = writeBuf;
+#ifdef _WINDOWS
+  Debug::log(Debug::Spam) << "  connected" << Debug::flush;
+#else
    Debug::log(Debug::Spam) << "  connected, fd=" << fd << Debug::flush;
+#endif
    return true;
  }

-bool Socket::disconnect() {
+bool Socket::disconnect(bool doFlush) {
    if (connected) {
      Debug::log(Debug::Debugging) << "Disconnecting socket" << Debug::flush;
-    flush();
+    if (doFlush) {
+      flush();
+    }
      connected = false;
  #ifdef _WINDOWS
      closesocket(sock);
@@ -125,6 +131,11 @@
    for (char* ptr = writeBuf; len > 0; ) {
      ssize_t n = send(sock, ptr, len, 0);
      if (n <= 0) {
+      if (errno == EPIPE) {
+        Debug::log(Debug::Warning) << "Other end of socket disconnected"  
<< Debug::flush;
+        disconnect(false);
+        return false;
+      }
        Debug::log(Debug::Error) << "Error " << errno << " writing " << len  
<< " bytes to socket"
            << Debug::flush;
        return false;
@@ -138,10 +149,17 @@

  bool Socket::fillReadBuf() {
    readBufPtr = readBuf;
+  errno = 0;
    ssize_t n = recv(sock, readBuf, BUF_SIZE, 0);
    if (n <= 0) {
-      Debug::log(Debug::Error) << "Error " << errno << " reading " <<  
BUF_SIZE << " bytes from socket"
-          << Debug::flush;
+    // EOF results in no error
+    if (!errno || errno == EPIPE) {
+      Debug::log(Debug::Warning) << "Other end of socket disconnected" <<  
Debug::flush;
+      disconnect(false);
+      return false;
+    }
+    Debug::log(Debug::Error) << "Error " << errno << " reading " <<  
BUF_SIZE << " bytes from socket"
+        << Debug::flush;
      return false;
    }
    ++numReads;

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    Wed Sep 24 12:42:55  
2008
@@ -118,9 +118,10 @@
    /**
     * Disconnect this socket.
     *
+   * @param doFlush true (the default value) if the socket should be  
flushed.
     * @return true if disconnect succeeds
     */
-  bool disconnect();
+  bool disconnect(bool doFlush = true);

    /**
     * Read a single byte from the socket.

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   Wed Sep 24  
12:42:55 2008
@@ -25,6 +25,7 @@
  #include "jsapi.h"

  class HostChannel;
+class Value;

  class FFSessionHandler :
    public SessionData,

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       Wed Sep 24  
12:42:55 2008
@@ -33,9 +33,9 @@
    JavaObject::getProperty, /* get property */
    JavaObject::setProperty, /* set property */

-  NULL, // reinterpret_cast<JSEnumerateOp>(JavaObject::enumerate), /*  
enumerate */
-  JavaObject::resolve, /* resolve */
-  NULL, // JavaObject::convert, /* convert */
+  JS_EnumerateStub, //  
reinterpret_cast<JSEnumerateOp>(JavaObject::enumerate), /* enumerate */
+  JS_ResolveStub, // JavaObject::resolve, /* resolve */
+  JS_ConvertStub, // JavaObject::convert, /* convert */
    JavaObject::finalize, /* finalize */ //TODO

    NULL, /* object hooks */
@@ -103,7 +103,7 @@
      JSString* str = JSVAL_TO_STRING(id);
      Debug::log(Debug::Error) << "Getting string property "
          << JS_ValueToString(ctx, id) << Debug::flush;
-#if 0
+#if 1
      if ((JS_GetStringLength(str) == 8) && !strncmp("toString",
            JS_GetStringBytes(str), 8)) {
        *vp = data->getToStringTearOff();
@@ -259,21 +259,23 @@
  JSBool JavaObject::call(JSContext* ctx, JSObject*, uintN argc, jsval*  
argv, jsval* rval) {
    // Get the JavaObject called as a function
    JSObject* obj = JSVAL_TO_OBJECT(argv[-2]);
-  Debug::log(Debug::Info) << "JavaObject::call oid="
-      << JavaObject::getObjectId(ctx, obj) << " (" << Debug::flush;
    if (argc < 2 || !JSVAL_IS_INT(argv[0]) || !JSVAL_IS_OBJECT(argv[1])) {
      Debug::log(Debug::Error) << "JavaObject::call incorrect arguments" <<  
Debug::flush;
      return JS_FALSE;
    }
-
+  int dispId = JSVAL_TO_INT(argv[0]);
+  Debug::DebugStream& dbg = Debug::log(Debug::Info) << "JavaObject::call  
oid="
+      << JavaObject::getObjectId(ctx, obj) << ",dispId=" << dispId << " (";
    for (int i = 2; i < argc; ++i) {
-    Debug::log(Debug::Info) << "argv[" << i + "] = " <<  
JS_ValueToString(ctx, argv[i]) << Debug::flush;
+    if (i > 2) {
+      dbg << ", ";
+    }
+    dbg << JS_ValueToString(ctx, argv[i]);
    }
+  dbg << ")" << Debug::flush;

    SessionData* data = JavaObject::getSessionData(ctx, obj);
    Debug::log(Debug::Spam) << "Data = " << data << Debug::flush;
-
-  int dispId = JSVAL_TO_INT(argv[0]);

    Value javaThis;
    if (!JSVAL_IS_NULL(argv[1])) {

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

Reply via email to