summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sratom/sratom.h54
-rw-r--r--src/atom_to_rdf.c158
-rw-r--r--tests/sratom_test.c62
-rw-r--r--wscript72
4 files changed, 180 insertions, 166 deletions
diff --git a/sratom/sratom.h b/sratom/sratom.h
index 1fe2547..d063d8c 100644
--- a/sratom/sratom.h
+++ b/sratom/sratom.h
@@ -15,11 +15,11 @@
*/
/**
- @file seriatom.h API for Seriatom, an LV2 Atom RDF serialisation library.
+ @file sratom.h API for Sratom, an LV2 Atom RDF serialisation library.
*/
-#ifndef SERIATOM_SERIATOM_H
-#define SERIATOM_SERIATOM_H
+#ifndef SRATOM_SRATOM_H
+#define SRATOM_SRATOM_H
#include <stdint.h>
@@ -27,21 +27,21 @@
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "serd/serd.h"
-#ifdef SERIATOM_SHARED
+#ifdef SRATOM_SHARED
# ifdef _WIN32
-# define SERIATOM_LIB_IMPORT __declspec(dllimport)
-# define SERIATOM_LIB_EXPORT __declspec(dllexport)
+# define SRATOM_LIB_IMPORT __declspec(dllimport)
+# define SRATOM_LIB_EXPORT __declspec(dllexport)
# else
-# define SERIATOM_LIB_IMPORT __attribute__((visibility("default")))
-# define SERIATOM_LIB_EXPORT __attribute__((visibility("default")))
+# define SRATOM_LIB_IMPORT __attribute__((visibility("default")))
+# define SRATOM_LIB_EXPORT __attribute__((visibility("default")))
# endif
-# ifdef SERIATOM_INTERNAL
-# define SERIATOM_API SERIATOM_LIB_EXPORT
+# ifdef SRATOM_INTERNAL
+# define SRATOM_API SRATOM_LIB_EXPORT
# else
-# define SERIATOM_API SERIATOM_LIB_IMPORT
+# define SRATOM_API SRATOM_LIB_IMPORT
# endif
#else
-# define SERIATOM_API
+# define SRATOM_API
#endif
#ifdef __cplusplus
@@ -49,7 +49,7 @@ extern "C" {
#endif
/**
- @defgroup seriatom Seriatom
+ @defgroup sratom Sratom
An LV2 Atom RDF serialisation library.
@{
*/
@@ -57,29 +57,29 @@ extern "C" {
/**
Atom serialiser.
*/
-typedef struct SeriatomImpl Seriatom;
+typedef struct SratomImpl Sratom;
/**
Create a new Atom serialiser.
*/
-SERIATOM_API
-Seriatom*
-seriatom_new(LV2_URID_Map* map,
- LV2_URID_Unmap* unmap);
+SRATOM_API
+Sratom*
+sratom_new(LV2_URID_Map* map,
+ LV2_URID_Unmap* unmap);
/**
Free an Atom serialisation.
*/
-SERIATOM_API
+SRATOM_API
void
-seriatom_free(Seriatom* seriatom);
+sratom_free(Sratom* sratom);
/**
Serialise an Atom to a SerdWriter.
*/
-SERIATOM_API
+SRATOM_API
void
-atom_to_rdf(Seriatom* seriatom,
+atom_to_rdf(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
const LV2_Atom* atom,
@@ -88,9 +88,9 @@ atom_to_rdf(Seriatom* seriatom,
/**
Serialise an Atom body to a SerdWriter.
*/
-SERIATOM_API
+SRATOM_API
void
-atom_body_to_rdf(Seriatom* seriatom,
+atom_body_to_rdf(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
uint32_t type_urid,
@@ -102,9 +102,9 @@ atom_body_to_rdf(Seriatom* seriatom,
Serialise an Atom to a Turtle string.
The returned string must be free()'d by the caller.
*/
-SERIATOM_API
+SRATOM_API
char*
-atom_to_turtle(Seriatom* seriatom,
+atom_to_turtle(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
const LV2_Atom* atom);
@@ -117,4 +117,4 @@ atom_to_turtle(Seriatom* seriatom,
} /* extern "C" */
#endif
-#endif /* SERIATOM_SERIATOM_H */
+#endif /* SRATOM_SRATOM_H */
diff --git a/src/atom_to_rdf.c b/src/atom_to_rdf.c
index e280244..b44a908 100644
--- a/src/atom_to_rdf.c
+++ b/src/atom_to_rdf.c
@@ -21,7 +21,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "seriatom/seriatom.h"
+#include "sratom/sratom.h"
#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#"
@@ -29,7 +29,7 @@
#define USTR(str) ((const uint8_t*)(str))
-struct SeriatomImpl {
+struct SratomImpl {
SerdWriter* writer;
LV2_URID_Map* map;
LV2_URID_Unmap* unmap;
@@ -39,27 +39,27 @@ struct SeriatomImpl {
unsigned next_id;
};
-SERIATOM_API
-Seriatom*
-seriatom_new(LV2_URID_Map* map,
+SRATOM_API
+Sratom*
+sratom_new(LV2_URID_Map* map,
LV2_URID_Unmap* unmap)
{
- Seriatom* seriatom = (Seriatom*)malloc(sizeof(Seriatom));
- seriatom->writer = NULL;
- seriatom->map = map;
- seriatom->unmap = unmap;
- seriatom->atom_Event = map->map(map->handle, LV2_ATOM_URI "#Event");
- seriatom->midi_MidiEvent = map->map(map->handle, (const char*)NS_MIDI "MidiEvent");
- seriatom->next_id = 0;
- lv2_atom_forge_init(&seriatom->forge, map);
- return seriatom;
+ Sratom* sratom = (Sratom*)malloc(sizeof(Sratom));
+ sratom->writer = NULL;
+ sratom->map = map;
+ sratom->unmap = unmap;
+ sratom->atom_Event = map->map(map->handle, LV2_ATOM_URI "#Event");
+ sratom->midi_MidiEvent = map->map(map->handle, (const char*)NS_MIDI "MidiEvent");
+ sratom->next_id = 0;
+ lv2_atom_forge_init(&sratom->forge, map);
+ return sratom;
}
-SERIATOM_API
+SRATOM_API
void
-seriatom_free(Seriatom* seriatom)
+sratom_free(Sratom* sratom)
{
- free(seriatom);
+ free(sratom);
}
typedef struct {
@@ -85,7 +85,7 @@ gensym(SerdNode* out, char c, unsigned num)
}
static void
-list_append(Seriatom* seriatom,
+list_append(Sratom* sratom,
unsigned* flags,
SerdNode* s,
SerdNode* p,
@@ -95,17 +95,17 @@ list_append(Seriatom* seriatom,
void* body)
{
// Generate a list node
- gensym(node, 'l', seriatom->next_id);
- serd_writer_write_statement(seriatom->writer, *flags, NULL,
+ gensym(node, 'l', sratom->next_id);
+ serd_writer_write_statement(sratom->writer, *flags, NULL,
s, p, node, NULL, NULL);
// _:node rdf:first value
*flags = SERD_LIST_CONT;
*p = serd_node_from_string(SERD_URI, NS_RDF "first");
- atom_body_to_rdf(seriatom, node, p, type, size, body, SERD_LIST_CONT);
+ atom_body_to_rdf(sratom, node, p, type, size, body, SERD_LIST_CONT);
// Set subject to node and predicate to rdf:rest for next time
- gensym(node, 'l', ++seriatom->next_id);
+ gensym(node, 'l', ++sratom->next_id);
*s = *node;
*p = serd_node_from_string(SERD_URI, NS_RDF "rest");
}
@@ -125,7 +125,7 @@ list_end(SerdWriter* writer,
}
static void
-start_object(Seriatom* seriatom,
+start_object(Sratom* sratom,
uint32_t flags,
const SerdNode* subject,
const SerdNode* predicate,
@@ -133,20 +133,20 @@ start_object(Seriatom* seriatom,
const char* type)
{
serd_writer_write_statement(
- seriatom->writer, flags|SERD_ANON_O_BEGIN, NULL,
+ sratom->writer, flags|SERD_ANON_O_BEGIN, NULL,
subject, predicate, node, NULL, NULL);
if (type) {
SerdNode p = serd_node_from_string(SERD_URI, NS_RDF "type");
SerdNode o = serd_node_from_string(SERD_URI, USTR(type));
serd_writer_write_statement(
- seriatom->writer, SERD_ANON_CONT, NULL,
+ sratom->writer, SERD_ANON_CONT, NULL,
node, &p, &o, NULL, NULL);
}
}
-SERIATOM_API
+SRATOM_API
void
-atom_body_to_rdf(Seriatom* seriatom,
+atom_body_to_rdf(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
uint32_t type_urid,
@@ -154,7 +154,7 @@ atom_body_to_rdf(Seriatom* seriatom,
const void* body,
uint32_t flags)
{
- LV2_URID_Unmap* unmap = seriatom->unmap;
+ LV2_URID_Unmap* unmap = sratom->unmap;
const char* const type = unmap->unmap(unmap->handle, type_urid);
uint8_t idbuf[12] = "b0000000000";
SerdNode id = serd_node_from_string(SERD_BLANK, idbuf);
@@ -166,9 +166,9 @@ atom_body_to_rdf(Seriatom* seriatom,
bool new_node = false;
if (type_urid == 0 && size == 0) {
object = serd_node_from_string(SERD_BLANK, USTR("null"));
- } else if (type_urid == seriatom->forge.String) {
+ } else if (type_urid == sratom->forge.String) {
object = serd_node_from_string(SERD_LITERAL, (const uint8_t*)body);
- } else if (type_urid == seriatom->forge.Literal) {
+ } else if (type_urid == sratom->forge.Literal) {
LV2_Atom_Literal_Body* lit = (LV2_Atom_Literal_Body*)body;
const uint8_t* str = USTR(lit + 1);
object = serd_node_from_string(SERD_LITERAL, str);
@@ -186,39 +186,39 @@ atom_body_to_rdf(Seriatom* seriatom,
fprintf(stderr, "Unknown language URI <%s>\n", lang);
}
}
- } else if (type_urid == seriatom->forge.URID) {
+ } else if (type_urid == sratom->forge.URID) {
const uint32_t id = *(const uint32_t*)body;
const uint8_t* str = USTR(unmap->unmap(unmap->handle, id));
object = serd_node_from_string(SERD_URI, str);
- } else if (type_urid == seriatom->forge.Path) {
+ } else if (type_urid == sratom->forge.Path) {
const uint8_t* str = USTR(body);
object = serd_node_from_string(SERD_LITERAL, str);
datatype = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__Path));
- } else if (type_urid == seriatom->forge.URI) {
+ } else if (type_urid == sratom->forge.URI) {
const uint8_t* str = USTR(body);
object = serd_node_from_string(SERD_URI, str);
- } else if (type_urid == seriatom->forge.Int32) {
+ } else if (type_urid == sratom->forge.Int32) {
new_node = true;
object = serd_node_new_integer(*(int32_t*)body);
datatype = serd_node_from_string(SERD_URI, NS_XSD "int");
- } else if (type_urid == seriatom->forge.Int64) {
+ } else if (type_urid == sratom->forge.Int64) {
new_node = true;
object = serd_node_new_integer(*(int64_t*)body);
datatype = serd_node_from_string(SERD_URI, NS_XSD "long");
- } else if (type_urid == seriatom->forge.Float) {
+ } else if (type_urid == sratom->forge.Float) {
new_node = true;
object = serd_node_new_decimal(*(float*)body, 8);
datatype = serd_node_from_string(SERD_URI, NS_XSD "float");
- } else if (type_urid == seriatom->forge.Double) {
+ } else if (type_urid == sratom->forge.Double) {
new_node = true;
object = serd_node_new_decimal(*(double*)body, 16);
datatype = serd_node_from_string(SERD_URI, NS_XSD "double");
- } else if (type_urid == seriatom->forge.Bool) {
+ } else if (type_urid == sratom->forge.Bool) {
const int32_t val = *(const int32_t*)body;
datatype = serd_node_from_string(SERD_URI, NS_XSD "boolean");
object = serd_node_from_string(SERD_LITERAL,
USTR(val ? "true" : "false"));
- } else if (type_urid == seriatom->midi_MidiEvent) {
+ } else if (type_urid == sratom->midi_MidiEvent) {
new_node = true;
datatype = serd_node_from_string(SERD_URI, NS_MIDI "MidiEvent");
uint8_t* str = calloc(size * 2, 1);
@@ -227,40 +227,40 @@ atom_body_to_rdf(Seriatom* seriatom,
(unsigned)(uint8_t)*((uint8_t*)body + i));
}
object = serd_node_from_string(SERD_LITERAL, USTR(str));
- } else if (type_urid == seriatom->atom_Event) {
+ } else if (type_urid == sratom->atom_Event) {
const LV2_Atom_Event* ev = (const LV2_Atom_Event*)body;
- gensym(&id, 'e', seriatom->next_id++);
- start_object(seriatom, flags, subject, predicate, &id, NULL);
+ gensym(&id, 'e', sratom->next_id++);
+ start_object(sratom, flags, subject, predicate, &id, NULL);
// TODO: beat time
SerdNode p = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__frameTime));
SerdNode time = serd_node_new_integer(ev->time.frames);
datatype = serd_node_from_string(SERD_URI, NS_XSD "decimal");
- serd_writer_write_statement(seriatom->writer, SERD_ANON_CONT, NULL,
+ serd_writer_write_statement(sratom->writer, SERD_ANON_CONT, NULL,
&id, &p, &time,
&datatype, &language);
serd_node_free(&time);
p = serd_node_from_string(SERD_URI, NS_RDF "value");
- atom_body_to_rdf(seriatom, &id, &p,
+ atom_body_to_rdf(sratom, &id, &p,
ev->body.type, ev->body.size,
LV2_ATOM_BODY(&ev->body),
SERD_ANON_CONT);
- serd_writer_end_anon(seriatom->writer, &id);
- } else if (type_urid == seriatom->forge.Tuple) {
- gensym(&id, 't', seriatom->next_id++);
- start_object(seriatom, flags, subject, predicate, &id, type);
+ serd_writer_end_anon(sratom->writer, &id);
+ } else if (type_urid == sratom->forge.Tuple) {
+ gensym(&id, 't', sratom->next_id++);
+ start_object(sratom, flags, subject, predicate, &id, type);
SerdNode p = serd_node_from_string(SERD_URI, NS_RDF "value");
flags |= SERD_LIST_O_BEGIN;
LV2_TUPLE_BODY_FOREACH(body, size, i) {
- list_append(seriatom, &flags, &id, &p, &node,
+ list_append(sratom, &flags, &id, &p, &node,
i->type, i->size, LV2_ATOM_BODY(i));
}
- list_end(seriatom->writer, unmap, &flags, &id, &p);
- serd_writer_end_anon(seriatom->writer, &id);
- } else if (type_urid == seriatom->forge.Vector) {
+ list_end(sratom->writer, unmap, &flags, &id, &p);
+ serd_writer_end_anon(sratom->writer, &id);
+ } else if (type_urid == sratom->forge.Vector) {
const LV2_Atom_Vector_Body* vec = (const LV2_Atom_Vector_Body*)body;
- gensym(&id, 'v', seriatom->next_id++);
- start_object(seriatom, flags, subject, predicate, &id, type);
+ gensym(&id, 'v', sratom->next_id++);
+ start_object(sratom, flags, subject, predicate, &id, type);
SerdNode p = serd_node_from_string(SERD_URI, NS_RDF "value");
const uint32_t content_size = size - sizeof(LV2_Atom_Vector_Body);
const uint32_t elem_size = content_size / vec->elem_count;
@@ -268,47 +268,47 @@ atom_body_to_rdf(Seriatom* seriatom,
for (char* i = (char*)(vec + 1);
i < (char*)vec + size;
i += elem_size) {
- list_append(seriatom, &flags, &id, &p, &node,
+ list_append(sratom, &flags, &id, &p, &node,
vec->elem_type, elem_size, i);
}
- list_end(seriatom->writer, unmap, &flags, &id, &p);
- serd_writer_end_anon(seriatom->writer, &id);
- } else if (type_urid == seriatom->forge.Blank) {
+ list_end(sratom->writer, unmap, &flags, &id, &p);
+ serd_writer_end_anon(sratom->writer, &id);
+ } else if (type_urid == sratom->forge.Blank) {
const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*)body;
const char* otype = unmap->unmap(unmap->handle, obj->otype);
- gensym(&id, 'b', seriatom->next_id++);
- start_object(seriatom, flags, subject, predicate, &id, otype);
+ gensym(&id, 'b', sratom->next_id++);
+ start_object(sratom, flags, subject, predicate, &id, otype);
LV2_OBJECT_BODY_FOREACH(obj, size, i) {
const LV2_Atom_Property_Body* prop = lv2_object_iter_get(i);
const char* const key = unmap->unmap(unmap->handle, prop->key);
SerdNode pred = serd_node_from_string(SERD_URI, USTR(key));
- atom_body_to_rdf(seriatom, &id, &pred,
+ atom_body_to_rdf(sratom, &id, &pred,
prop->value.type, prop->value.size,
LV2_ATOM_BODY(&prop->value),
flags|SERD_ANON_CONT);
}
- serd_writer_end_anon(seriatom->writer, &id);
- } else if (type_urid == seriatom->forge.Sequence) {
+ serd_writer_end_anon(sratom->writer, &id);
+ } else if (type_urid == sratom->forge.Sequence) {
const LV2_Atom_Sequence_Body* seq = (const LV2_Atom_Sequence_Body*)body;
- gensym(&id, 'v', seriatom->next_id++);
- start_object(seriatom, flags, subject, predicate, &id, type);
+ gensym(&id, 'v', sratom->next_id++);
+ start_object(sratom, flags, subject, predicate, &id, type);
SerdNode p = serd_node_from_string(SERD_URI, NS_RDF "value");
flags |= SERD_LIST_O_BEGIN;
LV2_SEQUENCE_BODY_FOREACH(seq, size, i) {
LV2_Atom_Event* ev = lv2_sequence_iter_get(i);
- list_append(seriatom, &flags, &id, &p, &node,
- seriatom->atom_Event,
+ list_append(sratom, &flags, &id, &p, &node,
+ sratom->atom_Event,
sizeof(LV2_Atom_Event) + ev->body.size,
ev);
}
- list_end(seriatom->writer, unmap, &flags, &id, &p);
- serd_writer_end_anon(seriatom->writer, &id);
+ list_end(sratom->writer, unmap, &flags, &id, &p);
+ serd_writer_end_anon(sratom->writer, &id);
} else {
object = serd_node_from_string(SERD_LITERAL, USTR("(unknown)"));
}
if (object.buf) {
- serd_writer_write_statement(seriatom->writer, flags, NULL,
+ serd_writer_write_statement(sratom->writer, flags, NULL,
subject, predicate, &object,
&datatype, &language);
}
@@ -318,22 +318,22 @@ atom_body_to_rdf(Seriatom* seriatom,
}
}
-SERIATOM_API
+SRATOM_API
void
-atom_to_rdf(Seriatom* seriatom,
+atom_to_rdf(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
const LV2_Atom* atom,
uint32_t flags)
{
- atom_body_to_rdf(seriatom, subject, predicate,
+ atom_body_to_rdf(sratom, subject, predicate,
atom->type, atom->size, LV2_ATOM_BODY(atom),
flags);
}
-SERIATOM_API
+SRATOM_API
char*
-atom_to_turtle(Seriatom* seriatom,
+atom_to_turtle(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
const LV2_Atom* atom)
@@ -350,16 +350,16 @@ atom_to_turtle(Seriatom* seriatom,
serd_env_set_prefix_from_strings(env, USTR("eg"),
USTR("http://example.org/"));
- seriatom->writer = serd_writer_new(
+ sratom->writer = serd_writer_new(
SERD_TURTLE,
SERD_STYLE_ABBREVIATED|SERD_STYLE_RESOLVED|SERD_STYLE_CURIED,
env, &base_uri, string_sink, &str);
- atom_to_rdf(seriatom, subject, predicate, atom, 0);
- serd_writer_finish(seriatom->writer);
+ atom_to_rdf(sratom, subject, predicate, atom, 0);
+ serd_writer_finish(sratom->writer);
string_sink("", 1, &str);
- serd_writer_free(seriatom->writer);
+ serd_writer_free(sratom->writer);
serd_env_free(env);
free(str.buf);
return str.buf;
diff --git a/tests/sratom_test.c b/tests/sratom_test.c
index 67da65d..8f21c18 100644
--- a/tests/sratom_test.c
+++ b/tests/sratom_test.c
@@ -20,9 +20,10 @@
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "seriatom/seriatom.h"
+#include "sratom/sratom.h"
-#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_MIDI "http://lv2plug.in/ns/ext/midi#"
#define USTR(s) ((const uint8_t*)(s))
@@ -81,7 +82,7 @@ main()
LV2_Atom_Forge forge;
lv2_atom_forge_init(&forge, &map);
- Seriatom* seriatom = seriatom_new(&unmap);
+ Sratom* sratom = sratom_new(&map, &unmap);
LV2_URID eg_Object = urid_map(NULL, "http://example.org/Object");
LV2_URID eg_one = urid_map(NULL, "http://example.org/one");
@@ -111,43 +112,43 @@ main()
// eg_one = (Int32)1
lv2_atom_forge_property_head(&forge, eg_one, 0);
LV2_Atom_Int32* one = lv2_atom_forge_int32(&forge, 1);
- if (one->value != 1) {
- return test_fail("%d != 1\n", one->value);
+ if (one->body != 1) {
+ return test_fail("%d != 1\n", one->body);
}
// eg_two = (Int64)2
lv2_atom_forge_property_head(&forge, eg_two, 0);
LV2_Atom_Int64* two = lv2_atom_forge_int64(&forge, 2);
- if (two->value != 2) {
- return test_fail("%ld != 2\n", two->value);
+ if (two->body != 2) {
+ return test_fail("%ld != 2\n", two->body);
}
// eg_three = (Float)3.0
lv2_atom_forge_property_head(&forge, eg_three, 0);
LV2_Atom_Float* three = lv2_atom_forge_float(&forge, 3.0f);
- if (three->value != 3) {
- return test_fail("%f != 3\n", three->value);
+ if (three->body != 3) {
+ return test_fail("%f != 3\n", three->body);
}
// eg_four = (Double)4.0
lv2_atom_forge_property_head(&forge, eg_four, 0);
LV2_Atom_Double* four = lv2_atom_forge_double(&forge, 4.0);
- if (four->value != 4) {
- return test_fail("%ld != 4\n", four->value);
+ if (four->body != 4) {
+ return test_fail("%ld != 4\n", four->body);
}
// eg_true = (Bool)1
lv2_atom_forge_property_head(&forge, eg_true, 0);
LV2_Atom_Bool* t = lv2_atom_forge_bool(&forge, true);
- if (t->value != 1) {
- return test_fail("%ld != 1 (true)\n", t->value);
+ if (t->body != 1) {
+ return test_fail("%ld != 1 (true)\n", t->body);
}
// eg_false = (Bool)0
lv2_atom_forge_property_head(&forge, eg_false, 0);
LV2_Atom_Bool* f = lv2_atom_forge_bool(&forge, false);
- if (f->value != 0) {
- return test_fail("%ld != 0 (false)\n", f->value);
+ if (f->body != 0) {
+ return test_fail("%ld != 0 (false)\n", f->body);
}
// eg_path = (Path)"/foo/bar"
@@ -176,8 +177,8 @@ main()
LV2_URID eg_value = urid_map(NULL, "http://example.org/value");
lv2_atom_forge_property_head(&forge, eg_urid, 0);
LV2_Atom_URID* urid = lv2_atom_forge_urid(&forge, eg_value);
- if (urid->id != eg_value) {
- return test_fail("%u != %u\n", urid->id, eg_value);
+ if (urid->body != eg_value) {
+ return test_fail("%u != %u\n", urid->body, eg_value);
}
// eg_string = (String)"hello"
@@ -256,22 +257,35 @@ main()
}
// eg_seq = (Sequence)1, 2
+ LV2_URID midi_midiEvent = map.map(map.handle, NS_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);
- lv2_atom_forge_audio_time(&forge, 0, 0);
- lv2_atom_forge_int32(&forge, 1);
- lv2_atom_forge_audio_time(&forge, 1, 0);
- lv2_atom_forge_int32(&forge, 2);
- lv2_atom_forge_pop(&forge, &seq_frame);
+
+ const uint8_t ev1[3] = { 0x90, 0x1A, 0x1 };
+ lv2_atom_forge_frame_time(&forge, 1);
+ lv2_atom_forge_atom(&forge, midi_midiEvent, sizeof(ev1));
+ lv2_atom_forge_raw(&forge, ev1, sizeof(ev1));
+ lv2_atom_forge_pad(&forge, sizeof(ev1));
+
+ const uint8_t ev2[3] = { 0x90, 0x2B, 0x2 };
+ lv2_atom_forge_frame_time(&forge, 3);
+ lv2_atom_forge_atom(&forge, midi_midiEvent, sizeof(ev2));
+ lv2_atom_forge_raw(&forge, ev2, sizeof(ev2));
+ lv2_atom_forge_pad(&forge, sizeof(ev2));
+ lv2_atom_forge_pop(&forge, &seq_frame);
lv2_atom_forge_pop(&forge, &obj_frame);
SerdNode s = serd_node_from_string(SERD_BLANK, USTR("obj"));
SerdNode p = serd_node_from_string(SERD_URI, USTR(NS_RDF "value"));
- printf("%s", atom_to_turtle(seriatom, &s, &p, obj));
+ printf("%s", atom_to_turtle(sratom, &s, &p, obj));
printf("All tests passed.\n");
- seriatom_free(seriatom);
+ sratom_free(sratom);
+ for (uint32_t i = 0; i < n_uris; ++i) {
+ free(uris[i]);
+ }
+ free(uris);
return 0;
}
diff --git a/wscript b/wscript
index 15bbd2a..12ba8b5 100644
--- a/wscript
+++ b/wscript
@@ -9,19 +9,19 @@ from waflib.extras import autowaf as autowaf
import waflib.Logs as Logs, waflib.Options as Options
# Version of this package (even if built as a child)
-SERIATOM_VERSION = '0.0.0'
-SERIATOM_MAJOR_VERSION = '0'
+SRATOM_VERSION = '0.0.0'
+SRATOM_MAJOR_VERSION = '0'
# Library version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-# Seriatom uses the same version number for both library and package
-SERIATOM_LIB_VERSION = SERIATOM_VERSION
+# Sratom uses the same version number for both library and package
+SRATOM_LIB_VERSION = SRATOM_VERSION
# Variables for 'waf dist'
-APPNAME = 'seriatom'
-VERSION = SERIATOM_VERSION
+APPNAME = 'sratom'
+VERSION = SRATOM_VERSION
# Mandatory variables
top = '.'
@@ -38,7 +38,7 @@ def options(opt):
def configure(conf):
conf.load('compiler_c')
autowaf.configure(conf)
- autowaf.display_header('Seriatom Configuration')
+ autowaf.display_header('Sratom Configuration')
if conf.env['MSVC_COMPILER']:
conf.env.append_unique('CFLAGS', ['-TP', '-MD'])
@@ -57,8 +57,8 @@ def configure(conf):
autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
atleast_version='0.10.0', mandatory=True)
- autowaf.define(conf, 'SERIATOM_VERSION', SERIATOM_VERSION)
- conf.write_config_header('seriatom_config.h', remove=False)
+ autowaf.define(conf, 'SRATOM_VERSION', SRATOM_VERSION)
+ conf.write_config_header('sratom_config.h', remove=False)
autowaf.display_msg(conf, "Unit tests", str(conf.env['BUILD_TESTS']))
print('')
@@ -69,13 +69,13 @@ lib_source = [
def build(bld):
# C Headers
- includedir = '${INCLUDEDIR}/seriatom-%s/seriatom' % SERIATOM_MAJOR_VERSION
- bld.install_files(includedir, bld.path.ant_glob('seriatom/*.h'))
+ includedir = '${INCLUDEDIR}/sratom-%s/sratom' % SRATOM_MAJOR_VERSION
+ bld.install_files(includedir, bld.path.ant_glob('sratom/*.h'))
# Pkgconfig file
- autowaf.build_pc(bld, 'SERIATOM', SERIATOM_VERSION, SERIATOM_MAJOR_VERSION,
+ autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION,
'SERD',
- {'SERIATOM_MAJOR_VERSION' : SERIATOM_MAJOR_VERSION})
+ {'SRATOM_MAJOR_VERSION' : SRATOM_MAJOR_VERSION})
libflags = [ '-fvisibility=hidden' ]
libs = [ 'm' ]
@@ -89,12 +89,12 @@ def build(bld):
source = lib_source,
includes = ['.', './src'],
lib = libs,
- name = 'libseriatom',
- target = 'seriatom-%s' % SERIATOM_MAJOR_VERSION,
- vnum = SERIATOM_LIB_VERSION,
+ name = 'libsratom',
+ target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
+ vnum = SRATOM_LIB_VERSION,
install_path = '${LIBDIR}',
- cflags = libflags + [ '-DSERIATOM_SHARED',
- '-DSERIATOM_INTERNAL' ])
+ cflags = libflags + [ '-DSRATOM_SHARED',
+ '-DSRATOM_INTERNAL' ])
autowaf.use_lib(bld, obj, 'SERD')
# Static library
@@ -104,11 +104,11 @@ def build(bld):
source = lib_source,
includes = ['.', './src'],
lib = libs,
- name = 'libseriatom_static',
- target = 'seriatom-%s' % SERIATOM_MAJOR_VERSION,
- vnum = SERIATOM_LIB_VERSION,
+ name = 'libsratom_static',
+ target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
+ vnum = SRATOM_LIB_VERSION,
install_path = '${LIBDIR}',
- cflags = ['-DSERIATOM_INTERNAL'])
+ cflags = ['-DSRATOM_INTERNAL'])
autowaf.use_lib(bld, obj, 'SERD')
if bld.env['BUILD_TESTS']:
@@ -123,24 +123,24 @@ def build(bld):
source = lib_source,
includes = ['.', './src'],
lib = test_libs,
- name = 'libseriatom_profiled',
- target = 'seriatom_profiled',
+ name = 'libsratom_profiled',
+ target = 'sratom_profiled',
install_path = '',
- cflags = test_cflags + ['-DSERIATOM_INTERNAL'])
+ cflags = test_cflags + ['-DSRATOM_INTERNAL'])
autowaf.use_lib(bld, obj, 'SERD')
# Unit test program
obj = bld(features = 'c cprogram',
- source = 'tests/seriatom_test.c',
+ source = 'tests/sratom_test.c',
includes = ['.', './src'],
- use = 'libseriatom_profiled',
+ use = 'libsratom_profiled',
lib = test_libs,
- target = 'seriatom_test',
+ target = 'sratom_test',
install_path = '',
cflags = test_cflags)
# Documentation
- autowaf.build_dox(bld, 'SERIATOM', SERIATOM_VERSION, top, out)
+ autowaf.build_dox(bld, 'SRATOM', SRATOM_VERSION, top, out)
bld.add_post_fun(autowaf.run_ldconfig)
if bld.env['DOCS']:
@@ -149,11 +149,11 @@ def build(bld):
def test(ctx):
autowaf.pre_test(ctx, APPNAME)
os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH')
- autowaf.run_tests(ctx, APPNAME, ['seriatom_test'], dirs=['./src','./tests'])
+ autowaf.run_tests(ctx, APPNAME, ['sratom_test'], dirs=['./src','./tests'])
autowaf.post_test(ctx, APPNAME)
def lint(ctx):
- subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* seriatom/*', shell=True)
+ subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* sratom/*', shell=True)
def build_dir(ctx, subdir):
if autowaf.is_child():
@@ -165,17 +165,17 @@ def fix_docs(ctx):
try:
top = os.getcwd()
os.chdir(build_dir(ctx, 'doc/html'))
- os.system("sed -i 's/SERIATOM_API //' group__seriatom.html")
- os.system("sed -i 's/SERIATOM_DEPRECATED //' group__seriatom.html")
+ os.system("sed -i 's/SRATOM_API //' group__sratom.html")
+ os.system("sed -i 's/SRATOM_DEPRECATED //' group__sratom.html")
os.remove('index.html')
- os.symlink('group__seriatom.html',
+ os.symlink('group__sratom.html',
'index.html')
os.chdir(top)
os.chdir(build_dir(ctx, 'doc/man/man3'))
- os.system("sed -i 's/SERIATOM_API //' seriatom.3")
+ os.system("sed -i 's/SRATOM_API //' sratom.3")
os.chdir(top)
except:
Logs.error("Failed to fix up %s documentation" % APPNAME)
def upload_docs(ctx):
- os.system("rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/seriatom/")
+ os.system("rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/sratom/")