summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-03-19 14:22:42 +0000
committerDavid Robillard <d@drobilla.net>2008-03-19 14:22:42 +0000
commitca0ea9f5758a6ae27684888d2e33e801e5dfe682 (patch)
tree7961037992bb31b5927505d3b8f53257ab924505
parent49ddf1af831493cb34a44c35781f3323916314af (diff)
downloadlilv-ca0ea9f5758a6ae27684888d2e33e801e5dfe682.tar.gz
lilv-ca0ea9f5758a6ae27684888d2e33e801e5dfe682.tar.bz2
lilv-ca0ea9f5758a6ae27684888d2e33e801e5dfe682.zip
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
-rw-r--r--src/plugin.c30
-rw-r--r--src/value.c3
2 files changed, 30 insertions, 3 deletions
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 : <http://lv2plug.in/ns/lv2core#>\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);