The functions which accept a `NPP instance` parameter don't need the special shim: just make them static functions on PluginModuleParent. This leaves only the following functions which will need special treatment in the Mozilla plugin host:

* NP_Initialize
* NP_GetEntryPoints
* NP_Shutdown
* NP_GetPluginVersion
* NP_GetValue
* NPP_New
* NP_GetMIMEDescription
This commit is contained in:
Benjamin Smedberg 2009-09-14 14:56:23 -04:00
Родитель 8bd9f31a0e
Коммит 7cf65dc42e
2 изменённых файлов: 106 добавлений и 135 удалений

Просмотреть файл

@ -104,18 +104,18 @@ PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
// FIXME/cjones: /should/ dynamically allocate shim trampoline.
// but here we just HACK
aFuncs->newp = Shim::NPP_New;
aFuncs->destroy = Shim::NPP_Destroy;
aFuncs->setwindow = Shim::NPP_SetWindow;
aFuncs->newstream = Shim::NPP_NewStream;
aFuncs->destroystream = PluginModuleParent::NPP_DestroyStream;
aFuncs->asfile = PluginModuleParent::NPP_StreamAsFile;
aFuncs->writeready = PluginModuleParent::NPP_WriteReady;
aFuncs->write = PluginModuleParent::NPP_Write;
aFuncs->print = Shim::NPP_Print;
aFuncs->event = Shim::NPP_HandleEvent;
aFuncs->urlnotify = Shim::NPP_URLNotify;
aFuncs->getvalue = Shim::NPP_GetValue;
aFuncs->setvalue = Shim::NPP_SetValue;
aFuncs->destroy = NPP_Destroy;
aFuncs->setwindow = NPP_SetWindow;
aFuncs->newstream = NPP_NewStream;
aFuncs->destroystream = NPP_DestroyStream;
aFuncs->asfile = NPP_StreamAsFile;
aFuncs->writeready = NPP_WriteReady;
aFuncs->write = NPP_Write;
aFuncs->print = NPP_Print;
aFuncs->event = NPP_HandleEvent;
aFuncs->urlnotify = NPP_URLNotify;
aFuncs->getvalue = NPP_GetValue;
aFuncs->setvalue = NPP_SetValue;
}
#ifdef OS_LINUX
@ -222,7 +222,7 @@ PluginModuleParent::NPP_Destroy(NPP instance,
static_cast<PluginInstanceParent*>(instance->pdata);
NPError prv;
if (CallPPluginInstanceDestructor(parentInstance, &prv)) {
if (Shim::HACK_target->CallPPluginInstanceDestructor(parentInstance, &prv)) {
prv = NPERR_GENERIC_ERROR;
}
instance->pdata = nsnull;
@ -230,6 +230,87 @@ PluginModuleParent::NPP_Destroy(NPP instance,
return prv;
}
NPError
PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
{
return InstCast(instance)->NPP_SetWindow(window);
}
NPError
PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
NPStream* stream, NPBool seekable,
uint16_t* stype)
{
return InstCast(instance)->NPP_NewStream(type, stream, seekable,
stype);
}
NPError
PluginModuleParent::NPP_DestroyStream(NPP instance,
NPStream* stream,
NPReason reason)
{
return InstCast(instance)->NPP_DestroyStream(stream, reason);
}
int32_t
PluginModuleParent::NPP_WriteReady(NPP instance,
NPStream* stream)
{
return StreamCast(instance, stream)->WriteReady();
}
int32_t
PluginModuleParent::NPP_Write(NPP instance,
NPStream* stream,
int32_t offset,
int32_t len,
void* buffer)
{
return StreamCast(instance, stream)->Write(offset, len, buffer);
}
void
PluginModuleParent::NPP_StreamAsFile(NPP instance,
NPStream* stream,
const char* fname)
{
StreamCast(instance, stream)->StreamAsFile(fname);
}
void
PluginModuleParent::NPP_Print(NPP instance, NPPrint* platformPrint)
{
InstCast(instance)->NPP_Print(platformPrint);
}
int16_t
PluginModuleParent::NPP_HandleEvent(NPP instance, void* event)
{
return InstCast(instance)->NPP_HandleEvent(event);
}
void
PluginModuleParent::NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData)
{
return InstCast(instance)->NPP_URLNotify(url, reason, notifyData);
}
NPError
PluginModuleParent::NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value)
{
return InstCast(instance)->NPP_GetValue(variable, ret_value);
}
NPError
PluginModuleParent::NPP_SetValue(NPP instance, NPNVariable variable,
void *value)
{
return InstCast(instance)->NPP_SetValue(variable, value);
}
nsresult
PluginModuleParent::RecvNPN_GetStringIdentifier(const nsCString& aString,
NPRemoteIdentifier* aId)
@ -296,38 +377,5 @@ PluginModuleParent::StreamCast(NPP instance,
return sp;
}
NPError
PluginModuleParent::NPP_DestroyStream(NPP instance,
NPStream* stream,
NPReason reason)
{
return InstCast(instance)->NPP_DestroyStream(stream, reason);
}
int32_t
PluginModuleParent::NPP_WriteReady(NPP instance,
NPStream* stream)
{
return StreamCast(instance, stream)->WriteReady();
}
int32_t
PluginModuleParent::NPP_Write(NPP instance,
NPStream* stream,
int32_t offset,
int32_t len,
void* buffer)
{
return StreamCast(instance, stream)->Write(offset, len, buffer);
}
void
PluginModuleParent::NPP_StreamAsFile(NPP instance,
NPStream* stream,
const char* fname)
{
StreamCast(instance, stream)->StreamAsFile(fname);
}
} // namespace plugins
} // namespace mozilla

