diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 36 | ||||
-rw-r--r-- | src/port.c | 12 | ||||
-rw-r--r-- | src/slv2_internal.h | 6 | ||||
-rw-r--r-- | src/world.c | 43 |
4 files changed, 38 insertions, 59 deletions
diff --git a/src/plugin.c b/src/plugin.c index 3e6f61d..986eed2 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -124,10 +124,8 @@ slv2_plugin_query_node(SLV2Plugin p, librdf_node* subject, librdf_node* predicat SLV2Values result = slv2_values_new(); FOREACH_MATCH(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); + librdf_node* node = MATCH_OBJECT(results); + SLV2Value value = slv2_value_new_librdf_node(p->world, node); if (value) raptor_sequence_push(result, value); } @@ -183,10 +181,8 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p) NULL); FOREACH_MATCH(ports) { - librdf_statement* s = librdf_stream_get_object(ports); - librdf_node* port = librdf_statement_get_object(s); - - SLV2Value symbol = slv2_plugin_get_unique( + librdf_node* port = MATCH_OBJECT(ports); + SLV2Value symbol = slv2_plugin_get_unique( p, librdf_new_node_from_node(port), librdf_new_node_from_node(p->world->lv2_symbol_node)); @@ -233,8 +229,7 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p) librdf_new_node_from_node(p->world->rdf_a_node), NULL); FOREACH_MATCH(types) { - librdf_node* type = librdf_statement_get_object( - librdf_stream_get_object(types)); + librdf_node* type = MATCH_OBJECT(types); if (librdf_node_is_resource(type)) { raptor_sequence_push( this_port->classes, @@ -349,9 +344,8 @@ slv2_plugin_get_library_uri(SLV2Plugin p) librdf_new_node_from_node(p->world->lv2_binary_node), NULL); FOREACH_MATCH(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); + librdf_node* binary_node = MATCH_OBJECT(results); + librdf_uri* binary_uri = librdf_node_get_uri(binary_node); if (binary_uri) { p->binary_uri = slv2_value_new_librdf_uri(p->world, binary_uri); @@ -383,9 +377,8 @@ slv2_plugin_get_class(SLV2Plugin p) librdf_new_node_from_node(p->world->rdf_a_node), NULL); FOREACH_MATCH(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); + librdf_node* class_node = librdf_new_node_from_node(MATCH_OBJECT(results)); + librdf_uri* class_uri = librdf_node_get_uri(class_node); if (!class_uri) { continue; @@ -639,9 +632,7 @@ slv2_plugin_has_latency(SLV2Plugin p) bool ret = false; FOREACH_MATCH(ports) { - librdf_statement* s = librdf_stream_get_object(ports); - librdf_node* port = librdf_statement_get_object(s); - + librdf_node* port = MATCH_OBJECT(ports); librdf_stream* reports_latency = slv2_plugin_find_statements( p, librdf_new_node_from_node(port), @@ -673,9 +664,7 @@ slv2_plugin_get_latency_port_index(SLV2Plugin p) uint32_t ret = 0; FOREACH_MATCH(ports) { - librdf_statement* s = librdf_stream_get_object(ports); - librdf_node* port = librdf_statement_get_object(s); - + librdf_node* port = MATCH_OBJECT(ports); librdf_stream* reports_latency = slv2_plugin_find_statements( p, librdf_new_node_from_node(port), @@ -850,8 +839,7 @@ slv2_plugin_get_uis(SLV2Plugin p) librdf_new_node_from_uri_string(p->world->world, NS_UI "ui"), NULL); FOREACH_MATCH(uis) { - librdf_statement* s = librdf_stream_get_object(uis); - librdf_node* ui = librdf_statement_get_object(s); + librdf_node* ui = MATCH_OBJECT(uis); SLV2Value type = slv2_plugin_get_unique( p, @@ -76,10 +76,8 @@ slv2_port_get_node(SLV2Plugin p, NULL); librdf_node* ret = NULL; FOREACH_MATCH(ports) { - librdf_statement* s = librdf_stream_get_object(ports); - librdf_node* node = librdf_statement_get_object(s); - - SLV2Value symbol = slv2_plugin_get_unique( + librdf_node* node = MATCH_OBJECT(ports); + SLV2Value symbol = slv2_plugin_get_unique( p, librdf_new_node_from_node(node), librdf_new_node_from_node(p->world->lv2_symbol_node)); @@ -148,8 +146,7 @@ slv2_values_from_stream_objects(SLV2Plugin p, librdf_stream* stream) values, slv2_value_new_librdf_node( p->world, - librdf_statement_get_object( - librdf_stream_get_object(stream)))); + MATCH_OBJECT(stream))); } END_MATCH(stream); return values; @@ -322,8 +319,7 @@ slv2_port_get_scale_points(SLV2Plugin p, ret = slv2_scale_points_new(); FOREACH_MATCH(points) { - librdf_statement* s = librdf_stream_get_object(points); - librdf_node* point = librdf_statement_get_object(s); + librdf_node* point = MATCH_OBJECT(points); SLV2Value value = slv2_plugin_get_unique( p, diff --git a/src/slv2_internal.h b/src/slv2_internal.h index 590c143..08d223f 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -46,6 +46,12 @@ extern "C" { #define FOREACH_MATCH(stream) \ for (; !librdf_stream_end(stream); librdf_stream_next(stream)) +#define MATCH_SUBJECT(stream) \ + librdf_statement_get_subject(librdf_stream_get_object(stream)) + +#define MATCH_OBJECT(stream) \ + librdf_statement_get_object(librdf_stream_get_object(stream)) + #define END_MATCH(stream) librdf_free_stream(stream) /* ********* PORT ********* */ diff --git a/src/world.c b/src/world.c index e179534..ace5de3 100644 --- a/src/world.c +++ b/src/world.c @@ -263,10 +263,8 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->dyn_manifest_node)); FOREACH_MATCH(dmanifests) { - librdf_statement* s = librdf_stream_get_object(dmanifests); - librdf_node* dmanifest = librdf_statement_get_subject(s); - - librdf_stream* binaries = slv2_world_find_statements( + librdf_node* dmanifest = MATCH_SUBJECT(dmanifests); + librdf_stream* binaries = slv2_world_find_statements( world, world->model, librdf_new_node_from_node(dmanifest), librdf_new_node_from_node(world->lv2_binary_node), @@ -323,8 +321,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_plugin_node)); FOREACH_MATCH(dyn_plugins) { - librdf_statement* s = librdf_stream_get_object(dyn_plugins); - librdf_node* plugin = librdf_statement_get_subject(s); + librdf_node* plugin = MATCH_SUBJECT(dyn_plugins); // Add ?plugin slv2:dynamic-manifest ?binary to dynamic model librdf_model_add( @@ -351,8 +348,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_plugin_node)); FOREACH_MATCH(results) { - librdf_statement* s = librdf_stream_get_object(results); - librdf_node* plugin = librdf_statement_get_subject(s); + librdf_node* plugin = MATCH_SUBJECT(results); // Add ?plugin rdfs:seeAlso <manifest.ttl> librdf_model_add( @@ -377,8 +373,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_specification_node)); FOREACH_MATCH(results) { - librdf_statement* s = librdf_stream_get_object(results); - librdf_node* spec = librdf_statement_get_subject(s); + librdf_node* spec = MATCH_SUBJECT(results); // Add ?specification rdfs:seeAlso <manifest.ttl> librdf_model_add( @@ -497,8 +492,7 @@ slv2_world_load_specifications(SLV2World world) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_specification_node)); FOREACH_MATCH(specs) { - librdf_statement* s = librdf_stream_get_object(specs); - librdf_node* spec_node = librdf_statement_get_subject(s); + librdf_node* spec_node = MATCH_SUBJECT(specs); librdf_stream* files = slv2_world_find_statements( world, world->model, @@ -506,9 +500,8 @@ slv2_world_load_specifications(SLV2World world) librdf_new_node_from_node(world->rdfs_seealso_node), NULL); FOREACH_MATCH(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); + librdf_node* file_node = MATCH_OBJECT(files); + librdf_uri* file_uri = librdf_node_get_uri(file_node); slv2_world_load_file(world, file_uri); } @@ -533,9 +526,8 @@ slv2_world_load_plugin_classes(SLV2World world) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->rdfs_class_node)); FOREACH_MATCH(classes) { - librdf_statement* s = librdf_stream_get_object(classes); - librdf_node* class_node = librdf_statement_get_subject(s); - librdf_uri* class_uri = librdf_node_get_uri(class_node); + librdf_node* class_node = MATCH_SUBJECT(classes); + librdf_uri* class_uri = librdf_node_get_uri(class_node); // Get parents (superclasses) librdf_stream* parents = slv2_world_find_statements( @@ -652,9 +644,8 @@ slv2_world_load_all(SLV2World world) librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_plugin_node)); FOREACH_MATCH(plugins) { - librdf_statement* s = librdf_stream_get_object(plugins); - librdf_node* plugin_node = librdf_statement_get_subject(s); - librdf_uri* plugin_uri = librdf_node_get_uri(plugin_node); + librdf_node* plugin_node = MATCH_SUBJECT(plugins); + librdf_uri* plugin_uri = librdf_node_get_uri(plugin_node); librdf_stream* bundles = slv2_world_find_statements( world, world->model, @@ -708,9 +699,8 @@ slv2_world_load_all(SLV2World world) librdf_new_node_from_node(world->slv2_dmanifest_node), NULL); FOREACH_MATCH(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); + librdf_node* lib_node = MATCH_OBJECT(dmanifests); + librdf_uri* lib_uri = librdf_node_get_uri(lib_node); if (dlopen( slv2_uri_to_path((const char*)librdf_uri_as_string(lib_uri)), @@ -727,9 +717,8 @@ slv2_world_load_all(SLV2World world) librdf_new_node_from_node(world->rdfs_seealso_node), NULL); FOREACH_MATCH(files) { - librdf_statement* s = librdf_stream_get_object(files); - librdf_node* file_node = librdf_statement_get_object(s); - librdf_uri* file_uri = librdf_node_get_uri(file_node); + librdf_node* file_node = MATCH_OBJECT(files); + librdf_uri* file_uri = librdf_node_get_uri(file_node); raptor_sequence_push(plugin->data_uris, slv2_value_new_librdf_uri(world, file_uri)); |