From 579a58106e541ef4a005eceaf4577048c69fa539 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Jun 2006 20:18:00 +0000 Subject: Fixes to the plugin system, it's a little tricky to test, but it's looking good. --- src/plugger.h | 6 +++--- src/plugin.cpp | 10 ---------- src/plugin.h | 14 -------------- src/test/plugin/plugin.cpp | 10 ++++++++++ src/test/plugin/plugin.h | 14 ++++++++++++++ tests/guy.cpp | 22 ++++++++++++++++++++++ tests/makeplugin.sh | 3 +++ 7 files changed, 52 insertions(+), 27 deletions(-) delete mode 100644 src/plugin.cpp delete mode 100644 src/plugin.h create mode 100644 src/test/plugin/plugin.cpp create mode 100644 src/test/plugin/plugin.h create mode 100644 tests/guy.cpp create mode 100755 tests/makeplugin.sh diff --git a/src/plugger.h b/src/plugger.h index 2cf224e..5f7df6d 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -17,13 +17,13 @@ typedef struct PluginInfo void (*destroyPlugin)( class Plugin * ); } PluginInfo; -#define PluginInterface( classname, name, ver, rev ) \ +#define PluginInterface( classname, baseclass, name, ver, rev ) \ extern "C" { \ - class Plugin *create ##classname() \ + class baseclass *create ##classname() \ { \ return new classname(); \ } \ - void destroy ##classname( class Plugin *pCls ) \ + void destroy ##classname( class baseclass *pCls ) \ { \ delete pCls; \ } \ diff --git a/src/plugin.cpp b/src/plugin.cpp deleted file mode 100644 index ea558fd..0000000 --- a/src/plugin.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "plugin.h" - -Plugin::Plugin() -{ -} - -Plugin::~Plugin() -{ -} - diff --git a/src/plugin.h b/src/plugin.h deleted file mode 100644 index f726867..0000000 --- a/src/plugin.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef PLUGIN_H -#define PLUGIN_H - -class Plugin -{ -public: - Plugin(); - virtual ~Plugin(); - -private: - -}; - -#endif diff --git a/src/test/plugin/plugin.cpp b/src/test/plugin/plugin.cpp new file mode 100644 index 0000000..ea558fd --- /dev/null +++ b/src/test/plugin/plugin.cpp @@ -0,0 +1,10 @@ +#include "plugin.h" + +Plugin::Plugin() +{ +} + +Plugin::~Plugin() +{ +} + diff --git a/src/test/plugin/plugin.h b/src/test/plugin/plugin.h new file mode 100644 index 0000000..f726867 --- /dev/null +++ b/src/test/plugin/plugin.h @@ -0,0 +1,14 @@ +#ifndef PLUGIN_H +#define PLUGIN_H + +class Plugin +{ +public: + Plugin(); + virtual ~Plugin(); + +private: + +}; + +#endif diff --git a/tests/guy.cpp b/tests/guy.cpp new file mode 100644 index 0000000..6510771 --- /dev/null +++ b/tests/guy.cpp @@ -0,0 +1,22 @@ +#include "stdio.h" +#include "plugin.h" +#include "plugger.h" + +class Guy : public Plugin +{ +public: + Guy() + { + printf("I'm guy!\n"); + } + + virtual ~Guy() + { + printf("Guy is dead...\n"); + } + +private: +}; + +PluginInterface( Guy, Plugin, "Mike", 0, 1 ) + diff --git a/tests/makeplugin.sh b/tests/makeplugin.sh new file mode 100755 index 0000000..086fefd --- /dev/null +++ b/tests/makeplugin.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +g++ -fPIC -shared -Wl,-soname,guy.so -o guy.so -I../src -I../src/test/plugin guy.cpp ../src/test/plugin/plugin.cpp -- cgit v1.2.3