1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Plugin App.
18 * The Initial Developer of the Original Code is
19 * Josh Aas <josh@mozilla.com>
20 * Portions created by the Initial Developer are Copyright (C) 2009
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "mozilla/PluginPRLibrary.h"
41 // Some plugins on Windows, notably Quake Live, implement NP_Initialize using
42 // cdecl instead of the documented stdcall. In order to work around this,
43 // we force the caller to use a frame pointer.
44 #if defined(XP_WIN) && defined(_M_IX86)
47 // gNotOptimized exists so that the compiler will not optimize the alloca
49 static int gNotOptimized
;
50 #define CALLING_CONVENTION_HACK void* foo = _alloca(gNotOptimized);
52 #define CALLING_CONVENTION_HACK
57 #if defined(XP_UNIX) && !defined(XP_MACOSX)
59 PluginPRLibrary::NP_Initialize(NPNetscapeFuncs
* bFuncs
,
60 NPPluginFuncs
* pFuncs
, NPError
* error
)
63 *error
= mNP_Initialize(bFuncs
, pFuncs
);
65 NP_InitializeFunc pfNP_Initialize
= (NP_InitializeFunc
)
66 PR_FindFunctionSymbol(mLibrary
, "NP_Initialize");
68 return NS_ERROR_FAILURE
;
69 *error
= pfNP_Initialize(bFuncs
, pFuncs
);
73 mNPP_New
= pFuncs
->newp
;
78 PluginPRLibrary::NP_Initialize(NPNetscapeFuncs
* bFuncs
, NPError
* error
)
80 CALLING_CONVENTION_HACK
83 *error
= mNP_Initialize(bFuncs
);
85 NP_InitializeFunc pfNP_Initialize
= (NP_InitializeFunc
)
86 PR_FindFunctionSymbol(mLibrary
, "NP_Initialize");
88 return NS_ERROR_FAILURE
;
89 *error
= pfNP_Initialize(bFuncs
);
97 PluginPRLibrary::NP_Shutdown(NPError
* error
)
99 CALLING_CONVENTION_HACK
102 *error
= mNP_Shutdown();
104 NP_ShutdownFunc pfNP_Shutdown
= (NP_ShutdownFunc
)
105 PR_FindFunctionSymbol(mLibrary
, "NP_Shutdown");
107 return NS_ERROR_FAILURE
;
108 *error
= pfNP_Shutdown();
115 PluginPRLibrary::NP_GetMIMEDescription(const char** mimeDesc
)
117 CALLING_CONVENTION_HACK
119 if (mNP_GetMIMEDescription
) {
120 *mimeDesc
= mNP_GetMIMEDescription();
123 NP_GetMIMEDescriptionFunc pfNP_GetMIMEDescription
=
124 (NP_GetMIMEDescriptionFunc
)
125 PR_FindFunctionSymbol(mLibrary
, "NP_GetMIMEDescription");
126 if (!pfNP_GetMIMEDescription
) {
128 return NS_ERROR_FAILURE
;
130 *mimeDesc
= pfNP_GetMIMEDescription();
137 PluginPRLibrary::NP_GetValue(void *future
, NPPVariable aVariable
,
138 void *aValue
, NPError
* error
)
141 *error
= mNP_GetValue(future
, aVariable
, aValue
);
143 NP_GetValueFunc pfNP_GetValue
= (NP_GetValueFunc
)
144 PR_FindFunctionSymbol(mLibrary
, "NP_GetValue");
146 return NS_ERROR_FAILURE
;
147 *error
= pfNP_GetValue(future
, aVariable
, aValue
);
153 #if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
155 PluginPRLibrary::NP_GetEntryPoints(NPPluginFuncs
* pFuncs
, NPError
* error
)
157 CALLING_CONVENTION_HACK
159 if (mNP_GetEntryPoints
) {
160 *error
= mNP_GetEntryPoints(pFuncs
);
162 NP_GetEntryPointsFunc pfNP_GetEntryPoints
= (NP_GetEntryPointsFunc
)
163 PR_FindFunctionSymbol(mLibrary
, "NP_GetEntryPoints");
164 if (!pfNP_GetEntryPoints
)
165 return NS_ERROR_FAILURE
;
166 *error
= pfNP_GetEntryPoints(pFuncs
);
170 mNPP_New
= pFuncs
->newp
;
176 PluginPRLibrary::NPP_New(NPMIMEType pluginType
, NPP instance
,
177 uint16_t mode
, int16_t argc
, char* argn
[],
178 char* argv
[], NPSavedData
* saved
,
182 return NS_ERROR_FAILURE
;
183 *error
= mNPP_New(pluginType
, instance
, mode
, argc
, argn
, argv
, saved
);
187 } // namespace mozilla