summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-12 23:47:14 +0000
committerDavid Robillard <d@drobilla.net>2012-04-12 23:47:14 +0000
commitcb35f7aa4a179673598c77282390d9a4084f6f2a (patch)
treed959d1673afe76efebf4b4406c226677e2865078
parentf3b37538c6355ca2f878dafeaf322312dd742e59 (diff)
downloadsratom-cb35f7aa4a179673598c77282390d9a4084f6f2a.tar.gz
sratom-cb35f7aa4a179673598c77282390d9a4084f6f2a.tar.bz2
sratom-cb35f7aa4a179673598c77282390d9a4084f6f2a.zip
Use URI defines from LV2 headers where possible.
git-svn-id: http://svn.drobilla.net/lad/trunk/sratom@4175 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/sratom.c16
-rw-r--r--tests/sratom_test.c5
-rw-r--r--wscript2
3 files changed, 11 insertions, 12 deletions
diff --git a/src/sratom.c b/src/sratom.c
index 4caf14b..fe53065 100644
--- a/src/sratom.c
+++ b/src/sratom.c
@@ -22,12 +22,12 @@
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "sratom/sratom.h"
-#define NS_MIDI (const uint8_t*)"http://lv2plug.in/ns/ext/midi#"
-#define NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-#define NS_XSD (const uint8_t*)"http://www.w3.org/2001/XMLSchema#"
+#define NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_XSD (const uint8_t*)"http://www.w3.org/2001/XMLSchema#"
#define USTR(str) ((const uint8_t*)(str))
@@ -73,8 +73,7 @@ sratom_new(LV2_URID_Map* map)
Sratom* sratom = (Sratom*)malloc(sizeof(Sratom));
sratom->map = map;
sratom->atom_Event = map->map(map->handle, LV2_ATOM__Event);
- sratom->midi_MidiEvent = map->map(map->handle,
- (const char*)NS_MIDI "MidiEvent");
+ sratom->midi_MidiEvent = map->map(map->handle, LV2_MIDI__MidiEvent);
sratom->next_id = 0;
sratom->base_uri = SERD_NODE_NULL;
sratom->pretty_numbers = false;
@@ -290,7 +289,7 @@ sratom_write(Sratom* sratom,
USTR(val ? "true" : "false"));
} else if (type_urid == sratom->midi_MidiEvent) {
new_node = true;
- datatype = serd_node_from_string(SERD_URI, NS_MIDI "MidiEvent");
+ datatype = serd_node_from_string(SERD_URI, USTR(LV2_MIDI__MidiEvent));
uint8_t* str = (uint8_t*)calloc(size * 2 + 1, 1);
for (uint32_t i = 0; i < size; ++i) {
snprintf((char*)str + (2 * i), size * 2 + 1, "%02X",
@@ -422,7 +421,8 @@ sratom_to_turtle(Sratom* sratom,
SerdEnv* env = serd_env_new(&base);
SerdChunk str = { NULL, 0 };
- serd_env_set_prefix_from_strings(env, USTR("midi"), NS_MIDI);
+ serd_env_set_prefix_from_strings(env, USTR("midi"),
+ USTR(LV2_MIDI_PREFIX));
serd_env_set_prefix_from_strings(env, USTR("atom"),
USTR(LV2_ATOM_URI "#"));
serd_env_set_prefix_from_strings(env, USTR("rdf"), NS_RDF);
@@ -545,7 +545,7 @@ read_node(Sratom* sratom,
free(body);
} else if (!strcmp(type_uri, LV2_ATOM__Path)) {
lv2_atom_forge_path(forge, str, len);
- } else if (!strcmp(type_uri, (char*)NS_MIDI "MidiEvent")) {
+ } else if (!strcmp(type_uri, LV2_MIDI__MidiEvent)) {
lv2_atom_forge_atom(forge, len / 2, sratom->midi_MidiEvent);
for (const char* s = str; s < str + len; s += 2) {
unsigned num;
diff --git a/tests/sratom_test.c b/tests/sratom_test.c
index f992153..3f7cf17 100644
--- a/tests/sratom_test.c
+++ b/tests/sratom_test.c
@@ -22,8 +22,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "sratom/sratom.h"
-#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-#define NS_MIDI "http://lv2plug.in/ns/ext/midi#"
+#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
#define USTR(s) ((const uint8_t*)(s))
@@ -199,7 +198,7 @@ main()
lv2_atom_forge_vector(&forge, 4, forge.Int, sizeof(int32_t), elems);
// eg_seq = (Sequence)1, 2
- LV2_URID midi_midiEvent = map.map(map.handle, NS_MIDI "MidiEvent");
+ LV2_URID midi_midiEvent = map.map(map.handle, LV2_MIDI__MidiEvent);
lv2_atom_forge_property_head(&forge, eg_seq, 0);
LV2_Atom_Forge_Frame seq_frame;
lv2_atom_forge_sequence_head(&forge, &seq_frame, 0);
diff --git a/wscript b/wscript
index 3b1f161..63cfd50 100644
--- a/wscript
+++ b/wscript
@@ -55,7 +55,7 @@ def configure(conf):
define_name='HAVE_GCOV',
mandatory=False)
- autowaf.check_pkg(conf, 'lv2', atleast_version='0.4.0', uselib_store='LV2')
+ autowaf.check_pkg(conf, 'lv2', atleast_version='0.5.0', uselib_store='LV2')
autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
atleast_version='0.11.0', mandatory=True)
autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',