summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-23 04:17:01 +0000
committerDavid Robillard <d@drobilla.net>2012-02-23 04:17:01 +0000
commit55ff753b52b08a3ee987376faa528c93e7a84184 (patch)
tree82db75bf367c1dd70ca80c7bb60741474c75c0c0
parent9423949cfe2975a5ed13c514c623127325919070 (diff)
downloadsratom-55ff753b52b08a3ee987376faa528c93e7a84184.tar.gz
sratom-55ff753b52b08a3ee987376faa528c93e7a84184.tar.bz2
sratom-55ff753b52b08a3ee987376faa528c93e7a84184.zip
Clean up API.
git-svn-id: http://svn.drobilla.net/lad/trunk/sratom@3997 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--sratom/sratom.h36
-rw-r--r--src/atom_to_rdf.c74
-rw-r--r--tests/sratom_test.c3
-rw-r--r--wscript3
4 files changed, 43 insertions, 73 deletions
diff --git a/sratom/sratom.h b/sratom/sratom.h
index d063d8c..68d1390 100644
--- a/sratom/sratom.h
+++ b/sratom/sratom.h
@@ -23,7 +23,6 @@
#include <stdint.h>
-#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "serd/serd.h"
@@ -75,39 +74,30 @@ void
sratom_free(Sratom* sratom);
/**
- Serialise an Atom to a SerdWriter.
+ Write an Atom to RDF.
*/
SRATOM_API
void
-atom_to_rdf(Sratom* sratom,
- const SerdNode* subject,
- const SerdNode* predicate,
- const LV2_Atom* atom,
- uint32_t flags);
+sratom_write(Sratom* sratom,
+ uint32_t flags,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ uint32_t type_urid,
+ uint32_t size,
+ const void* body);
/**
- Serialise an Atom body to a SerdWriter.
+ Serialise an Atom to a Turtle string.
+ The returned string must be free()'d by the caller.
*/
SRATOM_API
-void
-atom_body_to_rdf(Sratom* sratom,
+char*
+sratom_to_turtle(Sratom* sratom,
const SerdNode* subject,
const SerdNode* predicate,
uint32_t type_urid,
uint32_t size,
- const void* body,
- uint32_t flags);
-
-/**
- Serialise an Atom to a Turtle string.
- The returned string must be free()'d by the caller.
-*/
-SRATOM_API
-char*
-atom_to_turtle(Sratom* sratom,
- const SerdNode* subject,
- const SerdNode* predicate,
- const LV2_Atom* atom);
+ const void* body);
/**
@}
diff --git a/src/atom_to_rdf.c b/src/atom_to_rdf.c
index b44a908..045273e 100644
--- a/src/atom_to_rdf.c
+++ b/src/atom_to_rdf.c
@@ -42,7 +42,7 @@ struct SratomImpl {
SRATOM_API
Sratom*
sratom_new(LV2_URID_Map* map,
- LV2_URID_Unmap* unmap)
+ LV2_URID_Unmap* unmap)
{
Sratom* sratom = (Sratom*)malloc(sizeof(Sratom));
sratom->writer = NULL;
@@ -85,7 +85,7 @@ gensym(SerdNode* out, char c, unsigned num)
}
static void
-list_append(Sratom* sratom,
+list_append(Sratom* sratom,
unsigned* flags,
SerdNode* s,
SerdNode* p,
@@ -102,7 +102,7 @@ list_append(Sratom* sratom,
// _:node rdf:first value
*flags = SERD_LIST_CONT;
*p = serd_node_from_string(SERD_URI, NS_RDF "first");
- atom_body_to_rdf(sratom, node, p, type, size, body, SERD_LIST_CONT);
+ sratom_write(sratom, SERD_LIST_CONT, node, p, type, size, body);
// Set subject to node and predicate to rdf:rest for next time
gensym(node, 'l', ++sratom->next_id);
@@ -111,12 +111,7 @@ list_append(Sratom* sratom,
}
static void
-list_end(SerdWriter* writer,
- LV2_URID_Unmap* unmap,
- unsigned* flags,
- SerdNode* s,
- SerdNode* p)
-
+list_end(SerdWriter* writer, unsigned* flags, SerdNode* s, SerdNode* p)
{
// _:node rdf:rest rdf:nil
const SerdNode nil = serd_node_from_string(SERD_URI, NS_RDF "nil");
@@ -125,7 +120,7 @@ list_end(SerdWriter* writer,
}
static void
-start_object(Sratom* sratom,
+start_object(Sratom* sratom,
uint32_t flags,
const SerdNode* subject,
const SerdNode* predicate,
@@ -146,13 +141,13 @@ start_object(Sratom* sratom,
SRATOM_API
void
-atom_body_to_rdf(Sratom* sratom,
- const SerdNode* subject,
- const SerdNode* predicate,
- uint32_t type_urid,
- uint32_t size,
- const void* body,
- uint32_t flags)
+sratom_write(Sratom* sratom,
+ uint32_t flags,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ uint32_t type_urid,
+ uint32_t size,
+ const void* body)
{
LV2_URID_Unmap* unmap = sratom->unmap;
const char* const type = unmap->unmap(unmap->handle, type_urid);
@@ -241,10 +236,9 @@ atom_body_to_rdf(Sratom* sratom,
serd_node_free(&time);
p = serd_node_from_string(SERD_URI, NS_RDF "value");
- atom_body_to_rdf(sratom, &id, &p,
- ev->body.type, ev->body.size,
- LV2_ATOM_BODY(&ev->body),
- SERD_ANON_CONT);
+ sratom_write(sratom, SERD_ANON_CONT, &id, &p,
+ ev->body.type, ev->body.size,
+ LV2_ATOM_BODY(&ev->body));
serd_writer_end_anon(sratom->writer, &id);
} else if (type_urid == sratom->forge.Tuple) {
gensym(&id, 't', sratom->next_id++);
@@ -255,7 +249,7 @@ atom_body_to_rdf(Sratom* sratom,
list_append(sratom, &flags, &id, &p, &node,
i->type, i->size, LV2_ATOM_BODY(i));
}
- list_end(sratom->writer, unmap, &flags, &id, &p);
+ list_end(sratom->writer, &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;
@@ -271,7 +265,7 @@ atom_body_to_rdf(Sratom* sratom,
list_append(sratom, &flags, &id, &p, &node,
vec->elem_type, elem_size, i);
}
- list_end(sratom->writer, unmap, &flags, &id, &p);
+ list_end(sratom->writer, &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;
@@ -282,10 +276,9 @@ atom_body_to_rdf(Sratom* sratom,
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(sratom, &id, &pred,
- prop->value.type, prop->value.size,
- LV2_ATOM_BODY(&prop->value),
- flags|SERD_ANON_CONT);
+ sratom_write(sratom, flags|SERD_ANON_CONT, &id, &pred,
+ prop->value.type, prop->value.size,
+ LV2_ATOM_BODY(&prop->value));
}
serd_writer_end_anon(sratom->writer, &id);
} else if (type_urid == sratom->forge.Sequence) {
@@ -301,7 +294,7 @@ atom_body_to_rdf(Sratom* sratom,
sizeof(LV2_Atom_Event) + ev->body.size,
ev);
}
- list_end(sratom->writer, unmap, &flags, &id, &p);
+ list_end(sratom->writer, &flags, &id, &p);
serd_writer_end_anon(sratom->writer, &id);
} else {
object = serd_node_from_string(SERD_LITERAL, USTR("(unknown)"));
@@ -319,24 +312,13 @@ atom_body_to_rdf(Sratom* sratom,
}
SRATOM_API
-void
-atom_to_rdf(Sratom* sratom,
- const SerdNode* subject,
- const SerdNode* predicate,
- const LV2_Atom* atom,
- uint32_t flags)
-{
- atom_body_to_rdf(sratom, subject, predicate,
- atom->type, atom->size, LV2_ATOM_BODY(atom),
- flags);
-}
-
-SRATOM_API
char*
-atom_to_turtle(Sratom* sratom,
- const SerdNode* subject,
- const SerdNode* predicate,
- const LV2_Atom* atom)
+sratom_to_turtle(Sratom* sratom,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ uint32_t type,
+ uint32_t size,
+ const void* body)
{
SerdURI base_uri = SERD_URI_NULL;
SerdEnv* env = serd_env_new(NULL);
@@ -355,7 +337,7 @@ atom_to_turtle(Sratom* sratom,
SERD_STYLE_ABBREVIATED|SERD_STYLE_RESOLVED|SERD_STYLE_CURIED,
env, &base_uri, string_sink, &str);
- atom_to_rdf(sratom, subject, predicate, atom, 0);
+ sratom_write(sratom, 0, subject, predicate, type, size, body);
serd_writer_finish(sratom->writer);
string_sink("", 1, &str);
diff --git a/tests/sratom_test.c b/tests/sratom_test.c
index 8f21c18..253d52c 100644
--- a/tests/sratom_test.c
+++ b/tests/sratom_test.c
@@ -279,7 +279,8 @@ main()
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(sratom, &s, &p, obj));
+ printf("%s", sratom_to_turtle(sratom, &s, &p,
+ obj->type, obj->size, LV2_ATOM_BODY(obj)));
printf("All tests passed.\n");
sratom_free(sratom);
diff --git a/wscript b/wscript
index 12ba8b5..41bad53 100644
--- a/wscript
+++ b/wscript
@@ -171,9 +171,6 @@ def fix_docs(ctx):
os.symlink('group__sratom.html',
'index.html')
os.chdir(top)
- os.chdir(build_dir(ctx, 'doc/man/man3'))
- os.system("sed -i 's/SRATOM_API //' sratom.3")
- os.chdir(top)
except:
Logs.error("Failed to fix up %s documentation" % APPNAME)