diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | src/sratom.c | 21 | ||||
-rw-r--r-- | tests/sratom_test.c | 41 | ||||
-rw-r--r-- | wscript | 4 |
4 files changed, 41 insertions, 30 deletions
@@ -1,10 +1,11 @@ -sratom (0.4.9) unstable; +sratom (0.4.10) unstable; + * Support round-trip serialisation of relative paths * Support sequences with beat time stamps * Fix warnings when building with ISO C++ compilers * Upgrade to waf 1.8.14 - -- David Robillard <d@drobilla.net> Tue, 15 Mar 2016 17:57:49 -0400 + -- David Robillard <d@drobilla.net> Sun, 10 Jul 2016 18:57:29 -0400 sratom (0.4.6) stable; diff --git a/src/sratom.c b/src/sratom.c index 22f578d..f5beea4 100644 --- a/src/sratom.c +++ b/src/sratom.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2014 David Robillard <http://drobilla.net> + Copyright 2012-2016 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -46,6 +46,7 @@ struct SratomImpl { LV2_URID midi_MidiEvent; unsigned next_id; SerdNode base_uri; + SerdURI base; SerdStatementSink write_statement; SerdEndSink end_anon; void* handle; @@ -84,6 +85,7 @@ sratom_new(LV2_URID_Map* map) sratom->midi_MidiEvent = map->map(map->handle, LV2_MIDI__MidiEvent); sratom->next_id = 0; sratom->base_uri = SERD_NODE_NULL; + sratom->base = SERD_URI_NULL; sratom->object_mode = SRATOM_OBJECT_MODE_BLANK; sratom->pretty_numbers = false; memset(&sratom->nodes, 0, sizeof(sratom->nodes)); @@ -111,6 +113,7 @@ sratom_set_sink(Sratom* sratom, serd_node_free(&sratom->base_uri); sratom->base_uri = serd_node_new_uri_from_string( USTR(base_uri), NULL, NULL); + serd_uri_parse(sratom->base_uri.buf, &sratom->base); } sratom->write_statement = write_statement; sratom->end_anon = end_anon; @@ -284,7 +287,6 @@ sratom_write(Sratom* sratom, new_node = true; object = serd_node_new_file_uri(str, NULL, NULL, true); } else { - SerdURI base_uri = SERD_URI_NULL; if (!sratom->base_uri.buf || strncmp((const char*)sratom->base_uri.buf, "file://", 7)) { fprintf(stderr, "warning: Relative path but base is not a file URI.\n"); @@ -292,12 +294,9 @@ sratom_write(Sratom* sratom, object = serd_node_from_string(SERD_LITERAL, str); datatype = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__Path)); } else { - if (sratom->base_uri.buf) { - serd_uri_parse(sratom->base_uri.buf, &base_uri); - } new_node = true; SerdNode rel = serd_node_new_file_uri(str, NULL, NULL, true); - object = serd_node_new_uri_from_node(&rel, &base_uri, NULL); + object = serd_node_new_uri_from_node(&rel, &sratom->base, NULL); serd_node_free(&rel); } } @@ -478,7 +477,7 @@ sratom_to_turtle(Sratom* sratom, const void* body) { SerdURI buri = SERD_URI_NULL; - SerdNode base = serd_node_new_uri_from_string(USTR(base_uri), NULL, &buri); + SerdNode base = serd_node_new_uri_from_string(USTR(base_uri), &sratom->base, &buri); SerdEnv* env = serd_env_new(&base); SerdChunk str = { NULL, 0 }; @@ -649,7 +648,11 @@ read_node(Sratom* sratom, if (!strcmp(str, (const char*)NS_RDF "nil")) { lv2_atom_forge_atom(forge, 0, 0); } else if (!strncmp(str, "file://", 7)) { - uint8_t* path = serd_file_uri_parse((const uint8_t*)str, NULL); + SerdURI uri; + serd_uri_parse((const uint8_t*)str, &uri); + + SerdNode rel = serd_node_new_relative_uri(&uri, &sratom->base, NULL, NULL); + uint8_t* path = serd_file_uri_parse(rel.buf, NULL); lv2_atom_forge_path(forge, (const char*)path, strlen((const char*)path)); free(path); } else { @@ -794,7 +797,7 @@ sratom_from_turtle(Sratom* sratom, const char* str) { SerdChunk out = { NULL, 0 }; - SerdNode base = serd_node_new_uri_from_string(USTR(base_uri), NULL, NULL); + SerdNode base = serd_node_new_uri_from_string(USTR(base_uri), &sratom->base, NULL); SordWorld* world = sord_world_new(); SordModel* model = sord_new(world, SORD_SPO, false); SerdEnv* env = serd_env_new(&base); diff --git a/tests/sratom_test.c b/tests/sratom_test.c index 601e9e8..012b901 100644 --- a/tests/sratom_test.c +++ b/tests/sratom_test.c @@ -98,23 +98,24 @@ test(bool top_level, bool pretty_numbers) LV2_URID eg_false = urid_map(NULL, "http://example.org/f-false"); LV2_URID eg_path = urid_map(NULL, "http://example.org/g-path"); LV2_URID eg_winpath = urid_map(NULL, "http://example.org/h-winpath"); - LV2_URID eg_urid = urid_map(NULL, "http://example.org/i-urid"); - LV2_URID eg_string = urid_map(NULL, "http://example.org/j-string"); - LV2_URID eg_langlit = urid_map(NULL, "http://example.org/k-langlit"); - LV2_URID eg_typelit = urid_map(NULL, "http://example.org/l-typelit"); - LV2_URID eg_null = urid_map(NULL, "http://example.org/m-null"); - LV2_URID eg_chunk = urid_map(NULL, "http://example.org/n-chunk"); - LV2_URID eg_blob = urid_map(NULL, "http://example.org/o-blob"); - LV2_URID eg_blank = urid_map(NULL, "http://example.org/p-blank"); - LV2_URID eg_tuple = urid_map(NULL, "http://example.org/q-tuple"); - LV2_URID eg_rectup = urid_map(NULL, "http://example.org/r-rectup"); - LV2_URID eg_ivector = urid_map(NULL, "http://example.org/s-ivector"); - LV2_URID eg_lvector = urid_map(NULL, "http://example.org/t-lvector"); - LV2_URID eg_fvector = urid_map(NULL, "http://example.org/u-fvector"); - LV2_URID eg_dvector = urid_map(NULL, "http://example.org/v-dvector"); - LV2_URID eg_bvector = urid_map(NULL, "http://example.org/w-bvector"); - LV2_URID eg_fseq = urid_map(NULL, "http://example.org/x-fseq"); - LV2_URID eg_bseq = urid_map(NULL, "http://example.org/y-bseq"); + LV2_URID eg_relpath = urid_map(NULL, "http://example.org/i-relpath"); + LV2_URID eg_urid = urid_map(NULL, "http://example.org/j-urid"); + LV2_URID eg_string = urid_map(NULL, "http://example.org/k-string"); + LV2_URID eg_langlit = urid_map(NULL, "http://example.org/l-langlit"); + LV2_URID eg_typelit = urid_map(NULL, "http://example.org/m-typelit"); + LV2_URID eg_null = urid_map(NULL, "http://example.org/n-null"); + LV2_URID eg_chunk = urid_map(NULL, "http://example.org/o-chunk"); + LV2_URID eg_blob = urid_map(NULL, "http://example.org/p-blob"); + LV2_URID eg_blank = urid_map(NULL, "http://example.org/q-blank"); + LV2_URID eg_tuple = urid_map(NULL, "http://example.org/r-tuple"); + LV2_URID eg_rectup = urid_map(NULL, "http://example.org/s-rectup"); + LV2_URID eg_ivector = urid_map(NULL, "http://example.org/t-ivector"); + LV2_URID eg_lvector = urid_map(NULL, "http://example.org/u-lvector"); + LV2_URID eg_fvector = urid_map(NULL, "http://example.org/v-fvector"); + LV2_URID eg_dvector = urid_map(NULL, "http://example.org/w-dvector"); + LV2_URID eg_bvector = urid_map(NULL, "http://example.org/x-bvector"); + LV2_URID eg_fseq = urid_map(NULL, "http://example.org/y-fseq"); + LV2_URID eg_bseq = urid_map(NULL, "http://example.org/z-bseq"); uint8_t buf[1024]; lv2_atom_forge_set_buffer(&forge, buf, sizeof(buf)); @@ -165,6 +166,12 @@ test(bool top_level, bool pretty_numbers) lv2_atom_forge_key(&forge, eg_winpath); lv2_atom_forge_path(&forge, wpstr, wpstr_len); + // eg_relpath = (Path)"foo/bar" + const char* rpstr = "foo/bar"; + const size_t rpstr_len = strlen(rpstr); + lv2_atom_forge_key(&forge, eg_relpath); + lv2_atom_forge_path(&forge, rpstr, rpstr_len); + // eg_urid = (URID)"http://example.org/value" LV2_URID eg_value = urid_map(NULL, "http://example.org/value"); lv2_atom_forge_key(&forge, eg_urid); @@ -8,7 +8,7 @@ import waflib.extras.autowaf as autowaf # major increment <=> incompatible changes # minor increment <=> compatible changes (additions) # micro increment <=> no interface changes -SRATOM_VERSION = '0.4.9' +SRATOM_VERSION = '0.4.10' SRATOM_MAJOR_VERSION = '0' # Mandatory waf variables @@ -48,7 +48,7 @@ def configure(conf): autowaf.check_pkg(conf, 'lv2', uselib_store='LV2', atleast_version='1.8.1', mandatory=True) autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', - atleast_version='0.14.0', mandatory=True) + atleast_version='0.23.0', mandatory=True) autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD', atleast_version='0.12.0', mandatory=True) |