diff options
author | David Robillard <d@drobilla.net> | 2011-03-17 07:11:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-03-17 07:11:45 +0000 |
commit | 17f6705ae6d0e8c7202f598f5271786a00a065be (patch) | |
tree | de6c70bfb79ed8dfa034b198003c587e384e3bca /src | |
parent | e0c2436504f43c844aded3b021c6bcdd48bbf9cc (diff) | |
download | lilv-17f6705ae6d0e8c7202f598f5271786a00a065be.tar.gz lilv-17f6705ae6d0e8c7202f598f5271786a00a065be.tar.bz2 lilv-17f6705ae6d0e8c7202f598f5271786a00a065be.zip |
Add SLV2_OPTION_DYN_MANIFEST to dynamically enable/disable dyn-manifest.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3106 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/query.c | 2 | ||||
-rw-r--r-- | src/slv2_internal.h | 7 | ||||
-rw-r--r-- | src/world.c | 89 |
3 files changed, 60 insertions, 38 deletions
diff --git a/src/query.c b/src/query.c index 99c91d9..ab32c1c 100644 --- a/src/query.c +++ b/src/query.c @@ -143,7 +143,7 @@ slv2_values_from_stream_objects(SLV2Plugin p, if (slv2_matches_end(stream)) { slv2_match_end(stream); return NULL; - } else if (p->world->filter_language) { + } else if (p->world->opt.filter_language) { return slv2_values_from_stream_objects_i18n(p, stream); } else { SLV2Values values = slv2_values_new(); diff --git a/src/slv2_internal.h b/src/slv2_internal.h index c6b8a41..d24d570 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -221,6 +221,11 @@ void slv2_plugin_classes_free(); /* ********* World ********* */ +typedef struct { + bool dyn_manifest; + bool filter_language; +} SLV2Options; + /** Model of LV2 (RDF) data loaded from bundles. */ struct _SLV2World { @@ -259,7 +264,7 @@ struct _SLV2World { SLV2Node xsd_integer_node; SLV2Value doap_name_val; SLV2Value lv2_name_val; - bool filter_language; + SLV2Options opt; }; const uint8_t* diff --git a/src/world.c b/src/world.c index 9983ded..6209c8c 100644 --- a/src/world.c +++ b/src/world.c @@ -112,8 +112,9 @@ slv2_world_new() slv2_world_set_prefix(world, "lv2", "http://lv2plug.in/ns/lv2core#"); slv2_world_set_prefix(world, "lv2ev", "http://lv2plug.in/ns/ext/event#"); - world->n_read_files = 0; - world->filter_language = true; + world->n_read_files = 0; + world->opt.filter_language = true; + world->opt.dyn_manifest = true; return world; @@ -184,14 +185,18 @@ slv2_world_set_option(SLV2World world, const char* option, const SLV2Value value) { - if (!strcmp(option, SLV2_OPTION_FILTER_LANG)) { + if (!strcmp(option, SLV2_OPTION_DYN_MANIFEST)) { if (slv2_value_is_bool(value)) { - world->filter_language = slv2_value_as_bool(value); + world->opt.dyn_manifest = slv2_value_as_bool(value); + return; + } + } else if (!strcmp(option, SLV2_OPTION_FILTER_LANG)) { + if (slv2_value_is_bool(value)) { + world->opt.filter_language = slv2_value_as_bool(value); return; } - } else { - SLV2_WARNF("Unrecognized or invalid option `%s'\n", option); } + SLV2_WARNF("Unrecognized or invalid option `%s'\n", option); } static SLV2Matches @@ -316,39 +321,16 @@ slv2_world_add_plugin(SLV2World world, slv2_sequence_insert(world->plugins, plugin); } -SLV2_API -void -slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) +static void +slv2_world_load_dyn_manifest(SLV2World world, + const SordNode bundle_node, + SerdNode manifest_uri) { - if (!slv2_value_is_uri(bundle_uri)) { - SLV2_ERROR("Bundle 'URI' is not a URI\n"); +#ifdef SLV2_DYN_MANIFEST + if (!world->opt.dyn_manifest) { return; } - const SordNode bundle_node = bundle_uri->val.uri_val; - - SerdNode manifest_uri = slv2_new_uri_relative_to_base( - (const uint8_t*)"manifest.ttl", - (const uint8_t*)sord_node_get_string(bundle_node)); - - sord_read_file(world->model, manifest_uri.buf, bundle_node, - slv2_world_blank_node_prefix(world)); - - // ?plugin a lv2:Plugin - SLV2Matches plug_results = slv2_world_find_statements( - world, world->model, - NULL, - world->rdf_a_node, - world->lv2_plugin_node, - bundle_node); - FOREACH_MATCH(plug_results) { - SLV2Node plugin_node = slv2_match_subject(plug_results); - slv2_world_add_plugin(world, plugin_node, - &manifest_uri, NULL, bundle_node); - } - slv2_match_end(plug_results); - -#ifdef SLV2_DYN_MANIFEST typedef void* LV2_Dyn_Manifest_Handle; LV2_Dyn_Manifest_Handle handle = NULL; @@ -372,7 +354,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) if (slv2_matches_end(binaries)) { slv2_match_end(binaries); SLV2_ERRORF("Dynamic manifest in <%s> has no binaries, ignored\n", - slv2_value_as_uri(bundle_uri)); + sord_node_get_string(bundle_node)); continue; } @@ -441,6 +423,41 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) } slv2_match_end(dmanifests); #endif // SLV2_DYN_MANIFEST +} + +SLV2_API +void +slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) +{ + if (!slv2_value_is_uri(bundle_uri)) { + SLV2_ERROR("Bundle 'URI' is not a URI\n"); + return; + } + + const SordNode bundle_node = bundle_uri->val.uri_val; + + SerdNode manifest_uri = slv2_new_uri_relative_to_base( + (const uint8_t*)"manifest.ttl", + (const uint8_t*)sord_node_get_string(bundle_node)); + + sord_read_file(world->model, manifest_uri.buf, bundle_node, + slv2_world_blank_node_prefix(world)); + + // ?plugin a lv2:Plugin + SLV2Matches plug_results = slv2_world_find_statements( + world, world->model, + NULL, + world->rdf_a_node, + world->lv2_plugin_node, + bundle_node); + FOREACH_MATCH(plug_results) { + SLV2Node plugin_node = slv2_match_subject(plug_results); + slv2_world_add_plugin(world, plugin_node, + &manifest_uri, NULL, bundle_node); + } + slv2_match_end(plug_results); + + slv2_world_load_dyn_manifest(world, bundle_node, manifest_uri); // ?specification a lv2:Specification SLV2Matches spec_results = slv2_world_find_statements( |