Commit e4054fd6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

NPUnix: use Macros to support numerous SDK versions!

parent 68114f7f
......@@ -52,8 +52,10 @@
#include <npapi.h>
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
#include "npupp.h"
#define CALL_NPN(__CallNPNFunc__, ...) (__CallNPNFunc__(__VA_ARGS__))
#else
#include "npfunctions.h"
#define CALL_NPN(unused, FN, ...) ((*FN)(__VA_ARGS__))
#endif
#include <cstring>
......@@ -162,221 +164,136 @@ NPN_PluginThreadAsyncCall(NPP plugin,
NPError
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetValueProc(gNetscapeFuncs->getvalue,
return CALL_NPN(CallNPN_GetValueProc, gNetscapeFuncs->getvalue,
instance, variable, r_value);
#else
return (*gNetscapeFuncs->getvalue)(instance, variable, r_value);
#endif
}
NPError
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_SetValueProc(gNetscapeFuncs->setvalue,
return CALL_NPN(CallNPN_SetValueProc, gNetscapeFuncs->setvalue,
instance, variable, value);
#else
return (*gNetscapeFuncs->setvalue)(instance, variable, value);
#endif
}
NPError
NPN_GetURL(NPP instance, const char* url, const char* window)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetURLProc(gNetscapeFuncs->geturl, instance, url, window);
#else
return (*gNetscapeFuncs->geturl)(instance, url, window);
#endif
return CALL_NPN(CallNPN_GetURLProc, gNetscapeFuncs->geturl, instance, url, window);
}
NPError
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetURLNotifyProc(gNetscapeFuncs->geturlnotify, instance, url, window, notifyData);
#else
return (*gNetscapeFuncs->geturlnotify)(instance, url, window, notifyData);
#endif
return CALL_NPN(CallNPN_GetURLNotifyProc, gNetscapeFuncs->geturlnotify, instance, url, window, notifyData);
}
NPError
NPN_PostURL(NPP instance, const char* url, const char* window,
uint32_t len, const char* buf, NPBool file)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_PostURLProc(gNetscapeFuncs->posturl, instance,
return CALL_NPN(CallNPN_PostURLProc, gNetscapeFuncs->posturl, instance,
url, window, len, buf, file);
#else
return (*gNetscapeFuncs->posturl)(instance, url, window, len, buf, file);
#endif
}
NPError
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len,
const char* buf, NPBool file, void* notifyData)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_PostURLNotifyProc(gNetscapeFuncs->posturlnotify,
return CALL_NPN(CallNPN_PostURLNotifyProc, gNetscapeFuncs->posturlnotify,
instance, url, window, len, buf, file, notifyData);
#else
return (*gNetscapeFuncs->posturlnotify)(instance, url, window, len, buf, file, notifyData);
#endif
}
NPError
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_RequestReadProc(gNetscapeFuncs->requestread,
return CALL_NPN(CallNPN_RequestReadProc,gNetscapeFuncs->requestread,
stream, rangeList);
#else
return (*gNetscapeFuncs->requestread)(stream, rangeList);
#endif
}
NPError
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
NPStream** stream_ptr)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_NewStreamProc(gNetscapeFuncs->newstream, instance,
return CALL_NPN(CallNPN_NewStreamProc, gNetscapeFuncs->newstream, instance,
type, window, stream_ptr);
#else
return (*gNetscapeFuncs->newstream)(instance, type, window, stream_ptr);
#endif
}
int32_t
NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_WriteProc(gNetscapeFuncs->write, instance,
return CALL_NPN(CallNPN_WriteProc,gNetscapeFuncs->write, instance,
stream, len, buffer);
#else
return (*gNetscapeFuncs->write)(instance, stream, len, buffer);
#endif
}
NPError
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_DestroyStreamProc(gNetscapeFuncs->destroystream,
return CALL_NPN(CallNPN_DestroyStreamProc,gNetscapeFuncs->destroystream,
instance, stream, reason);
#else
return (*gNetscapeFuncs->destroystream)(instance, stream, reason);
#endif
}
void
NPN_Status(NPP instance, const char* message)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_StatusProc(gNetscapeFuncs->status, instance, message);
#else
(*gNetscapeFuncs->status)(instance, message);
#endif
CALL_NPN(CallNPN_StatusProc,gNetscapeFuncs->status, instance, message);
}
const char*
NPN_UserAgent(NPP instance)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_UserAgentProc(gNetscapeFuncs->uagent, instance);
#else
return (*gNetscapeFuncs->uagent)(instance);
#endif
return CALL_NPN(CallNPN_UserAgentProc,gNetscapeFuncs->uagent, instance);
}
void *NPN_MemAlloc(uint32_t size)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_MemAllocProc(gNetscapeFuncs->memalloc, size);
#else
return (*gNetscapeFuncs->memalloc)(size);
#endif
return CALL_NPN(CallNPN_MemAllocProc,gNetscapeFuncs->memalloc, size);
}
void NPN_MemFree(void* ptr)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_MemFreeProc(gNetscapeFuncs->memfree, ptr);
#else
(*gNetscapeFuncs->memfree)(ptr);
#endif
CALL_NPN(CallNPN_MemFreeProc,gNetscapeFuncs->memfree, ptr);
}
uint32_t NPN_MemFlush(uint32_t size)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_MemFlushProc(gNetscapeFuncs->memflush, size);
#else
return (*gNetscapeFuncs->memflush)(size);
#endif
return CALL_NPN(CallNPN_MemFlushProc,gNetscapeFuncs->memflush, size);
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_ReloadPluginsProc(gNetscapeFuncs->reloadplugins, reloadPages);
#else
(*gNetscapeFuncs->reloadplugins)(reloadPages);
#endif
CALL_NPN(CallNPN_ReloadPluginsProc,gNetscapeFuncs->reloadplugins, reloadPages);
}
void
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_InvalidateRectProc(gNetscapeFuncs->invalidaterect, instance,
CALL_NPN(CallNPN_InvalidateRectProc,gNetscapeFuncs->invalidaterect, instance,
invalidRect);
#else
(*gNetscapeFuncs->invalidaterect)(instance, invalidRect);
#endif
}
void
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_InvalidateRegionProc(gNetscapeFuncs->invalidateregion, instance,
CALL_NPN(CallNPN_InvalidateRegionProc,gNetscapeFuncs->invalidateregion, instance,
invalidRegion);
#else
(*gNetscapeFuncs->invalidateregion)(instance, invalidRegion);
#endif
}
void
NPN_ForceRedraw(NPP instance)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_ForceRedrawProc(gNetscapeFuncs->forceredraw, instance);
#else
(*gNetscapeFuncs->forceredraw)(instance);
#endif
CALL_NPN(CallNPN_ForceRedrawProc,gNetscapeFuncs->forceredraw, instance);
}
void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_PushPopupsEnabledStateProc(gNetscapeFuncs->pushpopupsenabledstate,
CALL_NPN(CallNPN_PushPopupsEnabledStateProc,gNetscapeFuncs->pushpopupsenabledstate,
instance, enabled);
#else
(*gNetscapeFuncs->pushpopupsenabledstate)(instance, enabled);
#endif
}
void NPN_PopPopupsEnabledState(NPP instance)
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_PopPopupsEnabledStateProc(gNetscapeFuncs->poppopupsenabledstate,
CALL_NPN(CallNPN_PopPopupsEnabledStateProc,gNetscapeFuncs->poppopupsenabledstate,
instance);
#else
(*gNetscapeFuncs->poppopupsenabledstate)(instance);
#endif
}
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
......@@ -384,12 +301,8 @@ NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetStringIdentifierProc(
return CALL_NPN(CallNPN_GetStringIdentifierProc,
gNetscapeFuncs->getstringidentifier, name);
#else
return (*gNetscapeFuncs->getstringidentifier)(name);
#endif
}
return NULL;
}
......@@ -400,12 +313,8 @@ void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_GetStringIdentifiersProc(gNetscapeFuncs->getstringidentifiers,
CALL_NPN(CallNPN_GetStringIdentifiersProc,gNetscapeFuncs->getstringidentifiers,
names, nameCount, identifiers);
#else
(*gNetscapeFuncs->getstringidentifiers)(names, nameCount, identifiers);
#endif
}
}
......@@ -414,11 +323,7 @@ NPIdentifier NPN_GetIntIdentifier(int32_t intid)
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetIntIdentifierProc(gNetscapeFuncs->getintidentifier, intid);
#else
return (*gNetscapeFuncs->getintidentifier)(intid);
#endif
return CALL_NPN(CallNPN_GetIntIdentifierProc,gNetscapeFuncs->getintidentifier, intid);
}
return NULL;
}
......@@ -428,13 +333,9 @@ bool NPN_IdentifierIsString(NPIdentifier identifier)
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_IdentifierIsStringProc(
return CALL_NPN(CallNPN_IdentifierIsStringProc,
gNetscapeFuncs->identifierisstring,
identifier);
#else
return (*gNetscapeFuncs->identifierisstring)(identifier);
#endif
}
return false;
}
......@@ -444,13 +345,9 @@ NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_UTF8FromIdentifierProc(
return CALL_NPN(CallNPN_UTF8FromIdentifierProc,
gNetscapeFuncs->utf8fromidentifier,
identifier);
#else
return (*gNetscapeFuncs->utf8fromidentifier)(identifier);
#endif
}
return NULL;
}
......@@ -460,13 +357,9 @@ int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
{
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_IntFromIdentifierProc(
return CALL_NPN(CallNPN_IntFromIdentifierProc,
gNetscapeFuncs->intfromidentifier,
identifier);
#else
return (*gNetscapeFuncs->intfromidentifier)(identifier);
#endif
}
return 0;
}
......@@ -475,11 +368,7 @@ NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_CreateObjectProc(gNetscapeFuncs->createobject, npp, aClass);
#else
return (*gNetscapeFuncs->createobject)(npp, aClass);
#endif
return CALL_NPN(CallNPN_CreateObjectProc,gNetscapeFuncs->createobject, npp, aClass);
return NULL;
}
......@@ -487,11 +376,7 @@ NPObject *NPN_RetainObject(NPObject *obj)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_RetainObjectProc(gNetscapeFuncs->retainobject, obj);
#else
return (*gNetscapeFuncs->retainobject)(obj);
#endif
return CALL_NPN(CallNPN_RetainObjectProc,gNetscapeFuncs->retainobject, obj);
return NULL;
}
......@@ -499,11 +384,7 @@ void NPN_ReleaseObject(NPObject *obj)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_ReleaseObjectProc(gNetscapeFuncs->releaseobject, obj);
#else
(*gNetscapeFuncs->releaseobject)(obj);
#endif
CALL_NPN(CallNPN_ReleaseObjectProc,gNetscapeFuncs->releaseobject, obj);
}
bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
......@@ -511,12 +392,8 @@ bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_InvokeProc(gNetscapeFuncs->invoke, npp, obj, methodName,
return CALL_NPN(CallNPN_InvokeProc,gNetscapeFuncs->invoke, npp, obj, methodName,
args, argCount, result);
#else
return (*gNetscapeFuncs->invoke)(npp, obj, methodName, args, argCount, result);
#endif
return false;
}
......@@ -525,12 +402,8 @@ bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_InvokeDefaultProc(gNetscapeFuncs->invokeDefault, npp, obj,
return CALL_NPN(CallNPN_InvokeDefaultProc,gNetscapeFuncs->invokeDefault, npp, obj,
args, argCount, result);
#else
return (*gNetscapeFuncs->invokeDefault)(npp, obj, args, argCount, result);
#endif
return false;
}
......@@ -539,12 +412,8 @@ bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_EvaluateProc(gNetscapeFuncs->evaluate, npp, obj,
return CALL_NPN(CallNPN_EvaluateProc,gNetscapeFuncs->evaluate, npp, obj,
script, result);
#else
return (*gNetscapeFuncs->evaluate)(npp, obj, script, result);
#endif
return false;
}
......@@ -553,12 +422,8 @@ bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_GetPropertyProc(gNetscapeFuncs->getproperty, npp, obj,
return CALL_NPN(CallNPN_GetPropertyProc,gNetscapeFuncs->getproperty, npp, obj,
propertyName, result);
#else
return (*gNetscapeFuncs->getproperty)(npp, obj, propertyName, result);
#endif
return false;
}
......@@ -567,12 +432,8 @@ bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_SetPropertyProc(gNetscapeFuncs->setproperty, npp, obj,
return CALL_NPN(CallNPN_SetPropertyProc,gNetscapeFuncs->setproperty, npp, obj,
propertyName, value);
#else
return (*gNetscapeFuncs->setproperty)(npp, obj, propertyName, value);
#endif
return false;
}
......@@ -580,12 +441,8 @@ bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_RemovePropertyProc(gNetscapeFuncs->removeproperty, npp, obj,
return CALL_NPN(CallNPN_RemovePropertyProc,gNetscapeFuncs->removeproperty, npp, obj,
propertyName);
#else
return (*gNetscapeFuncs->removeproperty)(npp, obj, propertyName);
#endif
return false;
}
......@@ -593,12 +450,8 @@ bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_HasPropertyProc(gNetscapeFuncs->hasproperty, npp, obj,
return CALL_NPN(CallNPN_HasPropertyProc,gNetscapeFuncs->hasproperty, npp, obj,
propertyName);
#else
return (*gNetscapeFuncs->hasproperty)(npp, obj, propertyName);
#endif
return false;
}
......@@ -606,12 +459,8 @@ bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
return CallNPN_HasMethodProc(gNetscapeFuncs->hasmethod, npp,
return CALL_NPN(CallNPN_HasMethodProc,gNetscapeFuncs->hasmethod, npp,
obj, methodName);
#else
return (*gNetscapeFuncs->hasmethod)(npp, obj, methodName);
#endif
return false;
}
......@@ -619,22 +468,14 @@ void NPN_ReleaseVariantValue(NPVariant *variant)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_ReleaseVariantValueProc(gNetscapeFuncs->releasevariantvalue, variant);
#else
(*gNetscapeFuncs->releasevariantvalue)(variant);
#endif
CALL_NPN(CallNPN_ReleaseVariantValueProc,gNetscapeFuncs->releasevariantvalue, variant);
}
void NPN_SetException(NPObject* obj, const NPUTF8 *message)
{
int minor = gNetscapeFuncs->version & 0xFF;
if( minor >= 14 )
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
CallNPN_SetExceptionProc(gNetscapeFuncs->setexception, obj, message);
#else
(*gNetscapeFuncs->setexception)(obj, message);
#endif
CALL_NPN(CallNPN_SetExceptionProc,gNetscapeFuncs->setexception, obj, message);
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment