From d4c9e413e0b38df37c1a4c777fe3d38b901dbae3 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 12 Jan 2009 12:46:49 +0100 Subject: [PATCH] move test plugins, fix the old C++ plugin example to make it compile again --- tests/Makefile.am | 2 +- tests/plugin/example_plugin.cpp | 61 --------- .../{ => examplepluginc}/example_plugin.c | 0 .../plugin/test-cpp-plugin/example_plugin.cpp | 129 ++++++++++++++++++ 4 files changed, 130 insertions(+), 62 deletions(-) delete mode 100644 tests/plugin/example_plugin.cpp rename tests/plugin/{ => examplepluginc}/example_plugin.c (100%) create mode 100644 tests/plugin/test-cpp-plugin/example_plugin.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 8c9876412..e1f01fc90 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -76,7 +76,7 @@ test_config_LDADD = \ check_LTLIBRARIES += examplepluginc.la -examplepluginc_la_SOURCES = $(tests_srcdir)/plugin/example_plugin.c +examplepluginc_la_SOURCES = $(tests_srcdir)/plugin/examplepluginc/example_plugin.c examplepluginc_la_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -DLUMIERA_PLUGIN -I$(top_srcdir)/src/ examplepluginc_la_LDFLAGS = -module -avoid-version -no-undefined -rpath /dev/null diff --git a/tests/plugin/example_plugin.cpp b/tests/plugin/example_plugin.cpp deleted file mode 100644 index aba34b44a..000000000 --- a/tests/plugin/example_plugin.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include - -#include "hello_interface.h" - -class example_plugin -{ -public: - static int myopen(void) - { - std::cout << "opened" << std::endl; - return 0; - } - - static int myclose(void) - { - std::cout << "closed" << std::endl; - return 0; - } -}; - -class example_plugin_de - : public example_plugin -{ -public: - static void hello(void) - { - std::cout << "Hallo Welt!" << std::endl; - } - - static void bye(const char* m) - { - std::cout << "Tschuess " << m << std::endl; - } -}; - - -class example_plugin_en - : public example_plugin -{ -public: - static void hello(void) - { - std::cout << "Hello World!" << std::endl; - } - - static void bye(const char* m) - { - std::cout << "Bye " << m << std::endl; - } -}; - - -LUMIERA_INTERFACE_IMPLEMENT(hello, 1, german, example_plugin_de::myopen, example_plugin_de::myclose, - example_plugin_de::hello, - example_plugin_de::bye - ); - -LUMIERA_INTERFACE_IMPLEMENT(hello, 1, english, example_plugin_en::myopen, example_plugin_en::myclose, - example_plugin_en::hello, - example_plugin_en::bye - ); diff --git a/tests/plugin/example_plugin.c b/tests/plugin/examplepluginc/example_plugin.c similarity index 100% rename from tests/plugin/example_plugin.c rename to tests/plugin/examplepluginc/example_plugin.c diff --git a/tests/plugin/test-cpp-plugin/example_plugin.cpp b/tests/plugin/test-cpp-plugin/example_plugin.cpp new file mode 100644 index 000000000..b99d951d3 --- /dev/null +++ b/tests/plugin/test-cpp-plugin/example_plugin.cpp @@ -0,0 +1,129 @@ +/* + example_plugin.cpp - example plugin (C++) for testing the interface/plugin system + + Copyright (C) Lumiera.org + 2008, Christian Thaeter , + Hermann Vosseler + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include +#include + +#include "common/interfacedescriptor.h" +#include "common/config_interface.h" + +extern "C" { +#include "common/interface.h" +#include "common/interfacedescriptor.h" + +#include "tests/common/hello_interface.h" +} + +using boost::format; +using std::cout; +using std::endl; + + + +class example_plugin + { + public: + static LumieraInterface + myopen (LumieraInterface self, LumieraInterface interfaces) + { + static format fmt("opened %x global interfaces %x"); + cout << fmt % self % interfaces << endl; + return self; + } + + static void + myclose (LumieraInterface) + { + std::cout << "closed" << endl; + } + }; + + +class example_plugin_de + : public example_plugin + { + public: + static void + griazi () + { + std::cout << "Hallo Welt!" << endl; + } + + static void + servus (const char* m) + { + std::cout << "Tschuess " << m << endl; + } + }; + + +class example_plugin_en + : public example_plugin + { + public: + static void + hello () + { + std::cout << "Hello World!" << endl; + } + + static void + bye (const char* m) + { + std::cout << "Bye " << m << endl; + } + }; + + + + +extern "C" { /* ================== define two lumieraorg_testhello instance ======================= */ + + + + LUMIERA_EXPORT( /* ===================== PLUGIN EXPORTS ================================== */ + + LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0 + ,lumieraorg_hello_german_cpp + , NULL /* no descriptor given */ + , example_plugin::myopen + , example_plugin::myclose + , LUMIERA_INTERFACE_MAP (hello, "\300\244\125\265\235\312\175\263\335\044\371\047\247\263\015\322", + example_plugin_de::griazi) + , LUMIERA_INTERFACE_MAP (goodbye, "\115\365\126\102\201\104\012\257\153\232\006\210\010\346\076\070", + example_plugin_de::servus) + ), + LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0 + ,lumieraorg_hello_english_cpp + , NULL /* no descriptor given */ + , example_plugin::myopen + , example_plugin::myclose + , LUMIERA_INTERFACE_MAP (hello, "\303\367\107\154\077\063\237\066\034\034\050\136\170\220\260\226", + example_plugin_en::hello) + , LUMIERA_INTERFACE_MAP (goodbye, "\107\207\072\105\101\102\150\201\322\043\104\110\232\023\205\161", + example_plugin_en::bye) + ) + ); + +} // extern "C"