diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | lilv/lilv.h | 7 | ||||
-rw-r--r-- | src/port.c | 19 | ||||
-rw-r--r-- | test/lilv_test.c | 9 |
4 files changed, 29 insertions, 11 deletions
@@ -1,9 +1,10 @@ lilv (0.14.5) unstable; - * Disable timestamps in HTML documentation for reproducible build + * Support atom:supports in lilv_port_supports_event(). * Correctly depend on serd at build time (fix compilation in odd cases) + * Disable timestamps in HTML documentation for reproducible build - -- David Robillard <d@drobilla.net> Thu, 22 Nov 2012 21:35:53 -0500 + -- David Robillard <d@drobilla.net> Thu, 22 Nov 2012 21:47:57 -0500 lilv (0.14.4) stable; diff --git a/lilv/lilv.h b/lilv/lilv.h index 9e9a907..30bb3f5 100644 --- a/lilv/lilv.h +++ b/lilv/lilv.h @@ -1037,13 +1037,16 @@ lilv_port_has_property(const LilvPlugin* p, const LilvNode* property_uri); /** - Return whether a port is an event port and supports a certain event type. + Return whether a port supports a certain event type. + + More precisely, this returns true iff the port has an atom:supports or an + ev:supportsEvent property with @p event_type as the value. */ LILV_API bool lilv_port_supports_event(const LilvPlugin* p, const LilvPort* port, - const LilvNode* event_uri); + const LilvNode* event_type); /** Get the index of a port. @@ -20,6 +20,7 @@ #include <stdlib.h> #include <string.h> +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/event/event.h" #include "lilv_internal.h" @@ -81,11 +82,19 @@ lilv_port_supports_event(const LilvPlugin* p, const LilvPort* port, const LilvNode* event) { - return lilv_world_ask_internal( - p->world, - port->node, - sord_new_uri(p->world->world, (const uint8_t*)LV2_EVENT__supportsEvent), - lilv_node_as_node(event)); + const uint8_t* predicates[] = { (const uint8_t*)LV2_EVENT__supportsEvent, + (const uint8_t*)LV2_ATOM__supports, + NULL }; + + for (const uint8_t** pred = predicates; *pred; ++pred) { + if (lilv_world_ask_internal(p->world, + port->node, + sord_new_uri(p->world->world, *pred), + lilv_node_as_node(event))) { + return true; + } + } + return false; } static LilvNodes* diff --git a/test/lilv_test.c b/test/lilv_test.c index f08656f..0fade61 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -170,6 +170,7 @@ struct TestCase { TestFunc func; }; +#define PREFIX_ATOM "@prefix atom: <http://lv2plug.in/ns/ext/atom#> . \n" #define PREFIX_LINE "@prefix : <http://example.org/> .\n" #define PREFIX_LV2 "@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n" #define PREFIX_LV2EV "@prefix lv2ev: <http://lv2plug.in/ns/ext/event#> . \n" @@ -180,7 +181,7 @@ struct TestCase { #define PREFIX_DOAP "@prefix doap: <http://usefulinc.com/ns/doap#> .\n" #define MANIFEST_PREFIXES PREFIX_LINE PREFIX_LV2 PREFIX_RDFS -#define BUNDLE_PREFIXES PREFIX_LINE PREFIX_LV2 PREFIX_RDF PREFIX_RDFS PREFIX_FOAF PREFIX_DOAP +#define BUNDLE_PREFIXES PREFIX_ATOM PREFIX_LINE PREFIX_LV2 PREFIX_RDF PREFIX_RDFS PREFIX_FOAF PREFIX_DOAP #define PLUGIN_NAME(name) "doap:name \"" name "\"" #define LICENSE_GPL "doap:license <http://usefulinc.com/doap/licenses/gpl>" @@ -756,7 +757,8 @@ test_port(void) " a lv2:EventPort ; a lv2:InputPort ; " " lv2:index 1 ; lv2:symbol \"event_in\" ; " " lv2:name \"Event Input\" ; " - " lv2ev:supportsEvent <http://example.org/event> " + " lv2ev:supportsEvent <http://example.org/event> ;" + " atom:supports <http://example.org/atomEvent> " "] .")) return 0; @@ -906,8 +908,10 @@ test_port(void) LilvNode* event_type = lilv_new_uri(world, "http://example.org/event"); LilvNode* event_type_2 = lilv_new_uri(world, "http://example.org/otherEvent"); + LilvNode* atom_event = lilv_new_uri(world, "http://example.org/atomEvent"); TEST_ASSERT(lilv_port_supports_event(plug, ep, event_type)); TEST_ASSERT(!lilv_port_supports_event(plug, ep, event_type_2)); + TEST_ASSERT(lilv_port_supports_event(plug, ep, atom_event)); LilvNode* name_p = lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#name"); LilvNodes* names = lilv_port_get_value(plug, p, name_p); @@ -941,6 +945,7 @@ test_port(void) lilv_node_free(toggled_prop); lilv_node_free(event_type); lilv_node_free(event_type_2); + lilv_node_free(atom_event); lilv_node_free(min); lilv_node_free(max); |