diff options
author | David Robillard <d@drobilla.net> | 2012-11-23 05:59:09 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-11-23 05:59:09 +0000 |
commit | 6ce5332b4e27d4fec3ed317386ea6839d217f7fd (patch) | |
tree | 2bef8a76b9c46bbe3491fcf268f9c1b3c08151dd /src/plugin.c | |
parent | c28f70ab84dcbc2a185b1dc9577ea97cb1042701 (diff) | |
download | lilv-6ce5332b4e27d4fec3ed317386ea6839d217f7fd.tar.gz lilv-6ce5332b4e27d4fec3ed317386ea6839d217f7fd.tar.bz2 lilv-6ce5332b4e27d4fec3ed317386ea6839d217f7fd.zip |
Add lilv_nodes_merge() to API (address part of #835).
More lightweight version of lilv_plugin_has_feature() and lilv_world_find_nodes().
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4860 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/plugin.c')
-rw-r--r-- | src/plugin.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/src/plugin.c b/src/plugin.c index 9912112..c284d98 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -680,13 +680,17 @@ bool lilv_plugin_has_feature(const LilvPlugin* p, const LilvNode* feature) { - LilvNodes* features = lilv_plugin_get_supported_features(p); + const SordNode* predicates[] = { p->world->uris.lv2_requiredFeature, + p->world->uris.lv2_optionalFeature, + NULL }; - const bool ret = (features && feature - && lilv_nodes_contains(features, feature)); - - lilv_nodes_free(features); - return ret; + for (const SordNode** pred = predicates; *pred; ++pred) { + if (lilv_world_ask_internal( + p->world, p->plugin_uri->node, *pred, feature->node)) { + return true; + } + } + return false; } LILV_API @@ -695,20 +699,9 @@ lilv_plugin_get_supported_features(const LilvPlugin* p) { LilvNodes* optional = lilv_plugin_get_optional_features(p); LilvNodes* required = lilv_plugin_get_required_features(p); - LilvNodes* result = lilv_nodes_new(); - - LILV_FOREACH(nodes, i, optional) - zix_tree_insert((ZixTree*)result, - lilv_node_duplicate(lilv_nodes_get(optional, i)), - NULL); - LILV_FOREACH(nodes, i, required) - zix_tree_insert((ZixTree*)result, - lilv_node_duplicate(lilv_nodes_get(required, i)), - NULL); - + LilvNodes* result = lilv_nodes_merge(optional, required); lilv_nodes_free(optional); lilv_nodes_free(required); - return result; } @@ -716,16 +709,20 @@ LILV_API LilvNodes* lilv_plugin_get_optional_features(const LilvPlugin* p) { - return lilv_plugin_get_value_internal( - p, p->world->uris.lv2_optionalFeature); + return lilv_world_query_values_internal(p->world, + p->plugin_uri->node, + p->world->uris.lv2_optionalFeature, + NULL); } LILV_API LilvNodes* lilv_plugin_get_required_features(const LilvPlugin* p) { - return lilv_plugin_get_value_internal( - p, p->world->uris.lv2_requiredFeature); + return lilv_world_query_values_internal(p->world, + p->plugin_uri->node, + p->world->uris.lv2_requiredFeature, + NULL); } LILV_API |