Bug 700172 - Fix XBL_DeserializeFunction's signature; r=enn
authorMs2ger <ms2ger@gmail.com>
Wed, 16 Nov 2011 08:50:18 +0100
changeset 80304 fc6e597b8b9e54d00cf2ab3c3c69bdedf2f50053
parent 80303 b832a0860c4b7a3a8c3f9fbd5dfe6434cadcb0ef
child 80305 ba55b19797a957c3e0894a14bef8d30ef05a7487
push id21484
push userMs2ger@gmail.com
push dateWed, 16 Nov 2011 07:55:38 +0000
treeherdermozilla-central@d51bd1645a2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn
bugs700172
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 700172 - Fix XBL_DeserializeFunction's signature; r=enn
content/xbl/src/nsXBLProtoImplMethod.cpp
content/xbl/src/nsXBLProtoImplProperty.cpp
content/xbl/src/nsXBLSerialize.cpp
content/xbl/src/nsXBLSerialize.h
--- a/content/xbl/src/nsXBLProtoImplMethod.cpp
+++ b/content/xbl/src/nsXBLProtoImplMethod.cpp
@@ -267,19 +267,17 @@ nsXBLProtoImplMethod::Trace(TraceCallbac
     aCallback(nsIProgrammingLanguage::JAVASCRIPT, mJSMethodObject, "mJSMethodObject", aClosure);
   }
 }
 
 nsresult
 nsXBLProtoImplMethod::Read(nsIScriptContext* aContext,
                            nsIObjectInputStream* aStream)
 {
-  void* methodCode;
-  nsresult rv = XBL_DeserializeFunction(aContext, aStream, this, &methodCode);
-  mJSMethodObject = (JSObject *)methodCode;
+  nsresult rv = XBL_DeserializeFunction(aContext, aStream, &mJSMethodObject);
   if (NS_FAILED(rv)) {
     SetUncompiledMethod(nsnull);
     return rv;
   }
 
 #ifdef DEBUG
   mIsCompiled = true;
 #endif
--- a/content/xbl/src/nsXBLProtoImplProperty.cpp
+++ b/content/xbl/src/nsXBLProtoImplProperty.cpp
@@ -355,34 +355,33 @@ nsXBLProtoImplProperty::Trace(TraceCallb
   }
 }
 
 nsresult
 nsXBLProtoImplProperty::Read(nsIScriptContext* aContext,
                              nsIObjectInputStream* aStream,
                              XBLBindingSerializeDetails aType)
 {
-  nsresult rv;
-  void* scriptObject;
-
   if (aType == XBLBinding_Serialize_GetterProperty ||
       aType == XBLBinding_Serialize_GetterSetterProperty) {
-    rv = XBL_DeserializeFunction(aContext, aStream, this, &scriptObject);
+    JSObject* getterObject;
+    nsresult rv = XBL_DeserializeFunction(aContext, aStream, &getterObject);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    mJSGetterObject = (JSObject *)scriptObject;
+    mJSGetterObject = getterObject;
     mJSAttributes |= JSPROP_GETTER | JSPROP_SHARED;
   }
 
   if (aType == XBLBinding_Serialize_SetterProperty ||
       aType == XBLBinding_Serialize_GetterSetterProperty) {
-    rv = XBL_DeserializeFunction(aContext, aStream, this, &scriptObject);
+    JSObject* setterObject;
+    nsresult rv = XBL_DeserializeFunction(aContext, aStream, &setterObject);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    mJSSetterObject = (JSObject *)scriptObject;
+    mJSSetterObject = setterObject;
     mJSAttributes |= JSPROP_SETTER | JSPROP_SHARED;
   }
 
 #ifdef DEBUG
   mIsCompiled = true;
 #endif
 
   return NS_OK;
--- a/content/xbl/src/nsXBLSerialize.cpp
+++ b/content/xbl/src/nsXBLSerialize.cpp
@@ -70,22 +70,19 @@ XBL_SerializeFunction(nsIScriptContext* 
 
   return rv;
 }
 
 // static
 nsresult
 XBL_DeserializeFunction(nsIScriptContext* aContext,
                         nsIObjectInputStream* aStream,
-                        void* aHolder,
-                        void **aScriptObject)
+                        JSObject** aFunctionObject)
 {
-  *aScriptObject = nsnull;
-
-  JSObject* functionObject = nsnull;
+  *aFunctionObject = nsnull;
 
   PRUint32 size;
   nsresult rv = aStream->Read32(&size);
   if (NS_FAILED(rv))
     return rv;
 
   char* data;
   rv = aStream->ReadBytes(size, &data);
@@ -96,25 +93,22 @@ XBL_DeserializeFunction(nsIScriptContext
   JSXDRState *xdr = JS_XDRNewMem(cx, JSXDR_DECODE);
   if (!xdr) {
     rv = NS_ERROR_OUT_OF_MEMORY;
   } else {
     xdr->userdata = static_cast<void*>(aStream);
     JSAutoRequest ar(cx);
     JS_XDRMemSetData(xdr, data, size);
 
-    if (!JS_XDRFunctionObject(xdr, &functionObject)) {
+    if (!JS_XDRFunctionObject(xdr, aFunctionObject)) {
       rv = NS_ERROR_FAILURE;
     }
 
     uint32 junk;
     data = static_cast<char*>(JS_XDRMemGetData(xdr, &junk));
     JS_XDRMemSetData(xdr, NULL, 0);
     JS_XDRDestroy(xdr);
   }
 
   nsMemory::Free(data);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  *aScriptObject = functionObject;
-
   return rv;
 }
--- a/content/xbl/src/nsXBLSerialize.h
+++ b/content/xbl/src/nsXBLSerialize.h
@@ -108,12 +108,11 @@ PR_STATIC_ASSERT(XBLBinding_Serialize_Cu
 nsresult
 XBL_SerializeFunction(nsIScriptContext* aContext,
                       nsIObjectOutputStream* aStream,
                       JSObject* aFunctionObject);
 
 nsresult
 XBL_DeserializeFunction(nsIScriptContext* aContext,
                         nsIObjectInputStream* aStream,
-                        void* aHolder,
-                        void **aScriptObject);
+                        JSObject** aFunctionObject);
 
 #endif // nsXBLSerialize_h__