summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-19 00:46:59 +0000
committerDavid Robillard <d@drobilla.net>2007-02-19 00:46:59 +0000
commitd3d736deba06ca2ef655858ac22d8267c5cc6363 (patch)
tree1f21bcdb93d2935a3641c7e150771688bb1b63bb /src
parent0153919a422e7a520c38f9cd01e9a079f73c80fd (diff)
downloadlilv-d3d736deba06ca2ef655858ac22d8267c5cc6363.tar.gz
lilv-d3d736deba06ca2ef655858ac22d8267c5cc6363.tar.bz2
lilv-d3d736deba06ca2ef655858ac22d8267c5cc6363.zip
Header/API cleanups.
Removed public exposure of raptor/rasqal. Redefined opaque types properly. git-svn-id: http://svn.drobilla.net/lad/slv2@317 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/library.c2
-rw-r--r--src/plugin.c49
-rw-r--r--src/plugininstance.c6
-rw-r--r--src/pluginlist.c8
-rw-r--r--src/port.c38
-rw-r--r--src/private_types.h5
-rw-r--r--src/query.c40
-rw-r--r--src/stringlist.c17
8 files changed, 69 insertions, 96 deletions
diff --git a/src/library.c b/src/library.c
index 591218d..45f298c 100644
--- a/src/library.c
+++ b/src/library.c
@@ -17,9 +17,9 @@
*/
#include "config.h"
+#include <rasqal.h>
#include <slv2/slv2.h>
-
raptor_uri* slv2_ontology_uri = NULL;
diff --git a/src/plugin.c b/src/plugin.c
index 6571326..8918fa3 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -24,14 +24,13 @@
#include <rasqal.h>
#include <slv2/plugin.h>
#include <slv2/types.h>
-#include <slv2/query.h>
#include <slv2/util.h>
#include <slv2/stringlist.h>
#include "private_types.h"
-SLV2Plugin*
-slv2_plugin_duplicate(const SLV2Plugin* p)
+SLV2Plugin
+slv2_plugin_duplicate(SLV2Plugin p)
{
assert(p);
struct _Plugin* result = malloc(sizeof(struct _Plugin));
@@ -47,7 +46,7 @@ slv2_plugin_duplicate(const SLV2Plugin* p)
const char*
-slv2_plugin_get_uri(const SLV2Plugin* p)
+slv2_plugin_get_uri(SLV2Plugin p)
{
assert(p);
return p->plugin_uri;
@@ -55,7 +54,7 @@ slv2_plugin_get_uri(const SLV2Plugin* p)
SLV2Strings
-slv2_plugin_get_data_uris(const SLV2Plugin* p)
+slv2_plugin_get_data_uris(SLV2Plugin p)
{
assert(p);
return p->data_uris;
@@ -63,7 +62,7 @@ slv2_plugin_get_data_uris(const SLV2Plugin* p)
const char*
-slv2_plugin_get_library_uri(const SLV2Plugin* p)
+slv2_plugin_get_library_uri(SLV2Plugin p)
{
assert(p);
return p->lib_uri;
@@ -71,7 +70,7 @@ slv2_plugin_get_library_uri(const SLV2Plugin* p)
bool
-slv2_plugin_verify(const SLV2Plugin* plugin)
+slv2_plugin_verify(SLV2Plugin plugin)
{
// FIXME: finish this (properly)
@@ -96,7 +95,7 @@ slv2_plugin_verify(const SLV2Plugin* plugin)
char*
-slv2_plugin_get_name(const SLV2Plugin* plugin)
+slv2_plugin_get_name(SLV2Plugin plugin)
{
char* result = NULL;
SLV2Strings prop = slv2_plugin_get_value(plugin, "doap:name");
@@ -113,25 +112,11 @@ slv2_plugin_get_name(const SLV2Plugin* plugin)
SLV2Strings
-slv2_plugin_get_value(const SLV2Plugin* p,
- const char* predicate)
+slv2_plugin_get_value(SLV2Plugin p,
+ const char* predicate)
{
assert(predicate);
- /*
- char* header = slv2_query_header(p);
- char* lang_filter = slv2_query_lang_filter("?value");
-
- char* query_string = slv2_strjoin(
- header,
- "SELECT DISTINCT ?value WHERE { \n",
- "plugin: ", property, " ?value . \n",
- ((lang_filter != NULL) ? lang_filter : ""),
- "}", 0);
-
- free(header);
- free(lang_filter);*/
-
char* query = slv2_strjoin(
"SELECT DISTINCT ?value WHERE {\n"
"plugin: ", predicate, " ?value .\n"
@@ -146,21 +131,21 @@ slv2_plugin_get_value(const SLV2Plugin* p,
SLV2Strings
-slv2_plugin_get_properties(const SLV2Plugin* p)
+slv2_plugin_get_properties(SLV2Plugin p)
{
return slv2_plugin_get_value(p, "lv2:pluginProperty");
}
SLV2Strings
-slv2_plugin_get_hints(const SLV2Plugin* p)
+slv2_plugin_get_hints(SLV2Plugin p)
{
return slv2_plugin_get_value(p, "lv2:pluginHint");
}
uint32_t
-slv2_plugin_get_num_ports(const SLV2Plugin* p)
+slv2_plugin_get_num_ports(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?port\n"
@@ -171,7 +156,7 @@ slv2_plugin_get_num_ports(const SLV2Plugin* p)
bool
-slv2_plugin_has_latency(const SLV2Plugin* p)
+slv2_plugin_has_latency(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?port WHERE {\n"
@@ -190,7 +175,7 @@ slv2_plugin_has_latency(const SLV2Plugin* p)
uint32_t
-slv2_plugin_get_latency_port(const SLV2Plugin* p)
+slv2_plugin_get_latency_port(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?value WHERE {\n"
@@ -212,7 +197,7 @@ slv2_plugin_get_latency_port(const SLV2Plugin* p)
SLV2Strings
-slv2_plugin_get_supported_features(const SLV2Plugin* p)
+slv2_plugin_get_supported_features(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
@@ -228,7 +213,7 @@ slv2_plugin_get_supported_features(const SLV2Plugin* p)
SLV2Strings
-slv2_plugin_get_optional_features(const SLV2Plugin* p)
+slv2_plugin_get_optional_features(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
@@ -242,7 +227,7 @@ slv2_plugin_get_optional_features(const SLV2Plugin* p)
SLV2Strings
-slv2_plugin_get_required_features(const SLV2Plugin* p)
+slv2_plugin_get_required_features(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
diff --git a/src/plugininstance.c b/src/plugininstance.c
index 13a659a..906bfb8 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -28,8 +28,8 @@
#include "private_types.h"
-SLV2Instance*
-slv2_plugin_instantiate(const SLV2Plugin* plugin,
+SLV2Instance
+slv2_plugin_instantiate(SLV2Plugin plugin,
uint32_t sample_rate,
const LV2_Host_Feature** host_features)
{
@@ -114,7 +114,7 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin,
void
-slv2_instance_free(SLV2Instance* instance)
+slv2_instance_free(SLV2Instance instance)
{
struct _Instance* i = (struct _Instance*)instance;
i->lv2_descriptor->cleanup(i->lv2_handle);
diff --git a/src/pluginlist.c b/src/pluginlist.c
index d6c1665..a6a2a97 100644
--- a/src/pluginlist.c
+++ b/src/pluginlist.c
@@ -114,7 +114,7 @@ slv2_plugins_load_bundle(SLV2Plugins list,
/* Get all plugins explicitly mentioned in the manifest (discovery pass 1) */
char* query_string =
- "PREFIX : <http://lv2plug.in/ontology#>\n\n"
+ "PREFIX : <http://lv2plug.in/ontology#>\n\n"
"SELECT DISTINCT ?plugin_uri FROM <>\n"
"WHERE { ?plugin_uri a :Plugin }\n";
@@ -179,7 +179,7 @@ slv2_plugins_load_bundle(SLV2Plugins list,
const char* binary = (const char*)rasqal_literal_as_string(
rasqal_query_results_get_binding_value(results, 2));
- SLV2Plugin* plugin = slv2_plugins_get_by_uri(list, subject);
+ SLV2Plugin plugin = slv2_plugins_get_by_uri(list, subject);
if (plugin && data_uri && !slv2_strings_contains(plugin->data_uris, data_uri))
raptor_sequence_push(plugin->data_uris, strdup(data_uri));
@@ -269,7 +269,7 @@ slv2_plugins_size(const SLV2Plugins list)
}
-SLV2Plugin*
+SLV2Plugin
slv2_plugins_get_by_uri(const SLV2Plugins list, const char* uri)
{
if (list->num_plugins > 0) {
@@ -284,7 +284,7 @@ slv2_plugins_get_by_uri(const SLV2Plugins list, const char* uri)
}
-SLV2Plugin*
+SLV2Plugin
slv2_plugins_get_at(const SLV2Plugins list, unsigned index)
{
if (list->num_plugins == 0)
diff --git a/src/port.c b/src/port.c
index c6d0c10..8a298d7 100644
--- a/src/port.c
+++ b/src/port.c
@@ -19,11 +19,11 @@
#define _XOPEN_SOURCE 500
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <slv2/port.h>
#include <slv2/types.h>
-#include <slv2/query.h>
#include <slv2/util.h>
@@ -50,8 +50,8 @@ slv2_port_by_symbol(const char* symbol)
SLV2PortClass
-slv2_port_get_class(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_class(SLV2Plugin p,
+ SLV2PortID id)
{
SLV2Strings class = slv2_port_get_value(p, id, "rdf:type");
@@ -61,7 +61,7 @@ slv2_port_get_class(SLV2Plugin* p,
enum { UNKNOWN, AUDIO, CONTROL, MIDI } type = UNKNOWN;
for (unsigned i=0; i < slv2_strings_size(class); ++i) {
- char* value = slv2_strings_get_at(class, i);
+ const char* value = slv2_strings_get_at(class, i);
if (!strcmp(value, "http://lv2plug.in/ontology#InputPort"))
io = 0;
else if (!strcmp(value, "http://lv2plug.in/ontology#OutputPort"))
@@ -97,7 +97,7 @@ slv2_port_get_class(SLV2Plugin* p,
SLV2Strings
-slv2_port_get_value(SLV2Plugin* p,
+slv2_port_get_value(SLV2Plugin p,
SLV2PortID id,
const char* property)
{
@@ -136,8 +136,8 @@ slv2_port_get_value(SLV2Plugin* p,
char*
-slv2_port_get_symbol(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_symbol(SLV2Plugin p,
+ SLV2PortID id)
{
char* result = NULL;
@@ -154,8 +154,8 @@ slv2_port_get_symbol(SLV2Plugin* p,
char*
-slv2_port_get_name(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_name(SLV2Plugin p,
+ SLV2PortID id)
{
char* result = NULL;
@@ -172,8 +172,8 @@ slv2_port_get_name(SLV2Plugin* p,
float
-slv2_port_get_default_value(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_default_value(SLV2Plugin p,
+ SLV2PortID id)
{
// FIXME: do casting properly in the SPARQL query
@@ -192,8 +192,8 @@ slv2_port_get_default_value(SLV2Plugin* p,
float
-slv2_port_get_minimum_value(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_minimum_value(SLV2Plugin p,
+ SLV2PortID id)
{
// FIXME: do casting properly in the SPARQL query
@@ -212,8 +212,8 @@ slv2_port_get_minimum_value(SLV2Plugin* p,
float
-slv2_port_get_maximum_value(SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_maximum_value(SLV2Plugin p,
+ SLV2PortID id)
{
// FIXME: do casting properly in the SPARQL query
@@ -232,16 +232,16 @@ slv2_port_get_maximum_value(SLV2Plugin* p,
SLV2Strings
-slv2_port_get_properties(const SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_properties(SLV2Plugin p,
+ SLV2PortID id)
{
return slv2_port_get_value(p, id, "lv2:portProperty");
}
SLV2Strings
-slv2_port_get_hints(const SLV2Plugin* p,
- SLV2PortID id)
+slv2_port_get_hints(SLV2Plugin p,
+ SLV2PortID id)
{
return slv2_port_get_value(p, id, "lv2:portHint");
}
diff --git a/src/private_types.h b/src/private_types.h
index 0d755f8..027d68d 100644
--- a/src/private_types.h
+++ b/src/private_types.h
@@ -29,6 +29,11 @@ extern "C" {
#include <slv2/lv2.h>
+/** The URI of the lv2.ttl file.
+ */
+extern raptor_uri* slv2_ontology_uri;
+
+
/** Record of an installed/available plugin.
*
* A simple reference to a plugin somewhere on the system. This just holds
diff --git a/src/query.c b/src/query.c
index 617b1df..b671ac8 100644
--- a/src/query.c
+++ b/src/query.c
@@ -17,10 +17,11 @@
*/
#define _XOPEN_SOURCE 500
+#include <string.h>
#include <stdlib.h>
#include <assert.h>
+#include <rasqal.h>
#include <slv2/plugin.h>
-#include <slv2/query.h>
#include <slv2/library.h>
#include <slv2/util.h>
#include <slv2/stringlist.h>
@@ -28,7 +29,7 @@
char*
-slv2_query_header(const SLV2Plugin* p)
+slv2_query_header(SLV2Plugin p)
{
const char* const plugin_uri = slv2_plugin_get_uri(p);
//SLV2Strings files = slv2_plugin_get_data_uris(p);
@@ -109,7 +110,7 @@ slv2_query_count_bindings(rasqal_query_results* results)
rasqal_query_results*
-slv2_plugin_query(SLV2Plugin* plugin,
+slv2_plugin_query(SLV2Plugin plugin,
const char* sparql_str)
{
raptor_uri* base_uri = raptor_new_uri((unsigned char*)slv2_plugin_get_uri(plugin));
@@ -156,7 +157,7 @@ slv2_plugin_query(SLV2Plugin* plugin,
/** Query a single variable */
SLV2Strings
-slv2_plugin_simple_query(SLV2Plugin* plugin,
+slv2_plugin_simple_query(SLV2Plugin plugin,
const char* sparql_str,
const char* variable)
{
@@ -174,7 +175,7 @@ slv2_plugin_simple_query(SLV2Plugin* plugin,
* in the number of results (ie slv2_plugin_num_ports).
*/
unsigned
-slv2_plugin_query_count(SLV2Plugin* plugin,
+slv2_plugin_query_count(SLV2Plugin plugin,
const char* sparql_str)
{
rasqal_query_results* results = slv2_plugin_query(plugin, sparql_str);
@@ -185,10 +186,9 @@ slv2_plugin_query_count(SLV2Plugin* plugin,
}
-// FIXME: stupid interface
size_t
-slv2_query_count_results(const SLV2Plugin* p,
- const char* query)
+slv2_query_count_results(SLV2Plugin p,
+ const char* query)
{
char* header = slv2_query_header(p);
char* query_str = slv2_strjoin(header, query, NULL);
@@ -222,27 +222,3 @@ slv2_query_count_results(const SLV2Plugin* p,
return count;
}
-
-/*
-size_t
-slv2_query_get_num_results(rasqal_query_results* results, const char* var_name)
-{
- size_t result = 0;
-
- while (!rasqal_query_results_finished(results)) {
- if (!strcmp((const char*)rasqal_query_results_get_binding_name(results, 0), var_name)) {
- ++result;
- }
- rasqal_query_results_next(results);
- }
-
- return result;
-}
-*/
-
-void
-slv2_strings_free(SLV2Strings list)
-{
- raptor_free_sequence(list);
-}
-
diff --git a/src/stringlist.c b/src/stringlist.c
index bdb173e..930454f 100644
--- a/src/stringlist.c
+++ b/src/stringlist.c
@@ -30,25 +30,32 @@ slv2_strings_new()
}
+void
+slv2_strings_free(SLV2Strings list)
+{
+ raptor_free_sequence(list);
+}
+
+
unsigned
-slv2_strings_size(const SLV2Strings list)
+slv2_strings_size(SLV2Strings list)
{
return raptor_sequence_size(list);
}
-char*
-slv2_strings_get_at(const SLV2Strings list, unsigned index)
+const char*
+slv2_strings_get_at(SLV2Strings list, unsigned index)
{
if (index > INT_MAX)
return NULL;
else
- return (char*)raptor_sequence_get_at(list, (int)index);
+ return (const char*)raptor_sequence_get_at(list, (int)index);
}
bool
-slv2_strings_contains(const SLV2Strings list, const char* uri)
+slv2_strings_contains(SLV2Strings list, const char* uri)
{
for (unsigned i=0; i < slv2_strings_size(list); ++i)
if (!strcmp(slv2_strings_get_at(list, i), uri))