summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugin.c40
-rw-r--r--src/world.c2
2 files changed, 19 insertions, 23 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 5841bd2..32c40da 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -81,35 +81,31 @@ lilv_plugin_free(LilvPlugin* p)
free(p);
}
-LilvNode*
-lilv_plugin_get_unique(const LilvPlugin* p,
- const SordNode* subject,
- const SordNode* predicate)
+static LilvNode*
+lilv_plugin_get_one(const LilvPlugin* p,
+ const SordNode* subject,
+ const SordNode* predicate)
{
- LilvNodes* values = lilv_world_query_values(p->world,
- subject, predicate, NULL);
- if (!values || lilv_nodes_size(values) != 1) {
- LILV_ERRORF("Port does not have exactly one `%s' property\n",
- sord_node_get_string(predicate));
- return NULL;
+ LilvNode* ret = NULL;
+ SordIter* stream = lilv_world_query(p->world, subject, predicate, NULL);
+ if (!lilv_matches_end(stream)) {
+ ret = lilv_node_new_from_node(p->world, lilv_match_object(stream));
}
- LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values));
- lilv_nodes_free(values);
+ lilv_match_end(stream);
return ret;
}
-static LilvNode*
-lilv_plugin_get_one(const LilvPlugin* p,
- const SordNode* subject,
- const SordNode* predicate)
+LilvNode*
+lilv_plugin_get_unique(const LilvPlugin* p,
+ const SordNode* subject,
+ const SordNode* predicate)
{
- LilvNodes* values = lilv_world_query_values(p->world,
- subject, predicate, NULL);
- if (!values) {
- return NULL;
+ LilvNode* ret = lilv_plugin_get_one(p, subject, predicate);
+ if (!ret) {
+ LILV_ERRORF("Multiple values found for (%s %s ...) property\n",
+ sord_node_get_string(subject),
+ sord_node_get_string(predicate));
}
- LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values));
- lilv_nodes_free(values);
return ret;
}
diff --git a/src/world.c b/src/world.c
index 5d093d0..336970f 100644
--- a/src/world.c
+++ b/src/world.c
@@ -744,7 +744,7 @@ lilv_world_load_all(LilvWorld* world)
LILV_FOREACH(plugins, p, world->plugins) {
const LilvPlugin* plugin = lilv_collection_get(world->plugins, p);
- const LilvNode* plugin_uri = lilv_plugin_get_uri(plugin);
+ const LilvNode* plugin_uri = lilv_plugin_get_uri(plugin);
// ?new dc:replaces plugin
SordIter* replacement = lilv_world_find_statements(