summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-02 01:44:12 +0000
committerDavid Robillard <d@drobilla.net>2010-02-02 01:44:12 +0000
commit653679e967f11a0e008521885fcaf6994d2961fa (patch)
tree1b66e2e8ad84aac7f2d40da7f98182c74ad98d58 /src
parentc1ac1f31457708db618143f54a3dfef7eb3361aa (diff)
downloadingen-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')
-rw-r--r--src/shared/LV2URIMap.cpp32
-rw-r--r--src/shared/LV2URIMap.hpp4
2 files changed, 9 insertions, 27 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);
}
diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp
index ae43a9f2..b1e6a89f 100644
--- a/src/shared/LV2URIMap.hpp
+++ b/src/shared/LV2URIMap.hpp
@@ -47,16 +47,12 @@ public:
uint32_t uri_to_id(const char* map, const char* uri);
private:
- typedef std::map<std::string, uint32_t> URIMap;
-
static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
const char* map,
const char* uri);
LV2_Feature uri_map_feature;
LV2_URI_Map_Feature uri_map_feature_data;
- URIMap uri_map;
- uint32_t next_uri_id;
public:
const uint32_t object_class_bool;