PIPluginLoader patch for several plugins
This commit is contained in:
@@ -68,27 +68,24 @@
|
||||
#endif
|
||||
|
||||
#define __PIP_PLUGIN_LOADER_VERSION_FUNC__ pip_loader_version
|
||||
#define __PIP_PLUGIN_PLUGIN_INFO_FUNC__ pip_plugin_info
|
||||
#define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
|
||||
#define __PIP_PLUGIN_LOADER_VERSION__ 1
|
||||
#define __PIP_PLUGIN_LOADER_VERSION__ 2
|
||||
|
||||
#define PIP_PLUGIN_SET_USER_VERSION(v) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIPluginInfo::instance()->setUserVersion(v); \
|
||||
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
||||
if (pi) pi->setUserVersion(v); \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIPluginInfo::instance()->setStaticSection(type, ptr); \
|
||||
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
||||
if (pi) pi->setStaticSection(type, ptr); \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
#define PIP_PLUGIN \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIPluginInfo::instance()->enterPlugin(); \
|
||||
STATIC_INITIALIZER_END \
|
||||
extern "C" { \
|
||||
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() {return __PIP_PLUGIN_LOADER_VERSION__;} \
|
||||
PIP_PLUGIN_EXPORT PIPluginInfo * __PIP_PLUGIN_PLUGIN_INFO_FUNC__() {return PIPluginInfo::instance();} \
|
||||
}
|
||||
|
||||
#define PIP_PLUGIN_STATIC_SECTION_MERGE \
|
||||
@@ -108,16 +105,34 @@ public:
|
||||
|
||||
void setUserVersion(const PIString & v);
|
||||
void setStaticSection(int type, void * ptr);
|
||||
PIString userVersion(bool plugin) const;
|
||||
PIMap<int, void*> staticSections(bool plugin) const;
|
||||
void enterPlugin();
|
||||
|
||||
static PIPluginInfo * instance();
|
||||
PIString userVersion() const;
|
||||
PIMap<int, void*> staticSections() const;
|
||||
|
||||
private:
|
||||
PIString user_version[2];
|
||||
PIMap<int, void*> static_sections[2];
|
||||
bool in_plugin;
|
||||
PIString user_version;
|
||||
PIMap<int, void*> static_sections;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class PIP_EXPORT PIPluginInfoStorage {
|
||||
public:
|
||||
PIPluginInfoStorage();
|
||||
|
||||
PIPluginInfo * currentInfo();
|
||||
PIPluginInfo * pluginInfo(void * p);
|
||||
PIPluginInfo * applicationInfo();
|
||||
PIPluginInfo * enterPlugin(void * p);
|
||||
void unloadPlugin(void * p);
|
||||
|
||||
static PIPluginInfoStorage * instance();
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIPluginInfoStorage)
|
||||
|
||||
void * current;
|
||||
PIMap<void*, PIPluginInfo * > info;
|
||||
|
||||
};
|
||||
|
||||
@@ -127,9 +142,18 @@ private:
|
||||
class PIP_EXPORT PIPluginLoader {
|
||||
public:
|
||||
typedef int(*FunctionLoaderVersion)();
|
||||
typedef PIPluginInfo*(*FunctionPluginInfo)();
|
||||
typedef void(*FunctionStaticMerge)(int, void *, void *);
|
||||
|
||||
//! Possible load plugin error
|
||||
enum Error {
|
||||
Unknown /** No \a load call yet */ ,
|
||||
NoError /** No error */ ,
|
||||
LibraryLoadError /** System can`t load library */ ,
|
||||
MissingSymbols /** Can`t find necessary symbols */ ,
|
||||
InvalidLoaderVersion /** Integer version mismatch */ ,
|
||||
InvalidUserVersion /** User version mismatch */ ,
|
||||
};
|
||||
|
||||
//! Contruscts loader with filename "name"
|
||||
PIPluginLoader(const PIString & name = PIString());
|
||||
|
||||
@@ -147,12 +171,21 @@ public:
|
||||
//! Returns if plugin is successfully loaded
|
||||
bool isLoaded() const;
|
||||
|
||||
//! Returns error of last \a load() call
|
||||
Error lastError() const;
|
||||
|
||||
//! Returns error message of last \a load() call
|
||||
PIString lastErrorText() const;
|
||||
|
||||
//! Set if %PIPluginLoader should print load messages, \b true by default
|
||||
void setMessages(bool yes);
|
||||
|
||||
//! Returns if %PIPluginLoader should print load messages, \b true by default
|
||||
bool isMessages() const;
|
||||
|
||||
//! Returns loaded plugin library path
|
||||
PIString libPath();
|
||||
|
||||
//! Returns library lastError
|
||||
PIString lastError();
|
||||
|
||||
//! Resolve symbol "name" from plugin library
|
||||
void * resolve(const char * name);
|
||||
|
||||
@@ -169,10 +202,10 @@ private:
|
||||
|
||||
PILibrary lib;
|
||||
FunctionLoaderVersion func_loader_version;
|
||||
FunctionPluginInfo func_plugin_info;
|
||||
FunctionStaticMerge func_static_merge;
|
||||
PIPluginInfo * plugin_info;
|
||||
bool loaded;
|
||||
PIString error_str;
|
||||
Error error;
|
||||
bool loaded, messages;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user