From ca0ea9f5758a6ae27684888d2e33e801e5dfe682 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 19 Mar 2008 14:22:42 +0000 Subject: Support plugins where lv2:binary is not in manifest.ttl git-svn-id: http://svn.drobilla.net/lad/slv2@1174 a436a847-0d15-0410-975c-d299462d15a1 --- src/plugin.c | 30 +++++++++++++++++++++++++++--- src/value.c | 3 +++ 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugin.c b/src/plugin.c index ed90490..f77b94a 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -133,8 +133,8 @@ slv2_plugin_load(SLV2Plugin p) librdf_query_results* results = librdf_query_execute(q, p->rdf); while (!librdf_query_results_finished(results)) { - librdf_node* class_node = librdf_query_results_get_binding_value(results, 0); - librdf_uri* class_uri = librdf_node_get_uri(class_node); + librdf_node* class_node = librdf_query_results_get_binding_value(results, 0); + librdf_uri* class_uri = librdf_node_get_uri(class_node); SLV2Value class = slv2_value_new_librdf_uri(p->world, class_uri); @@ -236,6 +236,29 @@ slv2_plugin_load(SLV2Plugin p) librdf_free_query_results(results); librdf_free_query(q); + // Load binary URI + query = (const unsigned char*) + "PREFIX : \n" + "SELECT ?binary WHERE { <> :binary ?binary . }"; + + q = librdf_new_query(p->world->world, "sparql", + NULL, query, slv2_value_as_librdf_uri(p->plugin_uri)); + + results = librdf_query_execute(q, p->rdf); + + if (!librdf_query_results_finished(results)) { + librdf_node* binary_node = librdf_query_results_get_binding_value(results, 0); + librdf_uri* binary_uri = librdf_node_get_uri(binary_node); + + SLV2Value binary = slv2_value_new_librdf_uri(p->world, binary_uri); + p->binary_uri = binary; + + librdf_free_node(binary_node); + } + + librdf_free_query_results(results); + librdf_free_query(q); + //printf("%p %s: NUM PORTS: %d\n", (void*)p, p->plugin_uri, slv2_plugin_get_num_ports(p)); } @@ -262,7 +285,8 @@ SLV2Value slv2_plugin_get_library_uri(SLV2Plugin p) { assert(p); - assert(p->binary_uri); + if (!p->binary_uri && !p->rdf) + slv2_plugin_load(p); return p->binary_uri; } diff --git a/src/value.c b/src/value.c index f1d2731..6eeef04 100644 --- a/src/value.c +++ b/src/value.c @@ -122,6 +122,9 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node) SLV2Value slv2_value_new_librdf_uri(SLV2World world, librdf_uri* uri) { + if (!uri) + return NULL; + SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value)); val->type = SLV2_VALUE_URI; val->val.uri_val = librdf_new_uri_from_uri(uri); -- cgit v1.2.1