diff --git a/mozilla/content/events/public/nsPLDOMEvent.h b/mozilla/content/events/public/nsPLDOMEvent.h index 3e9ba642e5d..ce4c58a348a 100644 --- a/mozilla/content/events/public/nsPLDOMEvent.h +++ b/mozilla/content/events/public/nsPLDOMEvent.h @@ -61,7 +61,7 @@ struct nsPLDOMEvent : public PLEvent { nsString mEventType; }; -static void PR_CALLBACK HandlePLDOMEvent(nsPLDOMEvent* aEvent); -static void PR_CALLBACK DestroyPLDOMEvent(nsPLDOMEvent* aEvent); +static void* PR_CALLBACK HandlePLDOMEvent(PLEvent* aEvent); +static void PR_CALLBACK DestroyPLDOMEvent(PLEvent* aEvent); #endif diff --git a/mozilla/content/events/src/nsPLDOMEvent.cpp b/mozilla/content/events/src/nsPLDOMEvent.cpp index f89a1a60b7e..2615c435aa3 100644 --- a/mozilla/content/events/src/nsPLDOMEvent.cpp +++ b/mozilla/content/events/src/nsPLDOMEvent.cpp @@ -73,19 +73,22 @@ nsresult nsPLDOMEvent::PostDOMEvent() nsCOMPtr eventQueue; nsresult rv = NS_GetCurrentEventQ(getter_AddRefs(eventQueue)); if (NS_SUCCEEDED(rv)) { - PL_InitEvent(this, nsnull, (PLHandleEventProc) ::HandlePLDOMEvent, (PLDestroyEventProc) ::DestroyPLDOMEvent); + PL_InitEvent(this, nsnull, ::HandlePLDOMEvent, ::DestroyPLDOMEvent); rv = eventQueue->PostEvent(this); } return rv; } -static void PR_CALLBACK HandlePLDOMEvent(nsPLDOMEvent* aEvent) +static void* PR_CALLBACK HandlePLDOMEvent(PLEvent* aEvent) { - aEvent->HandleEvent(); + nsPLDOMEvent* event = NS_STATIC_CAST(nsPLDOMEvent*, aEvent); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyPLDOMEvent(nsPLDOMEvent* aEvent) +static void PR_CALLBACK DestroyPLDOMEvent(PLEvent* aEvent) { - delete aEvent; + nsPLDOMEvent* event = NS_STATIC_CAST(nsPLDOMEvent*, aEvent); + delete event; } diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index acd32441368..f1516bb5de3 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -354,14 +354,17 @@ struct OnLinkClickEvent : public PLEvent { PopupControlState mPopupState; }; -static void PR_CALLBACK HandlePLEvent(OnLinkClickEvent* aEvent) +static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent) { - aEvent->HandleEvent(); + OnLinkClickEvent* event = NS_STATIC_CAST(OnLinkClickEvent*, aEvent); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyPLEvent(OnLinkClickEvent* aEvent) +static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent) { - delete aEvent; + OnLinkClickEvent* event = NS_STATIC_CAST(OnLinkClickEvent*, aEvent); + delete event; } OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler, @@ -385,9 +388,7 @@ OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler, mPopupState = window->GetPopupControlState(); - PL_InitEvent(this, nsnull, - (PLHandleEventProc) ::HandlePLEvent, - (PLDestroyEventProc) ::DestroyPLEvent); + PL_InitEvent(this, nsnull, ::HandlePLEvent, ::DestroyPLEvent); nsCOMPtr eventQueue; aHandler->GetEventQueue(getter_AddRefs(eventQueue)); diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index cff21d2bd72..7156d1f13c6 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -4364,13 +4364,16 @@ struct nsCloseEvent : public PLEvent { nsRefPtr mWindow; }; -static void PR_CALLBACK HandleCloseEvent(nsCloseEvent* aEvent) +static void* PR_CALLBACK HandleCloseEvent(PLEvent* aEvent) { - aEvent->HandleEvent(); + nsCloseEvent *event = NS_STATIC_CAST(nsCloseEvent*, aEvent); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyCloseEvent(nsCloseEvent* aEvent) +static void PR_CALLBACK DestroyCloseEvent(PLEvent* aEvent) { - delete aEvent; + nsCloseEvent *event = NS_STATIC_CAST(nsCloseEvent*, aEvent); + delete event; } nsresult @@ -4382,7 +4385,7 @@ nsCloseEvent::PostCloseEvent() eventService->GetThreadEventQueue(PR_GetCurrentThread(), getter_AddRefs(eventQueue)); if (eventQueue) { - PL_InitEvent(this, nsnull, (PLHandleEventProc) ::HandleCloseEvent, (PLDestroyEventProc) ::DestroyCloseEvent); + PL_InitEvent(this, nsnull, ::HandleCloseEvent, ::DestroyCloseEvent); return eventQueue->PostEvent(this); } } diff --git a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp b/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp index 669e729560c..eeb94b82018 100644 --- a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp +++ b/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp @@ -104,7 +104,7 @@ private: }; // Define PL Callback Functions -static void PR_CALLBACK HandlePLEvent(PLEvent* aEvent); +static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent); static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent); @@ -201,7 +201,7 @@ CPrintingPromptService::FirePauseEvent() return PR_FALSE; } - PL_InitEvent(event, this, (PLHandleEventProc)::HandlePLEvent, (PLDestroyEventProc)::DestroyPLEvent); + PL_InitEvent(event, this, ::HandlePLEvent, ::DestroyPLEvent); // The event owns the content pointer now. NS_ADDREF_THIS(); @@ -277,7 +277,7 @@ void CPrintingPromptService::NotifyObserver() } //------------------------------------------------------------------------ -void PR_CALLBACK HandlePLEvent(PLEvent* aEvent) +void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent) { CPrintingPromptService *printingPromptService = (CPrintingPromptService*)PL_GetEventOwner(aEvent); @@ -285,6 +285,7 @@ void PR_CALLBACK HandlePLEvent(PLEvent* aEvent) if (printingPromptService) { printingPromptService->NotifyObserver(); } + return nsnull; } //------------------------------------------------------------------------ diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 39a9836a2ea..59d622c7eda 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -6319,14 +6319,17 @@ struct ReflowEvent : public PLEvent { nsWeakPtr mPresShell; }; -static void PR_CALLBACK HandlePLEvent(ReflowEvent* aEvent) +static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent) { - aEvent->HandleEvent(); + ReflowEvent* event = NS_STATIC_CAST(ReflowEvent*, aEvent); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyPLEvent(ReflowEvent* aEvent) +static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent) { - delete aEvent; + ReflowEvent* event = NS_STATIC_CAST(ReflowEvent*, aEvent); + delete event; } @@ -6336,9 +6339,7 @@ ReflowEvent::ReflowEvent(nsIPresShell* aPresShell) mPresShell = do_GetWeakReference(aPresShell); - PL_InitEvent(this, aPresShell, - (PLHandleEventProc) ::HandlePLEvent, - (PLDestroyEventProc) ::DestroyPLEvent); + PL_InitEvent(this, aPresShell, ::HandlePLEvent, ::DestroyPLEvent); } //-------------- End Reflow Event Definition --------------------------- diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 105fda4b822..0bdf1e7b947 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -7163,8 +7163,8 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView, return rv; } -static void PR_CALLBACK HandlePLEvent(nsScrollSelectionIntoViewEvent* aEvent); -static void PR_CALLBACK DestroyPLEvent(nsScrollSelectionIntoViewEvent* aEvent); +static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent); +static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent); struct nsScrollSelectionIntoViewEvent : public PLEvent { nsScrollSelectionIntoViewEvent(nsTypedSelection *aTypedSelection, SelectionRegion aRegion) { @@ -7174,9 +7174,7 @@ struct nsScrollSelectionIntoViewEvent : public PLEvent { mTypedSelection = aTypedSelection; mRegion = aRegion; - PL_InitEvent(this, aTypedSelection, - (PLHandleEventProc) ::HandlePLEvent, - (PLDestroyEventProc) ::DestroyPLEvent); + PL_InitEvent(this, aTypedSelection, ::HandlePLEvent, ::DestroyPLEvent); } ~nsScrollSelectionIntoViewEvent() {} @@ -7194,16 +7192,21 @@ struct nsScrollSelectionIntoViewEvent : public PLEvent { SelectionRegion mRegion; }; -static void PR_CALLBACK HandlePLEvent(nsScrollSelectionIntoViewEvent* aEvent) +static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent) { - NS_ASSERTION(nsnull != aEvent,"Event is null"); - aEvent->HandleEvent(); + nsScrollSelectionIntoViewEvent* event = + NS_STATIC_CAST(nsScrollSelectionIntoViewEvent*, aEvent); + NS_ASSERTION(nsnull != event,"Event is null"); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyPLEvent(nsScrollSelectionIntoViewEvent* aEvent) +static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent) { - NS_ASSERTION(nsnull != aEvent,"Event is null"); - delete aEvent; + nsScrollSelectionIntoViewEvent* event = + NS_STATIC_CAST(nsScrollSelectionIntoViewEvent*, aEvent); + NS_ASSERTION(nsnull != event,"Event is null"); + delete event; } nsresult diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index aabfb0020de..67b6a2b34cd 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -4555,7 +4555,7 @@ nsPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const PRUnicha //--------------------------------------------------------------- //-- PLEvent Notification //--------------------------------------------------------------- -void PR_CALLBACK HandlePLEvent(PLEvent* aEvent) +PR_STATIC_CALLBACK(void*) HandlePLEvent(PLEvent* aEvent) { nsIDocumentViewerPrint *docViewerPrint = (nsIDocumentViewerPrint*)PL_GetEventOwner(aEvent); @@ -4563,10 +4563,12 @@ void PR_CALLBACK HandlePLEvent(PLEvent* aEvent) if (docViewerPrint) { docViewerPrint->OnDonePrinting(); } + + return nsnull; } //------------------------------------------------------------------------ -void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent) +PR_STATIC_CALLBACK(void) DestroyPLEvent(PLEvent* aEvent) { nsIDocumentViewerPrint *docViewerPrint = (nsIDocumentViewerPrint*)PL_GetEventOwner(aEvent); NS_IF_RELEASE(docViewerPrint); @@ -4606,7 +4608,7 @@ nsPrintEngine::FirePrintCompletionEvent() return; } - PL_InitEvent(event, mDocViewerPrint, (PLHandleEventProc)::HandlePLEvent, (PLDestroyEventProc)::DestroyPLEvent); + PL_InitEvent(event, mDocViewerPrint, ::HandlePLEvent, ::DestroyPLEvent); // The event owns the docviewer pointer now. NS_ADDREF(mDocViewerPrint); diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index ec6e270baa5..0d489de1593 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -127,7 +127,7 @@ HandleImagePLEvent(nsIContent *aContent, PRUint32 aMessage, PRUint32 aFlags) aContent->HandleDOMEvent(pres_context, &event, nsnull, aFlags, &status); } -static void PR_CALLBACK +static void* PR_CALLBACK HandleImageOnloadPLEvent(PLEvent *aEvent) { nsIContent *content = (nsIContent *)PL_GetEventOwner(aEvent); @@ -135,17 +135,23 @@ HandleImageOnloadPLEvent(PLEvent *aEvent) HandleImagePLEvent(content, NS_IMAGE_LOAD, NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_CANT_BUBBLE); + // XXXldb Why not put this in DestroyImagePLEvent? NS_RELEASE(content); + + return nsnull; } -static void PR_CALLBACK +static void* PR_CALLBACK HandleImageOnerrorPLEvent(PLEvent *aEvent) { nsIContent *content = (nsIContent *)PL_GetEventOwner(aEvent); HandleImagePLEvent(content, NS_IMAGE_ERROR, NS_EVENT_FLAG_INIT); + // XXXldb Why not put this in DestroyImagePLEvent? NS_RELEASE(content); + + return nsnull; } static void PR_CALLBACK @@ -202,11 +208,11 @@ FireDOMEvent(nsIContent* aContent, PRUint32 aMessage) switch (aMessage) { case NS_IMAGE_LOAD : - f = (PLHandleEventProc)::HandleImageOnloadPLEvent; + f = ::HandleImageOnloadPLEvent; break; case NS_IMAGE_ERROR : - f = (PLHandleEventProc)::HandleImageOnerrorPLEvent; + f = ::HandleImageOnerrorPLEvent; break; default: @@ -215,7 +221,7 @@ FireDOMEvent(nsIContent* aContent, PRUint32 aMessage) return; } - PL_InitEvent(event, aContent, f, (PLDestroyEventProc)::DestroyImagePLEvent); + PL_InitEvent(event, aContent, f, ::DestroyImagePLEvent); // The event owns the content pointer now. NS_ADDREF(aContent); diff --git a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp index bbdc3d5879a..334435dfc23 100644 --- a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp +++ b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp @@ -776,7 +776,7 @@ FireEvent(nsMsgPrintEngine* aMPE, PLHandleEventProc handler, PLDestroyEventProc return PR_TRUE; } -void PR_CALLBACK HandlePLEventPrintMsgWindow(PLEvent* aEvent) +PR_STATIC_CALLBACK(void*) HandlePLEventPrintMsgWindow(PLEvent* aEvent) { nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent); @@ -785,10 +785,12 @@ void PR_CALLBACK HandlePLEventPrintMsgWindow(PLEvent* aEvent) { msgPrintEngine->PrintMsgWindow(); } + + return nsnull; } //------------------------------------------------------------------------ -void PR_CALLBACK DestroyPLEventPrintMsgWindow(PLEvent* aEvent) +PR_STATIC_CALLBACK(void) DestroyPLEventPrintMsgWindow(PLEvent* aEvent) { nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent); NS_IF_RELEASE(msgPrintEngine); @@ -800,11 +802,11 @@ void PR_CALLBACK DestroyPLEventPrintMsgWindow(PLEvent* aEvent) PRBool nsMsgPrintEngine::FirePrintEvent() { - return FireEvent(this, (PLHandleEventProc)::HandlePLEventPrintMsgWindow, - (PLDestroyEventProc)::DestroyPLEventPrintMsgWindow); + return FireEvent(this, ::HandlePLEventPrintMsgWindow, + ::DestroyPLEventPrintMsgWindow); } -void PR_CALLBACK HandlePLEventStartNext(PLEvent* aEvent) +PR_STATIC_CALLBACK(void*) HandlePLEventStartNext(PLEvent* aEvent) { nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent); @@ -813,10 +815,12 @@ void PR_CALLBACK HandlePLEventStartNext(PLEvent* aEvent) { msgPrintEngine->StartNextPrintOperation(); } + + return nsnull; } //------------------------------------------------------------------------ -void PR_CALLBACK DestroyPLEventStartNext(PLEvent* aEvent) +PR_STATIC_CALLBACK(void) DestroyPLEventStartNext(PLEvent* aEvent) { nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent); NS_IF_RELEASE(msgPrintEngine); @@ -828,8 +832,8 @@ void PR_CALLBACK DestroyPLEventStartNext(PLEvent* aEvent) PRBool nsMsgPrintEngine::FireStartNextEvent() { - return FireEvent(this, (PLHandleEventProc)::HandlePLEventStartNext, - (PLDestroyEventProc)::DestroyPLEventStartNext); + return FireEvent(this, ::HandlePLEventStartNext, + ::DestroyPLEventStartNext); } /* void setStartupPPObserver (in nsIObserver startupPPObs); */ diff --git a/mozilla/mailnews/imap/src/nsImapProxyEvent.cpp b/mozilla/mailnews/imap/src/nsImapProxyEvent.cpp index b48a7b59bba..6bb0228c683 100644 --- a/mozilla/mailnews/imap/src/nsImapProxyEvent.cpp +++ b/mozilla/mailnews/imap/src/nsImapProxyEvent.cpp @@ -69,9 +69,7 @@ nsImapEvent::SetNotifyCompletion(PRBool notifyCompletion) void nsImapEvent::InitEvent() { - PL_InitEvent(this, nsnull, - (PLHandleEventProc) imap_event_handler, - (PLDestroyEventProc) imap_event_destructor); + PL_InitEvent(this, nsnull, imap_event_handler, imap_event_destructor); } void @@ -83,11 +81,12 @@ nsImapEvent::PostEvent(nsIEventQueue* aEventQ) aEventQ->PostEvent(this); } -void PR_CALLBACK +void* PR_CALLBACK nsImapEvent::imap_event_handler(PLEvent *aEvent) { nsImapEvent* ev = (nsImapEvent*) aEvent; ev->HandleEvent(); + return nsnull; } void PR_CALLBACK diff --git a/mozilla/mailnews/imap/src/nsImapProxyEvent.h b/mozilla/mailnews/imap/src/nsImapProxyEvent.h index 7da460a9ed4..216f3f64eb9 100644 --- a/mozilla/mailnews/imap/src/nsImapProxyEvent.h +++ b/mozilla/mailnews/imap/src/nsImapProxyEvent.h @@ -77,7 +77,7 @@ struct nsImapEvent : public PLEvent void PostEvent(nsIEventQueue* aEventQ); virtual void SetNotifyCompletion(PRBool notifyCompletion); - static void PR_CALLBACK imap_event_handler(PLEvent* aEvent); + static void* PR_CALLBACK imap_event_handler(PLEvent* aEvent); static void PR_CALLBACK imap_event_destructor(PLEvent *aEvent); PRBool m_notifyCompletion; }; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index c47ee288465..289155df86a 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -351,13 +351,16 @@ nsresult nsPluginDocReframeEvent::HandlePluginDocReframeEvent() { //---------------------------------------------------------------------- static void* PR_CALLBACK HandlePluginDocReframePLEvent(PLEvent* aEvent) { - nsPluginDocReframeEvent* event = NS_REINTERPRET_CAST(nsPluginDocReframeEvent*, aEvent); + nsPluginDocReframeEvent* event = + NS_STATIC_CAST(nsPluginDocReframeEvent*, aEvent); event->HandlePluginDocReframeEvent(); return nsnull; } static void PR_CALLBACK DestroyPluginDocReframePLEvent(PLEvent* aEvent) { - delete aEvent; + nsPluginDocReframeEvent* event = + NS_STATIC_CAST(nsPluginDocReframeEvent*, aEvent); + delete event; } @@ -991,13 +994,16 @@ nsPluginUnloadEvent::nsPluginUnloadEvent (PRLibrary* aLibrary) } //---------------------------------------------------------------------- // helper static callback functions for plugin unloading PLEvents -static void PR_CALLBACK HandlePluginUnloadPLEvent(nsPluginUnloadEvent* aEvent) +static void* PR_CALLBACK HandlePluginUnloadPLEvent(PLEvent* aEvent) { - aEvent->HandleEvent(); + nsPluginUnloadEvent *event = NS_STATIC_CAST(nsPluginUnloadEvent*, aEvent); + event->HandleEvent(); + return nsnull; } -static void PR_CALLBACK DestroyPluginUnloadPLEvent(nsPluginUnloadEvent* aEvent) +static void PR_CALLBACK DestroyPluginUnloadPLEvent(PLEvent* aEvent) { - delete aEvent; + nsPluginUnloadEvent *event = NS_STATIC_CAST(nsPluginUnloadEvent*, aEvent); + delete event; } // unload plugin asynchronously if possible, otherwise just unload now @@ -1011,7 +1017,7 @@ nsresult PostPluginUnloadEvent (PRLibrary* aLibrary) nsPluginUnloadEvent * ev = new nsPluginUnloadEvent(aLibrary); if (ev) { - PL_InitEvent(ev, nsnull, (PLHandleEventProc) ::HandlePluginUnloadPLEvent, (PLDestroyEventProc) ::DestroyPluginUnloadPLEvent); + PL_InitEvent(ev, nsnull, ::HandlePluginUnloadPLEvent, ::DestroyPluginUnloadPLEvent); if (NS_SUCCEEDED(eventQueue->PostEvent(ev))) return NS_OK; else NS_WARNING("failed to post event onto queue"); diff --git a/mozilla/modules/plugin/samples/SanePlugin/nsSanePlugin.cpp b/mozilla/modules/plugin/samples/SanePlugin/nsSanePlugin.cpp index 014634ef875..ebd1094c2bb 100644 --- a/mozilla/modules/plugin/samples/SanePlugin/nsSanePlugin.cpp +++ b/mozilla/modules/plugin/samples/SanePlugin/nsSanePlugin.cpp @@ -76,7 +76,7 @@ struct my_JPEG_error_mgr typedef struct my_JPEG_error_mgr *emptr; static void PR_CALLBACK ThreadedDestroyEvent(PLEvent* aEvent); -static void PR_CALLBACK ThreadedHandleEvent(PLEvent* aEvent); +static void* PR_CALLBACK ThreadedHandleEvent(PLEvent* aEvent); //static void PR_CALLBACK scanimage_thread_routine( void * arg ); @@ -2550,10 +2550,7 @@ void PR_CALLBACK scanimage_thread_routine( void * arg ) } // ThreadHandleEvent will now execute in the UI thread. - PL_InitEvent(event, - pthis, - (PLHandleEventProc) ThreadedHandleEvent, - (PLDestroyEventProc) ThreadedDestroyEvent); + PL_InitEvent(event, pthis, ThreadedHandleEvent, ThreadedDestroyEvent); if (NS_FAILED(eventQ->PostEvent(event))) { NS_ERROR("Error trying to post event!\n"); @@ -2562,7 +2559,7 @@ void PR_CALLBACK scanimage_thread_routine( void * arg ) } } -void PR_CALLBACK ThreadedHandleEvent(PLEvent * event) +void* PR_CALLBACK ThreadedHandleEvent(PLEvent * event) { nsSanePluginInstance *pthis = (nsSanePluginInstance *)event->owner; @@ -2577,6 +2574,8 @@ void PR_CALLBACK ThreadedHandleEvent(PLEvent * event) // Notify user that routine is finished pthis->DoScanCompleteCallback(); + + return nsnull; } void PR_CALLBACK ThreadedDestroyEvent(PLEvent* aEvent) diff --git a/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp b/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp index 369653553d0..8dd26862beb 100644 --- a/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp +++ b/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp @@ -71,7 +71,7 @@ public: NS_IMETHOD HandleEvent() = 0; protected: - static void PR_CALLBACK HandlePLEvent(PLEvent* aEvent); + static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent); static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent); nsAsyncStreamObserver* mListener; @@ -105,7 +105,7 @@ nsStreamListenerEvent::~nsStreamListenerEvent() NS_IF_RELEASE(mContext); } -void PR_CALLBACK nsStreamListenerEvent::HandlePLEvent(PLEvent* aEvent) +void* PR_CALLBACK nsStreamListenerEvent::HandlePLEvent(PLEvent* aEvent) { nsStreamListenerEvent* ev = GET_STREAM_LISTENER_EVENT(aEvent); NS_ASSERTION(nsnull != ev,"null event."); @@ -123,6 +123,8 @@ void PR_CALLBACK nsStreamListenerEvent::HandlePLEvent(PLEvent* aEvent) nsresult cancelRv = ev->mRequest->Cancel(rv); NS_ASSERTION(NS_SUCCEEDED(cancelRv), "Cancel failed"); } + + return nsnull; } void PR_CALLBACK nsStreamListenerEvent::DestroyPLEvent(PLEvent* aEvent) @@ -139,8 +141,8 @@ nsStreamListenerEvent::Fire(nsIEventQueue* aEventQueue) PL_InitEvent(&mEvent, nsnull, - (PLHandleEventProc) nsStreamListenerEvent::HandlePLEvent, - (PLDestroyEventProc) nsStreamListenerEvent::DestroyPLEvent); + nsStreamListenerEvent::HandlePLEvent, + nsStreamListenerEvent::DestroyPLEvent); return aEventQueue->PostEvent(&mEvent); } diff --git a/mozilla/netwerk/base/src/nsRequestObserverProxy.cpp b/mozilla/netwerk/base/src/nsRequestObserverProxy.cpp index 31f330d3bd5..47dfe325a00 100644 --- a/mozilla/netwerk/base/src/nsRequestObserverProxy.cpp +++ b/mozilla/netwerk/base/src/nsRequestObserverProxy.cpp @@ -100,11 +100,11 @@ nsARequestObserverEvent::nsARequestObserverEvent(nsIRequest *request, NS_PRECONDITION(mRequest, "null pointer"); PL_InitEvent(&mEvent, nsnull, - (PLHandleEventProc) nsARequestObserverEvent::HandlePLEvent, - (PLDestroyEventProc) nsARequestObserverEvent::DestroyPLEvent); + nsARequestObserverEvent::HandlePLEvent, + nsARequestObserverEvent::DestroyPLEvent); } -void PR_CALLBACK +void* PR_CALLBACK nsARequestObserverEvent::HandlePLEvent(PLEvent *plev) { nsARequestObserverEvent *ev = FromPLEvent(plev); @@ -113,6 +113,8 @@ nsARequestObserverEvent::HandlePLEvent(PLEvent *plev) // Pass control to the real event handler if (ev) ev->HandleEvent(); + + return nsnull; } void PR_CALLBACK diff --git a/mozilla/netwerk/base/src/nsRequestObserverProxy.h b/mozilla/netwerk/base/src/nsRequestObserverProxy.h index 607af3f3bb7..294c54df1de 100644 --- a/mozilla/netwerk/base/src/nsRequestObserverProxy.h +++ b/mozilla/netwerk/base/src/nsRequestObserverProxy.h @@ -88,7 +88,7 @@ public: virtual void HandleEvent() = 0; protected: - static void PR_CALLBACK HandlePLEvent(PLEvent *); + static void* PR_CALLBACK HandlePLEvent(PLEvent *); static void PR_CALLBACK DestroyPLEvent(PLEvent *); PLEvent mEvent; // this _must_ be the first data member diff --git a/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp b/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp index 654d21838ed..c277bd6105b 100644 --- a/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp +++ b/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp @@ -75,14 +75,14 @@ nsStreamObserverEvent::FireEvent(nsIEventQueue *aEventQ) NS_PRECONDITION(aEventQ, "null event queue"); PL_InitEvent(&mEvent, nsnull, - (PLHandleEventProc) nsStreamObserverEvent::HandlePLEvent, - (PLDestroyEventProc) nsStreamObserverEvent::DestroyPLEvent); + nsStreamObserverEvent::HandlePLEvent, + nsStreamObserverEvent::DestroyPLEvent); PRStatus status = aEventQ->PostEvent(&mEvent); return status == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE; } -void PR_CALLBACK +void* PR_CALLBACK nsStreamObserverEvent::HandlePLEvent(PLEvent *aEvent) { nsStreamObserverEvent *ev = GET_STREAM_OBSERVER_EVENT(aEvent); @@ -91,6 +91,8 @@ nsStreamObserverEvent::HandlePLEvent(PLEvent *aEvent) // Pass control the real event handler if (ev) ev->HandleEvent(); + + return nsnull; } void PR_CALLBACK diff --git a/mozilla/netwerk/base/src/nsStreamObserverProxy.h b/mozilla/netwerk/base/src/nsStreamObserverProxy.h index fe2457108f9..b667a8c78a3 100644 --- a/mozilla/netwerk/base/src/nsStreamObserverProxy.h +++ b/mozilla/netwerk/base/src/nsStreamObserverProxy.h @@ -94,7 +94,7 @@ public: NS_IMETHOD HandleEvent() = 0; protected: - static void PR_CALLBACK HandlePLEvent(PLEvent *); + static void* PR_CALLBACK HandlePLEvent(PLEvent *); static void PR_CALLBACK DestroyPLEvent(PLEvent *); PLEvent mEvent; diff --git a/mozilla/security/manager/ssl/src/nsNSSComponent.cpp b/mozilla/security/manager/ssl/src/nsNSSComponent.cpp index c8cfe7397c3..786f1fdd0fa 100644 --- a/mozilla/security/manager/ssl/src/nsNSSComponent.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSComponent.cpp @@ -212,24 +212,30 @@ struct CRLDownloadEvent : PLEvent { // Note that nsNSSComponent is a singleton object across all threads, // and automatic downloads are always scheduled sequentially - that is, // once one crl download is complete, the next one is scheduled -static void PR_CALLBACK HandleCRLImportPLEvent(CRLDownloadEvent *aEvent) +static void* PR_CALLBACK HandleCRLImportPLEvent(PLEvent *aEvent) { + CRLDownloadEvent *event = NS_STATIC_CAST(CRLDownloadEvent*, aEvent); + nsresult rv; nsIURI *pURL; - if((aEvent->psmDownloader==nsnull) || (aEvent->urlString==nsnull) ) - return; + if((event->psmDownloader==nsnull) || (event->urlString==nsnull) ) + return nsnull; - rv = NS_NewURI(&pURL, aEvent->urlString->get()); + rv = NS_NewURI(&pURL, event->urlString->get()); if(NS_SUCCEEDED(rv)){ - NS_OpenURI(aEvent->psmDownloader, nsnull, pURL); + NS_OpenURI(event->psmDownloader, nsnull, pURL); } + + return nsnull; } -static void PR_CALLBACK DestroyCRLImportPLEvent(CRLDownloadEvent* aEvent) +static void PR_CALLBACK DestroyCRLImportPLEvent(PLEvent* aEvent) { - delete aEvent->urlString; - delete aEvent; + CRLDownloadEvent *event = NS_STATIC_CAST(CRLDownloadEvent*, aEvent); + + delete event->urlString; + delete event; } //This class is used to run the callback code @@ -905,7 +911,7 @@ nsNSSComponent::PostCRLImportEvent(nsCAutoString *urlString, PSMContentDownloade { //Create the event CRLDownloadEvent *event = new CRLDownloadEvent; - PL_InitEvent(event, this, (PLHandleEventProc)HandleCRLImportPLEvent, (PLDestroyEventProc)DestroyCRLImportPLEvent); + PL_InitEvent(event, this, HandleCRLImportPLEvent, DestroyCRLImportPLEvent); event->urlString = urlString; event->psmDownloader = (nsIStreamListener *)psmDownloader; diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 5eb6277061a..de0441ed56a 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -988,15 +988,14 @@ struct ExitEvent : public PLEvent { nsWebCrawler* crawler; - static void PR_CALLBACK HandleMe(ExitEvent* e); - static void PR_CALLBACK DeleteMe(ExitEvent* e); + static void* PR_CALLBACK HandleMe(PLEvent* e); + static void PR_CALLBACK DeleteMe(PLEvent* e); }; ExitEvent::ExitEvent(nsWebCrawler* aCrawler) : crawler(aCrawler) { - PL_InitEvent(this, crawler, (PLHandleEventProc) HandleMe, - (PLDestroyEventProc) DeleteMe); + PL_InitEvent(this, crawler, HandleMe, DeleteMe); NS_ADDREF(aCrawler); } @@ -1005,15 +1004,18 @@ ExitEvent::~ExitEvent() NS_RELEASE(crawler); } -void -ExitEvent::HandleMe(ExitEvent* e) +void* +ExitEvent::HandleMe(PLEvent* aEvent) { + ExitEvent* e = NS_STATIC_CAST(ExitEvent*, aEvent); e->DoIt(); + return nsnull; } void -ExitEvent::DeleteMe(ExitEvent* e) +ExitEvent::DeleteMe(PLEvent* aEvent) { + ExitEvent* e = NS_STATIC_CAST(ExitEvent*, aEvent); delete e; } @@ -1043,16 +1045,15 @@ struct LoadEvent : public PLEvent { nsString url; nsWebCrawler* crawler; - static void PR_CALLBACK HandleMe(LoadEvent* e); - static void PR_CALLBACK DeleteMe(LoadEvent* e); + static void* PR_CALLBACK HandleMe(PLEvent* aEvent); + static void PR_CALLBACK DeleteMe(PLEvent* aEvent); }; LoadEvent::LoadEvent(nsWebCrawler* aCrawler, const nsString& aURL) : url(aURL), crawler(aCrawler) { - PL_InitEvent(this, crawler, (PLHandleEventProc) HandleMe, - (PLDestroyEventProc) DeleteMe); + PL_InitEvent(this, crawler, HandleMe, DeleteMe); NS_ADDREF(aCrawler); } @@ -1061,15 +1062,18 @@ LoadEvent::~LoadEvent() NS_RELEASE(crawler); } -void -LoadEvent::HandleMe(LoadEvent* e) +void* +LoadEvent::HandleMe(PLEvent* aEvent) { + LoadEvent *e = NS_STATIC_CAST(LoadEvent*, aEvent); e->DoIt(); + return nsnull; } void -LoadEvent::DeleteMe(LoadEvent* e) +LoadEvent::DeleteMe(PLEvent* aEvent) { + LoadEvent *e = NS_STATIC_CAST(LoadEvent*, aEvent); delete e; } diff --git a/mozilla/xpcom/threads/nsTimerImpl.cpp b/mozilla/xpcom/threads/nsTimerImpl.cpp index a4193077a18..4517dbb5561 100644 --- a/mozilla/xpcom/threads/nsTimerImpl.cpp +++ b/mozilla/xpcom/threads/nsTimerImpl.cpp @@ -436,8 +436,10 @@ struct TimerEventType : public PLEvent { }; -void* handleTimerEvent(TimerEventType* event) +PR_STATIC_CALLBACK(void*) handleTimerEvent(PLEvent* aEvent) { + TimerEventType *event = NS_STATIC_CAST(TimerEventType*, aEvent); + nsTimerImpl* timer = NS_STATIC_CAST(nsTimerImpl*, event->owner); if (event->mGeneration != timer->GetGeneration()) return nsnull; @@ -467,8 +469,10 @@ void* handleTimerEvent(TimerEventType* event) return nsnull; } -void destroyTimerEvent(TimerEventType* event) +PR_STATIC_CALLBACK(void) destroyTimerEvent(PLEvent* aEvent) { + TimerEventType *event = NS_STATIC_CAST(TimerEventType*, aEvent); + nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl*, event->owner); NS_RELEASE(timer); PR_DELETE(event); @@ -486,9 +490,7 @@ void nsTimerImpl::PostTimerEvent() return; // initialize - PL_InitEvent((PLEvent*)event, this, - (PLHandleEventProc)handleTimerEvent, - (PLDestroyEventProc)destroyTimerEvent); + PL_InitEvent((PLEvent*)event, this, handleTimerEvent, destroyTimerEvent); // Since TimerThread addref'd 'this' for us, we don't need to addref here. // We will release in destroyMyEvent. We do need to copy the generation diff --git a/mozilla/xpcom/threads/plevent.h b/mozilla/xpcom/threads/plevent.h index 0b3eb0a67e8..173fea16288 100644 --- a/mozilla/xpcom/threads/plevent.h +++ b/mozilla/xpcom/threads/plevent.h @@ -105,16 +105,18 @@ Handling Events To handle an event you must write a callback that is passed the event record you defined containing the event's arguments: - PR_STATIC_CALLBACK(void*) handleMyEvent(MyEventType* event) + PR_STATIC_CALLBACK(void*) handleMyEvent(PLEvent* aEvent) { + MyEventType *event = NS_STATIC_CAST(MyEventType*, aEvent); doit(event->x, event->y); return NULL; // you could return a value for a sync event } Similarly for the destruction callback: - PR_STATIC_CALLBACK(void) destroyMyEvent(MyEventType* event) + PR_STATIC_CALLBACK(void) destroyMyEvent(PLEvent* aEvent) { + MyEventType *event = NS_STATIC_CAST(MyEventType*, aEvent); free(event->y); // created by strdup free(event); } diff --git a/mozilla/xpinstall/src/nsXPITriggerInfo.cpp b/mozilla/xpinstall/src/nsXPITriggerInfo.cpp index 70076d2d338..d73b21068d5 100644 --- a/mozilla/xpinstall/src/nsXPITriggerInfo.cpp +++ b/mozilla/xpinstall/src/nsXPITriggerInfo.cpp @@ -236,16 +236,18 @@ void nsXPITriggerInfo::SaveCallback( JSContext *aCx, jsval aVal ) } } -static void destroyTriggerEvent(XPITriggerEvent* event) +PR_STATIC_CALLBACK(void) destroyTriggerEvent(PLEvent* aEvent) { + XPITriggerEvent *event = NS_STATIC_CAST(XPITriggerEvent*, aEvent); JS_BeginRequest(event->cx); JS_RemoveRoot( event->cx, &event->cbval ); JS_EndRequest(event->cx); delete event; } -static void* handleTriggerEvent(XPITriggerEvent* event) +PR_STATIC_CALLBACK(void*) handleTriggerEvent(PLEvent* aEvent) { + XPITriggerEvent *event = NS_STATIC_CAST(XPITriggerEvent*, aEvent); jsval ret; void* mark; jsval* args; @@ -323,9 +325,9 @@ void nsXPITriggerInfo::SendStatus(const PRUnichar* URL, PRInt32 status) XPITriggerEvent* event = new XPITriggerEvent(); if (event) { - PL_InitEvent(&event->e, 0, - (PLHandleEventProc)handleTriggerEvent, - (PLDestroyEventProc)destroyTriggerEvent); + PL_InitEvent(event, 0, + handleTriggerEvent, + destroyTriggerEvent); event->URL = URL; event->status = status; @@ -348,7 +350,7 @@ void nsXPITriggerInfo::SendStatus(const PRUnichar* URL, PRInt32 status) // JSContext from dying before we handle this event. event->ref = mGlobalWrapper; - eq->PostEvent(&event->e); + eq->PostEvent(event); } else rv = NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/xpinstall/src/nsXPITriggerInfo.h b/mozilla/xpinstall/src/nsXPITriggerInfo.h index c1be4bc90df..0ae0c070620 100644 --- a/mozilla/xpinstall/src/nsXPITriggerInfo.h +++ b/mozilla/xpinstall/src/nsXPITriggerInfo.h @@ -54,8 +54,7 @@ #include "nsICryptoHash.h" #include "nsIPrincipal.h" -typedef struct XPITriggerEvent { - PLEvent e; +struct XPITriggerEvent : public PLEvent { nsString URL; PRInt32 status; JSContext* cx; @@ -63,7 +62,7 @@ typedef struct XPITriggerEvent { jsval cbval; nsCOMPtr ref; nsCOMPtr princ; -} XPITriggerEvent; +};