summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-29 02:03:23 +0000
committerDavid Robillard <d@drobilla.net>2011-04-29 02:03:23 +0000
commit8bc9aca63644d63de3ccccbb4752e79d3d3c7854 (patch)
tree7f8e4be2eab57edc3d422ad5a8d34c6ed6473b9d /src/client
parent77d22f06129e91f51e37c09c71c0917a0136dd7d (diff)
downloadingen-8bc9aca63644d63de3ccccbb4752e79d3d3c7854.tar.gz
ingen-8bc9aca63644d63de3ccccbb4752e79d3d3c7854.tar.bz2
ingen-8bc9aca63644d63de3ccccbb4752e79d3d3c7854.zip
Don't hide pointers behind typedefs.
Use const appropriately in API (makes it clear from the type whether objects should be freed or not). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3222 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/NodeModel.cpp15
-rw-r--r--src/client/PluginModel.cpp52
-rw-r--r--src/client/PluginModel.hpp16
-rw-r--r--src/client/PluginUI.cpp12
-rw-r--r--src/client/PluginUI.hpp2
5 files changed, 51 insertions, 46 deletions
diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp
index f7321472..4c00e6ec 100644
--- a/src/client/NodeModel.cpp
+++ b/src/client/NodeModel.cpp
@@ -217,15 +217,18 @@ NodeModel::port_label(SharedPtr<PortModel> port) const
#ifdef HAVE_LILV
if (_plugin && _plugin->type() == PluginModel::LV2) {
- LilvWorld c_world = _plugin->lilv_world();
- LilvPlugin c_plugin = _plugin->lilv_plugin();
- LilvValue c_sym = lilv_value_new_string(c_world, port->symbol().c_str());
- LilvPort c_port = lilv_plugin_get_port_by_symbol(c_plugin, c_sym);
+ LilvWorld* c_world = _plugin->lilv_world();
+ const LilvPlugin* c_plugin = _plugin->lilv_plugin();
+ LilvValue* c_sym = lilv_value_new_string(c_world, port->symbol().c_str());
+ const LilvPort* c_port = lilv_plugin_get_port_by_symbol(c_plugin, c_sym);
if (c_port) {
- LilvValue c_name = lilv_port_get_name(c_plugin, c_port);
+ LilvValue* c_name = lilv_port_get_name(c_plugin, c_port);
if (c_name && lilv_value_is_string(c_name)) {
- return lilv_value_as_string(c_name);
+ std::string ret(lilv_value_as_string(c_name));
+ lilv_value_free(c_name);
+ return ret;
}
+ lilv_value_free(c_name);
}
}
#endif
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index dd22549b..62bed5fb 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -36,8 +36,8 @@ namespace Ingen {
namespace Client {
#ifdef HAVE_LILV
-LilvWorld PluginModel::_lilv_world = NULL;
-LilvPlugins PluginModel::_lilv_plugins = NULL;
+LilvWorld* PluginModel::_lilv_world = NULL;
+const LilvPlugins* PluginModel::_lilv_plugins = NULL;
#endif
Sord::World* PluginModel::_rdf_world = NULL;
@@ -52,7 +52,7 @@ PluginModel::PluginModel(Shared::LV2URIMap& uris,
assert(_rdf_world);
add_property("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", this->type_uri());
#ifdef HAVE_LILV
- LilvValue plugin_uri = lilv_value_new_uri(_lilv_world, uri.c_str());
+ LilvValue* plugin_uri = lilv_value_new_uri(_lilv_world, uri.c_str());
_lilv_plugin = lilv_plugins_get_by_uri(_lilv_plugins, plugin_uri);
lilv_value_free(plugin_uri);
#endif
@@ -100,11 +100,11 @@ PluginModel::get_property(const URI& key) const
#ifdef HAVE_LILV
if (_lilv_plugin) {
boost::optional<Raul::Atom&> ret;
- LilvValue lv2_pred = lilv_value_new_uri(_lilv_world, key.str().c_str());
- LilvValues values = lilv_plugin_get_value(_lilv_plugin, lv2_pred);
+ LilvValue* lv2_pred = lilv_value_new_uri(_lilv_world, key.str().c_str());
+ LilvValues* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred);
lilv_value_free(lv2_pred);
LILV_FOREACH(values, i, values) {
- LilvValue val = lilv_values_get(values, i);
+ const LilvValue* val = lilv_values_get(values, i);
if (lilv_value_is_uri(val)) {
ret = set_property(key, Atom(Atom::URI, lilv_value_as_uri(val)));
break;
@@ -173,9 +173,9 @@ PluginModel::port_human_name(uint32_t index) const
{
#ifdef HAVE_LILV
if (_lilv_plugin) {
- LilvPort port = lilv_plugin_get_port_by_index(_lilv_plugin, index);
- LilvValue name = lilv_port_get_name(_lilv_plugin, port);
- string ret = lilv_value_as_string(name);
+ const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index);
+ LilvValue* name = lilv_port_get_name(_lilv_plugin, port);
+ const string ret(lilv_value_as_string(name));
lilv_value_free(name);
return ret;
}
@@ -187,8 +187,10 @@ PluginModel::port_human_name(uint32_t index) const
bool
PluginModel::has_ui() const
{
- LilvUIs uis = lilv_plugin_get_uis(_lilv_plugin);
- return (lilv_values_size(uis) > 0);
+ LilvUIs* uis = lilv_plugin_get_uis(_lilv_plugin);
+ const bool ret = (lilv_values_size(uis) > 0);
+ lilv_uis_free(uis);
+ return ret;
}
SharedPtr<PluginUI>
@@ -213,16 +215,16 @@ PluginModel::icon_path() const
/** RDF world mutex must be held by the caller */
string
-PluginModel::get_lv2_icon_path(LilvPlugin plugin)
+PluginModel::get_lv2_icon_path(const LilvPlugin* plugin)
{
string result;
- LilvValue svg_icon_pred = lilv_value_new_uri(_lilv_world,
+ LilvValue* svg_icon_pred = lilv_value_new_uri(_lilv_world,
"http://ll-plugins.nongnu.org/lv2/namespace#svgIcon");
- LilvValues paths = lilv_plugin_get_value(plugin, svg_icon_pred);
+ LilvValues* paths = lilv_plugin_get_value(plugin, svg_icon_pred);
if (lilv_values_size(paths) > 0) {
- LilvValue value = lilv_values_get_first(paths);
+ const LilvValue* value = lilv_values_get_first(paths);
if (lilv_value_is_uri(value))
result = lilv_uri_to_path(lilv_value_as_string(value));
lilv_values_free(paths);
@@ -243,12 +245,12 @@ PluginModel::documentation() const
//LilvValue lv2_documentation = lilv_value_new_uri(
// _lilv_world, LILV_NAMESPACE_LV2 "documentation");
- LilvValue rdfs_comment = lilv_value_new_uri(
+ LilvValue* rdfs_comment = lilv_value_new_uri(
_lilv_world, "http://www.w3.org/2000/01/rdf-schema#comment");
- LilvValues vals = lilv_plugin_get_value(_lilv_plugin,
- rdfs_comment);
- LilvValue val = lilv_values_get_first(vals);
+ LilvValues* vals = lilv_plugin_get_value(_lilv_plugin,
+ rdfs_comment);
+ const LilvValue* val = lilv_values_get_first(vals);
if (lilv_value_is_string(val)) {
doc += lilv_value_as_string(val);
}
@@ -266,17 +268,17 @@ PluginModel::port_documentation(uint32_t index) const
if (!_lilv_plugin)
return doc;
- LilvPort port = lilv_plugin_get_port_by_index(_lilv_plugin, index);
+ const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index);
//LilvValue lv2_documentation = lilv_value_new_uri(
// _lilv_world, LILV_NAMESPACE_LV2 "documentation");
- LilvValue rdfs_comment = lilv_value_new_uri(
+ LilvValue* rdfs_comment = lilv_value_new_uri(
_lilv_world, "http://www.w3.org/2000/01/rdf-schema#comment");
- LilvValues vals = lilv_port_get_value(_lilv_plugin,
- port,
- rdfs_comment);
- LilvValue val = lilv_values_get_first(vals);
+ LilvValues* vals = lilv_port_get_value(_lilv_plugin,
+ port,
+ rdfs_comment);
+ const LilvValue* val = lilv_values_get_first(vals);
if (lilv_value_is_string(val)) {
doc += lilv_value_as_string(val);
}
diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp
index e7076ff2..faba8c8b 100644
--- a/src/client/PluginModel.hpp
+++ b/src/client/PluginModel.hpp
@@ -68,14 +68,14 @@ public:
std::string port_human_name(uint32_t index) const;
#ifdef HAVE_LILV
- static LilvWorld lilv_world() { return _lilv_world; }
- LilvPlugin lilv_plugin() const { return _lilv_plugin; }
+ static LilvWorld* lilv_world() { return _lilv_world; }
+ const LilvPlugin* lilv_plugin() const { return _lilv_plugin; }
- LilvPort lilv_port(uint32_t index) {
+ const LilvPort* lilv_port(uint32_t index) {
return lilv_plugin_get_port_by_index(_lilv_plugin, index);
}
- static void set_lilv_world(LilvWorld world) {
+ static void set_lilv_world(LilvWorld* world) {
_lilv_world = world;
_lilv_plugins = lilv_world_get_all_plugins(_lilv_world);
}
@@ -86,7 +86,7 @@ public:
SharedPtr<NodeModel> node) const;
const std::string& icon_path() const;
- static std::string get_lv2_icon_path(LilvPlugin plugin);
+ static std::string get_lv2_icon_path(const LilvPlugin* plugin);
#endif
std::string documentation() const;
@@ -110,10 +110,10 @@ private:
Type _type;
#ifdef HAVE_LILV
- static LilvWorld _lilv_world;
- static LilvPlugins _lilv_plugins;
+ static LilvWorld* _lilv_world;
+ static const LilvPlugins* _lilv_plugins;
- LilvPlugin _lilv_plugin;
+ const LilvPlugin* _lilv_plugin;
mutable std::string _icon_path;
#endif
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index 437e0f27..d545d670 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -117,7 +117,7 @@ PluginUI::~PluginUI()
SharedPtr<PluginUI>
PluginUI::create(Ingen::Shared::World* world,
SharedPtr<NodeModel> node,
- LilvPlugin plugin)
+ const LilvPlugin* plugin)
{
if (!PluginUI::ui_host) {
PluginUI::ui_host = suil_host_new(lv2_ui_write, NULL, NULL, NULL);
@@ -125,13 +125,13 @@ PluginUI::create(Ingen::Shared::World* world,
static const char* gtk_ui_uri = "http://lv2plug.in/ns/extensions/ui#GtkUI";
- LilvValue gtk_ui = lilv_value_new_uri(world->lilv_world(), gtk_ui_uri);
+ LilvValue* gtk_ui = lilv_value_new_uri(world->lilv_world(), gtk_ui_uri);
- LilvUIs uis = lilv_plugin_get_uis(plugin);
- LilvUI ui = NULL;
- LilvValue ui_type = NULL;
+ LilvUIs* uis = lilv_plugin_get_uis(plugin);
+ const LilvUI* ui = NULL;
+ const LilvValue* ui_type = NULL;
LILV_FOREACH(uis, u, uis) {
- LilvUI this_ui = lilv_uis_get(uis, u);
+ const LilvUI* this_ui = lilv_uis_get(uis, u);
if (lilv_ui_is_supported(this_ui,
suil_ui_supported,
gtk_ui,
diff --git a/src/client/PluginUI.hpp b/src/client/PluginUI.hpp
index fd8d14f4..cedc4fe2 100644
--- a/src/client/PluginUI.hpp
+++ b/src/client/PluginUI.hpp
@@ -46,7 +46,7 @@ public:
static SharedPtr<PluginUI> create(Ingen::Shared::World* world,
SharedPtr<NodeModel> node,
- LilvPlugin plugin);
+ const LilvPlugin* plugin);
SuilWidget get_widget();