diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 9 | ||||
-rw-r--r-- | src/port.c | 30 | ||||
-rw-r--r-- | src/slv2_internal.h | 3 | ||||
-rw-r--r-- | src/world.c | 10 |
4 files changed, 35 insertions, 17 deletions
diff --git a/src/plugin.c b/src/plugin.c index 0224b60..2bdae5c 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -381,7 +381,7 @@ slv2_plugin_verify(SLV2Plugin plugin) } slv2_values_free(results); - results = slv2_plugin_get_value_by_qname(plugin, "doap:name"); + results = slv2_plugin_get_value(plugin, plugin->world->doap_name_val); if (!results) { return false; } @@ -406,9 +406,10 @@ SLV2_API SLV2Value slv2_plugin_get_name(SLV2Plugin plugin) { - SLV2Values results = slv2_plugin_get_value_by_qname(plugin, "doap:name"); - SLV2Value ret = NULL; + SLV2Values results = slv2_plugin_get_value(plugin, + plugin->world->doap_name_val); + SLV2Value ret = NULL; if (results) { SLV2Value val = slv2_values_get_at(results, 0); if (slv2_value_is_string(val)) @@ -418,7 +419,7 @@ slv2_plugin_get_name(SLV2Plugin plugin) if (!ret) SLV2_WARNF("<%s> has no (mandatory) doap:name\n", - slv2_value_as_string(slv2_plugin_get_uri(plugin))); + slv2_value_as_string(slv2_plugin_get_uri(plugin))); return ret; } @@ -199,19 +199,21 @@ SLV2Value slv2_port_get_name(SLV2Plugin p, SLV2Port port) { - SLV2Value ret = NULL; - SLV2Values results = slv2_port_get_value_by_qname(p, port, "lv2:name"); - - if (results && slv2_values_size(results) > 0) { - ret = slv2_value_duplicate(slv2_values_get_at(results, 0)); - } else { - results = slv2_port_get_value_by_qname(p, port, "lv2:name"); - if (results && slv2_values_size(results) > 0) - ret = slv2_value_duplicate(slv2_values_get_at(results, 0)); + SLV2Values results = slv2_port_get_value(p, port, + p->world->lv2_name_val); + + SLV2Value ret = NULL; + if (results) { + SLV2Value val = slv2_values_get_at(results, 0); + if (slv2_value_is_string(val)) + ret = slv2_value_duplicate(val); + slv2_values_free(results); } - slv2_values_free(results); - + if (!ret) + SLV2_WARNF("<%s> has no (mandatory) doap:name\n", + slv2_value_as_string(slv2_plugin_get_uri(p))); + return ret; } @@ -301,6 +303,10 @@ SLV2Values slv2_port_get_properties(SLV2Plugin p, SLV2Port port) { - return slv2_port_get_value_by_qname(p, port, "lv2:portProperty"); + SLV2Value pred = slv2_value_new_from_node( + p->world, p->world->lv2_portproperty_node); + SLV2Values ret = slv2_port_get_value(p, port, pred); + slv2_value_free(pred); + return ret; } diff --git a/src/slv2_internal.h b/src/slv2_internal.h index 12a32a0..4424467 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -40,6 +40,7 @@ extern "C" { #include "lv2/lv2plug.in/ns/ext/dyn-manifest/dyn-manifest.h" #endif +#define SLV2_NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#" #define SLV2_NS_RDFS (const uint8_t*)"http://www.w3.org/2000/01/rdf-schema#" #define SLV2_NS_SLV2 (const uint8_t*)"http://drobilla.net/ns/slv2#" #define SLV2_NS_LV2 (const uint8_t*)"http://lv2plug.in/ns/lv2core#" @@ -202,6 +203,8 @@ struct _SLV2World { SLV2Node slv2_dmanifest_node; SLV2Node xsd_integer_node; SLV2Node xsd_decimal_node; + SLV2Value doap_name_val; + SLV2Value lv2_name_val; bool filter_language; }; diff --git a/src/world.c b/src/world.c index ae04b17..6cb0bad 100644 --- a/src/world.c +++ b/src/world.c @@ -56,7 +56,9 @@ slv2_world_new() #define NS_DYNMAN (const uint8_t*)"http://lv2plug.in/ns/ext/dynmanifest#" -#define NEW_URI(uri) sord_get_uri(world->model, true, uri) +#define NEW_URI(uri) sord_get_uri(world->model, true, uri) +#define NEW_URI_VAL(uri) slv2_value_new_from_node( \ + world,sord_get_uri(world->model, true, uri)); world->dyn_manifest_node = NEW_URI(NS_DYNMAN "DynManifest"); world->lv2_specification_node = NEW_URI(SLV2_NS_LV2 "Specification"); @@ -81,6 +83,9 @@ slv2_world_new() world->xsd_integer_node = NEW_URI(SLV2_NS_XSD "integer"); world->xsd_decimal_node = NEW_URI(SLV2_NS_XSD "decimal"); + world->doap_name_val = NEW_URI_VAL(SLV2_NS_DOAP "name"); + world->lv2_name_val = NEW_URI_VAL(SLV2_NS_LV2 "name"); + world->lv2_plugin_class = slv2_plugin_class_new( world, NULL, world->lv2_plugin_node, "Plugin"); assert(world->lv2_plugin_class); @@ -133,6 +138,9 @@ slv2_world_free(SLV2World world) slv2_node_free(world->xsd_integer_node); slv2_node_free(world->xsd_decimal_node); + slv2_value_free(world->doap_name_val); + slv2_value_free(world->lv2_name_val); + for (unsigned i = 0; i < ((GPtrArray*)world->plugins)->len; ++i) slv2_plugin_free(g_ptr_array_index((GPtrArray*)world->plugins, i)); g_ptr_array_unref(world->plugins); |