synced with scummvm to 2011-Apr-13

This commit is contained in:
Pawel Kolodziejski 2011-04-14 12:41:26 +02:00
parent f0a4299aef
commit 0640dcf2c7
347 changed files with 53648 additions and 8521 deletions

View file

@ -1,100 +0,0 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#if defined(DYNAMIC_MODULES) && defined(__DC__)
#include "backends/plugins/dc/dc-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "dcloader.h"
class DCPlugin : public DynamicPlugin {
protected:
void *_dlHandle;
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
void *func = dlsym(_dlHandle, symbol);
if (!func)
warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
// standard and POSIX: ISO C++ disallows casting between function pointers
// and data pointers, but dlsym always returns a void pointer. For details,
// see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
assert(sizeof(VoidFunc) == sizeof(func));
VoidFunc tmp;
memcpy(&tmp, &func, sizeof(VoidFunc));
return tmp;
}
public:
DCPlugin(const Common::String &filename)
: _dlHandle(0), _filename(filename) {}
bool loadPlugin() {
assert(!_dlHandle);
_dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
if (!_dlHandle) {
warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
return false;
}
bool ret = DynamicPlugin::loadPlugin();
if (ret)
dlforgetsyms(_dlHandle);
return ret;
}
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
if (dlclose(_dlHandle) != 0)
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
_dlHandle = 0;
}
}
};
Plugin* DCPluginProvider::createPlugin(const Common::FSNode &node) const {
return new DCPlugin(node.getPath());
}
bool DCPluginProvider::isPluginFilename(const Common::FSNode &node) const {
// Check the plugin suffix
Common::String filename = node.getName();
if (!filename.hasSuffix(".PLG"))
return false;
return true;
}
#endif // defined(DYNAMIC_MODULES) && defined(__DC__)

View file

@ -1,42 +0,0 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef BACKENDS_PLUGINS_DC_H
#define BACKENDS_PLUGINS_DC_H
#include "base/plugins.h"
#if defined(DYNAMIC_MODULES) && defined(__DC__)
class DCPluginProvider : public FilePluginProvider {
protected:
Plugin* createPlugin(const Common::FSNode &node) const;
bool isPluginFilename(const Common::FSNode &node) const;
};
#endif // defined(DYNAMIC_MODULES) && defined(__DC__)
#endif

View file

@ -37,7 +37,12 @@ protected:
virtual VoidFunc findSymbol(const char *symbol) = 0;
const Common::String _filename;
public:
DynamicPlugin(const Common::String &filename) :
_filename(filename) {}
virtual bool loadPlugin() {
// Validate the plugin API version
IntFunc verFunc = (IntFunc)findSymbol("PLUGIN_getVersion");
@ -97,6 +102,10 @@ public:
virtual void unloadPlugin() {
delete _pluginObject;
}
virtual const char *getFileName() const {
return _filename.c_str();
}
};
#endif

View file

@ -23,6 +23,8 @@
*
*/
#include "common/sys.h"
#if defined(DYNAMIC_MODULES) && defined(UNIX)
#include "backends/plugins/posix/posix-provider.h"
@ -35,7 +37,6 @@
class POSIXPlugin : public DynamicPlugin {
protected:
void *_dlHandle;
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
void *func = dlsym(_dlHandle, symbol);
@ -54,7 +55,7 @@ protected:
public:
POSIXPlugin(const Common::String &filename)
: _dlHandle(0), _filename(filename) {}
: DynamicPlugin(filename), _dlHandle(0) {}
bool loadPlugin() {
assert(!_dlHandle);

View file

@ -23,20 +23,19 @@
*
*/
#include "common/sys.h"
#if defined(DYNAMIC_MODULES) && defined(SDL_BACKEND)
#include "backends/plugins/sdl/sdl-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "SDL.h"
#include "SDL_loadso.h"
#include "backends/platform/sdl/sdl-sys.h"
class SDLPlugin : public DynamicPlugin {
protected:
void *_dlHandle;
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
void *func = SDL_LoadFunction(_dlHandle, symbol);
@ -55,7 +54,7 @@ protected:
public:
SDLPlugin(const Common::String &filename)
: _dlHandle(0), _filename(filename) {}
: DynamicPlugin(filename), _dlHandle(0) {}
bool loadPlugin() {
assert(!_dlHandle);

View file

@ -23,6 +23,8 @@
*
*/
#include "common/sys.h"
#if defined(DYNAMIC_MODULES) && defined(_WIN32)
#include "backends/plugins/win32/win32-provider.h"
@ -49,7 +51,6 @@ private:
protected:
void *_dlHandle;
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
#ifndef _WIN32_WCE
@ -65,7 +66,7 @@ protected:
public:
Win32Plugin(const Common::String &filename)
: _dlHandle(0), _filename(filename) {}
: DynamicPlugin(filename), _dlHandle(0) {}
bool loadPlugin() {
assert(!_dlHandle);