diff options
author | David Robillard <d@drobilla.net> | 2010-02-02 01:44:12 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-02-02 01:44:12 +0000 |
commit | 653679e967f11a0e008521885fcaf6994d2961fa (patch) | |
tree | 1b66e2e8ad84aac7f2d40da7f98182c74ad98d58 /src/shared/LV2URIMap.cpp | |
parent | c1ac1f31457708db618143f54a3dfef7eb3361aa (diff) | |
download | ingen-653679e967f11a0e008521885fcaf6994d2961fa.tar.gz ingen-653679e967f11a0e008521885fcaf6994d2961fa.tar.bz2 ingen-653679e967f11a0e008521885fcaf6994d2961fa.zip |
Use Glib quarks to implement LV2 URI Map extension.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2406 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared/LV2URIMap.cpp')
-rw-r--r-- | src/shared/LV2URIMap.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index 3666c2a3..d0c71acf 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -18,6 +18,7 @@ #define __STDC_LIMIT_MACROS 1 #include <cassert> #include <stdint.h> +#include <glib.h> #include "raul/log.hpp" #include "object.lv2/object.h" #include "LV2URIMap.hpp" @@ -30,9 +31,7 @@ namespace Shared { LV2URIMap::LV2URIMap() - : uri_map() - , next_uri_id(1) - , object_class_bool(uri_to_id(NULL, LV2_OBJECT_URI "#Bool")) + : object_class_bool(uri_to_id(NULL, LV2_OBJECT_URI "#Bool")) , object_class_string(uri_to_id(NULL, LV2_OBJECT_URI "#String")) , object_class_int32(uri_to_id(NULL, LV2_OBJECT_URI "#Int32")) , object_class_float32(uri_to_id(NULL, LV2_OBJECT_URI "#Float32")) @@ -53,7 +52,12 @@ uint32_t LV2URIMap::uri_to_id(const char* map, const char* uri) { - return uri_map_uri_to_id(this, map, uri); + const uint32_t ret = static_cast<uint32_t>(g_quark_from_string(uri)); + debug << "[LV2URIMap] "; + if (map) + debug << map << " : "; + debug << uri << " => " << ret << endl; + return ret; } @@ -62,26 +66,8 @@ LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char* map, const char* uri) { - // TODO: map ignored, < UINT16_MAX assumed - LV2URIMap* me = (LV2URIMap*)callback_data; - uint32_t ret = 0; - - URIMap::iterator i = me->uri_map.find(uri); - if (i != me->uri_map.end()) { - ret = i->second; - } else { - ret = me->next_uri_id++; - me->uri_map.insert(make_pair(string(uri), ret)); - } - - debug << "[LV2URIMap] "; - if (map) - debug << map << " : "; - debug << uri << " => " << ret << endl; - - assert(ret <= UINT16_MAX); - return ret; + return me->uri_to_id(map, uri); } |