From b975a90c55711db1fcfd317ac285431a9dfc18f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 5 Mar 2020 11:25:32 +0100 Subject: [PATCH] C++ example project --- tests/multiplexx/Makefile | 28 ++++++++++++++++++++++++++++ tests/multiplexx/README.md | 8 ++++++++ tests/multiplexx/multiplexx-help.pd | 7 +++++++ tests/multiplexx/multiplexx-meta.pd | 9 +++++++++ tests/multiplexx/multiplexxA.cpp | 21 +++++++++++++++++++++ tests/multiplexx/multiplexxB.c | 13 +++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 tests/multiplexx/Makefile create mode 100644 tests/multiplexx/README.md create mode 100644 tests/multiplexx/multiplexx-help.pd create mode 100644 tests/multiplexx/multiplexx-meta.pd create mode 100644 tests/multiplexx/multiplexxA.cpp create mode 100644 tests/multiplexx/multiplexxB.c diff --git a/tests/multiplexx/Makefile b/tests/multiplexx/Makefile new file mode 100644 index 0000000..7438f0a --- /dev/null +++ b/tests/multiplexx/Makefile @@ -0,0 +1,28 @@ +# Makefile to build class 'multiplexx' for Pure Data. +# Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build +# settings and rules. + +# library name +lib.name = multiplexx + +# input source file (class name == source file basename) +class.sources = multiplexxA.cpp multiplexxB.c + +# all extra files to be included in binary distribution of the library +datafiles = multiplexx-help.pd multiplexx-meta.pd + +# include Makefile.pdlibbuilder +# (for real-world projects see the "Project Management" section +# in tips-tricks.md) +PDLIBBUILDER_DIR=../.. +include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder + +# simplistic tests whether all expected files have been produced/installed +buildcheck: all + test -e multiplexxA.$(extension) + test -e multiplexxB.$(extension) +installcheck: install + test -e $(installpath)/multiplexxA.$(extension) + test -e $(installpath)/multiplexxB.$(extension) + test -e $(installpath)/multiplexx-help.pd + test -e $(installpath)/multiplexx-meta.pd diff --git a/tests/multiplexx/README.md b/tests/multiplexx/README.md new file mode 100644 index 0000000..82aab9b --- /dev/null +++ b/tests/multiplexx/README.md @@ -0,0 +1,8 @@ +multiplexx +======== + +minimal pd-lib-builder project that shows how to compile +a library that contains multiplexx C-files that are compiled into +multiplexx binaries each containing a different Pd-objectclass. + +this is the general case of the one-object-per-binary library structure. diff --git a/tests/multiplexx/multiplexx-help.pd b/tests/multiplexx/multiplexx-help.pd new file mode 100644 index 0000000..b715d1a --- /dev/null +++ b/tests/multiplexx/multiplexx-help.pd @@ -0,0 +1,7 @@ +#N canvas 335 160 450 300 12; +#X msg 143 93 7; +#X obj 143 125 multiplexxA; +#X obj 223 125 multiplexxB; +#X msg 223 93 12; +#X connect 0 0 1 0; +#X connect 3 0 2 0; diff --git a/tests/multiplexx/multiplexx-meta.pd b/tests/multiplexx/multiplexx-meta.pd new file mode 100644 index 0000000..10132c9 --- /dev/null +++ b/tests/multiplexx/multiplexx-meta.pd @@ -0,0 +1,9 @@ +#N canvas 966 322 200 200 10; +#N canvas 19 51 420 300 META 0; +#X text 10 10 META this is a prototype of a libdir meta file; +#X text 10 51 AUTHOR IOhannes m zmolnig; +#X text 10 110 VERSION 1.0.0; +#X text 10 90 LICENSE CC0; +#X text 10 70 DESCRIPTION Example "multiplexx" external.; +#X text 10 30 NAME multiplexx; +#X restore 10 10 pd META; diff --git a/tests/multiplexx/multiplexxA.cpp b/tests/multiplexx/multiplexxA.cpp new file mode 100644 index 0000000..6ee490e --- /dev/null +++ b/tests/multiplexx/multiplexxA.cpp @@ -0,0 +1,21 @@ +#include +#include +t_class*multiplexxA_class; +static void multiplexxA_float(t_object*x, t_float f1) { + pd_error(x, "%s got %f", __FUNCTION__, f1); +} +static void*multiplexxA_new(void) { + return pd_new(multiplexxA_class); +} +#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) +extern "C" { + void multiplexxA_setup(void); +} +#endif +void multiplexxA_setup(void) { + std::cerr << __FUNCTION__ << std::endl; + multiplexxA_class = class_new(gensym("multiplexxA"), multiplexxA_new, 0, sizeof(t_object), 0, A_NULL); + class_addfloat(multiplexxA_class, multiplexxA_float); +} + + diff --git a/tests/multiplexx/multiplexxB.c b/tests/multiplexx/multiplexxB.c new file mode 100644 index 0000000..41cd95a --- /dev/null +++ b/tests/multiplexx/multiplexxB.c @@ -0,0 +1,13 @@ +#include +t_class*multiplexxB_class; +static void multiplexxB_float(t_object*x, t_float f1) { + pd_error(x, "%s got %f", __FUNCTION__, f1); +} +static void*multiplexxB_new(void) { + return pd_new(multiplexxB_class); +} +void multiplexxB_setup(void) { + post("%s", __FUNCTION__); + multiplexxB_class = class_new(gensym("multiplexxB"), multiplexxB_new, 0, sizeof(t_object), 0, A_NULL); + class_addfloat(multiplexxB_class, multiplexxB_float); +}