summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-10-27 21:48:48 -0400
committerDavid Robillard <d@drobilla.net>2021-10-27 21:48:48 -0400
commit42c4705bbcdf0a638aca6923325ed9a5660bfc26 (patch)
tree85a2f4f19f512e74ea80803c55964c7447dcbde7
parent6f36b5a3fb181f6b9f9b1538d894efe24a0e92c7 (diff)
downloadlilv-42c4705bbcdf0a638aca6923325ed9a5660bfc26.tar.gz
lilv-42c4705bbcdf0a638aca6923325ed9a5660bfc26.tar.bz2
lilv-42c4705bbcdf0a638aca6923325ed9a5660bfc26.zip
fixup! WIP: Port to serd1
-rw-r--r--src/instance.c6
-rw-r--r--src/lib.c10
-rw-r--r--src/node.c23
-rw-r--r--src/plugin.c79
-rw-r--r--src/pluginclass.c6
-rw-r--r--src/port.c10
-rw-r--r--src/query.c8
-rw-r--r--src/state.c193
-rw-r--r--src/world.c80
-rw-r--r--test/bad_syntax.lv2/test_bad_syntax.c5
-rw-r--r--test/failed_instantiation.lv2/test_failed_instantiation.c5
-rw-r--r--test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c5
-rw-r--r--test/lib_descriptor.lv2/test_lib_descriptor.c5
-rw-r--r--test/lilv_test_utils.c6
-rw-r--r--test/missing_descriptor.lv2/test_missing_descriptor.c5
-rw-r--r--test/missing_name.lv2/test_missing_name.c5
-rw-r--r--test/missing_plugin.lv2/test_missing_plugin.c5
-rw-r--r--test/missing_port.lv2/test_missing_port.c6
-rw-r--r--test/missing_port_name.lv2/test_missing_port_name.c5
-rw-r--r--test/test_state.c32
20 files changed, 267 insertions, 232 deletions
diff --git a/src/instance.c b/src/instance.c
index 2c9baa9..f0ad0da 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -44,11 +44,11 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
}
char* const bundle_path =
- serd_parse_file_uri(lilv_node_as_uri(bundle_uri), NULL);
+ serd_parse_file_uri(NULL, lilv_node_as_uri(bundle_uri), NULL);
LilvLib* lib = lilv_lib_open(plugin->world, lib_uri, bundle_path, features);
if (!lib) {
- serd_free(bundle_path);
+ serd_free(NULL, bundle_path);
return NULL;
}
@@ -81,7 +81,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
}
free(local_features);
- serd_free(bundle_path);
+ serd_free(NULL, bundle_path);
if (result) {
if (result->lv2_handle == NULL) {
diff --git a/src/lib.c b/src/lib.c
index 0540488..51c3457 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -44,7 +44,7 @@ lilv_lib_open(LilvWorld* world,
}
const char* const lib_uri = lilv_node_as_uri(uri);
- char* const lib_path = serd_parse_file_uri(lib_uri, NULL);
+ char* const lib_path = serd_parse_file_uri(NULL, lib_uri, NULL);
if (!lib_path) {
return NULL;
}
@@ -53,7 +53,7 @@ lilv_lib_open(LilvWorld* world,
void* lib = dlopen(lib_path, RTLD_NOW);
if (!lib) {
LILV_ERRORF("Failed to open library %s (%s)\n", lib_path, dlerror());
- serd_free(lib_path);
+ serd_free(NULL, lib_path);
return NULL;
}
@@ -69,17 +69,17 @@ lilv_lib_open(LilvWorld* world,
if (!desc) {
LILV_ERRORF("Call to %s:lv2_lib_descriptor failed\n", lib_path);
dlclose(lib);
- serd_free(lib_path);
+ serd_free(NULL, lib_path);
return NULL;
}
} else if (!df) {
LILV_ERRORF("No `lv2_descriptor' or `lv2_lib_descriptor' in %s\n",
lib_path);
dlclose(lib);
- serd_free(lib_path);
+ serd_free(NULL, lib_path);
return NULL;
}
- serd_free(lib_path);
+ serd_free(NULL, lib_path);
LilvLib* llib = (LilvLib*)malloc(sizeof(LilvLib));
llib->world = world;
diff --git a/src/node.c b/src/node.c
index 098298f..0a86d0a 100644
--- a/src/node.c
+++ b/src/node.c
@@ -31,7 +31,7 @@ LilvNode*
lilv_new_uri(LilvWorld* world, const char* uri)
{
(void)world;
- return serd_new_uri(SERD_STRING(uri));
+ return serd_new_uri(NULL, SERD_STRING(uri));
}
LilvNode*
@@ -40,8 +40,10 @@ lilv_new_file_uri(LilvWorld* world, const char* host, const char* path)
(void)world;
char* abs_path = lilv_path_absolute(path);
- SerdNode* s = serd_new_file_uri(
- SERD_STRING(abs_path), host ? SERD_STRING(host) : SERD_EMPTY_STRING());
+ SerdNode* s =
+ serd_new_file_uri(NULL,
+ SERD_STRING(abs_path),
+ host ? SERD_STRING(host) : SERD_EMPTY_STRING());
free(abs_path);
return s;
@@ -52,7 +54,7 @@ lilv_new_string(LilvWorld* world, const char* str)
{
(void)world;
- return serd_new_string(SERD_STRING(str));
+ return serd_new_string(NULL, SERD_STRING(str));
}
LilvNode*
@@ -60,7 +62,8 @@ lilv_new_int(LilvWorld* world, int val)
{
(void)world;
- return serd_new_integer(val, serd_node_string_view(world->uris.xsd_int));
+ return serd_new_integer(
+ NULL, val, serd_node_string_view(world->uris.xsd_int));
}
LilvNode*
@@ -68,7 +71,7 @@ lilv_new_float(LilvWorld* world, float val)
{
(void)world;
- return serd_new_float(val);
+ return serd_new_float(NULL, val);
}
LilvNode*
@@ -76,19 +79,19 @@ lilv_new_bool(LilvWorld* world, bool val)
{
(void)world;
- return serd_new_boolean(val);
+ return serd_new_boolean(NULL, val);
}
LilvNode*
lilv_node_duplicate(const LilvNode* val)
{
- return serd_node_copy(val);
+ return serd_node_copy(NULL, val);
}
void
lilv_node_free(LilvNode* val)
{
- serd_node_free(val);
+ serd_node_free(NULL, val);
}
bool
@@ -224,6 +227,6 @@ char*
lilv_node_get_path(const LilvNode* value, char** hostname)
{
return lilv_node_is_uri(value)
- ? serd_parse_file_uri(lilv_node_as_uri(value), hostname)
+ ? serd_parse_file_uri(NULL, lilv_node_as_uri(value), hostname)
: NULL;
}
diff --git a/src/plugin.c b/src/plugin.c
index 0f36169..9a9906c 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -128,7 +128,7 @@ lilv_plugin_get_one(const LilvPlugin* plugin,
const SerdNode* predicate)
{
return serd_node_copy(
- serd_model_get(plugin->world->model, subject, predicate, NULL, NULL));
+ NULL, serd_model_get(plugin->world->model, subject, predicate, NULL, NULL));
}
LilvNode*
@@ -150,7 +150,9 @@ lilv_plugin_load(LilvPlugin* plugin)
{
SerdNode* bundle_uri_node = plugin->bundle_uri;
- SerdEnv* env = serd_env_new(serd_node_string_view(bundle_uri_node));
+ SerdEnv* env =
+ serd_env_new(plugin->world->world, serd_node_string_view(bundle_uri_node));
+
SerdSink* inserter = serd_inserter_new(plugin->world->model, bundle_uri_node);
SerdReader* reader = serd_reader_new(plugin->world->world,
@@ -160,18 +162,19 @@ lilv_plugin_load(LilvPlugin* plugin)
inserter,
LILV_READER_STACK_SIZE);
- SerdModel* prots = lilv_world_filter_model(plugin->world,
+ SerdModel* prots = lilv_world_filter_model(plugin->world,
plugin->world->model,
plugin->plugin_uri,
plugin->world->uris.lv2_prototype,
NULL,
NULL);
- SerdModel* skel = serd_model_new(plugin->world->world, SERD_ORDER_SPO, 0u);
- SerdCursor* iter = serd_model_begin(prots);
+
+ SerdModel* skel = serd_model_new(plugin->world->world, SERD_ORDER_SPO, 0u);
+ SerdCursor* iter = serd_model_begin(prots);
for (; !serd_cursor_is_end(iter); serd_cursor_advance(iter)) {
const SerdStatement* statement = serd_cursor_get(iter);
const SerdNode* t = serd_statement_object(statement);
- LilvNode* prototype = serd_node_copy(t);
+ LilvNode* prototype = serd_node_copy(NULL, t);
lilv_world_load_resource(plugin->world, prototype);
@@ -326,7 +329,7 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_plugin)
const SerdNode* type = serd_statement_object(t);
if (serd_node_type(type) == SERD_URI) {
zix_tree_insert(
- (ZixTree*)this_port->classes, serd_node_copy(type), NULL);
+ (ZixTree*)this_port->classes, serd_node_copy(NULL, type), NULL);
} else {
LILV_WARNF("Plugin <%s> port type is not a URI\n",
lilv_node_as_uri(plugin->plugin_uri));
@@ -387,7 +390,7 @@ lilv_plugin_get_library_uri(const LilvPlugin* plugin)
FOREACH_MATCH (s, i) {
const SerdNode* binary_node = serd_statement_object(s);
if (serd_node_type(binary_node) == SERD_URI) {
- ((LilvPlugin*)plugin)->binary_uri = serd_node_copy(binary_node);
+ ((LilvPlugin*)plugin)->binary_uri = serd_node_copy(NULL, binary_node);
break;
}
}
@@ -423,7 +426,7 @@ lilv_plugin_get_class(const LilvPlugin* plugin)
continue;
}
- LilvNode* klass = serd_node_copy(class_node);
+ LilvNode* klass = serd_node_copy(NULL, class_node);
if (!lilv_node_equals(klass, plugin->world->lv2_plugin_class->uri)) {
const LilvPluginClass* pclass =
lilv_plugin_classes_get_by_uri(plugin->world->plugin_classes, klass);
@@ -825,7 +828,8 @@ lilv_plugin_get_project(const LilvPlugin* plugin)
{
lilv_plugin_load_if_necessary(plugin);
- return serd_node_copy(serd_model_get(plugin->world->model,
+ return serd_node_copy(NULL,
+ serd_model_get(plugin->world->model,
plugin->plugin_uri,
plugin->world->uris.lv2_project,
NULL,
@@ -837,7 +841,8 @@ lilv_plugin_get_author(const LilvPlugin* plugin)
{
lilv_plugin_load_if_necessary(plugin);
- SerdNode* doap_maintainer = serd_new_uri(SERD_STRING(NS_DOAP "maintainer"));
+ SerdNode* doap_maintainer =
+ serd_new_uri(NULL, SERD_STRING(NS_DOAP "maintainer"));
const SerdNode* maintainer = serd_model_get(
plugin->world->model, plugin->plugin_uri, doap_maintainer, NULL, NULL);
@@ -845,7 +850,7 @@ lilv_plugin_get_author(const LilvPlugin* plugin)
if (!maintainer) {
LilvNode* project = lilv_plugin_get_project(plugin);
if (!project) {
- serd_node_free(doap_maintainer);
+ serd_node_free(NULL, doap_maintainer);
return NULL;
}
@@ -855,9 +860,9 @@ lilv_plugin_get_author(const LilvPlugin* plugin)
lilv_node_free(project);
}
- serd_node_free(doap_maintainer);
+ serd_node_free(NULL, doap_maintainer);
- return maintainer ? serd_node_copy(maintainer) : NULL;
+ return maintainer ? serd_node_copy(NULL, maintainer) : NULL;
}
static LilvNode*
@@ -865,10 +870,10 @@ lilv_plugin_get_author_property(const LilvPlugin* plugin, const char* uri)
{
SerdNode* author = lilv_plugin_get_author(plugin);
if (author) {
- SerdNode* pred = serd_new_uri(SERD_STRING(uri));
+ SerdNode* pred = serd_new_uri(NULL, SERD_STRING(uri));
LilvNode* ret = lilv_plugin_get_one(plugin, author, pred);
- serd_node_free(pred);
- serd_node_free(author);
+ serd_node_free(NULL, pred);
+ serd_node_free(NULL, author);
return ret;
}
return NULL;
@@ -903,8 +908,8 @@ lilv_plugin_get_uis(const LilvPlugin* plugin)
{
lilv_plugin_load_if_necessary(plugin);
- SerdNode* ui_ui_node = serd_new_uri(SERD_STRING(LV2_UI__ui));
- SerdNode* ui_binary_node = serd_new_uri(SERD_STRING(LV2_UI__binary));
+ SerdNode* ui_ui_node = serd_new_uri(NULL, SERD_STRING(LV2_UI__ui));
+ SerdNode* ui_binary_node = serd_new_uri(NULL, SERD_STRING(LV2_UI__binary));
LilvUIs* result = lilv_uis_new();
SerdCursor* uis = serd_model_find(
@@ -930,14 +935,14 @@ lilv_plugin_get_uis(const LilvPlugin* plugin)
}
LilvUI* lilv_ui =
- lilv_ui_new(plugin->world, serd_node_copy(ui), type, binary);
+ lilv_ui_new(plugin->world, serd_node_copy(NULL, ui), type, binary);
zix_tree_insert((ZixTree*)result, lilv_ui, NULL);
}
serd_cursor_free(uis);
- serd_node_free(ui_binary_node);
- serd_node_free(ui_ui_node);
+ serd_node_free(NULL, ui_binary_node);
+ serd_node_free(NULL, ui_ui_node);
if (lilv_uis_size(result) > 0) {
return result;
@@ -964,7 +969,7 @@ lilv_plugin_get_related(const LilvPlugin* plugin, const LilvNode* type)
LILV_FOREACH (nodes, i, related) {
LilvNode* node = (LilvNode*)lilv_collection_get((ZixTree*)related, i);
if (serd_model_ask(world->model, node, world->uris.rdf_a, type, NULL)) {
- zix_tree_insert((ZixTree*)matches, serd_node_copy(node), NULL);
+ zix_tree_insert((ZixTree*)matches, serd_node_copy(NULL, node), NULL);
}
}
@@ -973,9 +978,9 @@ lilv_plugin_get_related(const LilvPlugin* plugin, const LilvNode* type)
}
static SerdEnv*
-new_lv2_env(const SerdNode* base)
+new_lv2_env(const SerdWorld* const world, const SerdNode* base)
{
- SerdEnv* env = serd_env_new(serd_node_string_view(base));
+ SerdEnv* env = serd_env_new(world, serd_node_string_view(base));
serd_env_set_prefix(env, SERD_STRING("doap"), SERD_STRING(NS_DOAP));
serd_env_set_prefix(env, SERD_STRING("foaf"), SERD_STRING(NS_FOAF));
@@ -1008,12 +1013,13 @@ lilv_plugin_write_description(LilvWorld* world,
const LilvNode* subject = lilv_plugin_get_uri(plugin);
const uint32_t num_ports = lilv_plugin_get_num_ports(plugin);
const SerdNode* base = base_uri;
- SerdEnv* env = new_lv2_env(base);
+ SerdEnv* env = new_lv2_env(world->world, base);
- SerdByteSink* const sink =
- serd_byte_sink_new_function((SerdWriteFunc)fwrite, NULL, plugin_file, 1);
+ SerdOutputStream out = serd_open_output_stream(
+ (SerdWriteFunc)fwrite, (SerdErrorFunc)ferror, NULL, plugin_file);
- SerdWriter* writer = serd_writer_new(world->world, SERD_TURTLE, 0, env, sink);
+ SerdWriter* writer =
+ serd_writer_new(world->world, SERD_TURTLE, 0u, env, &out, 1);
const SerdSink* iface = serd_writer_sink(writer);
@@ -1023,14 +1029,14 @@ lilv_plugin_write_description(LilvWorld* world,
// Write plugin description
SerdCursor* plug_range =
serd_model_find(world->model, subject, NULL, NULL, NULL);
- serd_write_range(plug_range, iface, 0);
+ serd_describe_range(plug_range, iface, 0u);
// Write port descriptions
for (uint32_t i = 0; i < num_ports; ++i) {
const LilvPort* port = plugin->ports[i];
SerdCursor* port_range =
serd_model_find(world->model, port->node, NULL, NULL, NULL);
- serd_write_range(port_range, iface, 0);
+ serd_describe_range(port_range, iface, 0u);
}
serd_writer_free(writer);
@@ -1046,12 +1052,13 @@ lilv_plugin_write_manifest_entry(LilvWorld* world,
{
const LilvNode* subject = lilv_plugin_get_uri(plugin);
const SerdNode* base = base_uri;
- SerdEnv* env = new_lv2_env(base);
+ SerdEnv* env = new_lv2_env(world->world, base);
- SerdByteSink* const sink =
- serd_byte_sink_new_function((SerdWriteFunc)fwrite, NULL, manifest_file, 1);
+ SerdOutputStream out = serd_open_output_stream(
+ (SerdWriteFunc)fwrite, (SerdErrorFunc)ferror, NULL, manifest_file);
- SerdWriter* writer = serd_writer_new(world->world, SERD_TURTLE, 0, env, sink);
+ SerdWriter* writer =
+ serd_writer_new(world->world, SERD_TURTLE, 0u, env, &out, 1u);
const SerdSink* iface = serd_writer_sink(writer);
@@ -1066,7 +1073,7 @@ lilv_plugin_write_manifest_entry(LilvWorld* world,
plugin->world->uris.lv2_Plugin,
NULL);
- const SerdNode* file_node = serd_new_uri(SERD_STRING(plugin_file_path));
+ const SerdNode* file_node = serd_new_uri(NULL, SERD_STRING(plugin_file_path));
serd_sink_write(serd_writer_sink(writer),
0,
diff --git a/src/pluginclass.c b/src/pluginclass.c
index 64bbf51..5ec89bc 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -32,9 +32,9 @@ lilv_plugin_class_new(LilvWorld* world,
LilvPluginClass* pc = (LilvPluginClass*)malloc(sizeof(LilvPluginClass));
pc->world = world;
- pc->uri = serd_node_copy(uri);
- pc->label = serd_new_string(SERD_STRING(label));
- pc->parent_uri = (parent_node ? serd_node_copy(parent_node) : NULL);
+ pc->uri = serd_node_copy(NULL, uri);
+ pc->label = serd_new_string(NULL, SERD_STRING(label));
+ pc->parent_uri = (parent_node ? serd_node_copy(NULL, parent_node) : NULL);
return pc;
}
diff --git a/src/port.c b/src/port.c
index 033182e..2734727 100644
--- a/src/port.c
+++ b/src/port.c
@@ -35,9 +35,9 @@ lilv_port_new(const SerdNode* node, uint32_t index, const char* symbol)
{
LilvPort* const port = (LilvPort*)malloc(sizeof(LilvPort));
- port->node = serd_node_copy(node);
+ port->node = serd_node_copy(NULL, node);
port->index = index;
- port->symbol = serd_new_string(SERD_STRING(symbol));
+ port->symbol = serd_new_string(NULL, SERD_STRING(symbol));
port->classes = lilv_nodes_new();
return port;
}
@@ -94,7 +94,7 @@ lilv_port_supports_event(const LilvPlugin* plugin,
for (const char** pred = predicates; *pred; ++pred) {
if (serd_model_ask(plugin->world->model,
port->node,
- serd_new_uri(SERD_STRING(*pred)),
+ serd_new_uri(NULL, SERD_STRING(*pred)),
event_type,
NULL)) {
return true;
@@ -232,7 +232,7 @@ lilv_port_get_scale_points(const LilvPlugin* plugin, const LilvPort* port)
SerdCursor* points =
serd_model_find(plugin->world->model,
port->node,
- serd_new_uri(SERD_STRING(LV2_CORE__scalePoint)),
+ serd_new_uri(NULL, SERD_STRING(LV2_CORE__scalePoint)),
NULL,
NULL);
@@ -263,7 +263,7 @@ lilv_port_get_scale_points(const LilvPlugin* plugin, const LilvPort* port)
LilvNodes*
lilv_port_get_properties(const LilvPlugin* plugin, const LilvPort* port)
{
- LilvNode* pred = serd_node_copy(plugin->world->uris.lv2_portProperty);
+ LilvNode* pred = serd_node_copy(NULL, plugin->world->uris.lv2_portProperty);
LilvNodes* ret = lilv_port_get_value(plugin, port, pred);
lilv_node_free(pred);
return ret;
diff --git a/src/query.c b/src/query.c
index 5bed1ce..77a9d8c 100644
--- a/src/query.c
+++ b/src/query.c
@@ -78,13 +78,13 @@ lilv_nodes_from_range_i18n(LilvWorld* world, SerdCursor* range, SerdField field)
if (lm == LILV_LANG_MATCH_EXACT) {
// Exact language match, add to results
- zix_tree_insert((ZixTree*)values, serd_node_copy(value), NULL);
+ zix_tree_insert((ZixTree*)values, serd_node_copy(NULL, value), NULL);
} else if (lm == LILV_LANG_MATCH_PARTIAL) {
// Partial language match, save in case we find no exact
partial = value;
}
} else {
- zix_tree_insert((ZixTree*)values, serd_node_copy(value), NULL);
+ zix_tree_insert((ZixTree*)values, serd_node_copy(NULL, value), NULL);
}
}
serd_cursor_free(range);
@@ -105,7 +105,7 @@ lilv_nodes_from_range_i18n(LilvWorld* world, SerdCursor* range, SerdField field)
}
if (best) {
- zix_tree_insert((ZixTree*)values, serd_node_copy(best), NULL);
+ zix_tree_insert((ZixTree*)values, serd_node_copy(NULL, best), NULL);
} else {
// No matches whatsoever
lilv_nodes_free(values);
@@ -127,7 +127,7 @@ lilv_nodes_from_range(LilvWorld* world, SerdCursor* range, SerdField field)
LilvNodes* values = lilv_nodes_new();
FOREACH_MATCH (s, range) {
const SerdNode* value = serd_statement_node(s, field);
- LilvNode* node = serd_node_copy(value);
+ LilvNode* node = serd_node_copy(NULL, value);
if (node) {
zix_tree_insert((ZixTree*)values, node, NULL);
}
diff --git a/src/state.c b/src/state.c
index 078e962..9de6d9a 100644
--- a/src/state.c
+++ b/src/state.c
@@ -579,10 +579,10 @@ set_state_dir_from_model(LilvState* state, const SerdNode* graph)
{
if (!state->dir && graph) {
const char* const uri = serd_node_string(graph);
- char* const path = serd_parse_file_uri(uri, NULL);
+ char* const path = serd_parse_file_uri(NULL, uri, NULL);
state->dir = lilv_path_join(path, NULL);
- serd_free(path);
+ serd_free(NULL, path);
}
assert(!state->dir || lilv_path_is_absolute(state->dir));
}
@@ -638,7 +638,7 @@ new_state_from_model(LilvWorld* world,
LilvState* const state = (LilvState*)calloc(1, sizeof(LilvState));
state->dir = lilv_path_join(dir, NULL);
state->atom_Path = map->map(map->handle, LV2_ATOM__Path);
- state->uri = serd_node_copy(node);
+ state->uri = serd_node_copy(NULL, node);
// Get the plugin URI this state applies to
SerdCursor* i = serd_model_find(model, node, world->uris.lv2_appliesTo, 0, 0);
@@ -646,13 +646,13 @@ new_state_from_model(LilvWorld* world,
const SerdStatement* s = serd_cursor_get(i);
const SerdNode* object = serd_statement_object(s);
const SerdNode* graph = serd_statement_graph(s);
- state->plugin_uri = serd_node_copy(object);
+ state->plugin_uri = serd_node_copy(NULL, object);
set_state_dir_from_model(state, graph);
serd_cursor_free(i);
} else if (serd_model_ask(
model, node, world->uris.rdf_a, world->uris.lv2_Plugin, 0)) {
// Loading plugin description as state (default state)
- state->plugin_uri = serd_node_copy(node);
+ state->plugin_uri = serd_node_copy(NULL, node);
} else {
LILV_ERRORF("State %s missing lv2:appliesTo property\n",
serd_node_string(node));
@@ -669,7 +669,7 @@ new_state_from_model(LilvWorld* world,
serd_cursor_free(i);
}
- SerdEnv* env = serd_env_new(SERD_EMPTY_STRING());
+ SerdEnv* env = serd_env_new(world->world, SERD_EMPTY_STRING());
SratomLoader* loader = sratom_loader_new(world->world, map);
SerdBuffer buffer = {NULL, 0};
@@ -731,7 +731,7 @@ new_state_from_model(LilvWorld* world,
serd_cursor_free(props);
}
- serd_free(buffer.buf);
+ serd_free(NULL, buffer.buf);
sratom_loader_free(loader);
if (state->props.props) {
@@ -772,18 +772,19 @@ lilv_state_new_from_file(LilvWorld* world,
char* abs_path = lilv_path_absolute(path);
SerdNode* node =
- serd_new_file_uri(SERD_STRING(abs_path), SERD_EMPTY_STRING());
- SerdEnv* env = serd_env_new(serd_node_string_view(node));
- SerdModel* model = serd_model_new(world->world, SERD_ORDER_SPO, 0u);
+ serd_new_file_uri(NULL, SERD_STRING(abs_path), SERD_EMPTY_STRING());
+
+ SerdEnv* env = serd_env_new(world->world, serd_node_string_view(node));
+ SerdModel* model = serd_model_new(world->world, SERD_ORDER_SPO, 0u);
SerdSink* inserter = serd_inserter_new(model, NULL);
SerdReader* reader = serd_reader_new(
world->world, SERD_TURTLE, 0, env, inserter, LILV_READER_STACK_SIZE);
- SerdByteSource* source = serd_byte_source_new_filename(abs_path, 4096);
- serd_reader_start(reader, source);
+ SerdInputStream in = serd_open_input_file(abs_path);
+ serd_reader_start(reader, &in, NULL, 4096);
serd_reader_read_document(reader);
serd_reader_finish(reader);
- serd_byte_source_free(source);
+ serd_close_input(&in);
const SerdNode* subject_node = subject ? subject : node;
@@ -796,7 +797,7 @@ lilv_state_new_from_file(LilvWorld* world,
free(real_path);
free(dirname);
- serd_node_free(node);
+ serd_node_free(NULL, node);
free(abs_path);
serd_reader_free(reader);
serd_model_free(model);
@@ -825,7 +826,7 @@ lilv_state_new_from_string(LilvWorld* world, LV2_URID_Map* map, const char* str)
return NULL;
}
- SerdEnv* env = serd_env_new(SERD_EMPTY_STRING());
+ SerdEnv* env = serd_env_new(world->world, SERD_EMPTY_STRING());
SerdModel* model = serd_model_new(world->world, SERD_ORDER_SPO, 0u);
SerdSink* inserter = serd_inserter_new(model, NULL);
SerdReader* reader = serd_reader_new(
@@ -833,18 +834,19 @@ lilv_state_new_from_string(LilvWorld* world, LV2_URID_Map* map, const char* str)
serd_model_add_index(model, SERD_ORDER_OPS);
- SerdByteSource* source = serd_byte_source_new_string(str, NULL);
+ const char* position = str;
+ SerdInputStream in = serd_open_input_string(&position);
set_prefixes(env);
- serd_reader_start(reader, source);
+ serd_reader_start(reader, &in, NULL, 1);
serd_reader_read_document(reader);
+ serd_close_input(&in);
- SerdNode* o = serd_new_uri(SERD_STRING(LV2_PRESETS__Preset));
+ SerdNode* o = serd_new_uri(NULL, SERD_STRING(LV2_PRESETS__Preset));
const SerdNode* s = serd_model_get(model, NULL, world->uris.rdf_a, o, NULL);
LilvState* state = new_state_from_model(world, map, model, s, NULL);
- serd_node_free(o);
- serd_byte_source_free(source);
+ serd_node_free(NULL, o);
serd_reader_free(reader);
serd_model_free(model);
serd_env_free(env);
@@ -853,16 +855,17 @@ lilv_state_new_from_string(LilvWorld* world, LV2_URID_Map* map, const char* str)
}
static SerdWriter*
-ttl_writer(SerdWorld* world,
- SerdByteSink* const sink,
- const SerdNode* base,
- SerdEnv** new_env)
+ttl_writer(SerdWorld* world,
+ SerdOutputStream* const out,
+ const SerdNode* base,
+ SerdEnv** new_env)
{
SerdEnv* env =
- *new_env ? *new_env : serd_env_new(serd_node_string_view(base));
+ *new_env ? *new_env : serd_env_new(world, serd_node_string_view(base));
+
set_prefixes(env);
- SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, sink);
+ SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0u, env, out, 1);
if (!*new_env) {
*new_env = env;
@@ -872,12 +875,13 @@ ttl_writer(SerdWorld* world,
}
static SerdWriter*
-ttl_file_writer(SerdWorld* world, FILE* fd, const SerdNode* node, SerdEnv** env)
+ttl_file_writer(SerdWorld* world,
+ SerdOutputStream* out,
+ FILE* fd,
+ const SerdNode* node,
+ SerdEnv** env)
{
- SerdByteSink* const sink =
- serd_byte_sink_new_function((SerdWriteFunc)fwrite, NULL, fd, 1);
-
- SerdWriter* const writer = ttl_writer(world, sink, node, env);
+ SerdWriter* const writer = ttl_writer(world, out, node, env);
fseek(fd, 0, SEEK_END);
if (ftell(fd) == 0) {
@@ -892,13 +896,13 @@ ttl_file_writer(SerdWorld* world, FILE* fd, const SerdNode* node, SerdEnv** env)
static void
remove_manifest_entry(SerdModel* model, const char* subject)
{
- SerdNode* const s = serd_new_uri(SERD_STRING(subject));
+ SerdNode* const s = serd_new_uri(NULL, SERD_STRING(subject));
SerdCursor* const r = serd_model_find(model, s, NULL, NULL, NULL);
serd_model_erase_statements(model, r);
serd_cursor_free(r);
- serd_node_free(s);
+ serd_node_free(NULL, s);
}
static int
@@ -908,23 +912,26 @@ write_manifest(LilvWorld* world,
const SerdNode* file_uri)
{
const char* file_uri_str = serd_node_string(file_uri);
- char* const path = serd_parse_file_uri(file_uri_str, NULL);
+ char* const path = serd_parse_file_uri(NULL, file_uri_str, NULL);
FILE* const wfd = fopen(path, "w");
if (!wfd) {
LILV_ERRORF("Failed to open %s for writing (%s)\n", path, strerror(errno));
- serd_free(path);
+ serd_free(NULL, path);
return 1;
}
- SerdWriter* writer = ttl_file_writer(world->world, wfd, file_uri, &env);
+ SerdOutputStream out = serd_open_output_stream(
+ (SerdWriteFunc)fwrite, (SerdErrorFunc)ferror, (SerdCloseFunc)fclose, wfd);
+
+ SerdWriter* writer = ttl_file_writer(world->world, &out, wfd, file_uri, &env);
SerdCursor* all = serd_model_begin_ordered(model, SERD_ORDER_SPO);
- serd_write_range(all, serd_writer_sink(writer), 0);
+ serd_describe_range(all, serd_writer_sink(writer), 0);
serd_cursor_free(all);
serd_writer_free(writer);
- fclose(wfd);
- serd_free(path);
+ serd_close_output(&out);
+ serd_free(NULL, path);
return 0;
}
@@ -941,9 +948,9 @@ add_state_to_manifest(LilvWorld* lworld,
const SerdStringView state_path_view = SERD_STRING(state_path);
SerdWorld* world = lworld->world;
- SerdNode* manifest = serd_new_file_uri(manifest_path_view, empty);
- SerdNode* file = serd_new_file_uri(state_path_view, empty);
- SerdEnv* env = serd_env_new(serd_node_string_view(manifest));
+ SerdNode* manifest = serd_new_file_uri(NULL, manifest_path_view, empty);
+ SerdNode* file = serd_new_file_uri(NULL, state_path_view, empty);
+ SerdEnv* env = serd_env_new(world, serd_node_string_view(manifest));
SerdModel* model = serd_model_new(world, SERD_ORDER_SPO, 0u);
SerdSink* inserter = serd_inserter_new(model, NULL);
@@ -955,22 +962,17 @@ add_state_to_manifest(LilvWorld* lworld,
SerdReader* reader = serd_reader_new(
world, SERD_TURTLE, 0, env, inserter, LILV_READER_STACK_SIZE);
- SerdByteSource* source =
- serd_byte_source_new_function((SerdReadFunc)fread,
- (SerdStreamErrorFunc)ferror,
- NULL,
- rfd,
- manifest,
- PAGE_SIZE);
+ SerdInputStream in = serd_open_input_stream(
+ (SerdReadFunc)fread, (SerdErrorFunc)ferror, NULL, rfd);
SerdStatus st = SERD_SUCCESS;
- if ((st = serd_reader_start(reader, source)) ||
+ if ((st = serd_reader_start(reader, &in, manifest, PAGE_SIZE)) ||
(st = serd_reader_read_document(reader))) {
LILV_WARNF("Failed to read manifest (%s)\n", serd_strerror(st));
return st;
}
- serd_byte_source_free(source);
+ serd_close_input(&in);
serd_reader_free(reader);
fclose(rfd);
}
@@ -984,7 +986,7 @@ add_state_to_manifest(LilvWorld* lworld,
remove_manifest_entry(model, state_uri);
// Add manifest entry for this state to model
- SerdNode* s = serd_new_uri(SERD_STRING(state_uri));
+ SerdNode* s = serd_new_uri(NULL, SERD_STRING(state_uri));
// <state> a pset:Preset
serd_model_add(model, s, lworld->uris.rdf_a, lworld->uris.pset_Preset, NULL);
@@ -998,10 +1000,10 @@ add_state_to_manifest(LilvWorld* lworld,
// Write manifest model to file
write_manifest(lworld, env, model, manifest);
- serd_node_free(s);
+ serd_node_free(NULL, s);
serd_model_free(model);
- serd_node_free(file);
- serd_node_free(manifest);
+ serd_node_free(NULL, file);
+ serd_node_free(NULL, manifest);
serd_env_free(env);
return 0;
@@ -1051,7 +1053,7 @@ write_property_array(const LilvState* state,
Property* prop = &array->props[i];
const char* key = unmap->unmap(unmap->handle, prop->key);
- SerdNode* p = serd_new_uri(SERD_STRING(key));
+ SerdNode* p = serd_new_uri(NULL, SERD_STRING(key));
if (prop->type == state->atom_Path && !dir) {
const char* path = (const char*)prop->value;
const char* abs_path = lilv_state_rel2abs(state, path);
@@ -1072,7 +1074,7 @@ write_property_array(const LilvState* state,
} else {
LILV_WARNF("Lost non-POD property <%s> on save\n", key);
}
- serd_node_free(p);
+ serd_node_free(NULL, p);
}
}
@@ -1089,7 +1091,7 @@ lilv_state_write(LilvWorld* world,
const SerdSink* sink = serd_writer_sink(writer);
const SerdNode* plugin_uri = state->plugin_uri;
SerdNode* subject =
- serd_new_uri(uri ? SERD_STRING(uri) : SERD_EMPTY_STRING());
+ serd_new_uri(NULL, uri ? SERD_STRING(uri) : SERD_EMPTY_STRING());
SerdStatus st = SERD_SUCCESS;
@@ -1107,13 +1109,13 @@ lilv_state_write(LilvWorld* world,
// <subject> rdfs:label label
if (state->label) {
- SerdNode* label = serd_new_string(SERD_STRING(state->label));
+ SerdNode* label = serd_new_string(NULL, SERD_STRING(state->label));
if ((st = serd_sink_write(
sink, 0, subject, world->uris.rdfs_label, label, NULL))) {
return st;
}
- serd_node_free(label);
+ serd_node_free(NULL, label);
}
SratomDumper* dumper = sratom_dumper_new(world->world, map, unmap);
@@ -1125,7 +1127,8 @@ lilv_state_write(LilvWorld* world,
// Write port values (with pretty numbers)
for (uint32_t i = 0; i < state->n_values; ++i) {
PortValue* const value = &state->values[i];
- SerdNode* port = serd_new_token(SERD_BLANK, SERD_STRING(value->symbol));
+ SerdNode* port =
+ serd_new_token(NULL, SERD_BLANK, SERD_STRING(value->symbol));
// <> lv2:port _:symbol
if ((st = serd_sink_write(
@@ -1134,13 +1137,13 @@ lilv_state_write(LilvWorld* world,
}
// _:symbol lv2:symbol "symbol"
- SerdNode* symbol = serd_new_string(SERD_STRING(value->symbol));
+ SerdNode* symbol = serd_new_string(NULL, SERD_STRING(value->symbol));
if ((st = serd_sink_write(
sink, 0, port, world->uris.lv2_symbol, symbol, NULL))) {
return st;
}
- serd_node_free(symbol);
+ serd_node_free(NULL, symbol);
// _:symbol pset:value value
// FIXME: error handling
@@ -1159,7 +1162,7 @@ lilv_state_write(LilvWorld* world,
// <> state:state _:body
- SerdNode* body = serd_new_token(SERD_BLANK, SERD_STRING("body"));
+ SerdNode* body = serd_new_token(NULL, SERD_BLANK, SERD_STRING("body"));
if (state->props.n > 0) {
if ((st = serd_sink_write(
sink, SERD_ANON_O, subject, world->uris.state_state, body, NULL))) {
@@ -1178,7 +1181,7 @@ lilv_state_write(LilvWorld* world,
}
}
- serd_node_free(body);
+ serd_node_free(NULL, body);
sratom_dumper_free(dumper);
return SERD_SUCCESS;
}
@@ -1255,10 +1258,17 @@ lilv_state_save(LilvWorld* world,
lilv_state_make_links(state, abs_dir);
// Write state to Turtle file
- SerdNode* file = serd_new_file_uri(SERD_STRING(path), SERD_EMPTY_STRING());
- SerdNode* node = uri ? serd_new_uri(SERD_STRING(uri)) : serd_node_copy(file);
- SerdEnv* env = NULL;
- SerdWriter* ttl = ttl_file_writer(world->world, fd, file, &env);
+ SerdNode* file =
+ serd_new_file_uri(NULL, SERD_STRING(path), SERD_EMPTY_STRING());
+
+ SerdNode* node =
+ uri ? serd_new_uri(NULL, SERD_STRING(uri)) : serd_node_copy(NULL, file);
+
+ SerdOutputStream out = serd_open_output_stream(
+ (SerdWriteFunc)fwrite, (SerdErrorFunc)ferror, (SerdCloseFunc)fclose, fd);
+
+ SerdEnv* env = NULL;
+ SerdWriter* ttl = ttl_file_writer(world->world, &out, fd, file, &env);
SerdStatus st = lilv_state_write(
world, map, unmap, state, env, ttl, serd_node_string(node), dir);
@@ -1268,7 +1278,7 @@ lilv_state_save(LilvWorld* world,
((LilvState*)state)->dir = lilv_path_join(abs_dir, NULL);
((LilvState*)state)->uri = node;
- serd_node_free(file);
+ serd_node_free(NULL, file);
serd_writer_free(ttl);
serd_env_free(env);
fclose(fd);
@@ -1296,22 +1306,22 @@ lilv_state_to_string(LilvWorld* world,
return NULL;
}
- SerdBuffer buffer = {NULL, 0};
- SerdEnv* env = NULL;
- SerdNode* base =
- serd_new_uri(base_uri ? SERD_STRING(base_uri) : SERD_EMPTY_STRING());
+ SerdDynamicBuffer buffer = {NULL, NULL, 0};
+ SerdEnv* env = NULL;
+ SerdNode* base =
+ serd_new_uri(NULL, base_uri ? SERD_STRING(base_uri) : SERD_EMPTY_STRING());
- SerdByteSink* sink = serd_byte_sink_new_buffer(&buffer);
- SerdWriter* writer = ttl_writer(world->world, sink, base, &env);
+ SerdOutputStream out = serd_open_output_buffer(&buffer);
+ SerdWriter* writer = ttl_writer(world->world, &out, base, &env);
lilv_state_write(world, map, unmap, state, env, writer, uri, NULL);
serd_writer_free(writer);
- serd_byte_sink_free(sink);
+ serd_close_output(&out);
serd_env_free(env);
- char* str = serd_buffer_sink_finish(&buffer);
- char* result = lilv_strdup(str);
- serd_free(str);
+ char* str = (char*)buffer.buf;
+ char* result = lilv_strdup(str); // FIXME: Alloc in lilv to avoid this (win32)
+ serd_free(NULL, str);
return result;
}
@@ -1351,17 +1361,16 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
if (has_manifest) {
// Read manifest into temporary local model
- SerdEnv* env = serd_env_new(serd_node_string_view(manifest));
- SerdSink* inserter = serd_inserter_new(model, NULL);
- SerdReader* reader = serd_reader_new(
+ SerdEnv* env = serd_env_new(world->world, serd_node_string_view(manifest));
+ SerdSink* inserter = serd_inserter_new(model, NULL);
+ SerdReader* reader = serd_reader_new(
world->world, SERD_TURTLE, 0, env, inserter, LILV_READER_STACK_SIZE);
- SerdByteSource* source =
- serd_byte_source_new_filename(manifest_path, PAGE_SIZE);
+ SerdInputStream in = serd_open_input_file(manifest_path);
- serd_reader_start(reader, source);
+ serd_reader_start(reader, &in, NULL, PAGE_SIZE);
serd_reader_read_document(reader);
- serd_byte_source_free(source);
+ serd_close_input(&in);
serd_reader_free(reader);
serd_env_free(env);
}
@@ -1370,7 +1379,9 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
const SerdNode* file =
serd_model_get(model, state->uri, world->uris.rdfs_seeAlso, NULL, NULL);
if (file) {
- char* const path = serd_parse_file_uri(serd_node_string(file), NULL);
+ char* const path =
+ serd_parse_file_uri(NULL, serd_node_string(file), NULL);
+
char* const real_path = lilv_path_canonical(path);
// Remove state file
@@ -1378,8 +1389,8 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
try_unlink(state->dir, real_path);
}
- serd_free(real_path);
- serd_free(path);
+ serd_free(NULL, real_path);
+ serd_free(NULL, path);
}
// Remove any existing manifest entries for this state
@@ -1424,7 +1435,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
}
} else {
// Still something in the manifest, update and reload bundle
- SerdEnv* env = serd_env_new(serd_node_string_view(manifest));
+ SerdEnv* env = serd_env_new(NULL, serd_node_string_view(manifest));
if (write_manifest(world, env, model, manifest)) {
return 1;
diff --git a/src/world.c b/src/world.c
index 8d84e36..7024cb2 100644
--- a/src/world.c
+++ b/src/world.c
@@ -45,7 +45,7 @@ lilv_world_new(void)
{
LilvWorld* world = (LilvWorld*)calloc(1, sizeof(LilvWorld));
- world->world = serd_world_new();
+ world->world = serd_world_new(NULL);
if (!world->world) {
goto fail;
}
@@ -74,7 +74,7 @@ lilv_world_new(void)
#define NS_DYNMAN "http://lv2plug.in/ns/ext/dynmanifest#"
#define NS_OWL "http://www.w3.org/2002/07/owl#"
-#define NEW_URI(uri) serd_new_uri(SERD_STRING(uri))
+#define NEW_URI(uri) serd_new_uri(NULL, SERD_STRING(uri))
world->uris.dc_replaces = NEW_URI(NS_DCTERMS "replaces");
world->uris.dman_DynManifest = NEW_URI(NS_DYNMAN "DynManifest");
@@ -145,13 +145,13 @@ lilv_world_free(LilvWorld* world)
world->lv2_plugin_class = NULL;
for (SerdNode** n = (SerdNode**)&world->uris; *n; ++n) {
- serd_node_free(*n);
+ serd_node_free(NULL, *n);
}
for (LilvSpec* spec = world->specs; spec;) {
LilvSpec* next = spec->next;
- serd_node_free(spec->spec);
- serd_node_free(spec->bundle);
+ serd_node_free(NULL, spec->spec);
+ serd_node_free(NULL, spec->bundle);
lilv_nodes_free(spec->data_uris);
free(spec);
spec = next;
@@ -243,7 +243,7 @@ lilv_world_get(LilvWorld* world,
const LilvNode* object)
{
return serd_node_copy(
- serd_model_get(world->model, subject, predicate, object, NULL));
+ NULL, serd_model_get(world->model, subject, predicate, object, NULL));
}
bool
@@ -354,15 +354,16 @@ lilv_world_add_spec(LilvWorld* world,
const SerdNode* bundle_node)
{
LilvSpec* spec = (LilvSpec*)malloc(sizeof(LilvSpec));
- spec->spec = serd_node_copy(specification_node);
- spec->bundle = serd_node_copy(bundle_node);
+ spec->spec = serd_node_copy(NULL, specification_node);
+ spec->bundle = serd_node_copy(NULL, bundle_node);
spec->data_uris = lilv_nodes_new();
// Add all data files (rdfs:seeAlso)
FOREACH_PAT (
s, world->model, specification_node, world->uris.rdfs_seeAlso, NULL, NULL) {
const SerdNode* file_node = serd_statement_object(s);
- zix_tree_insert((ZixTree*)spec->data_uris, serd_node_copy(file_node), NULL);
+ zix_tree_insert(
+ (ZixTree*)spec->data_uris, serd_node_copy(NULL, file_node), NULL);
}
// Add specification to world specification list
@@ -429,7 +430,7 @@ lilv_world_add_plugin(LilvWorld* world,
s, world->model, plugin_uri, world->uris.rdfs_seeAlso, NULL, NULL) {
const SerdNode* file_node = serd_statement_object(s);
zix_tree_insert(
- (ZixTree*)plugin->data_uris, serd_node_copy(file_node), NULL);
+ (ZixTree*)plugin->data_uris, serd_node_copy(NULL, file_node), NULL);
}
}
@@ -438,7 +439,7 @@ lilv_world_load_graph(LilvWorld* world,
const SerdNode* graph,
const LilvNode* uri)
{
- SerdEnv* env = serd_env_new(serd_node_string_view(uri));
+ SerdEnv* env = serd_env_new(world->world, serd_node_string_view(uri));
SerdSink* inserter = serd_inserter_new(world->model, graph);
SerdReader* reader = serd_reader_new(
world->world, SERD_TURTLE, 0, env, inserter, LILV_READER_STACK_SIZE);
@@ -530,7 +531,7 @@ lilv_world_load_dyn_manifest(LilvWorld* world,
}
LilvDynManifest* desc = (LilvDynManifest*)malloc(sizeof(LilvDynManifest));
- desc->bundle = serd_node_copy(bundle_node);
+ desc->bundle = serd_node_copy(NULL, bundle_node);
desc->lib = lib;
desc->handle = handle;
desc->refs = 0;
@@ -547,7 +548,7 @@ lilv_world_load_dyn_manifest(LilvWorld* world,
const SerdNode* base = dmanifest;
SerdEnv* env = serd_env_new(base);
SerdReader* reader = serd_model_new_reader(
- world->model, env, SERD_TURTLE, serd_node_copy(dmanifest));
+ world->model, env, SERD_TURTLE, serd_node_copy(NULL, dmanifest));
serd_reader_add_blank_prefix(reader, lilv_world_blank_node_prefix(world));
serd_reader_read_file_handle(reader, fd, "(dyn-manifest)");
serd_reader_free(reader);
@@ -611,7 +612,7 @@ lilv_world_get_manifest_node(LilvWorld* world, const LilvNode* bundle_node)
const SerdURIView manifest_ref = serd_parse_uri("manifest.ttl");
const SerdURIView manifest_uri = serd_resolve_uri(manifest_ref, bundle_uri);
- return serd_new_parsed_uri(manifest_uri);
+ return serd_new_parsed_uri(NULL, manifest_uri);
}
char*
@@ -619,7 +620,7 @@ lilv_world_get_manifest_path(LilvWorld* world, const LilvNode* bundle_node)
{
const SerdNode* const node = lilv_world_get_manifest_node(world, bundle_node);
- return serd_parse_file_uri(serd_node_string(node), NULL);
+ return serd_parse_file_uri(NULL, serd_node_string(node), NULL);
}
static SerdModel*
@@ -628,19 +629,18 @@ load_plugin_model(LilvWorld* world,
const LilvNode* plugin_uri)
{
// Create model and reader for loading into it
- SerdModel* model = serd_model_new(world->world, SERD_ORDER_SPO, 0u);
- SerdEnv* env = serd_env_new(serd_node_string_view(bundle_uri));
- SerdSink* inserter = serd_inserter_new(model, NULL);
- SerdReader* reader = serd_reader_new(
+ SerdModel* model = serd_model_new(world->world, SERD_ORDER_SPO, 0u);
+ SerdEnv* env = serd_env_new(world->world, serd_node_string_view(bundle_uri));
+ SerdSink* inserter = serd_inserter_new(model, NULL);
+ SerdReader* reader = serd_reader_new(
world->world, SERD_TURTLE, 0, env, inserter, LILV_READER_STACK_SIZE);
serd_model_add_index(model, SERD_ORDER_OPS);
// Load manifest
- char* manifest_path = lilv_world_get_manifest_path(world, bundle_uri);
- SerdByteSource* manifest_source =
- serd_byte_source_new_filename(manifest_path, 4096);
- serd_reader_start(reader, manifest_source);
+ char* manifest_path = lilv_world_get_manifest_path(world, bundle_uri);
+ SerdInputStream manifest_in = serd_open_input_file(manifest_path);
+ serd_reader_start(reader, &manifest_in, bundle_uri, PAGE_SIZE);
serd_reader_read_document(reader);
serd_reader_finish(reader);
@@ -653,14 +653,13 @@ load_plugin_model(LilvWorld* world,
const SerdNode* file = serd_statement_object(serd_cursor_get(f));
const char* uri_str = serd_node_string(file);
if (serd_node_type(file) == SERD_URI) {
- char* path_str = serd_parse_file_uri(uri_str, NULL);
- SerdByteSource* source = serd_byte_source_new_filename(path_str, 4096);
+ char* path_str = serd_parse_file_uri(NULL, uri_str, NULL);
+ SerdInputStream in = serd_open_input_file(path_str);
- serd_reader_start(reader, source);
+ serd_reader_start(reader, &in, file, PAGE_SIZE);
serd_reader_read_document(reader);
serd_reader_finish(reader);
-
- serd_byte_source_free(source);
+ serd_close_input(&in);
}
}
@@ -716,7 +715,7 @@ lilv_world_load_bundle(LilvWorld* world, const LilvNode* bundle_uri)
FOREACH_MATCH (s, plug_results) {
const SerdNode* plug = serd_statement_subject(s);
- LilvNode* plugin_uri = serd_node_copy(plug);
+ LilvNode* plugin_uri = serd_node_copy(NULL, plug);
const LilvPlugin* plugin =
lilv_plugins_get_by_uri(world->plugins, plugin_uri);
const LilvNode* last_bundle =
@@ -898,12 +897,14 @@ load_dir_entry(const char* dir, const char* name, void* data)
}
char* path = lilv_strjoin(dir, "/", name, "/", NULL);
- SerdNode* suri = serd_new_file_uri(SERD_STRING(path), SERD_EMPTY_STRING());
+ SerdNode* suri =
+ serd_new_file_uri(NULL, SERD_STRING(path), SERD_EMPTY_STRING());
+
LilvNode* node = lilv_new_uri(world, serd_node_string(suri));
lilv_world_load_bundle(world, node);
lilv_node_free(node);
- serd_node_free(suri);
+ serd_node_free(NULL, suri);
free(path);
}
@@ -1050,15 +1051,16 @@ lilv_world_load_file(LilvWorld* world, SerdReader* reader, const LilvNode* uri)
SerdStatus st = SERD_SUCCESS;
char* hostname = NULL;
- char* filename = serd_parse_file_uri(serd_node_string(uri), &hostname);
+ char* filename = serd_parse_file_uri(NULL, serd_node_string(uri), &hostname);
if (!filename || hostname) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
- SerdByteSource* const source =
- serd_byte_source_new_filename(filename, PAGE_SIZE);
+ SerdInputStream in = serd_open_input_file(filename);
+
+ serd_free(NULL, filename);
- if ((st = serd_reader_start(reader, source)) ||
+ if ((st = serd_reader_start(reader, &in, uri, PAGE_SIZE)) ||
(st = serd_reader_read_document(reader)) ||
(st = serd_reader_finish(reader))) {
LILV_ERRORF("Error loading file `%s'\n", lilv_node_as_string(uri));
@@ -1087,7 +1089,7 @@ lilv_world_load_resource(LilvWorld* world, const LilvNode* resource)
serd_cursor_advance(f)) {
const SerdNode* file = serd_statement_object(serd_cursor_get(f));
const char* file_str = serd_node_string(file);
- LilvNode* file_node = serd_node_copy(file);
+ LilvNode* file_node = serd_node_copy(NULL, file);
if (serd_node_type(file) != SERD_URI) {
LILV_ERRORF("rdfs:seeAlso node `%s' is not a URI\n", file_str);
} else if (!lilv_world_load_graph(world, (SerdNode*)file, file_node)) {
@@ -1116,7 +1118,7 @@ lilv_world_unload_resource(LilvWorld* world, const LilvNode* resource)
int n_dropped = 0;
for (; !serd_cursor_is_end(f); serd_cursor_advance(f)) {
const SerdNode* file = serd_statement_object(serd_cursor_get(f));
- LilvNode* file_node = serd_node_copy(file);
+ LilvNode* file_node = serd_node_copy(NULL, file);
if (serd_node_type(file) != SERD_URI) {
LILV_ERRORF("rdfs:seeAlso node `%s' is not a URI\n",
serd_node_string(file));
@@ -1158,7 +1160,7 @@ lilv_world_get_symbol(LilvWorld* world, const LilvNode* subject)
serd_model_get(world->model, subject, world->uris.lv2_symbol, NULL, NULL);
if (snode) {
- return serd_node_copy(snode);
+ return serd_node_copy(NULL, snode);
}
if (!lilv_node_is_uri(subject)) {
diff --git a/test/bad_syntax.lv2/test_bad_syntax.c b/test/bad_syntax.lv2/test_bad_syntax.c
index 6403560..3922df0 100644
--- a/test/bad_syntax.lv2/test_bad_syntax.c
+++ b/test/bad_syntax.lv2/test_bad_syntax.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/failed_instantiation.lv2/test_failed_instantiation.c b/test/failed_instantiation.lv2/test_failed_instantiation.c
index 7e910c2..64e7a80 100644
--- a/test/failed_instantiation.lv2/test_failed_instantiation.c
+++ b/test/failed_instantiation.lv2/test_failed_instantiation.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
index 920f4a5..5f7329f 100644
--- a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
+++ b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/lib_descriptor.lv2/test_lib_descriptor.c b/test/lib_descriptor.lv2/test_lib_descriptor.c
index 914986f..3909feb 100644
--- a/test/lib_descriptor.lv2/test_lib_descriptor.c
+++ b/test/lib_descriptor.lv2/test_lib_descriptor.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c
index 6f0b8d9..563da20 100644
--- a/test/lilv_test_utils.c
+++ b/test/lilv_test_utils.c
@@ -94,15 +94,15 @@ create_bundle(LilvTestEnv* env,
return 1;
}
- SerdNode* s =
- serd_new_file_uri(SERD_STRING(env->test_bundle_path), SERD_EMPTY_STRING());
+ SerdNode* s = serd_new_file_uri(
+ NULL, SERD_STRING(env->test_bundle_path), SERD_EMPTY_STRING());
env->test_bundle_uri = lilv_new_uri(env->world, serd_node_string(s));
env->test_manifest_path =
lilv_path_join(env->test_bundle_path, "manifest.ttl");
env->test_content_path = lilv_path_join(env->test_bundle_path, "plugin.ttl");
- serd_node_free(s);
+ serd_node_free(NULL, s);
FILE* const manifest_file = fopen(env->test_manifest_path, "w");
if (!manifest_file) {
diff --git a/test/missing_descriptor.lv2/test_missing_descriptor.c b/test/missing_descriptor.lv2/test_missing_descriptor.c
index 3f901b0..d811d8f 100644
--- a/test/missing_descriptor.lv2/test_missing_descriptor.c
+++ b/test/missing_descriptor.lv2/test_missing_descriptor.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_name.lv2/test_missing_name.c b/test/missing_name.lv2/test_missing_name.c
index c6de224..ef00cc1 100644
--- a/test/missing_name.lv2/test_missing_name.c
+++ b/test/missing_name.lv2/test_missing_name.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_plugin.lv2/test_missing_plugin.c b/test/missing_plugin.lv2/test_missing_plugin.c
index 4143f36..a50f7cc 100644
--- a/test/missing_plugin.lv2/test_missing_plugin.c
+++ b/test/missing_plugin.lv2/test_missing_plugin.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_port.lv2/test_missing_port.c b/test/missing_port.lv2/test_missing_port.c
index 05430cb..fcb5435 100644
--- a/test/missing_port.lv2/test_missing_port.c
+++ b/test/missing_port.lv2/test_missing_port.c
@@ -25,10 +25,12 @@ main(int argc, char** argv)
// Load test plugin bundle
char* const abs_bundle = lilv_path_absolute(bundle_path);
const SerdStringView abs_bundle_view = SERD_STRING(abs_bundle);
- SerdNode* bundle = serd_new_file_uri(abs_bundle_view, SERD_EMPTY_STRING());
+ SerdNode* bundle =
+ serd_new_file_uri(NULL, abs_bundle_view, SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_port_name.lv2/test_missing_port_name.c b/test/missing_port_name.lv2/test_missing_port_name.c
index e9dcae8..2832077 100644
--- a/test/missing_port_name.lv2/test_missing_port_name.c
+++ b/test/missing_port_name.lv2/test_missing_port_name.c
@@ -25,10 +25,11 @@ main(int argc, char** argv)
// Load test plugin bundle
char* abs_bundle = lilv_path_absolute(bundle_path);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+
lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/test_state.c b/test/test_state.c
index 1acad5e..2951b61 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -248,7 +248,7 @@ load_test_plugin(const TestContext* const ctx)
LilvWorld* world = ctx->env->world;
char* abs_bundle = lilv_path_absolute(LILV_TEST_BUNDLE);
SerdNode* bundle =
- serd_new_file_uri(SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(abs_bundle), SERD_EMPTY_STRING());
LilvNode* bundle_uri = lilv_new_uri(world, serd_node_string(bundle));
LilvNode* plugin_uri = lilv_new_uri(world, TEST_PLUGIN_URI);
@@ -260,7 +260,7 @@ load_test_plugin(const TestContext* const ctx)
lilv_node_free(plugin_uri);
lilv_node_free(bundle_uri);
- serd_node_free(bundle);
+ serd_node_free(NULL, bundle);
free(abs_bundle);
assert(plugin);
@@ -549,26 +549,25 @@ count_statements(const char* path)
{
size_t n_statements = 0;
- SerdWorld* const world = serd_world_new();
+ SerdWorld* const world = serd_world_new(NULL);
const SerdStringView path_view = SERD_STRING(path);
- SerdNode* const base = serd_new_file_uri(path_view, SERD_EMPTY_STRING());
+ SerdNode* const base =
+ serd_new_file_uri(NULL, path_view, SERD_EMPTY_STRING());
- SerdEnv* const env = serd_env_new(serd_node_string_view(base));
- SerdSink* const sink = serd_sink_new(&n_statements, count_func, NULL);
+ SerdEnv* const env = serd_env_new(world, serd_node_string_view(base));
+ SerdSink* const sink = serd_sink_new(world, &n_statements, count_func, NULL);
SerdReader* const reader =
serd_reader_new(world, SERD_TURTLE, 0, env, sink, 4096);
- SerdByteSource* const source = serd_byte_source_new_filename(path, 4096);
-
- SerdStatus st = SERD_SUCCESS;
- assert(!(st = serd_reader_start(reader, source)));
+ SerdInputStream in = serd_open_input_file(path);
+ SerdStatus st = SERD_SUCCESS;
+ assert(!(st = serd_reader_start(reader, &in, NULL, 4096)));
assert(!(st = serd_reader_read_document(reader)));
- serd_byte_source_free(source);
- serd_reader_free(reader);
+ serd_close_input(&in);
serd_sink_free(sink);
serd_env_free(env);
- serd_node_free(base);
+ serd_node_free(NULL, base);
serd_world_free(world);
return n_statements;
@@ -918,10 +917,13 @@ test_world_round_trip(void)
"state.ttl"));
// Load state bundle into world
+
SerdNode* bundle_uri =
- serd_new_file_uri(SERD_STRING(bundle_path), SERD_EMPTY_STRING());
+ serd_new_file_uri(NULL, SERD_STRING(bundle_path), SERD_EMPTY_STRING());
+
LilvNode* const bundle_node =
lilv_new_uri(world, serd_node_string(bundle_uri));
+
LilvNode* const state_node = lilv_new_uri(world, state_uri);
lilv_world_load_bundle(world, bundle_node);
lilv_world_load_resource(world, state_node);
@@ -945,7 +947,7 @@ test_world_round_trip(void)
lilv_state_free(restored);
lilv_node_free(state_node);
lilv_node_free(bundle_node);
- serd_node_free(bundle_uri);
+ serd_node_free(NULL, bundle_uri);
lilv_state_free(start_state);
free(bundle_path);
test_context_free(ctx);