summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--slv2/slv2.h10
-rw-r--r--src/query.c2
-rw-r--r--src/slv2_internal.h7
-rw-r--r--src/world.c89
4 files changed, 69 insertions, 39 deletions
diff --git a/slv2/slv2.h b/slv2/slv2.h
index b55cc16..5536740 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -532,9 +532,17 @@ slv2_world_new(void);
#define SLV2_OPTION_FILTER_LANG "http://drobilla.net/ns/slv2#filter-lang"
/**
+ Enable/disable dynamic manifest support.
+ Dynamic manifest data will only be loaded if this option is true.
+*/
+#define SLV2_OPTION_DYN_MANIFEST "http://drobilla.net/ns/slv2#dyn-manifest"
+
+/**
Set an SLV2 option for @a world.
- Currently recognized options: SLV2_OPTION_FILTER_LANG.
+ Currently recognized options:
+ @ref SLV2_OPTION_FILTER_LANG
+ @ref SLV2_OPTION_DYN_MANIFEST
*/
SLV2_API
void
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(