summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-10-18 21:46:16 +0000
committerDavid Robillard <d@drobilla.net>2010-10-18 21:46:16 +0000
commit5177aa485f28e40e087042c2b7292fb9a94e7a3c (patch)
tree12133a503c0ec4000d6d56097c1f0939189ea4e0 /src
parent44657ee4df631379f77695408aa4c275182db50f (diff)
downloadingen-5177aa485f28e40e087042c2b7292fb9a94e7a3c.tar.gz
ingen-5177aa485f28e40e087042c2b7292fb9a94e7a3c.tar.bz2
ingen-5177aa485f28e40e087042c2b7292fb9a94e7a3c.zip
Implement URI unmap extension and use it to serialise JSON dictionary keys.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2637 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/LV2Node.cpp2
-rw-r--r--src/module/World.cpp1
-rw-r--r--src/shared/LV2URIMap.cpp37
-rw-r--r--src/shared/LV2URIMap.hpp27
4 files changed, 62 insertions, 5 deletions
diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp
index e2b4b2cd..e6593d13 100644
--- a/src/engine/LV2Node.cpp
+++ b/src/engine/LV2Node.cpp
@@ -172,7 +172,6 @@ LV2Node::instantiate(BufferFactory& bufs)
instance(i), LV2_CONTEXT_MESSAGE);
if (i == 0 && ctx_ext) {
- Raul::info << _lv2_plugin->uri() << " has message context" << endl;
assert(!_message_funcs);
_message_funcs = (LV2_Contexts_MessageContext*)ctx_ext;
}
@@ -322,7 +321,6 @@ LV2Node::instantiate(BufferFactory& bufs)
SLV2Value c = slv2_values_get_at(contexts, i);
const char* context = slv2_value_as_string(c);
if (!strcmp(LV2_CONTEXT_MESSAGE, context)) {
- Raul::info << _lv2_plugin->uri() << " port " << i << " has message context" << endl;
if (!_message_funcs) {
warn << _lv2_plugin->uri()
<< " has a message port, but no context extension data." << endl;
diff --git a/src/module/World.cpp b/src/module/World.cpp
index eddeda73..5b21e9ec 100644
--- a/src/module/World.cpp
+++ b/src/module/World.cpp
@@ -111,6 +111,7 @@ struct WorldImpl : public boost::noncopyable {
#ifdef HAVE_SLV2
lv2_features = new Ingen::Shared::LV2Features();
lv2_features->add_feature(LV2_URI_MAP_URI, uris);
+ lv2_features->add_feature(LV2_URI_UNMAP_URI, uris->unmap_feature());
slv2_world_load_all(slv2_world);
#endif
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp
index d77721d1..623ad69d 100644
--- a/src/shared/LV2URIMap.cpp
+++ b/src/shared/LV2URIMap.cpp
@@ -115,6 +115,13 @@ LV2URIMap::LV2URIMap()
uri_map_feature_data.callback_data = this;
uri_map_feature.URI = LV2_URI_MAP_URI;
uri_map_feature.data = &uri_map_feature_data;
+
+ uri_unmap_feature_data.id_to_uri = &LV2URIMap::uri_unmap_id_to_uri;
+ uri_unmap_feature_data.callback_data = this;
+ uri_unmap_feature.URI = LV2_URI_UNMAP_URI;
+ uri_unmap_feature.data = &uri_unmap_feature_data;
+
+ _unmap_feature = SharedPtr<UnmapFeature>(new UnmapFeature(*this));
}
@@ -129,13 +136,41 @@ LV2URIMap::uri_to_id(const char* map,
}
+const char*
+LV2URIMap::id_to_uri(const char* map,
+ const uint32_t id)
+{
+ // FIXME: Handle event map properly
+ return g_quark_to_string(id);
+}
+
+
uint32_t
LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
const char* map,
const char* uri)
{
+ LV2URIMap* me = (LV2URIMap*)callback_data;
+ const uint32_t id = me->uri_to_id(map, uri);
+
+ // FIXME: Handle event type map properly
+ assert(!map || strcmp(map, "http://lv2plug.in/ns/ext/event") || id <= UINT16_MAX);
+
+ return id;
+}
+
+
+const char*
+LV2URIMap::uri_unmap_id_to_uri(LV2_URI_Map_Callback_Data callback_data,
+ const char* map,
+ uint32_t id)
+{
LV2URIMap* me = (LV2URIMap*)callback_data;
- return me->uri_to_id(map, uri);
+
+ // FIXME: Handle event type map properly
+ assert(!map || strcmp(map, "http://lv2plug.in/ns/ext/event") || id <= UINT16_MAX);
+
+ return me->id_to_uri(map, id);
}
diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp
index 8c645ae0..d34be8f9 100644
--- a/src/shared/LV2URIMap.hpp
+++ b/src/shared/LV2URIMap.hpp
@@ -21,6 +21,7 @@
#include <boost/utility.hpp>
#include "raul/URI.hpp"
#include "lv2/http/lv2plug.in/ns/ext/uri-map/uri-map.h"
+#include "lv2/http/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h"
#include "ingen-config.h"
#include "LV2Features.hpp"
@@ -28,7 +29,7 @@ namespace Ingen {
namespace Shared {
-/** Implementation of the LV2 URI Map extension
+/** Implementation of the LV2 URI Map and URI Unmap extensions
*/
class LV2URIMap : public boost::noncopyable, public LV2Features::Feature {
public:
@@ -38,16 +39,38 @@ public:
return SharedPtr<LV2_Feature>(&uri_map_feature, NullDeleter<LV2_Feature>);
}
- virtual uint32_t uri_to_id(const char* map, const char* uri);
+ struct UnmapFeature : public LV2Features::Feature {
+ UnmapFeature(const LV2URIMap& map) : _feature(map.uri_unmap_feature) {}
+
+ SharedPtr<LV2_Feature> feature(Node*) {
+ return SharedPtr<LV2_Feature>(&_feature, NullDeleter<LV2_Feature>);
+ }
+
+ LV2_Feature _feature;
+ };
+
+ SharedPtr<UnmapFeature> unmap_feature() { return _unmap_feature; }
+
+ virtual uint32_t uri_to_id(const char* map, const char* uri);
+ virtual const char* id_to_uri(const char* map, uint32_t id);
private:
static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
const char* map,
const char* uri);
+ static const char* uri_unmap_id_to_uri(LV2_URI_Map_Callback_Data callback_data,
+ const char* map,
+ const uint32_t id);
+
LV2_Feature uri_map_feature;
LV2_URI_Map_Feature uri_map_feature_data;
+ LV2_Feature uri_unmap_feature;
+ LV2_URI_Unmap_Feature uri_unmap_feature_data;
+
+ SharedPtr<UnmapFeature> _unmap_feature;
+
public:
struct Quark : public Raul::URI {
Quark(const char* str);