diff --git a/mozilla/modules/plugin/tools/sdk/samples/common/np_entry.cpp b/mozilla/modules/plugin/tools/sdk/samples/common/np_entry.cpp index 312aacfa421..f24427b5f90 100644 --- a/mozilla/modules/plugin/tools/sdk/samples/common/np_entry.cpp +++ b/mozilla/modules/plugin/tools/sdk/samples/common/np_entry.cpp @@ -56,10 +56,26 @@ static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs) if(aNPPFuncs == NULL) return NPERR_INVALID_FUNCTABLE_ERROR; - if(aNPPFuncs->size < sizeof(NPPluginFuncs)) - return NPERR_INVALID_FUNCTABLE_ERROR; + // Set up the plugin function table that Netscape will use to + // call us. Netscape needs to know about our version and size + // and have a UniversalProcPointer for every function we implement. aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; +#ifdef XP_MAC + aNPPFuncs->newp = NewNPP_NewProc(Private_New); + aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy); + aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow); + aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream); + aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream); + aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile); + aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady); + aNPPFuncs->write = NewNPP_WriteProc(Private_Write); + aNPPFuncs->print = NewNPP_PrintProc(Private_Print); + aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent); + aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify); + aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue); + aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue); +#else aNPPFuncs->newp = NPP_New; aNPPFuncs->destroy = NPP_Destroy; aNPPFuncs->setwindow = NPP_SetWindow; @@ -73,6 +89,7 @@ static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs) aNPPFuncs->urlnotify = NPP_URLNotify; aNPPFuncs->getvalue = NPP_GetValue; aNPPFuncs->setvalue = NPP_SetValue; +#endif aNPPFuncs->javaClass = NULL; return NPERR_NO_ERROR; @@ -267,15 +284,16 @@ void SetUpQD(void) #endif /* !TARGET_API_MAC_CARBON */ } -NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp); - -#pragma export on +NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp); #if !TARGET_API_MAC_CARBON +#pragma export on +#if GENERATINGCFM RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main); #endif - #pragma export off +#endif /* !TARGET_API_MAC_CARBON */ + NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp) { @@ -291,26 +309,7 @@ NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownU if (rv == NPERR_NO_ERROR) { // defer static constructors until the global functions are initialized. __InitCode__(); - - // Set up the plugin function table that Netscape will use to - // call us. Netscape needs to know about our version and size - // and have a UniversalProcPointer for every function we implement. - pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR; - pluginFuncs->size = sizeof(NPPluginFuncs); - pluginFuncs->newp = NewNPP_NewProc(Private_New); - pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy); - pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow); - pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream); - pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream); - pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile); - pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady); - pluginFuncs->write = NewNPP_WriteProc(Private_Write); - pluginFuncs->print = NewNPP_PrintProc(Private_Print); - pluginFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent); - pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify); - pluginFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue); - pluginFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue); - pluginFuncs->javaClass = NULL; + rv = fillPluginFunctionTable(aNPPFuncs); } *aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown); diff --git a/mozilla/modules/plugin/tools/sdk/samples/common/npn_gate.cpp b/mozilla/modules/plugin/tools/sdk/samples/common/npn_gate.cpp index 5d595208d7a..d831ab71b1f 100644 --- a/mozilla/modules/plugin/tools/sdk/samples/common/npn_gate.cpp +++ b/mozilla/modules/plugin/tools/sdk/samples/common/npn_gate.cpp @@ -35,6 +35,29 @@ * * ***** END LICENSE BLOCK ***** */ +// +// The Mixed Mode procInfos defined in npupp.h assume Think C- +// style calling conventions. These conventions are used by +// Metrowerks with the exception of pointer return types, which +// in Metrowerks 68K are returned in A0, instead of the standard +// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers, +// Mixed Mode will return the values to a 68K plugin in D0, but +// a 68K plugin compiled by Metrowerks will expect the result in +// A0. The following pragma forces Metrowerks to use D0 instead. +// +#ifdef __MWERKS__ +#ifndef powerc +#pragma pointers_in_D0 +#endif +#endif + +#ifdef __MWERKS__ +#ifndef powerc +#pragma pointers_in_A0 +#endif +#endif + + //////////////////////////////////////////////////////////// // // Implementation of Netscape entry points (NPN_*) diff --git a/mozilla/modules/plugin/tools/sdk/samples/common/npp_gate.cpp b/mozilla/modules/plugin/tools/sdk/samples/common/npp_gate.cpp index af3d7835734..90705bbc5e1 100644 --- a/mozilla/modules/plugin/tools/sdk/samples/common/npp_gate.cpp +++ b/mozilla/modules/plugin/tools/sdk/samples/common/npp_gate.cpp @@ -35,6 +35,29 @@ * * ***** END LICENSE BLOCK ***** */ +// +// The Mixed Mode procInfos defined in npupp.h assume Think C- +// style calling conventions. These conventions are used by +// Metrowerks with the exception of pointer return types, which +// in Metrowerks 68K are returned in A0, instead of the standard +// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers, +// Mixed Mode will return the values to a 68K plugin in D0, but +// a 68K plugin compiled by Metrowerks will expect the result in +// A0. The following pragma forces Metrowerks to use D0 instead. +// +#ifdef __MWERKS__ +#ifndef powerc +#pragma pointers_in_D0 +#endif +#endif + +#ifdef __MWERKS__ +#ifndef powerc +#pragma pointers_in_A0 +#endif +#endif + + //////////////////////////////////////////////////////////// // // Implementation of plugin entry points (NPP_*)