diff options
author | David Robillard <d@drobilla.net> | 2012-03-15 00:39:10 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-15 00:39:10 +0000 |
commit | e75e4c88f91c6ca5320d61580404e48931b30345 (patch) | |
tree | 4e57c94aee6707383b82f7207a5a5e65c4c5c5b7 /src/shared | |
parent | 8fc92b0e098133cd8b09acbae99c52b458a2868e (diff) | |
download | ingen-e75e4c88f91c6ca5320d61580404e48931b30345.tar.gz ingen-e75e4c88f91c6ca5320d61580404e48931b30345.tar.bz2 ingen-e75e4c88f91c6ca5320d61580404e48931b30345.zip |
Use host-provided URI-map for internally mapped URIs.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4061 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/LV2URIMap.cpp | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index 43a949a8..c66a8984 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -51,24 +51,55 @@ LV2URIMap::URIMapFeature::URIMapFeature(LV2URIMap* map) LV2URIMap::URIDMapFeature::URIDMapFeature(LV2URIMap* map, LV2_URID_Map* urid_map) - : Feature(LV2_URID__map, urid_map ? urid_map : &_feature_data) + : Feature(LV2_URID__map, &_feature_data) { - if (!urid_map) { - _feature_data.map = &LV2URIMap::urid_map; - _feature_data.handle = map; + if (urid_map) { + _feature_data = *urid_map; + } else { + _feature_data.map = default_map; + _feature_data.handle = NULL; } } +LV2_URID +LV2URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle handle, + const char* uri) +{ + return static_cast<LV2_URID>(g_quark_from_string(uri)); +} + +LV2_URID +LV2URIMap::URIDMapFeature::map(const char* uri) +{ + return _feature_data.map(_feature_data.handle, uri); +} + + LV2URIMap::URIDUnmapFeature::URIDUnmapFeature(LV2URIMap* map, LV2_URID_Unmap* urid_unmap) - : Feature(LV2_URID__unmap, urid_unmap ? urid_unmap : &_feature_data) + : Feature(LV2_URID__unmap, &_feature_data) { - if (!urid_unmap) { - _feature_data.unmap = &LV2URIMap::urid_unmap; - _feature_data.handle = map; + if (urid_unmap) { + _feature_data = *urid_unmap; + } else { + _feature_data.unmap = default_unmap; + _feature_data.handle = NULL; } } +const char* +LV2URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle handle, + LV2_URID urid) +{ + return g_quark_to_string(urid); +} + +const char* +LV2URIMap::URIDUnmapFeature::unmap(LV2_URID urid) +{ + return _feature_data.unmap(_feature_data.handle, urid); +} + uint32_t LV2URIMap::uri_to_id(const char* map, const char* uri) @@ -146,23 +177,16 @@ LV2URIMap::urid_map(LV2_URID_Map_Handle handle, const char* uri) 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)); + return _urid_map_feature->map(uri); } const char* LV2URIMap::unmap_uri(uint32_t urid) { - return g_quark_to_string(urid); + return _urid_unmap_feature->unmap(urid); } } // namespace Shared |