Просмотреть файл

@ -178,32 +178,14 @@ private:
int16_t argc, char* argn[], char* argv[],
NPSavedData* saved);
NPError NPP_Destroy(NPP instance, NPSavedData** save);
static inline PluginInstanceParent& InstCast(void* p)
{
return *static_cast<PluginInstanceParent*>(p);
}
static NPError NPP_Destroy(NPP instance, NPSavedData** save);
static PluginInstanceParent* InstCast(NPP instance);
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
static inline const PluginInstanceParent& InstCast(const void* p)
{
return *static_cast<const PluginInstanceParent*>(p);
}
NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
return InstCast(instance->pdata).NPP_SetWindow(window);
}
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype)
{
return InstCast(instance->pdata).NPP_NewStream(type, stream, seekable, stype);
}
static NPError NPP_SetWindow(NPP instance, NPWindow* window);
static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype);
static NPError NPP_DestroyStream(NPP instance,
NPStream* stream, NPReason reason);
static int32_t NPP_WriteReady(NPP instance, NPStream* stream);
@ -211,34 +193,14 @@ private:
int32_t offset, int32_t len, void* buffer);
static void NPP_StreamAsFile(NPP instance,
NPStream* stream, const char* fname);
void NPP_Print(NPP instance, NPPrint* platformPrint)
{
return InstCast(instance->pdata).NPP_Print(platformPrint);
}
int16_t NPP_HandleEvent(NPP instance, void* event)
{
return InstCast(instance->pdata).NPP_HandleEvent(event);
}
void NPP_URLNotify(NPP instance,
const char* url, NPReason reason, void* notifyData)
{
return InstCast(instance->pdata).NPP_URLNotify(url,
reason, notifyData);
}
NPError NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value)
{
return InstCast(instance->pdata).NPP_GetValue(variable, ret_value);
}
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
{
return InstCast(instance->pdata).NPP_SetValue(variable, value);
}
static void NPP_Print(NPP instance, NPPrint* platformPrint);
static int16_t NPP_HandleEvent(NPP instance, void* event);
static void NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData);
static NPError NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value);
static NPError NPP_SetValue(NPP instance, NPNVariable variable,
void *value);
#if 0
// NPN-like API that IPC messages from the child process end up
@ -545,45 +507,6 @@ private:
argc, argn, argv,
saved);
}
static NPError NPP_Destroy(NPP instance, NPSavedData** save)
{
return HACK_target->NPP_Destroy(instance, save);
}
static NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
return HACK_target->NPP_SetWindow(instance, window);
}
static NPError NPP_NewStream(NPP instance,
NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype)
{
return HACK_target->NPP_NewStream(instance, type, stream,
seekable, stype);
}
static void NPP_Print(NPP instance, NPPrint* platformPrint)
{
return HACK_target->NPP_Print(instance, platformPrint);
}
static int16_t NPP_HandleEvent(NPP instance, void* event)
{
return HACK_target->NPP_HandleEvent(instance, event);
}
static void NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData)
{
return HACK_target->NPP_URLNotify(instance, url, reason,
notifyData);
}
static NPError NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value)
{
return HACK_target->NPP_GetValue(instance, variable, ret_value);
}
static NPError NPP_SetValue(NPP instance,
NPNVariable variable, void *value)
{
return HACK_target->NPP_SetValue(instance, variable, value);
}
static PluginModuleParent* HACK_target;
friend class PluginModuleParent;