Adding masks for gcc3 and Mach-O builds for NPAPI variables that pass interface pointers, bug 182117 r=beard,cls sr=sfraser
git-svn-id: svn://10.0.0.236/trunk@138581 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* npapi.h $Revision: 3.26 $
|
||||
* npapi.h $Revision: 3.27 $
|
||||
* Netscape client plug-in API spec
|
||||
*/
|
||||
|
||||
@@ -321,6 +321,49 @@ typedef struct
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
|
||||
/*
|
||||
* The following masks are applied on certain platforms to NPNV and
|
||||
* NPPV selectors that pass around pointers to COM interfaces. Newer
|
||||
* compilers on some platforms may generate vtables that are not
|
||||
* compatible with older compilers. To prevent older plugins from
|
||||
* not understanding a new browser's ABI, these masks change the
|
||||
* values of those selectors on those platforms. To remain backwards
|
||||
* compatible with differenet versions of the browser, plugins can
|
||||
* use these masks to dynamically determine and use the correct C++
|
||||
* ABI that the browser is expecting. This does not apply to Windows
|
||||
* as Microsoft's COM ABI will likely not change.
|
||||
*/
|
||||
|
||||
#define NP_ABI_GCC3_MASK 0x10000000
|
||||
/*
|
||||
* gcc 3.x generated vtables on UNIX and OSX are incompatible with
|
||||
* previous compilers.
|
||||
*/
|
||||
#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
|
||||
#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
|
||||
#else
|
||||
#define _NP_ABI_MIXIN_FOR_GCC3 0
|
||||
#endif
|
||||
|
||||
|
||||
#define NP_ABI_MACHO_MASK 0x01000000
|
||||
/*
|
||||
* On OSX, the Mach-O executable format is significantly
|
||||
* different than CFM. In addition to having a different
|
||||
* C++ ABI, it also has has different C calling convention.
|
||||
* You must use glue code when calling between CFM and
|
||||
* Mach-O C functions.
|
||||
*/
|
||||
#if (defined(TARGET_RT_MAC_MACHO))
|
||||
#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
|
||||
#else
|
||||
#define _NP_ABI_MIXIN_FOR_MACHO 0
|
||||
#endif
|
||||
|
||||
|
||||
#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
|
||||
|
||||
/*
|
||||
* List of variable names for which NPP_GetValue shall be implemented
|
||||
*/
|
||||
@@ -333,7 +376,7 @@ typedef enum {
|
||||
NPPVpluginWindowSize,
|
||||
NPPVpluginTimerInterval,
|
||||
|
||||
NPPVpluginScriptableInstance = 10,
|
||||
NPPVpluginScriptableInstance = (10 | NP_ABI_MASK),
|
||||
NPPVpluginScriptableIID = 11,
|
||||
|
||||
/* 12 and over are available on Mozilla builds starting with 0.9.9 */
|
||||
@@ -353,9 +396,9 @@ typedef enum {
|
||||
NPNVisOfflineBool,
|
||||
|
||||
/* 10 and over are available on Mozilla builds starting with 0.9.4 */
|
||||
NPNVserviceManager = 10,
|
||||
NPNVDOMElement = 11, /* available in Mozilla 1.2 */
|
||||
NPNVDOMWindow = 12
|
||||
NPNVserviceManager = (10 | NP_ABI_MASK),
|
||||
NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */
|
||||
NPNVDOMWindow = (12 | NP_ABI_MASK)
|
||||
} NPNVariable;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1165,6 +1165,25 @@ NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* hand
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance::GetValueInternal(NPPVariable variable, void* value)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if(fCallbacks->getvalue && mStarted) {
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(res,
|
||||
CallNPP_GetValueProc(fCallbacks->getvalue,
|
||||
&fNPP,
|
||||
variable,
|
||||
value),
|
||||
fLibrary, this);
|
||||
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
|
||||
this, &fNPP, variable, value, res));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
||||
@@ -1190,17 +1209,7 @@ NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
||||
break;
|
||||
|
||||
default:
|
||||
if(fCallbacks->getvalue && mStarted) {
|
||||
NS_TRY_SAFE_CALL_RETURN(res,
|
||||
CallNPP_GetValueProc(fCallbacks->getvalue,
|
||||
&fNPP,
|
||||
(NPPVariable)variable,
|
||||
value),
|
||||
fLibrary, this);
|
||||
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
|
||||
this, &fNPP, variable, value, res));
|
||||
}
|
||||
res = GetValueInternal((NPPVariable)variable, value);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1254,7 +1263,7 @@ NS_IMETHODIMP ns4xPluginInstance :: GetScriptablePeer(void * *aScriptablePeer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptablePeer = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableInstance, aScriptablePeer);
|
||||
return GetValueInternal(NPPVpluginScriptableInstance, aScriptablePeer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1262,13 +1271,9 @@ NS_IMETHODIMP ns4xPluginInstance :: GetScriptablePeer(void * *aScriptablePeer)
|
||||
/* readonly attribute nsIIDPtr scriptableInterface; */
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetScriptableInterface(nsIID * *aScriptableInterface)
|
||||
{
|
||||
#if !defined(XP_MACOSX) // Workaround suspected bug
|
||||
if (!aScriptableInterface)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptableInterface = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableIID, (void*)aScriptableInterface);
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
return GetValueInternal(NPPVpluginScriptableIID, (void*)aScriptableInterface);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,11 @@ public:
|
||||
protected:
|
||||
|
||||
nsresult InitializePlugin(nsIPluginInstancePeer* peer);
|
||||
|
||||
/**
|
||||
* Calls NPP_GetValue
|
||||
*/
|
||||
nsresult GetValueInternal(NPPVariable variable, void* value);
|
||||
|
||||
/**
|
||||
* The plugin instance peer for this instance.
|
||||
|
||||
Reference in New Issue
Block a user