From d110d07e07835f57dd1cb150cbe53be009de2bce Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Aug 2012 15:56:48 +0000 Subject: [PATCH] Fix some const-violating casts. git-svn-id: svn://localhost/ardour2/branches/3.0@13138 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/lv2_plugin.h | 14 +++++----- libs/ardour/lv2_plugin.cc | 45 +++++++++++++++++---------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 68946d0e51..cbabaa7421 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -46,7 +46,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee public: LV2Plugin (ARDOUR::AudioEngine& engine, ARDOUR::Session& session, - void* c_plugin, + const void* c_plugin, framecnt_t sample_rate); LV2Plugin (const LV2Plugin &); ~LV2Plugin (); @@ -70,9 +70,9 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee const void* extension_data (const char* uri) const; - void* c_plugin(); - void* c_ui(); - void* c_ui_type(); + const void* c_plugin(); + const void* c_ui(); + const void* c_ui_type(); bool is_external_ui () const; bool ui_is_resizable () const; @@ -235,7 +235,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee static char* lv2_state_make_path (void* host_data, const char* path); - void init (void* c_plugin, framecnt_t rate); + void init (const void* c_plugin, framecnt_t rate); void run (pframes_t nsamples); void latency_compute_run (); @@ -248,14 +248,14 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee class LV2PluginInfo : public PluginInfo { public: - LV2PluginInfo (void* c_plugin); + LV2PluginInfo (const void* c_plugin); ~LV2PluginInfo (); static PluginInfoList* discover (); PluginPtr load (Session& session); - void* _c_plugin; + const void* _c_plugin; }; typedef boost::shared_ptr LV2PluginInfoPtr; diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 7dad13c077..407b77a214 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -241,19 +241,19 @@ struct LV2Plugin::Impl { */ LilvPort* designated_input (const char* uri, void** bufptrs[], void** bufptr); - LilvPlugin* plugin; - const LilvUI* ui; - const LilvNode* ui_type; - LilvNode* name; - LilvNode* author; - LilvInstance* instance; - LV2_Worker_Interface* work_iface; - LilvState* state; + const LilvPlugin* plugin; + const LilvUI* ui; + const LilvNode* ui_type; + LilvNode* name; + LilvNode* author; + LilvInstance* instance; + const LV2_Worker_Interface* work_iface; + LilvState* state; }; LV2Plugin::LV2Plugin (AudioEngine& engine, Session& session, - void* c_plugin, + const void* c_plugin, framecnt_t rate) : Plugin (engine, session) , Workee () @@ -282,11 +282,11 @@ LV2Plugin::LV2Plugin (const LV2Plugin& other) } void -LV2Plugin::init(void* c_plugin, framecnt_t rate) +LV2Plugin::init(const void* c_plugin, framecnt_t rate) { DEBUG_TRACE(DEBUG::LV2, "init\n"); - _impl->plugin = (LilvPlugin*)c_plugin; + _impl->plugin = (const LilvPlugin*)c_plugin; _impl->ui = NULL; _impl->ui_type = NULL; _to_ui = NULL; @@ -314,7 +314,7 @@ LV2Plugin::init(void* c_plugin, framecnt_t rate) buf_size_access.handle = &_engine; #endif - LilvPlugin* plugin = _impl->plugin; + const LilvPlugin* plugin = _impl->plugin; LilvNode* state_iface_uri = lilv_new_uri(_world.world, LV2_STATE__interface); LilvNode* state_uri = lilv_new_uri(_world.world, LV2_STATE_URI); @@ -380,7 +380,8 @@ LV2Plugin::init(void* c_plugin, framecnt_t rate) _data_access_extension_data.extension_data = _impl->instance->lv2_descriptor->extension_data; _data_access_feature.data = &_data_access_extension_data; - _impl->work_iface = (LV2_Worker_Interface*)extension_data(LV2_WORKER__interface); + _impl->work_iface = (const LV2_Worker_Interface*)extension_data( + LV2_WORKER__interface); if (lilv_plugin_has_feature(plugin, _world.lv2_inPlaceBroken)) { error << string_compose( @@ -742,22 +743,22 @@ LV2Plugin::extension_data (const char* uri) const return lilv_instance_get_extension_data(_impl->instance, uri); } -void* +const void* LV2Plugin::c_plugin () { return _impl->plugin; } -void* +const void* LV2Plugin::c_ui () { - return (void*)_impl->ui; + return (const void*)_impl->ui; } -void* +const void* LV2Plugin::c_ui_type () { - return (void*)_impl->ui_type; + return (const void*)_impl->ui_type; } /** Directory for all plugin state. */ @@ -1460,7 +1461,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs, break; } if (msg.protocol == _event_transfer_type) { - LV2_Evbuf* buf = _ev_buffers[msg.index]; + LV2_Evbuf* buf = _ev_buffers[msg.index]; LV2_Evbuf_Iterator i = lv2_evbuf_end(buf); const LV2_Atom* const atom = (const LV2_Atom*)body; lv2_evbuf_write(&i, nframes, 0, atom->type, atom->size, @@ -1706,7 +1707,7 @@ LV2World::~LV2World() lilv_node_free(atom_AtomPort); } -LV2PluginInfo::LV2PluginInfo (void* c_plugin) +LV2PluginInfo::LV2PluginInfo (const void* c_plugin) : _c_plugin(c_plugin) { type = ARDOUR::LV2; @@ -1722,7 +1723,7 @@ LV2PluginInfo::load(Session& session) PluginPtr plugin; plugin.reset(new LV2Plugin(session.engine(), session, - (LilvPlugin*)_c_plugin, + (const LilvPlugin*)_c_plugin, session.frame_rate())); plugin->set_info(PluginInfoPtr(new LV2PluginInfo(*this))); @@ -1744,7 +1745,7 @@ LV2PluginInfo::discover() LILV_FOREACH(plugins, i, plugins) { const LilvPlugin* p = lilv_plugins_get(plugins, i); - LV2PluginInfoPtr info(new LV2PluginInfo((void*)p)); + LV2PluginInfoPtr info(new LV2PluginInfo((const void*)p)); LilvNode* name = lilv_plugin_get_name(p); if (!name) {