Author: [EMAIL PROTECTED]
Date: Wed Oct 8 15:43:45 2008
New Revision: 3727
Modified:
changes/jat/oophm-branch/plugins/xpcom/ExternalWrapper.cpp
changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp
changes/jat/oophm-branch/plugins/xpcom/JavaObject.cpp
changes/jat/oophm-branch/plugins/xpcom/Makefile.mac
changes/jat/oophm-branch/plugins/xpcom/VisualStudio/firefox-xpcom.vcproj
changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp
changes/jat/oophm-branch/plugins/xpcom/install-template.rdf
changes/jat/oophm-branch/plugins/xpcom/xpOOPHM.rc
Log:
Changes from review.
Review by: bobv
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 Wed Oct 8
15:43:45 2008
@@ -58,6 +58,7 @@
return NS_OK;
}
+// TODO: handle context object passed in (currently nsIDOMWindow below)
NS_IMETHODIMP ExternalWrapper::Connect(const nsACString & aAddr, const
nsACString & aModuleName, nsIDOMWindow* domWindow, PRBool *_retval) {
Debug::log(Debug::Spam) << "Address: " << aAddr << " Module: " <<
aModuleName << Debug::flush;
@@ -101,6 +102,7 @@
userAgent.c_str(),
sessionHandler.get());
+ // TODO: return session object?
*_retval = true;
return NS_OK;
}
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 Wed Oct 8
15:43:45 2008
@@ -96,7 +96,7 @@
Debug::log(Debug::Error) << "Error creating toString tear-off"
<< Debug::flush;
}
- // TODO(jat): what to do here?
+ // TODO(jat): show some crash page and die
}
}
@@ -186,6 +186,7 @@
}
jsval funcVal;
+ // TODO: handle non-ASCII method names
if (!JS_GetProperty(ctx, global, methodName.c_str(), &funcVal)) {
Debug::log(Debug::Error) << "Could not get function " << methodName <<
Debug::flush;
return true;
@@ -206,13 +207,9 @@
}
}
- // Debug::log(Debug::Spam) << "JS_IsExceptionPending: " <<
JS_IsExceptionPending(ctx)
- // << Debug::flush;
if (JS_IsExceptionPending(ctx)) {
JS_ClearPendingException(ctx);
}
- // Debug::log(Debug::Spam) << "JS_IsExceptionPending: " <<
JS_IsExceptionPending(ctx)
- // << Debug::flush;
jsval rval;
JSBool ok = JS_CallFunctionValue(ctx, JSVAL_TO_OBJECT(jsThis), funcVal,
@@ -502,6 +499,7 @@
javaObjectsToFree.insert(objectId);
}
+// TODO: investigate multiple module/tab scenario
static JSContextCallback oldCallback;
static std::map<JSContext*,FFSessionHandler*> contextMap;
static bool registeredCallback = false;
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 Oct 8
15:43:45 2008
@@ -118,13 +118,13 @@
Debug::log(Debug::Spam) << "JavaObject::getProperty obj=" << obj <<
Debug::flush;
SessionData* data = JavaObject::getSessionData(ctx, obj);
if (!data) {
+ // TODO: replace the frame with an error page instead?
*rval = JSVAL_VOID;
return JS_TRUE;
}
int objectRef = JavaObject::getObjectId(ctx, obj);
if (JSVAL_IS_STRING(id)) {
JSString* str = JSVAL_TO_STRING(id);
-#if 1
if ((JS_GetStringLength(str) == 8) && !strncmp("toString",
JS_GetStringBytes(str), 8)) {
*rval = data->getToStringTearOff();
@@ -135,14 +135,15 @@
*rval = INT_TO_JSVAL(objectRef);
return JS_TRUE;
}
-#endif
Debug::log(Debug::Error) << "Getting unexpected string property "
<< dumpJsVal(ctx, id) << Debug::flush;
+ // TODO: throw a better exception here
return JS_FALSE;
}
if (!JSVAL_IS_INT(id)) {
Debug::log(Debug::Error) << "Getting non-int/non-string property "
<< dumpJsVal(ctx, id) << Debug::flush;
+ // TODO: throw a better exception here
return JS_FALSE;
}
int dispId = JSVAL_TO_INT(id);
@@ -160,6 +161,7 @@
Debug::log(Debug::Spam) << "JavaObject::setProperty obj=" << obj <<
Debug::flush;
if (!JSVAL_IS_INT(id)) {
Debug::log(Debug::Error) << " Error: setting string property id" <<
Debug::flush;
+ // TODO: throw a better exception here
return JS_FALSE;
}
@@ -178,11 +180,13 @@
SessionHandler* handler = data->getSessionHandler();
if (!ServerMethods::setProperty(*channel, handler, objectRef, dispId,
value)) {
+ // TODO: throw a better exception here
return JS_FALSE;
}
return JS_TRUE;
}
+// TODO: can this be removed now?
JSBool JavaObject::convert(JSContext* ctx, JSObject* obj, JSType type,
jsval* vp) {
Debug::log(Debug::Spam) << "JavaObject::convert obj=" << obj
<< " type=" << type << Debug::flush;
@@ -246,6 +250,10 @@
<< ", DESTROY)" << Debug::flush;
*statep = JSVAL_NULL;
break;
+ default:
+ Debug::log(Debug::Error) << "Unknown Enumerate op " <<
+ static_cast<int>(op) << Debug::flush;
+ return JS_FALSE;
}
return JS_TRUE;
}
@@ -273,7 +281,7 @@
<< Debug::flush;
Value javaThis;
javaThis.setJavaObject(oid);
- // TODO: do we care if they supply arguments? For now we just ignore
them.
+ // we ignore any supplied parameters
return invokeJava(ctx, data, javaThis, InvokeMessage::TOSTRING_DISP_ID,
0,
NULL, rval);
}
@@ -297,15 +305,17 @@
return JS_FALSE;
}
int dispId = JSVAL_TO_INT(argv[0]);
- Debug::DebugStream& dbg = Debug::log(Debug::Spam) << "JavaObject::call
oid="
- << JavaObject::getObjectId(ctx, obj) << ",dispId=" << dispId << " (";
- for (unsigned i = 2; i < argc; ++i) {
- if (i > 2) {
- dbg << ", ";
+ if (Debug::level(Debug::Spam) {
+ Debug::DebugStream& dbg = Debug::log(Debug::Spam) << "JavaObject::call
oid="
+ << JavaObject::getObjectId(ctx, obj) << ",dispId=" << dispId << "
(";
+ for (unsigned i = 2; i < argc; ++i) {
+ if (i > 2) {
+ dbg << ", ";
+ }
+ dbg << dumpJsVal(ctx, argv[i]);
}
- dbg << dumpJsVal(ctx, argv[i]);
+ dbg << ")" << Debug::flush;
}
- dbg << ")" << Debug::flush;
SessionData* data = JavaObject::getSessionData(ctx, obj);
if (!data) {
@@ -322,20 +332,9 @@
} else {
data->makeValueFromJsval(javaThis, ctx, argv[1]);
}
-#if 0
- if (!dispId) {
- Debug::log(Debug::Spam) << "toString called" << Debug::flush;
- }
-#endif
} else {
int oid = getObjectId(ctx, obj);
javaThis.setJavaObject(oid);
-#if 0
- if (!dispId) {
- Debug::log(Debug::Spam) << "toString on JavaObj(" << oid << ")
called"
- << Debug::flush;
- }
-#endif
}
return invokeJava(ctx, data, javaThis, dispId, argc - 2, &argv[2], rval);
}
@@ -352,11 +351,8 @@
SessionHandler* handler = data->getSessionHandler();
scoped_array<Value> args(new Value[numArgs]);
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->makeValueFromJsval(args[i], ctx, jsargs[i]);
}
-// static_cast<FFSessionHandler*>(handler)->sendFreeValues(*channel);
if (!InvokeMessage::send(*channel, javaThis, dispId, numArgs,
args.get())) {
Debug::log(Debug::Error) << "JavaObject::call failed to send invoke
message" << Debug::flush;
return false;
@@ -370,6 +366,7 @@
Value returnValue = retMsg->getReturnValue();
// Since we can set exceptions normally, we always return false to the
// wrapper function and set the exception ourselves if one occurs.
+ // TODO: cleanup exception case
jsval retvalArray[] = {JSVAL_FALSE, JSVAL_VOID};
JSObject* retval = JS_NewArrayObject(ctx, 2, retvalArray);
*rval = OBJECT_TO_JSVAL(retval);
Modified: changes/jat/oophm-branch/plugins/xpcom/Makefile.mac
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/Makefile.mac (original)
+++ changes/jat/oophm-branch/plugins/xpcom/Makefile.mac Wed Oct 8 15:43:45
2008
@@ -1,5 +1,4 @@
-#XUL_SDK_PATH=/Users/sgross/Downloads/xulrunner-1.8-sdk/xulrunner-sdk
-XUL_SDK_PATH=../../..//xulrunner-sdk
+XUL_SDK_PATH=../../../xulrunner-sdk
GECKO_SDK_PATH=$(XUL_SDK_PATH)/sdk
INC=-I. -I../common -I$(GECKO_SDK_PATH)/include
-I$(XUL_SDK_PATH)/include/caps -I$(XUL_SDK_PATH)/include/dom
-I$(XUL_SDK_PATH)/include/js -I$(XUL_SDK_PATH)/include/necko
-I$(XUL_SDK_PATH)/include/string -I$(XUL_SDK_PATH)/include/widget
-I$(XUL_SDK_PATH)/include/xpcom -I$(XUL_SDK_PATH)/include/xpconnect
-I$(XUL_SDK_PATH)/include
RUN_PATH_FLAG=-executable_path
Modified:
changes/jat/oophm-branch/plugins/xpcom/VisualStudio/firefox-xpcom.vcproj
==============================================================================
---
changes/jat/oophm-branch/plugins/xpcom/VisualStudio/firefox-xpcom.vcproj
(original)
+++
changes/jat/oophm-branch/plugins/xpcom/VisualStudio/firefox-xpcom.vcproj
Wed Oct 8 15:43:45 2008
@@ -221,6 +221,10 @@
>
</File>
<File
+ RelativePath="..\XpcomDebug.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\FreeValueMessage.h"
>
</File>
@@ -698,6 +702,10 @@
</File>
<File
RelativePath="..\FFSessionHandler.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\XpcomDebug.cpp"
>
</File>
<File
Modified: changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp (original)
+++ changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp Wed Oct 8
15:43:45 2008
@@ -19,12 +19,27 @@
#include "XpcomDebug.h"
#include "JavaObject.h"
+#ifdef _WINDOWS
+// avoid deprecation warnings for strncpy
+#define strncpy(d,s,c) strncpy_s((d),(c),(s),(c))
+
+#include <cstdarg>
+inline int snprintf(char* buf, size_t buflen, const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ int n = _vsnprintf_s(buf, buflen, buflen, fmt, args);
+ va_end(args);
+ return n;
+}
+
+#endif
+
std::string dumpJsVal(JSContext* ctx, jsval v) {
char buf[70];
if (v == JSVAL_VOID) {
- strcpy(buf, "undef");
+ strncpy(buf, "undef", sizeof(buf));
} else if (v == JSVAL_NULL) {
- strcpy(buf, "null");
+ strncpy(buf, "null", sizeof(buf));
} else {
switch (JSVAL_TAG(v)) {
case JSVAL_OBJECT:
@@ -49,14 +64,14 @@
case JSVAL_STRING:
{
JSString* str = JSVAL_TO_STRING(v);
- int len = JS_GetStringLength(str);
+ size_t len = JS_GetStringLength(str);
char* continued = "";
if (len > 20) {
len = 20;
continued = "...";
}
// TODO: trashes Unicode
- snprintf(buf, sizeof(buf), "string(%.*s%s)", len,
+ snprintf(buf, sizeof(buf), "string(%.*s%s)", static_cast<int>(len),
JS_GetStringBytes(str), continued);
break;
}
Modified: changes/jat/oophm-branch/plugins/xpcom/install-template.rdf
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/install-template.rdf (original)
+++ changes/jat/oophm-branch/plugins/xpcom/install-template.rdf Wed Oct 8
15:43:45 2008
@@ -27,7 +27,6 @@
<em:targetPlatform>Linux_x86_64-gcc3</em:targetPlatform>
<em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
<em:targetPlatform>Darwin_x86-gcc3</em:targetPlatform>
- <em:targetPlatform>SunOS_x86-sunc</em:targetPlatform>
<!-- TODO
# prefs dialog
@@ -41,6 +40,7 @@
# platforms - any others?
<em:targetPlatform>Darwin_ppc-gcc3</em:targetPlatform>
<em:targetPlatform>SunOS_sparc-sunc</em:targetPlatform>
+ <em:targetPlatform>SunOS_x86-sunc</em:targetPlatform>
-->
</Description>
Modified: changes/jat/oophm-branch/plugins/xpcom/xpOOPHM.rc
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/xpOOPHM.rc (original)
+++ changes/jat/oophm-branch/plugins/xpcom/xpOOPHM.rc Wed Oct 8 15:43:45
2008
@@ -33,7 +33,7 @@
VALUE "FileOpenName", "Plugin to allow debugging of GWT
applications
in hosted mode."
VALUE "FileVersion", "0.1a"
VALUE "InternalName", "GWT XPCOM OOPHM Plugin"
- VALUE "LegalCopyright", "Copyright © 2008 Google Inc. All
rights
reserved."
+ VALUE "LegalCopyright", "Copyright © 2008 Google Inc. Licensed
under
Apache 2.0 license."
VALUE "MIMEType", "application/x-gwt-hosted-mode"
VALUE "OriginalFilename", "xpOOPHM.dll"
VALUE "ProductName", "GWT XPCOM OOPHM Plugin"
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---