From ebb9ed75cf8e3fb75a3e3b7d85f10ada026e4bba Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Thu, 26 Apr 2012 22:57:33 +0200 Subject: [PATCH] Fix for bug 741263 (Paris bindings constructors shouldn't abuse reserved identifiers). r=bz. --HG-- extra : rebase_source : cec6a0ffc58f3d7d262dc9658d52aac424ec715a --- content/base/src/nsXMLHttpRequest.h | 4 +-- dom/bindings/Codegen.py | 15 +++++------ dom/workers/DOMBindingBase.cpp | 4 +-- dom/workers/DOMBindingBase.h | 4 +-- dom/workers/EventListenerManager.h | 4 +-- dom/workers/EventTarget.cpp | 12 ++++----- dom/workers/EventTarget.h | 4 +-- dom/workers/Worker.cpp | 8 +++--- dom/workers/WorkerPrivate.cpp | 8 +++--- dom/workers/WorkerPrivate.h | 4 +-- dom/workers/WorkerScope.cpp | 32 ++++++++++++++--------- dom/workers/XMLHttpRequest.cpp | 10 +++---- dom/workers/XMLHttpRequest.h | 6 ++--- dom/workers/XMLHttpRequestEventTarget.cpp | 8 +++--- dom/workers/XMLHttpRequestEventTarget.h | 4 +-- dom/workers/XMLHttpRequestUpload.cpp | 8 +++--- dom/workers/XMLHttpRequestUpload.h | 4 +-- 17 files changed, 72 insertions(+), 67 deletions(-) diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 29bd639e2e5a..657e92cac2c9 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -177,9 +177,9 @@ public: return GetOwner(); } - // The WebIDL parser converts constructors into methods called _Constructor. + // The WebIDL constructor. static already_AddRefed - _Constructor(nsISupports* aGlobal, ErrorResult& aRv) + Constructor(nsISupports* aGlobal, ErrorResult& aRv) { nsCOMPtr window = do_QueryInterface(aGlobal); nsCOMPtr principal = do_QueryInterface(aGlobal); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index f2c812768961..d6c03778f722 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -11,11 +11,11 @@ from WebIDL import * AUTOGENERATED_WARNING_COMMENT = \ "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n" -ADDPROPERTY_HOOK_NAME = '_AddProperty' -FINALIZE_HOOK_NAME = '_Finalize' -TRACE_HOOK_NAME = '_Trace' -CONSTRUCT_HOOK_NAME = '_Construct' -HASINSTANCE_HOOK_NAME = '_HasInstance' +ADDPROPERTY_HOOK_NAME = '_addProperty' +FINALIZE_HOOK_NAME = '_finalize' +TRACE_HOOK_NAME = '_trace' +CONSTRUCT_HOOK_NAME = '_constructor' +HASINSTANCE_HOOK_NAME = '_hasInstance' def replaceFileIfChanged(filename, newContents): """ @@ -572,9 +572,8 @@ class CGClassConstructHook(CGAbstractStaticMethod): """ preArgs = "global, " - name = "_" + self._ctor.identifier.name - nativeName = "_" + MakeNativeName(self._ctor.identifier.name) - nativeName = self.descriptor.binaryNames.get(name, nativeName) + name = MakeNativeName(self._ctor.identifier.name) + nativeName = self.descriptor.binaryNames.get(name, name) callGenerator = CGMethodCall(preArgs, nativeName, True, self.descriptor, self._ctor, {}) return preamble + callGenerator.define(); diff --git a/dom/workers/DOMBindingBase.cpp b/dom/workers/DOMBindingBase.cpp index e9fdd6d54e85..9557ce89a3e0 100644 --- a/dom/workers/DOMBindingBase.cpp +++ b/dom/workers/DOMBindingBase.cpp @@ -30,7 +30,7 @@ DOMBindingBase::~DOMBindingBase() } void -DOMBindingBase::_Trace(JSTracer* aTrc) +DOMBindingBase::_trace(JSTracer* aTrc) { JSObject* obj = GetJSObject(); if (obj) { @@ -39,7 +39,7 @@ DOMBindingBase::_Trace(JSTracer* aTrc) } void -DOMBindingBase::_Finalize(JSFreeOp* aFop) +DOMBindingBase::_finalize(JSFreeOp* aFop) { ClearWrapper(); NS_RELEASE_THIS(); diff --git a/dom/workers/DOMBindingBase.h b/dom/workers/DOMBindingBase.h index 4302f60ebf8b..b26217979a22 100644 --- a/dom/workers/DOMBindingBase.h +++ b/dom/workers/DOMBindingBase.h @@ -37,10 +37,10 @@ protected: virtual ~DOMBindingBase(); virtual void - _Trace(JSTracer* aTrc); + _trace(JSTracer* aTrc); virtual void - _Finalize(JSFreeOp* aFop); + _finalize(JSFreeOp* aFop); JSContext* GetJSContextFromContextStack() const; diff --git a/dom/workers/EventListenerManager.h b/dom/workers/EventListenerManager.h index 8cd4b1006520..d12844bd503d 100644 --- a/dom/workers/EventListenerManager.h +++ b/dom/workers/EventListenerManager.h @@ -33,7 +33,7 @@ public: #endif void - _Trace(JSTracer* aTrc) const + _trace(JSTracer* aTrc) const { if (!PR_CLIST_IS_EMPTY(&mCollectionHead)) { TraceInternal(aTrc); @@ -41,7 +41,7 @@ public: } void - _Finalize(JSFreeOp* aFop) + _finalize(JSFreeOp* aFop) { if (!PR_CLIST_IS_EMPTY(&mCollectionHead)) { FinalizeInternal(aFop); diff --git a/dom/workers/EventTarget.cpp b/dom/workers/EventTarget.cpp index f32c4c354914..40a45f89a043 100644 --- a/dom/workers/EventTarget.cpp +++ b/dom/workers/EventTarget.cpp @@ -9,17 +9,17 @@ USING_WORKERS_NAMESPACE using mozilla::ErrorResult; void -EventTarget::_Trace(JSTracer* aTrc) +EventTarget::_trace(JSTracer* aTrc) { - mListenerManager._Trace(aTrc); - DOMBindingBase::_Trace(aTrc); + mListenerManager._trace(aTrc); + DOMBindingBase::_trace(aTrc); } void -EventTarget::_Finalize(JSFreeOp* aFop) +EventTarget::_finalize(JSFreeOp* aFop) { - mListenerManager._Finalize(aFop); - DOMBindingBase::_Finalize(aFop); + mListenerManager._finalize(aFop); + DOMBindingBase::_finalize(aFop); } JSObject* diff --git a/dom/workers/EventTarget.h b/dom/workers/EventTarget.h index 5d56681dc557..96f0bf14cdcc 100644 --- a/dom/workers/EventTarget.h +++ b/dom/workers/EventTarget.h @@ -32,10 +32,10 @@ protected: public: virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE; + _trace(JSTracer* aTrc) MOZ_OVERRIDE; virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE; + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; void AddEventListener(const nsAString& aType, JSObject* aListener, diff --git a/dom/workers/Worker.cpp b/dom/workers/Worker.cpp index 4e682a1aa68b..d5ac885bcfce 100644 --- a/dom/workers/Worker.cpp +++ b/dom/workers/Worker.cpp @@ -219,7 +219,7 @@ private: JS_ASSERT(JS_GetClass(aObj) == Class()); WorkerPrivate* worker = UnwrapDOMObject(aObj, Class()); if (worker) { - worker->_Finalize(aFop); + worker->_finalize(aFop); } } @@ -229,7 +229,7 @@ private: JS_ASSERT(JS_GetClass(aObj) == Class()); WorkerPrivate* worker = UnwrapDOMObject(aObj, Class()); if (worker) { - worker->_Trace(aTrc); + worker->_trace(aTrc); } } @@ -377,7 +377,7 @@ private: JS_ASSERT(JS_GetClass(aObj) == Class()); WorkerPrivate* worker = UnwrapDOMObject(aObj, Class()); if (worker) { - worker->_Finalize(aFop); + worker->_finalize(aFop); } } @@ -387,7 +387,7 @@ private: JS_ASSERT(JS_GetClass(aObj) == Class()); WorkerPrivate* worker = UnwrapDOMObject(aObj, Class()); if (worker) { - worker->_Trace(aTrc); + worker->_trace(aTrc); } } }; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 26a947b0db1e..240f8e3918d3 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -2047,17 +2047,17 @@ WorkerPrivateParent::Resume(JSContext* aCx) template void -WorkerPrivateParent::_Trace(JSTracer* aTrc) +WorkerPrivateParent::_trace(JSTracer* aTrc) { // This should only happen on the parent thread but we can't assert that // because it can also happen on the cycle collector thread when this is a // top-level worker. - EventTarget::_Trace(aTrc); + EventTarget::_trace(aTrc); } template void -WorkerPrivateParent::_Finalize(JSFreeOp* aFop) +WorkerPrivateParent::_finalize(JSFreeOp* aFop) { AssertIsOnParentThread(); @@ -2083,7 +2083,7 @@ WorkerPrivateParent::_Finalize(JSFreeOp* aFop) NS_ADDREF(extraSelfRef = this); } - EventTarget::_Finalize(aFop); + EventTarget::_finalize(aFop); if (extraSelfRef) { nsCOMPtr runnable = diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 80b25a0f28ed..a1376f5b8aeb 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -258,10 +258,10 @@ public: Resume(JSContext* aCx); virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE; + _trace(JSTracer* aTrc) MOZ_OVERRIDE; virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE; + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; void Finish(JSContext* aCx) diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 19ec1b5969fe..ed20ffb26408 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -101,6 +101,9 @@ public: sProperties, sFunctions, NULL, NULL); } + using EventTarget::GetEventListener; + using EventTarget::SetEventListener; + protected: WorkerGlobalScope(JSContext* aCx, WorkerPrivate* aWorker) : EventTarget(aCx), mWorker(aWorker) @@ -117,24 +120,24 @@ protected: } virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE + _trace(JSTracer* aTrc) MOZ_OVERRIDE { for (int32 i = 0; i < SLOT_COUNT; i++) { JS_CALL_VALUE_TRACER(aTrc, mSlots[i], "WorkerGlobalScope instance slot"); } mWorker->TraceInternal(aTrc); - EventTarget::_Trace(aTrc); + EventTarget::_trace(aTrc); } virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE { - EventTarget::_Finalize(aFop); + EventTarget::_finalize(aFop); } private: static JSBool - _GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp) + GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp) { JS_ASSERT(JSID_IS_INT(aIdval)); JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT); @@ -160,7 +163,7 @@ private: } static JSBool - _SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict, + SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict, jsval* aVp) { JS_ASSERT(JSID_IS_INT(aIdval)); @@ -614,7 +617,7 @@ JSPropertySpec WorkerGlobalScope::sProperties[] = { { sEventStrings[STRING_onerror], STRING_onerror, PROPERTY_FLAGS, GetOnErrorListener, SetOnErrorListener }, { sEventStrings[STRING_onclose], STRING_onclose, PROPERTY_FLAGS, - _GetEventListener, _SetEventListener }, + GetEventListener, SetEventListener }, { "navigator", SLOT_navigator, PROPERTY_FLAGS, GetNavigator, js_GetterOnlyPropertyStub }, { "self", 0, PROPERTY_FLAGS, GetSelf, js_GetterOnlyPropertyStub }, @@ -700,8 +703,11 @@ protected: } private: + using EventTarget::GetEventListener; + using EventTarget::SetEventListener; + static JSBool - _GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp) + GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp) { JS_ASSERT(JSID_IS_INT(aIdval)); JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT); @@ -727,8 +733,8 @@ private: } static JSBool - _SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict, - jsval* aVp) + SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict, + jsval* aVp) { JS_ASSERT(JSID_IS_INT(aIdval)); JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT); @@ -800,7 +806,7 @@ private: UnwrapDOMObject(aObj, Class()); if (scope) { DestroyProtoOrIfaceCache(aObj); - scope->_Finalize(aFop); + scope->_finalize(aFop); } } @@ -812,7 +818,7 @@ private: UnwrapDOMObject(aObj, Class()); if (scope) { mozilla::dom::TraceProtoOrIfaceCache(aTrc, aObj); - scope->_Trace(aTrc); + scope->_trace(aTrc); } } @@ -858,7 +864,7 @@ DOMJSClass DedicatedWorkerGlobalScope::sClass = { JSPropertySpec DedicatedWorkerGlobalScope::sProperties[] = { { sEventStrings[STRING_onmessage], STRING_onmessage, PROPERTY_FLAGS, - _GetEventListener, _SetEventListener }, + GetEventListener, SetEventListener }, { 0, 0, 0, NULL, NULL } }; diff --git a/dom/workers/XMLHttpRequest.cpp b/dom/workers/XMLHttpRequest.cpp index 8c2267fc9af2..1efd2e8527e2 100644 --- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -1430,25 +1430,25 @@ XMLHttpRequest::~XMLHttpRequest() } void -XMLHttpRequest::_Trace(JSTracer* aTrc) +XMLHttpRequest::_trace(JSTracer* aTrc) { if (mUpload) { JS_CALL_OBJECT_TRACER(aTrc, mUpload->GetJSObject(), "mUpload"); } JS_CALL_VALUE_TRACER(aTrc, mStateData.mResponse, "mResponse"); - XMLHttpRequestEventTarget::_Trace(aTrc); + XMLHttpRequestEventTarget::_trace(aTrc); } void -XMLHttpRequest::_Finalize(JSFreeOp* aFop) +XMLHttpRequest::_finalize(JSFreeOp* aFop) { ReleaseProxy(XHRIsGoingAway); - XMLHttpRequestEventTarget::_Finalize(aFop); + XMLHttpRequestEventTarget::_finalize(aFop); } // static XMLHttpRequest* -XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv) +XMLHttpRequest::Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv) { WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx); MOZ_ASSERT(workerPrivate); diff --git a/dom/workers/XMLHttpRequest.h b/dom/workers/XMLHttpRequest.h index 1b4ad2720a3a..099282db555c 100644 --- a/dom/workers/XMLHttpRequest.h +++ b/dom/workers/XMLHttpRequest.h @@ -62,13 +62,13 @@ protected: public: virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE; + _trace(JSTracer* aTrc) MOZ_OVERRIDE; virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE; + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; static XMLHttpRequest* - _Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv); + Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv); void Unpin(); diff --git a/dom/workers/XMLHttpRequestEventTarget.cpp b/dom/workers/XMLHttpRequestEventTarget.cpp index eb5b931446cf..1839fc79ff10 100644 --- a/dom/workers/XMLHttpRequestEventTarget.cpp +++ b/dom/workers/XMLHttpRequestEventTarget.cpp @@ -8,13 +8,13 @@ USING_WORKERS_NAMESPACE void -XMLHttpRequestEventTarget::_Trace(JSTracer* aTrc) +XMLHttpRequestEventTarget::_trace(JSTracer* aTrc) { - EventTarget::_Trace(aTrc); + EventTarget::_trace(aTrc); } void -XMLHttpRequestEventTarget::_Finalize(JSFreeOp* aFop) +XMLHttpRequestEventTarget::_finalize(JSFreeOp* aFop) { - EventTarget::_Finalize(aFop); + EventTarget::_finalize(aFop); } diff --git a/dom/workers/XMLHttpRequestEventTarget.h b/dom/workers/XMLHttpRequestEventTarget.h index 343b71a78eb5..3f2b13b348af 100644 --- a/dom/workers/XMLHttpRequestEventTarget.h +++ b/dom/workers/XMLHttpRequestEventTarget.h @@ -22,10 +22,10 @@ protected: public: virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE; + _trace(JSTracer* aTrc) MOZ_OVERRIDE; virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE; + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; #define IMPL_GETTER_AND_SETTER(_type) \ JSObject* \ diff --git a/dom/workers/XMLHttpRequestUpload.cpp b/dom/workers/XMLHttpRequestUpload.cpp index 28ed0e7ac384..27d45946b9a8 100644 --- a/dom/workers/XMLHttpRequestUpload.cpp +++ b/dom/workers/XMLHttpRequestUpload.cpp @@ -20,16 +20,16 @@ XMLHttpRequestUpload::Create(JSContext* aCx, XMLHttpRequest* aXHR) } void -XMLHttpRequestUpload::_Trace(JSTracer* aTrc) +XMLHttpRequestUpload::_trace(JSTracer* aTrc) { if (mXHR) { JS_CALL_OBJECT_TRACER(aTrc, mXHR->GetJSObject(), "mXHR"); } - XMLHttpRequestEventTarget::_Trace(aTrc); + XMLHttpRequestEventTarget::_trace(aTrc); } void -XMLHttpRequestUpload::_Finalize(JSFreeOp* aFop) +XMLHttpRequestUpload::_finalize(JSFreeOp* aFop) { - XMLHttpRequestEventTarget::_Finalize(aFop); + XMLHttpRequestEventTarget::_finalize(aFop); } diff --git a/dom/workers/XMLHttpRequestUpload.h b/dom/workers/XMLHttpRequestUpload.h index e763cd398e1d..11f0b1fad54c 100644 --- a/dom/workers/XMLHttpRequestUpload.h +++ b/dom/workers/XMLHttpRequestUpload.h @@ -29,10 +29,10 @@ public: Create(JSContext* aCx, XMLHttpRequest* aXHR); virtual void - _Trace(JSTracer* aTrc) MOZ_OVERRIDE; + _trace(JSTracer* aTrc) MOZ_OVERRIDE; virtual void - _Finalize(JSFreeOp* aFop) MOZ_OVERRIDE; + _finalize(JSFreeOp* aFop) MOZ_OVERRIDE; }; END_WORKERS_NAMESPACE