diff --git a/tests/plugin/Makefile.am b/tests/plugin/Makefile.am index 207e2b7e1..7beeacc75 100644 --- a/tests/plugin/Makefile.am +++ b/tests/plugin/Makefile.am @@ -25,8 +25,13 @@ test_plugin_SOURCES = $(examples_srcdir)/plugin_main.c noinst_HEADERS += $(examples_srcdir)/hello_interface.h -check_LTLIBRARIES += example_plugin.la +check_LTLIBRARIES += example_plugin.la example_plugin_cpp.la example_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src example_plugin_la_SOURCES = $(examples_srcdir)/example_plugin.c # the -rpath option is required, prolly a automake bug? example_plugin_la_LDFLAGS = -avoid-version -module -rpath $(shell pwd) + +example_plugin_cpp_la_CPPFLAGS = $(AM_CPPFLAGS) -Wall -Werror -I$(top_srcdir)/src +example_plugin_cpp_la_SOURCES = $(examples_srcdir)/example_plugin.cpp +# the -rpath option is required, prolly a automake bug? +example_plugin_cpp_la_LDFLAGS = -avoid-version -module -rpath $(shell pwd) diff --git a/tests/plugin/example_plugin.cpp b/tests/plugin/example_plugin.cpp new file mode 100644 index 000000000..b608887d8 --- /dev/null +++ b/tests/plugin/example_plugin.cpp @@ -0,0 +1,61 @@ +#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; + } +}; + + +CINELERRA_INTERFACE_IMPLEMENT(hello, 1, german, example_plugin_de::myopen, example_plugin_de::myclose, + example_plugin_de::hello, + example_plugin_de::bye + ); + +CINELERRA_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/plugin_main.c b/tests/plugin/plugin_main.c index e81c0724b..e691438b3 100644 --- a/tests/plugin/plugin_main.c +++ b/tests/plugin/plugin_main.c @@ -22,7 +22,6 @@ main(int argc, char** argv) if( !strcmp(argv[1],"C")) { - CINELERRA_INTERFACE_TYPE(hello, 1)* hello_de = (CINELERRA_INTERFACE_TYPE(hello, 1)*) cinelerra_interface_open ("example_plugin", "german_1", sizeof(CINELERRA_INTERFACE_TYPE(hello, 1))); @@ -45,27 +44,25 @@ main(int argc, char** argv) if( !strcmp(argv[1],"C++")) { -#if 0 - /* - same again for a plugin written in C++ - */ - hello_de = - cinelerra_interface_open ("hellocpp_1", "german_1", sizeof(struct hello_interface_1)); - if (!hello_de) CINELERRA_DIE; + /* same again for a plugin written in C++ */ + CINELERRA_INTERFACE_TYPE(hello, 1)* hello_de = + (CINELERRA_INTERFACE_TYPE(hello, 1)*) cinelerra_interface_open ("example_plugin_cpp", "german_1", sizeof(CINELERRA_INTERFACE_TYPE(hello, 1))); - hello_de->say_hello(); - hello_de->say_hello(); + if (!hello_de) CINELERRA_DIE; + hello_de->hello(); + hello_de->goodbye(argv[1]); - hello_en = - cinelerra_interface_open ("hellocpp_1", "english_1", sizeof(struct hello_interface_1)); - if (!hello_en) CINELERRA_DIE; + CINELERRA_INTERFACE_TYPE(hello, 1)* hello_en = + (CINELERRA_INTERFACE_TYPE(hello, 1)*) cinelerra_interface_open ("example_plugin_cpp", "english_1", sizeof(CINELERRA_INTERFACE_TYPE(hello, 1))); - hello_en->say_hello(); + if (!hello_en) CINELERRA_DIE; - cinelerra_interface_close (hello_en); - cinelerra_interface_close (hello_de); -#endif + hello_en->hello(); + hello_en->goodbye(argv[1]); + + cinelerra_interface_close (hello_en); + cinelerra_interface_close (hello_de); } return 0;