From 3990a92e929c8f074827d200777d5ca869296222 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 Jun 2012 21:51:04 +0000 Subject: Fix Lilv::Instance API to handle features and failed instantiations. Deprecate old flawed Lilv::Instance constructors. Add Lilv::Instance::get_handle() and Lilv::Instance::get_extension_data(). git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4502 a436a847-0d15-0410-975c-d299462d15a1 --- lilv/lilvmm.hpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'lilv') diff --git a/lilv/lilvmm.hpp b/lilv/lilvmm.hpp index fc080e2..df57db8 100644 --- a/lilv/lilvmm.hpp +++ b/lilv/lilvmm.hpp @@ -19,6 +19,12 @@ #include "lilv/lilv.h" +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define LILV_DEPRECATED __attribute__((__deprecated__)) +#else +# define LILV_DEPRECATED +#endif + namespace Lilv { static inline const char* @@ -215,10 +221,27 @@ struct Plugins { }; struct Instance { + inline Instance(LilvInstance* instance) : me(instance) {} + + LILV_DEPRECATED inline Instance(Plugin plugin, double sample_rate) { - // TODO: features me = lilv_plugin_instantiate(plugin, sample_rate, NULL); } + + LILV_DEPRECATED inline Instance(Plugin plugin, + double sample_rate, + LV2_Feature* const* features) { + me = lilv_plugin_instantiate(plugin, sample_rate, features); + } + + static inline Instance* create(Plugin plugin, + double sample_rate, + LV2_Feature* const* features) { + LilvInstance* me = lilv_plugin_instantiate( + plugin, sample_rate, features); + + return me ? new Instance(me) : NULL; + } LILV_WRAP_CONVERSION(LilvInstance); @@ -230,12 +253,18 @@ struct Instance { LILV_WRAP1_VOID(instance, run, unsigned, sample_count); LILV_WRAP0_VOID(instance, deactivate); - // TODO: get_extension_data + inline const void* get_extension_data(const char* uri) { + return lilv_instance_get_extension_data(me, uri); + } inline const LV2_Descriptor* get_descriptor() { return lilv_instance_get_descriptor(me); } + inline LV2_Handle get_handle() { + return lilv_instance_get_handle(me); + } + LilvInstance* me; }; -- cgit v1.2.1