summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-02-18 18:07:08 +0000
committerDavid Robillard <d@drobilla.net>2013-02-18 18:07:08 +0000
commit0171b7a4c60833d19c47a401fcbf666a6001284d (patch)
tree99e443bb5f7674ec51be90f4500a1d4e0e1056ad
parentbcdcb433808243999b4e15aa04b8be51135f89de (diff)
downloadlilv-0171b7a4c60833d19c47a401fcbf666a6001284d.tar.gz
lilv-0171b7a4c60833d19c47a401fcbf666a6001284d.tar.bz2
lilv-0171b7a4c60833d19c47a401fcbf666a6001284d.zip
Make use of sord_get().
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5057 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/state.c36
-rw-r--r--src/world.c62
2 files changed, 34 insertions, 64 deletions
diff --git a/src/state.c b/src/state.c
index 77f6365..9ab441f 100644
--- a/src/state.c
+++ b/src/state.c
@@ -432,15 +432,6 @@ lilv_state_restore(const LilvState* state,
}
}
-static SordNode*
-get1(SordModel* model, const SordNode* s, const SordNode* p)
-{
- SordIter* const i = sord_search(model, s, p, 0, 0);
- SordNode* const node = i ? sord_node_copy(sord_iter_get_node(i, SORD_OBJECT)) : NULL;
- sord_iter_free(i);
- return node;
-}
-
static LilvState*
new_state_from_model(LilvWorld* world,
LV2_URID_Map* map,
@@ -463,10 +454,10 @@ new_state_from_model(LilvWorld* world,
state->dir = lilv_strdup((const char*)sord_node_get_string(graph));
}
sord_iter_free(i);
- } else if (sord_search(model,
- node,
- world->uris.rdf_a,
- world->uris.lv2_Plugin, 0)) {
+ } else if (sord_ask(model,
+ node,
+ world->uris.rdf_a,
+ world->uris.lv2_Plugin, 0)) {
// Loading plugin description as state (default state)
state->plugin_uri = lilv_node_new_from_node(world, node);
} else {
@@ -496,12 +487,13 @@ new_state_from_model(LilvWorld* world,
// Get port values
SordIter* ports = sord_search(model, node, world->uris.lv2_port, 0, 0);
FOREACH_MATCH(ports) {
- const SordNode* port = sord_iter_get_node(ports, SORD_OBJECT);
- const SordNode* label = get1(model, port, world->uris.rdfs_label);
- const SordNode* symbol = get1(model, port, world->uris.lv2_symbol);
- const SordNode* value = get1(model, port, world->uris.pset_value);
+ const SordNode* port = sord_iter_get_node(ports, SORD_OBJECT);
+
+ SordNode* label = sord_get(model, port, world->uris.rdfs_label, 0, 0);
+ SordNode* symbol = sord_get(model, port, world->uris.lv2_symbol, 0, 0);
+ SordNode* value = sord_get(model, port, world->uris.pset_value, 0, 0);
if (!value) {
- value = get1(model, port, world->uris.lv2_default);
+ value = sord_get(model, port, world->uris.lv2_default, 0, 0);
}
if (!symbol) {
LILV_ERRORF("State `%s' port missing symbol.\n",
@@ -520,12 +512,15 @@ new_state_from_model(LilvWorld* world,
(const char*)sord_node_get_string(label));
}
}
+ sord_node_free(world->world, value);
+ sord_node_free(world->world, symbol);
+ sord_node_free(world->world, label);
}
sord_iter_free(ports);
// Get properties
- SordNode* statep = sord_new_uri(world->world, USTR(LV2_STATE__state));
- const SordNode* state_node = get1(model, node, statep);
+ SordNode* statep = sord_new_uri(world->world, USTR(LV2_STATE__state));
+ SordNode* state_node = sord_get(model, node, statep, NULL, NULL);
if (state_node) {
SordIter* props = sord_search(model, state_node, 0, 0, 0);
FOREACH_MATCH(props) {
@@ -558,6 +553,7 @@ new_state_from_model(LilvWorld* world,
}
sord_iter_free(props);
}
+ sord_node_free(world->world, state_node);
sord_node_free(world->world, statep);
free((void*)chunk.buf);
diff --git a/src/world.c b/src/world.c
index 4262723..a577bbe 100644
--- a/src/world.c
+++ b/src/world.c
@@ -693,49 +693,28 @@ lilv_world_load_plugin_classes(LilvWorld* world)
FOREACH_MATCH(classes) {
const SordNode* class_node = sord_iter_get_node(classes, SORD_SUBJECT);
- // Get parents (superclasses)
- SordIter* parents = sord_search(
- world->model,
- class_node,
- world->uris.rdfs_subClassOf,
- NULL,
- NULL);
-
- if (sord_iter_end(parents)) {
- sord_iter_free(parents);
- continue;
- }
-
- const SordNode* parent_node = sord_iter_get_node(parents, SORD_OBJECT);
- sord_iter_free(parents);
-
- if (!sord_node_get_type(parent_node) == SORD_URI) {
- // Class parent is not a resource, ignore (e.g. owl restriction)
+ SordNode* parent = sord_get(
+ world->model, class_node, world->uris.rdfs_subClassOf, NULL, NULL);
+ if (!parent || sord_node_get_type(parent) != SORD_URI) {
continue;
}
- // Get labels
- SordIter* labels = sord_search(
- world->model,
- class_node,
- world->uris.rdfs_label,
- NULL,
- NULL);
-
- if (sord_iter_end(labels)) {
- sord_iter_free(labels);
+ SordNode* label = sord_get(
+ world->model, class_node, world->uris.rdfs_label, NULL, NULL);
+ if (!label) {
+ sord_node_free(world->world, parent);
continue;
}
- const SordNode* label_node = sord_iter_get_node(labels, SORD_OBJECT);
- const uint8_t* label = sord_node_get_string(label_node);
- sord_iter_free(labels);
-
LilvPluginClass* pclass = lilv_plugin_class_new(
- world, parent_node, class_node, (const char*)label);
+ world, parent, class_node,
+ (const char*)sord_node_get_string(label));
if (pclass) {
zix_tree_insert((ZixTree*)world->plugin_classes, pclass, NULL);
}
+
+ sord_node_free(world->world, label);
+ sord_node_free(world->world, parent);
}
sord_iter_free(classes);
}
@@ -756,19 +735,14 @@ lilv_world_load_all(LilvWorld* world)
(ZixTree*)world->plugins, p);
// ?new dc:replaces plugin
- SordIter* replacement = sord_search(
- world->model,
- NULL,
- world->uris.dc_replaces,
- lilv_node_as_node(lilv_plugin_get_uri(plugin)),
- NULL);
- if (!sord_iter_end(replacement)) {
- /* TODO: Check if replacement is actually a known plugin,
- though this is expensive...
- */
+ if (sord_ask(world->model,
+ NULL,
+ world->uris.dc_replaces,
+ lilv_node_as_node(lilv_plugin_get_uri(plugin)),
+ NULL)) {
+ // TODO: Check if replacement is a known plugin? (expensive)
((LilvPlugin*)plugin)->replaced = true;
}
- sord_iter_free(replacement);
}
// Query out things to cache