compile against xulrunner 1.9.0 also

This commit is contained in:
David Rose 2009-11-18 18:07:29 +00:00
parent b2dad16e42
commit 3ea273ddb6
2 changed files with 32 additions and 9 deletions

View File

@ -74,6 +74,19 @@ extern string global_root_dir;
#include "npfunctions.h"
#endif
#if NP_VERSION_MAJOR == 0 && NP_VERSION_MINOR <= 19
#ifdef _WIN32
// Also somewhere in there, they started defining and using
// int16_t instead of int16, and so on. They already had int32_t
// from earlier, but the typedef is not quite the same as int32
// (!), so we have to use #define to keep things compatible.
typedef int16 int16_t;
typedef uint16 uint16_t;
// #define int32_t int32
// #define uint32_t uint32
#endif // _WIN32
#endif // NP_VERSION
#include "load_plugin.h"
// Mozilla's version of NPAPI has these names lowercase. WebKit's

View File

@ -29,6 +29,15 @@ string global_root_dir;
NPNetscapeFuncs *browser;
// These function prototypes changed slightly (but insignificantly)
// between releases of NPAPI. To avoid compilation errors, we use our
// own name, and cast it to the correct type.
static int32_t
NPP_WriteReady_x(NPP instance, NPStream *stream);
static int32_t
NPP_Write_x(NPP instance, NPStream *stream, int32_t offset,
int32_t len, void *buffer);
// open_logfile() also assigns global_root_dir.
static bool logfile_is_open = false;
static void
@ -226,15 +235,16 @@ NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) {
pluginFuncs->newstream = NPP_NewStream;
pluginFuncs->destroystream = NPP_DestroyStream;
pluginFuncs->asfile = NPP_StreamAsFile;
pluginFuncs->writeready = NPP_WriteReady;
// WebKit's NPAPI defines the wrong prototype for this type, so we
// have to cast it. But the casting typename isn't consistent
// between WebKit and Mozilla's NPAPI headers.
// WebKit's NPAPI defines the wrong prototype for these functions,
// so we have to cast them. But the casting typename isn't
// consistent between WebKit and Mozilla's NPAPI headers.
#ifdef NewNPP_WriteProc
pluginFuncs->write = NewNPP_WriteProc(NPP_Write);
pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady_x);
pluginFuncs->write = NewNPP_WriteProc(NPP_Write_x);
#else
pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
pluginFuncs->writeready = (NPP_WriteReadyProcPtr)NPP_WriteReady_x;
pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write_x;
#endif
pluginFuncs->print = NPP_Print;
@ -402,7 +412,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) {
// deliver for a stream.
////////////////////////////////////////////////////////////////////
int32_t
NPP_WriteReady(NPP instance, NPStream *stream) {
NPP_WriteReady_x(NPP instance, NPStream *stream) {
// nout << "WriteReady " << stream->url << " for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n";
PPInstance::generic_browser_call();
PPInstance *inst = (PPInstance *)(instance->pdata);
@ -418,8 +428,8 @@ NPP_WriteReady(NPP instance, NPStream *stream) {
// consumed.
////////////////////////////////////////////////////////////////////
int32_t
NPP_Write(NPP instance, NPStream *stream, int32_t offset,
int32_t len, void *buffer) {
NPP_Write_x(NPP instance, NPStream *stream, int32_t offset,
int32_t len, void *buffer) {
// nout << "Write " << stream->url << ", " << len << " for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n";
PPInstance::generic_browser_call();
PPInstance *inst = (PPInstance *)(instance->pdata);