summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-14 23:38:53 +0000
committerDavid Robillard <d@drobilla.net>2012-03-14 23:38:53 +0000
commitf8ca7f3cf6f4a0e967eacfd2e1f9a8ae9625c015 (patch)
treea1e7bff65900df78c2283fec7093454a18340195 /src/shared
parent31f009967ea0a1664c05d38ea1c126e0c678b20a (diff)
downloadingen-f8ca7f3cf6f4a0e967eacfd2e1f9a8ae9625c015.tar.gz
ingen-f8ca7f3cf6f4a0e967eacfd2e1f9a8ae9625c015.tar.bz2
ingen-f8ca7f3cf6f4a0e967eacfd2e1f9a8ae9625c015.zip
Use the host URI map/unmap when running as a plugin.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4058 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Builder.cpp1
-rw-r--r--src/shared/LV2Atom.cpp1
-rw-r--r--src/shared/LV2URIMap.cpp69
-rw-r--r--src/shared/ResourceImpl.cpp1
-rw-r--r--src/shared/URIs.cpp12
-rw-r--r--src/shared/World.cpp23
6 files changed, 80 insertions, 27 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp
index 3672e388..9dea08f0 100644
--- a/src/shared/Builder.cpp
+++ b/src/shared/Builder.cpp
@@ -26,6 +26,7 @@
#include "ingen/Port.hpp"
#include "ingen/shared/Builder.hpp"
#include "ingen/shared/LV2URIMap.hpp"
+#include "ingen/shared/URIs.hpp"
using namespace std;
using namespace Raul;
diff --git a/src/shared/LV2Atom.cpp b/src/shared/LV2Atom.cpp
index 991c4f7c..63686bf5 100644
--- a/src/shared/LV2Atom.cpp
+++ b/src/shared/LV2Atom.cpp
@@ -18,6 +18,7 @@
#include "ingen/shared/LV2Atom.hpp"
#include "ingen/shared/LV2Features.hpp"
#include "ingen/shared/LV2URIMap.hpp"
+#include "ingen/shared/URIs.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
#include "raul/Atom.hpp"
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp
index d39f0b88..43a949a8 100644
--- a/src/shared/LV2URIMap.cpp
+++ b/src/shared/LV2URIMap.cpp
@@ -35,20 +35,45 @@ using namespace Raul;
namespace Ingen {
namespace Shared {
-LV2URIMap::LV2URIMap(URIs& uris)
- : _uris(uris)
+LV2URIMap::LV2URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap)
+ : _uri_map_feature(new URIMapFeature(this))
+ , _urid_map_feature(new URIDMapFeature(this, map))
+ , _urid_unmap_feature(new URIDUnmapFeature(this, unmap))
{
- uri_map_feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id;
- uri_map_feature_data.callback_data = this;
- uri_map_feature.URI = LV2_URI_MAP_URI;
- uri_map_feature.data = &uri_map_feature_data;
+}
+
+LV2URIMap::URIMapFeature::URIMapFeature(LV2URIMap* map)
+ : Feature(LV2_URI_MAP_URI, &_feature_data)
+{
+ _feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id;
+ _feature_data.callback_data = map;
+}
+
+LV2URIMap::URIDMapFeature::URIDMapFeature(LV2URIMap* map,
+ LV2_URID_Map* urid_map)
+ : Feature(LV2_URID__map, urid_map ? urid_map : &_feature_data)
+{
+ if (!urid_map) {
+ _feature_data.map = &LV2URIMap::urid_map;
+ _feature_data.handle = map;
+ }
+}
+
+LV2URIMap::URIDUnmapFeature::URIDUnmapFeature(LV2URIMap* map,
+ LV2_URID_Unmap* urid_unmap)
+ : Feature(LV2_URID__unmap, urid_unmap ? urid_unmap : &_feature_data)
+{
+ if (!urid_unmap) {
+ _feature_data.unmap = &LV2URIMap::urid_unmap;
+ _feature_data.handle = map;
+ }
}
uint32_t
LV2URIMap::uri_to_id(const char* map,
const char* uri)
{
- const uint32_t id = _uris.map_uri(uri);
+ const uint32_t id = map_uri(uri);
if (map && !strcmp(map, LV2_EVENT_URI)) {
GlobalToEvent::iterator i = _global_to_event.find(id);
if (i != _global_to_event.end()) {
@@ -79,9 +104,9 @@ LV2URIMap::id_to_uri(const char* map,
error << "Failed to unmap event URI " << id << endl;
return NULL;
}
- return _uris.unmap_uri(i->second);
+ return unmap_uri(i->second);
} else {
- return _uris.unmap_uri(id);
+ return unmap_uri(id);
}
}
@@ -114,5 +139,31 @@ LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
return me->uri_to_id(map, uri);
}
+LV2_URID
+LV2URIMap::urid_map(LV2_URID_Map_Handle handle, const char* uri)
+{
+ LV2URIMap* me = (LV2URIMap*)handle;
+ return me->uri_to_id(NULL, uri);
+}
+
+const char*
+LV2URIMap::urid_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
+{
+ LV2URIMap* me = (LV2URIMap*)handle;
+ return me->id_to_uri(NULL, urid);
+}
+
+uint32_t
+LV2URIMap::map_uri(const char* uri)
+{
+ return static_cast<uint32_t>(g_quark_from_string(uri));
+}
+
+const char*
+LV2URIMap::unmap_uri(uint32_t urid)
+{
+ return g_quark_to_string(urid);
+}
+
} // namespace Shared
} // namespace Ingen
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index fb50ac54..de3eae17 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -19,6 +19,7 @@
#include "raul/Atom.hpp"
#include "ingen/shared/LV2URIMap.hpp"
#include "ingen/shared/ResourceImpl.hpp"
+#include "ingen/shared/URIs.hpp"
using namespace std;
using namespace Raul;
diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp
index bb2142e1..058049df 100644
--- a/src/shared/URIs.cpp
+++ b/src/shared/URIs.cpp
@@ -119,17 +119,5 @@ URIs::URIs(Raul::Forge& f)
{
}
-uint32_t
-URIs::map_uri(const char* uri)
-{
- return static_cast<uint32_t>(g_quark_from_string(uri));
-}
-
-const char*
-URIs::unmap_uri(uint32_t urid)
-{
- return g_quark_to_string(urid);
-}
-
} // namespace Shared
} // namespace Ingen
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index cf21cd44..140dd688 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -32,6 +32,7 @@
#include "ingen/shared/runtime_paths.hpp"
#include "ingen/shared/LV2Features.hpp"
#include "ingen/shared/LV2URIMap.hpp"
+#include "ingen/shared/URIs.hpp"
#define LOG(s) s << "[Module] "
@@ -98,19 +99,25 @@ ingen_load_module(const string& name)
class World::Pimpl {
public:
- Pimpl(Raul::Configuration* conf, int& a_argc, char**& a_argv)
+ Pimpl(Raul::Configuration* conf,
+ int& a_argc,
+ char**& a_argv,
+ LV2_URID_Map* map,
+ LV2_URID_Unmap* unmap)
: argc(a_argc)
, argv(a_argv)
, conf(conf)
, lv2_features(NULL)
, forge(new Raul::Forge())
, rdf_world(new Sord::World())
+ , lv2_uri_map(new Ingen::Shared::LV2URIMap(map, unmap))
, uris(new Shared::URIs(*forge))
- , lv2_uri_map(new Ingen::Shared::LV2URIMap(*uris.get()))
, lilv_world(lilv_world_new())
{
lv2_features = new Ingen::Shared::LV2Features();
- lv2_features->add_feature(lv2_uri_map);
+ lv2_features->add_feature(lv2_uri_map->uri_map_feature());
+ lv2_features->add_feature(lv2_uri_map->urid_map_feature());
+ lv2_features->add_feature(lv2_uri_map->urid_unmap_feature());
lilv_world_load_all(lilv_world);
// Set up RDF namespaces
@@ -167,8 +174,8 @@ public:
LV2Features* lv2_features;
Raul::Forge* forge;
Sord::World* rdf_world;
- SharedPtr<URIs> uris;
SharedPtr<LV2URIMap> lv2_uri_map;
+ SharedPtr<URIs> uris;
SharedPtr<ServerInterface> engine;
SharedPtr<EngineBase> local_engine;
SharedPtr<Serialisation::Serialiser> serialiser;
@@ -178,8 +185,12 @@ public:
std::string jack_uuid;
};
-World::World(Raul::Configuration* conf, int& argc, char**& argv)
- : _impl(new Pimpl(conf, argc, argv))
+World::World(Raul::Configuration* conf,
+ int& argc,
+ char**& argv,
+ LV2_URID_Map* map,
+ LV2_URID_Unmap* unmap)
+ : _impl(new Pimpl(conf, argc, argv, map, unmap))
{
}