summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lilv/lilv.h10
-rw-r--r--src/plugin.c35
-rw-r--r--test/lilv_test.c11
3 files changed, 55 insertions, 1 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h
index d5e0c8f..e748d1d 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -786,7 +786,15 @@ LilvNodes*
lilv_plugin_get_optional_features(const LilvPlugin* p);
/**
- Get the extension data implemented by a plugin.
+ Return whether or not a plugin provides a specific extension data.
+*/
+LILV_API
+bool
+lilv_plugin_has_extension_data(const LilvPlugin* p,
+ const LilvNode* uri);
+
+/**
+ Get a sequence of all extension data provided by a plugin.
This can be used to find which URIs lilv_instance_get_extension_data()
will return a value for without instantiating the plugin.
*/
diff --git a/src/plugin.c b/src/plugin.c
index 9fba6f4..88732d1 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -268,6 +268,17 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
}
}
lilv_match_end(ports);
+
+ // Check sanity
+ for (uint32_t i = 0; i < p->num_ports; ++i) {
+ if (!p->ports[i]) {
+ LILV_ERRORF("Plugin <%s> is missing port %d/%d\n",
+ lilv_node_as_uri(p->plugin_uri), i, p->num_ports);
+ free(p->ports);
+ p->ports = NULL;
+ p->num_ports = 0;
+ }
+ }
}
}
@@ -645,6 +656,30 @@ lilv_plugin_get_required_features(const LilvPlugin* p)
}
LILV_API
+bool
+lilv_plugin_has_extension_data(const LilvPlugin* p,
+ const LilvNode* uri)
+{
+ if (!lilv_node_is_uri(uri)) {
+ LILV_ERRORF("Extension data `%s' is not a URI\n", uri->str_val);
+ return false;
+ }
+
+ SordIter* iter = lilv_world_query_internal(
+ p->world,
+ p->plugin_uri->val.uri_val,
+ p->world->lv2_extensionData_val->val.uri_val,
+ uri->val.uri_val);
+
+ if (iter) {
+ sord_iter_free(iter);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+LILV_API
LilvNodes*
lilv_plugin_get_extension_data(const LilvPlugin* p)
{
diff --git a/test/lilv_test.c b/test/lilv_test.c
index 85f91da..2e17fb5 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -468,6 +468,7 @@ test_plugin(void)
LICENSE_GPL " ; "
"lv2:optionalFeature lv2:hardRTCapable ; "
"lv2:requiredFeature <http://lv2plug.in/ns/ext/event> ; "
+ "lv2:extensionData <http://example.org/extdata> ;"
":foo 1.6180 ; "
":bar true ; "
":baz false ; "
@@ -637,6 +638,16 @@ test_plugin(void)
TEST_ASSERT(lilv_uis_size(uis) == 0);
lilv_uis_free(uis);
+ LilvNode* extdata = lilv_new_uri(world, "http://example.org/extdata");
+ LilvNode* noextdata = lilv_new_uri(world, "http://example.org/noextdata");
+ LilvNodes* extdatas = lilv_plugin_get_extension_data(plug);
+ TEST_ASSERT(lilv_plugin_has_extension_data(plug, extdata));
+ TEST_ASSERT(!lilv_plugin_has_extension_data(plug, noextdata));
+ TEST_ASSERT(lilv_nodes_size(extdatas) == 1);
+ TEST_ASSERT(lilv_node_equals(lilv_nodes_get_first(extdatas), extdata));
+ lilv_node_free(extdata);
+ lilv_nodes_free(extdatas);
+
lilv_nodes_free(thing_names);
lilv_node_free(thing_uri);
lilv_node_free(name_p);