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

Mac: use the same common file

parent 62e3f545
......@@ -133,7 +133,7 @@ noinst_LTLIBRARIES = libvlcplugin_objc.la
libvlcplugin_la_SOURCES += \
vlcwindowless_base.cpp vlcwindowless_base.h \
vlcwindowless_mac.cpp vlcwindowless_mac.h \
support/npmac.cpp
support/npmac.cpp support/npcommon.cpp
libvlcplugin_la_LIBADD += libvlcplugin_objc.la
libvlcplugin_la_LDFLAGS += \
-bundle -Wl,-headerpad_max_install_names \
......
......@@ -44,7 +44,7 @@
#pragma mark -
#pragma mark Globals
static NPNetscapeFuncs *gNetscapeFuncs; /* Netscape Function table */
NPNetscapeFuncs *gNetscapeFuncs; /* Netscape Function table */
short gResFile; // Refnum of the plugin’s resource file
static inline int getMinorVersion() { return gNetscapeFuncs->version & 0xFF; }
......@@ -52,360 +52,14 @@ static inline int getMinorVersion() { return gNetscapeFuncs->version & 0xFF; }
#pragma mark -
#pragma mark Wrapper Functions
void
NPN_Version(int* plugin_major, int* plugin_minor,
int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
/* Major version is in high byte */
*netscape_major = gNetscapeFuncs->version >> 8;
/* Minor version is in low byte */
*netscape_minor = getMinorVersion();
}
void NPN_PluginThreadAsyncCall(NPP instance, void (*func)(void *), void *userData)
{
CALL_NPN(CallNPN_PluginThreadAsyncCallProc, gNetscapeFuncs->pluginthreadasynccall, instance, func, userData);
}
NPError
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
{
return CALL_NPN(CallNPN_GetValueProc, gNetscapeFuncs->getvalue,
instance, variable, r_value);
}
NPError
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
return CALL_NPN(CallNPN_SetValueProc, gNetscapeFuncs->setvalue,
instance, variable, value);
}
NPError
NPN_GetURL(NPP instance, const char* url, const char* window)
{
return CALL_NPN(CallNPN_GetURLProc, gNetscapeFuncs->geturl, instance, url, window);
}
NPError
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
{
int minor = getMinorVersion();
NPError err;
if (minor >= NPVERS_HAS_NOTIFICATION)
err = CALL_NPN(CallNPN_GetURLNotifyProc, gNetscapeFuncs->geturlnotify, instance, url, window, notifyData);
else
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
return err;
}
NPError
NPN_PostURL(NPP instance, const char* url, const char* window,
uint32_t len, const char* buf, NPBool file)
{
return CALL_NPN(CallNPN_PostURLProc, gNetscapeFuncs->posturl, instance,
url, window, len, buf, file);
}
NPError
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len,
const char* buf, NPBool file, void* notifyData)
{
int minor = getMinorVersion();
NPError err;
if (minor >= NPVERS_HAS_NOTIFICATION) {
err = CALL_NPN(CallNPN_PostURLNotifyProc, gNetscapeFuncs->posturlnotify, instance, url,
window, len, buf, file, notifyData);
}
else
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
return err;
}
NPError
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return CALL_NPN(CallNPN_RequestReadProc, gNetscapeFuncs->requestread,
stream, rangeList);
}
NPError
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
NPStream** stream)
{
int minor = getMinorVersion();
NPError err;
if (minor >= NPVERS_HAS_STREAMOUTPUT)
err = CALL_NPN(CallNPN_NewStreamProc, gNetscapeFuncs->newstream,
instance, type, window, stream);
else
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
return err;
}
int32_t
NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
{
int minor = getMinorVersion();
NPError err;
if (minor >= NPVERS_HAS_STREAMOUTPUT)
err = CALL_NPN(CallNPN_WriteProc, gNetscapeFuncs->write, instance, stream, len, buffer);
else
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
return err;
}
NPError
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int minor = getMinorVersion();
NPError err;
if (minor >= NPVERS_HAS_STREAMOUTPUT)
err = CALL_NPN(CallNPN_DestroyStreamProc, gNetscapeFuncs->destroystream, instance, stream, reason);
else
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
return err;
}
void
NPN_Status(NPP instance, const char* message)
{
CALL_NPN(CallNPN_StatusProc, gNetscapeFuncs->status, instance, message);
}
const char*
NPN_UserAgent(NPP instance)
{
return CALL_NPN(CallNPN_UserAgentProc, gNetscapeFuncs->uagent, instance);
}
void*
NPN_MemAlloc(uint32_t size)
{
return CALL_NPN(CallNPN_MemAllocProc, gNetscapeFuncs->memalloc, size);
}
void NPN_MemFree(void* ptr)
{
CALL_NPN(CallNPN_MemFreeProc, gNetscapeFuncs->memfree, ptr);
}
uint32_t NPN_MemFlush(uint32_t size)
{
return CALL_NPN(CallNPN_MemFlushProc, gNetscapeFuncs->memflush, size);
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
CALL_NPN(CallNPN_ReloadPluginsProc, gNetscapeFuncs->reloadplugins, reloadPages);
}
void
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
CALL_NPN(CallNPN_InvalidateRectProc, gNetscapeFuncs->invalidaterect, instance,
invalidRect);
}
void
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
CALL_NPN(CallNPN_InvalidateRegionProc, gNetscapeFuncs->invalidateregion, instance,
invalidRegion);
}
void
NPN_ForceRedraw(NPP instance)
{
CALL_NPN(CallNPN_ForceRedrawProc, gNetscapeFuncs->forceredraw, instance);
}
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
{
int minor = getMinorVersion();
if( minor >= 14 )
{
return CALL_NPN(CallNPN_GetStringIdentifierProc,
gNetscapeFuncs->getstringidentifier, name);
}
return NULL;
}
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
NPIdentifier *identifiers)
{
int minor = getMinorVersion();
if( minor >= 14 )
CALL_NPN(CallNPN_GetStringIdentifiersProc, gNetscapeFuncs->getstringidentifiers,
names, nameCount, identifiers);
}
NPIdentifier NPN_GetIntIdentifier(int32_t intid)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_GetIntIdentifierProc, gNetscapeFuncs->getintidentifier, intid);
return NULL;
}
bool NPN_IdentifierIsString(NPIdentifier identifier)
{
int minor = getMinorVersion();
if( minor >= 14 )
{
return CALL_NPN(CallNPN_IdentifierIsStringProc,
gNetscapeFuncs->identifierisstring,
identifier);
}
return false;
}
NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_UTF8FromIdentifierProc,
gNetscapeFuncs->utf8fromidentifier,
identifier);
return NULL;
}
int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_IntFromIdentifierProc,
gNetscapeFuncs->intfromidentifier,
identifier);
return 0;
}
NPObject *NPN_CreateObject(NPP instance, NPClass *aClass)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_CreateObjectProc, gNetscapeFuncs->createobject, instance, aClass);
return NULL;
}
NPObject *NPN_RetainObject(NPObject *npobj)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_RetainObjectProc, gNetscapeFuncs->retainobject, npobj);
return NULL;
}
void NPN_ReleaseObject(NPObject *npobj)
{
int minor = getMinorVersion();
if( minor >= 14 )
CALL_NPN(CallNPN_ReleaseObjectProc, gNetscapeFuncs->releaseobject, npobj);
}
bool NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName,
const NPVariant *args, uint32_t argCount, NPVariant *result)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_InvokeProc, gNetscapeFuncs->invoke, instance, npobj, methodName,
args, argCount, result);
return false;
}
bool NPN_InvokeDefault(NPP instance, NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_InvokeDefaultProc, gNetscapeFuncs->invokeDefault, instance, npobj,
args, argCount, result);
return false;
}
bool NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *result)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_EvaluateProc, gNetscapeFuncs->evaluate, instance, npobj,
script, result);
return false;
}
bool NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName,
NPVariant *result)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_GetPropertyProc, gNetscapeFuncs->getproperty, instance, npobj,
propertyName, result);
return false;
}
bool NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName,
const NPVariant *value)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_SetPropertyProc, gNetscapeFuncs->setproperty, instance, npobj,
propertyName, value);
return false;
}
bool NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_RemovePropertyProc, gNetscapeFuncs->removeproperty, instance, npobj,
propertyName);
return false;
}
bool NPN_HasProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_HasPropertyProc, gNetscapeFuncs->hasproperty, instance, npobj,
propertyName);
return false;
}
bool NPN_HasMethod(NPP instance, NPObject *npobj, NPIdentifier methodName)
{
int minor = getMinorVersion();
if( minor >= 14 )
return CALL_NPN(CallNPN_HasMethodProc, gNetscapeFuncs->hasmethod, instance,
npobj, methodName);
return false;
}
void NPN_ReleaseVariantValue(NPVariant *variant)
{
int minor = getMinorVersion();
if( minor >= 14 )
CALL_NPN(CallNPN_ReleaseVariantValueProc, gNetscapeFuncs->releasevariantvalue, variant);
}
void NPN_SetException(NPObject *npobj, const NPUTF8 *message)
{
int minor = getMinorVersion();
if( minor >= 14 )
CALL_NPN(CallNPN_SetExceptionProc, gNetscapeFuncs->setexception, npobj, message);
}
#pragma mark -
#pragma mark Private Functions
......
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