From e0996917fcb4ba46981a4d368f76eb80b917ebf5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 26 Nov 2011 11:08:42 +0100 Subject: [PATCH] Bug 698389 - Give nsIScriptContext::CompileFunction a JSObject outparam; r=peterv --- content/xbl/src/nsXBLProtoImplMethod.cpp | 4 ++-- content/xbl/src/nsXBLProtoImplProperty.cpp | 4 ++-- dom/base/nsIScriptContext.h | 6 +++--- dom/base/nsJSEnvironment.cpp | 9 +++++---- dom/base/nsJSEnvironment.h | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/content/xbl/src/nsXBLProtoImplMethod.cpp b/content/xbl/src/nsXBLProtoImplMethod.cpp index d31d70747a5f..d64c96ddbccf 100644 --- a/content/xbl/src/nsXBLProtoImplMethod.cpp +++ b/content/xbl/src/nsXBLProtoImplMethod.cpp @@ -239,13 +239,13 @@ nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString& nsresult rv = aContext->CompileFunction(aClassObject, cname, paramCount, - (const char**)args, + const_cast(args), body, functionUri.get(), uncompiledMethod->mBodyText.GetLineNumber(), JSVERSION_LATEST, true, - (void **) &methodObject); + &methodObject); // Destroy our uncompiled method and delete our arg list. delete uncompiledMethod; diff --git a/content/xbl/src/nsXBLProtoImplProperty.cpp b/content/xbl/src/nsXBLProtoImplProperty.cpp index df337cde2c8c..c6f6e05d825a 100644 --- a/content/xbl/src/nsXBLProtoImplProperty.cpp +++ b/content/xbl/src/nsXBLProtoImplProperty.cpp @@ -260,7 +260,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin mGetterText->GetLineNumber(), JSVERSION_LATEST, true, - (void **) &getterObject); + &getterObject); // Make sure we free mGetterText here before setting mJSGetterObject, since // that'll overwrite mGetterText @@ -310,7 +310,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin mSetterText->GetLineNumber(), JSVERSION_LATEST, true, - (void **) &setterObject); + &setterObject); // Make sure we free mSetterText here before setting mJSGetterObject, since // that'll overwrite mSetterText diff --git a/dom/base/nsIScriptContext.h b/dom/base/nsIScriptContext.h index a1ac549a6030..7a938095a4d8 100644 --- a/dom/base/nsIScriptContext.h +++ b/dom/base/nsIScriptContext.h @@ -74,8 +74,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal, NS_ISCRIPTCONTEXTPRINCIPAL_IID) #define NS_ISCRIPTCONTEXT_IID \ -{ 0x4289df58, 0x4f12, 0x4e16, \ - { 0x8c, 0x9a, 0x38, 0xd6, 0x30, 0xc4, 0x4d, 0xe6 } } +{ 0x67493f96, 0x304c, 0x4bd6, \ + { 0xac, 0xe7, 0xca, 0xeb, 0x85, 0xd1, 0x0b, 0x9d } } /* This MUST match JSVERSION_DEFAULT. This version stuff if we don't know what language we have is a little silly... */ @@ -266,7 +266,7 @@ public: PRUint32 aLineNo, PRUint32 aVersion, bool aShared, - void **aFunctionObject) = 0; + JSObject** aFunctionObject) = 0; /** * Set the default scripting language version for this context, which must diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index ac78c129e927..1c3e1ea647b8 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1793,11 +1793,14 @@ nsJSContext::CompileFunction(JSObject* aTarget, PRUint32 aLineNo, PRUint32 aVersion, bool aShared, - void** aFunctionObject) + JSObject** aFunctionObject) { NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s, url: %s, line: %d)", MOZ_FUNCTION_NAME, __LINE__, aName.BeginReading(), aURL, aLineNo); + NS_ABORT_IF_FALSE(aFunctionObject, + "Shouldn't call CompileFunction with null return value."); + NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED); // Don't compile if aVersion is unknown. Since the caller is responsible for @@ -1839,9 +1842,7 @@ nsJSContext::CompileFunction(JSObject* aTarget, if (!fun) return NS_ERROR_FAILURE; - JSObject *handler = ::JS_GetFunctionObject(fun); - if (aFunctionObject) - *aFunctionObject = (void*) handler; + *aFunctionObject = JS_GetFunctionObject(fun); return NS_OK; } diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 8f9b6dc9bdda..5eee290f1521 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -124,7 +124,7 @@ public: PRUint32 aLineNo, PRUint32 aVersion, bool aShared, - void** aFunctionObject); + JSObject** aFunctionObject); virtual void SetDefaultLanguageVersion(PRUint32 aVersion); virtual nsIScriptGlobalObject *GetGlobalObject();