summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-29 23:38:18 +0000
committerDavid Robillard <d@drobilla.net>2011-01-29 23:38:18 +0000
commit801876c89ef1e4dcd16f5c5f9c29416b78ac15c4 (patch)
tree7d5213af6e779033d591cd2ad093558a1f99a824 /src
parent1c040fd172230496d655ddce6033e8daa9ffa023 (diff)
downloadlilv-801876c89ef1e4dcd16f5c5f9c29416b78ac15c4.tar.gz
lilv-801876c89ef1e4dcd16f5c5f9c29416b78ac15c4.tar.bz2
lilv-801876c89ef1e4dcd16f5c5f9c29416b78ac15c4.zip
Use consistent (and terser) for loop idiom for iterating over librdf streams.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2860 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c19
-rw-r--r--src/world.c50
2 files changed, 26 insertions, 43 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 716e321..08e873c 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -123,15 +123,13 @@ slv2_plugin_query_node(SLV2Plugin p, librdf_node* subject, librdf_node* predicat
}
SLV2Values result = slv2_values_new();
- while (!librdf_stream_end(results)) {
+ for (; !librdf_stream_end(results); librdf_stream_next(results)) {
librdf_statement* s = librdf_stream_get_object(results);
librdf_node* value_node = librdf_statement_get_object(s);
SLV2Value value = slv2_value_new_librdf_node(p->world, value_node);
if (value)
raptor_sequence_push(result, value);
-
- librdf_stream_next(results);
}
librdf_free_stream(results);
@@ -184,7 +182,7 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p)
librdf_new_node_from_node(p->world->lv2_port_node),
NULL);
- while (!librdf_stream_end(ports)) {
+ for (; !librdf_stream_end(ports); librdf_stream_next(ports)) {
librdf_statement* s = librdf_stream_get_object(ports);
librdf_node* port = librdf_statement_get_object(s);
@@ -234,7 +232,7 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p)
librdf_new_node_from_node(port),
librdf_new_node_from_node(p->world->rdf_a_node),
NULL);
- while (!librdf_stream_end(types)) {
+ for (; !librdf_stream_end(types); librdf_stream_next(types)) {
librdf_node* type = librdf_statement_get_object(
librdf_stream_get_object(types));
if (librdf_node_is_resource(type)) {
@@ -244,7 +242,6 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p)
} else {
SLV2_WARN("port has non-URI rdf:type\n");
}
- librdf_stream_next(types);
}
librdf_free_stream(types);
@@ -259,8 +256,6 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p)
p->ports = NULL;
}
break; // Invalid plugin
- } else {
- librdf_stream_next(ports);
}
}
librdf_free_stream(ports);
@@ -353,7 +348,7 @@ slv2_plugin_get_library_uri(SLV2Plugin p)
librdf_new_node_from_uri(p->world->world, p->plugin_uri->val.uri_val),
librdf_new_node_from_node(p->world->lv2_binary_node),
NULL);
- while (!librdf_stream_end(results)) {
+ for (; !librdf_stream_end(results); librdf_stream_next(results)) {
librdf_statement* s = librdf_stream_get_object(results);
librdf_node* binary_node = librdf_statement_get_object(s);
librdf_uri* binary_uri = librdf_node_get_uri(binary_node);
@@ -362,8 +357,6 @@ slv2_plugin_get_library_uri(SLV2Plugin p)
p->binary_uri = slv2_value_new_librdf_uri(p->world, binary_uri);
break;
}
-
- librdf_stream_next(results);
}
librdf_free_stream(results);
}
@@ -389,13 +382,12 @@ slv2_plugin_get_class(SLV2Plugin p)
librdf_new_node_from_uri(p->world->world, p->plugin_uri->val.uri_val),
librdf_new_node_from_node(p->world->rdf_a_node),
NULL);
- while (!librdf_stream_end(results)) {
+ for (; !librdf_stream_end(results); librdf_stream_next(results)) {
librdf_statement* s = librdf_stream_get_object(results);
librdf_node* class_node = librdf_new_node_from_node(librdf_statement_get_object(s));
librdf_uri* class_uri = librdf_node_get_uri(class_node);
if (!class_uri) {
- librdf_stream_next(results);
continue;
}
@@ -416,7 +408,6 @@ slv2_plugin_get_class(SLV2Plugin p)
}
slv2_value_free(class);
- librdf_stream_next(results);
}
if (p->plugin_class == NULL)
diff --git a/src/world.c b/src/world.c
index 893d39c..53bee59 100644
--- a/src/world.c
+++ b/src/world.c
@@ -312,7 +312,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
NULL,
librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_plugin_node));
- while (!librdf_stream_end(dyn_plugins)) {
+ for (; !librdf_stream_end(dyn_plugins); librdf_stream_next(dyn_plugins)) {
librdf_statement* s = librdf_stream_get_object(dyn_plugins);
librdf_node* plugin = librdf_statement_get_subject(s);
@@ -340,7 +340,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
NULL,
librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_plugin_node));
- while (!librdf_stream_end(results)) {
+ for (; !librdf_stream_end(results); librdf_stream_next(results)) {
librdf_statement* s = librdf_stream_get_object(results);
librdf_node* plugin = librdf_statement_get_subject(s);
@@ -357,8 +357,6 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
librdf_new_node_from_node(plugin),
librdf_new_node_from_uri_string(world->world, SLV2_NS_SLV2 "bundleURI"),
librdf_new_node_from_uri(world->world, bundle_uri->val.uri_val));
-
- librdf_stream_next(results);
}
librdf_free_stream(results);
@@ -368,7 +366,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
NULL,
librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_specification_node));
- while (!librdf_stream_end(results)) {
+ for (; !librdf_stream_end(results); librdf_stream_next(results)) {
librdf_statement* s = librdf_stream_get_object(results);
librdf_node* spec = librdf_statement_get_subject(s);
@@ -385,8 +383,6 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
librdf_new_node_from_node(spec),
librdf_new_node_from_uri_string(world->world, SLV2_NS_SLV2 "bundleURI"),
librdf_new_node_from_uri(world->world, bundle_uri->val.uri_val));
-
- librdf_stream_next(results);
}
librdf_free_stream(results);
@@ -490,7 +486,7 @@ slv2_world_load_specifications(SLV2World world)
NULL,
librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_specification_node));
- while (!librdf_stream_end(specs)) {
+ for (; !librdf_stream_end(specs); librdf_stream_next(specs)) {
librdf_statement* s = librdf_stream_get_object(specs);
librdf_node* spec_node = librdf_statement_get_subject(s);
@@ -499,18 +495,14 @@ slv2_world_load_specifications(SLV2World world)
librdf_new_node_from_node(spec_node),
librdf_new_node_from_node(world->rdfs_seealso_node),
NULL);
- while (!librdf_stream_end(files)) {
+ for (; !librdf_stream_end(files); librdf_stream_next(files)) {
librdf_statement* t = librdf_stream_get_object(files);
librdf_node* file_node = librdf_statement_get_object(t);
librdf_uri* file_uri = librdf_node_get_uri(file_node);
slv2_world_load_file(world, file_uri);
-
- librdf_stream_next(files);
}
librdf_free_stream(files);
-
- librdf_stream_next(specs);
}
librdf_free_stream(specs);
}
@@ -700,23 +692,23 @@ slv2_world_load_all(SLV2World world)
#ifdef SLV2_DYN_MANIFEST
{
- librdf_stream* dmanifests = slv2_world_find_statements(
- world, world->model,
- librdf_new_node_from_node(plugin_node),
- librdf_new_node_from_node(world->slv2_dmanifest_node),
- NULL);
- for (; !librdf_stream_end(dmanifests); librdf_stream_next(dmanifests)) {
- librdf_statement* s = librdf_stream_get_object(dmanifests);
- librdf_node* lib_node = librdf_statement_get_object(s);
- librdf_uri* lib_uri = librdf_node_get_uri(lib_node);
-
- if (dlopen(
- slv2_uri_to_path((const char*)librdf_uri_as_string(lib_uri)),
- RTLD_LAZY)) {
- plugin->dynman_uri = slv2_value_new_librdf_uri(world, lib_uri);
- }
+ librdf_stream* dmanifests = slv2_world_find_statements(
+ world, world->model,
+ librdf_new_node_from_node(plugin_node),
+ librdf_new_node_from_node(world->slv2_dmanifest_node),
+ NULL);
+ for (; !librdf_stream_end(dmanifests); librdf_stream_next(dmanifests)) {
+ librdf_statement* s = librdf_stream_get_object(dmanifests);
+ librdf_node* lib_node = librdf_statement_get_object(s);
+ librdf_uri* lib_uri = librdf_node_get_uri(lib_node);
+
+ if (dlopen(
+ slv2_uri_to_path((const char*)librdf_uri_as_string(lib_uri)),
+ RTLD_LAZY)) {
+ plugin->dynman_uri = slv2_value_new_librdf_uri(world, lib_uri);
}
- librdf_free_stream(dmanifests);
+ }
+ librdf_free_stream(dmanifests);
}
#endif
librdf_stream* files = slv2_world_find_statements(