summaryrefslogtreecommitdiffstats
path: root/slv2
diff options
context:
space:
mode:
Diffstat (limited to 'slv2')
-rw-r--r--slv2/Makefile.am1
-rw-r--r--slv2/library.h5
-rw-r--r--slv2/plugin.h54
-rw-r--r--slv2/plugininstance.h50
-rw-r--r--slv2/pluginlist.h4
-rw-r--r--slv2/port.h18
-rw-r--r--slv2/query.h130
-rw-r--r--slv2/slv2.h3
-rw-r--r--slv2/stringlist.h14
-rw-r--r--slv2/types.h1
-rw-r--r--slv2/util.h8
11 files changed, 82 insertions, 206 deletions
diff --git a/slv2/Makefile.am b/slv2/Makefile.am
index d2b863e..0a90fb1 100644
--- a/slv2/Makefile.am
+++ b/slv2/Makefile.am
@@ -6,7 +6,6 @@ slv2include_HEADERS = \
slv2.h \
library.h \
plugin.h \
- query.h \
port.h \
pluginlist.h \
plugininstance.h \
diff --git a/slv2/library.h b/slv2/library.h
index 9c94139..c3d68ca 100644
--- a/slv2/library.h
+++ b/slv2/library.h
@@ -41,11 +41,6 @@ void
slv2_finish();
-/** The URI of the lv2.ttl file.
- */
-extern raptor_uri* slv2_ontology_uri;
-
-
#ifdef __cplusplus
}
#endif
diff --git a/slv2/plugin.h b/slv2/plugin.h
index 27fa982..559c927 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -24,13 +24,12 @@ extern "C" {
#endif
#include <stdint.h>
-#include <stddef.h>
#include <stdbool.h>
#include <slv2/types.h>
#include <slv2/stringlist.h>
-typedef const struct _Plugin SLV2Plugin;
+typedef struct _Plugin* SLV2Plugin;
/** \defgroup data Plugin - RDF data access
@@ -56,7 +55,7 @@ typedef const struct _Plugin SLV2Plugin;
* \return true if \a plugin is valid.
*/
bool
-slv2_plugin_verify(const SLV2Plugin* plugin);
+slv2_plugin_verify(SLV2Plugin plugin);
/** Duplicate a plugin.
@@ -66,8 +65,8 @@ slv2_plugin_verify(const SLV2Plugin* plugin);
*
* \return a newly allocated deep copy of \a plugin.
*/
-SLV2Plugin*
-slv2_plugin_duplicate(const SLV2Plugin* plugin);
+SLV2Plugin
+slv2_plugin_duplicate(SLV2Plugin plugin);
/** Get the URI of \a plugin.
@@ -85,7 +84,7 @@ slv2_plugin_duplicate(const SLV2Plugin* plugin);
* \return a shared string which must not be modified or free()'d.
*/
const char*
-slv2_plugin_get_uri(const SLV2Plugin* plugin);
+slv2_plugin_get_uri(SLV2Plugin plugin);
/** Get the (resolvable) URIs of the RDF data files that define a plugin.
@@ -97,7 +96,7 @@ slv2_plugin_get_uri(const SLV2Plugin* plugin);
* which is shared and must not be modified or free()'d.
*/
SLV2Strings
-slv2_plugin_get_data_uris(const SLV2Plugin* plugin);
+slv2_plugin_get_data_uris(SLV2Plugin plugin);
/** Get the (resolvable) URI of the shared library for \a plugin.
@@ -108,7 +107,7 @@ slv2_plugin_get_data_uris(const SLV2Plugin* plugin);
* \return a shared string which must not be modified or free()'d.
*/
const char*
-slv2_plugin_get_library_uri(const SLV2Plugin* plugin);
+slv2_plugin_get_library_uri(SLV2Plugin plugin);
@@ -119,7 +118,7 @@ slv2_plugin_get_library_uri(const SLV2Plugin* plugin);
* the caller.
*/
char*
-slv2_plugin_get_name(const SLV2Plugin* plugin);
+slv2_plugin_get_name(SLV2Plugin plugin);
/** Request some arbitrary RDF object of the plugin.
@@ -136,8 +135,8 @@ slv2_plugin_get_name(const SLV2Plugin* plugin);
* returned.
*/
SLV2Strings
-slv2_plugin_get_value(const SLV2Plugin* p,
- const char* predicate);
+slv2_plugin_get_value(SLV2Plugin p,
+ const char* predicate);
/** Get the LV2 Properties of a plugin.
@@ -149,7 +148,7 @@ slv2_plugin_get_value(const SLV2Plugin* p,
* Return value must be freed by caller with slv2_value_free.
*/
SLV2Strings
-slv2_plugin_get_properties(const SLV2Plugin* p);
+slv2_plugin_get_properties(SLV2Plugin p);
/** Get the LV2 Hints of a plugin.
@@ -160,13 +159,14 @@ slv2_plugin_get_properties(const SLV2Plugin* p);
* Return value must be freed by caller with slv2_value_free.
*/
SLV2Strings
-slv2_plugin_get_hints(const SLV2Plugin* p);
+slv2_plugin_get_hints(SLV2Plugin p);
/** Get the number of ports on this plugin.
*/
uint32_t
-slv2_plugin_get_num_ports(const SLV2Plugin* p);
+slv2_plugin_get_num_ports(SLV2Plugin p);
+
/** Return whether or not the plugin introduces (and reports) latency.
*
@@ -174,7 +174,8 @@ slv2_plugin_get_num_ports(const SLV2Plugin* p);
* ONLY if this function returns true.
*/
bool
-slv2_plugin_has_latency(const SLV2Plugin* p);
+slv2_plugin_has_latency(SLV2Plugin p);
+
/** Return the index of the plugin's latency port, or the empty string if the
* plugin has no latency.
@@ -187,7 +188,7 @@ slv2_plugin_has_latency(const SLV2Plugin* p);
* rate output port that reports the latency for each cycle in frames.
*/
uint32_t
-slv2_plugin_get_latency_port(const SLV2Plugin* p);
+slv2_plugin_get_latency_port(SLV2Plugin p);
/** Get a plugin's supported host features / extensions.
@@ -195,7 +196,7 @@ slv2_plugin_get_latency_port(const SLV2Plugin* p);
* This returns a list of all supported features (both required and optional).
*/
SLV2Strings
-slv2_plugin_get_supported_features(const SLV2Plugin* p);
+slv2_plugin_get_supported_features(SLV2Plugin p);
/** Get a plugin's requires host features / extensions.
@@ -204,7 +205,7 @@ slv2_plugin_get_supported_features(const SLV2Plugin* p);
* instantiate method for the plugin to instantiate successfully.
*/
SLV2Strings
-slv2_plugin_get_required_features(const SLV2Plugin* p);
+slv2_plugin_get_required_features(SLV2Plugin p);
/** Get a plugin's optional host features / extensions.
@@ -214,7 +215,22 @@ slv2_plugin_get_required_features(const SLV2Plugin* p);
* the plugin will act as it would if it did not support that feature at all.
*/
SLV2Strings
-slv2_plugin_get_optional_features(const SLV2Plugin* p);
+slv2_plugin_get_optional_features(SLV2Plugin p);
+
+
+/** Query a plugin for a single variable.
+ */
+SLV2Strings
+slv2_plugin_simple_query(SLV2Plugin plugin,
+ const char* sparql_str,
+ const char* variable);
+
+
+/** Query a plugin and return the number of results found.
+ */
+unsigned
+slv2_plugin_query_count(SLV2Plugin plugin,
+ const char* sparql_str);
/** @} */
diff --git a/slv2/plugininstance.h b/slv2/plugininstance.h
index e704383..122d536 100644
--- a/slv2/plugininstance.h
+++ b/slv2/plugininstance.h
@@ -24,21 +24,12 @@ extern "C" {
#endif
#include <assert.h>
-#include <dlfcn.h>
#include <slv2/lv2.h>
#include <slv2/plugin.h>
#include <slv2/port.h>
typedef struct _InstanceImpl* SLV2InstanceImpl;
-/** Instance of a plugin */
-typedef struct _Instance {
- const LV2_Descriptor* lv2_descriptor;
- LV2_Handle lv2_handle;
- SLV2InstanceImpl pimpl; ///< Opaque
-} SLV2Instance;
-
-
/** \defgroup lib Plugin Instance - Shared library access
*
* An SLV2Instance is an instantiated SLV2Plugin (eg a loaded dynamic
@@ -49,6 +40,21 @@ typedef struct _Instance {
*/
+/** Instance of a plugin.
+ *
+ * The LV2 descriptor and handle of this are exposed to allow inlining of
+ * performance critical functions like slv2_instance_run (hiding things in
+ * lv2.h is pointless anyway). The remaining implementation details are
+ * in the opaque pimpl member.
+ */
+typedef struct _Instance {
+ const LV2_Descriptor* lv2_descriptor;
+ LV2_Handle lv2_handle;
+ SLV2InstanceImpl pimpl; ///< Move along now, nothing to see here
+}* SLV2Instance;
+
+
+
/** Instantiate a plugin.
*
* The returned object represents shared library objects loaded into memory,
@@ -64,8 +70,8 @@ typedef struct _Instance {
*
* \return NULL if instantiation failed.
*/
-SLV2Instance*
-slv2_plugin_instantiate(const SLV2Plugin* plugin,
+SLV2Instance
+slv2_plugin_instantiate(SLV2Plugin plugin,
uint32_t sample_rate,
const LV2_Host_Feature** host_features);
@@ -75,7 +81,7 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin,
* \a instance is invalid after this call.
*/
void
-slv2_instance_free(SLV2Instance* instance);
+slv2_instance_free(SLV2Instance instance);
#ifndef LIBSLV2_SOURCE
@@ -86,7 +92,7 @@ slv2_instance_free(SLV2Instance* instance);
* Returned string is shared and must not be modified or deleted.
*/
static inline const char*
-slv2_instance_get_uri(SLV2Instance* instance)
+slv2_instance_get_uri(SLV2Instance instance)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -101,9 +107,9 @@ slv2_instance_get_uri(SLV2Instance* instance)
* activation and deactivation does not destroy port connections.
*/
static inline void
-slv2_instance_connect_port(SLV2Instance* instance,
- uint32_t port_index,
- void* data_location)
+slv2_instance_connect_port(SLV2Instance instance,
+ uint32_t port_index,
+ void* data_location)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -121,7 +127,7 @@ slv2_instance_connect_port(SLV2Instance* instance,
* before calling slv2_instance_run.
*/
static inline void
-slv2_instance_activate(SLV2Instance* instance)
+slv2_instance_activate(SLV2Instance instance)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -137,8 +143,8 @@ slv2_instance_activate(SLV2Instance* instance)
* guaranteed not to block.
*/
static inline void
-slv2_instance_run(SLV2Instance* instance,
- uint32_t sample_count)
+slv2_instance_run(SLV2Instance instance,
+ uint32_t sample_count)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -155,7 +161,7 @@ slv2_instance_run(SLV2Instance* instance,
* reset all state information (except port connections).
*/
static inline void
-slv2_instance_deactivate(SLV2Instance* instance)
+slv2_instance_deactivate(SLV2Instance instance)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -174,7 +180,7 @@ slv2_instance_deactivate(SLV2Instance* instance)
* The returned descriptor is shared and must not be deleted.
*/
static inline const LV2_Descriptor*
-slv2_instance_get_descriptor(SLV2Instance* instance)
+slv2_instance_get_descriptor(SLV2Instance instance)
{
assert(instance);
assert(instance->lv2_descriptor);
@@ -191,7 +197,7 @@ slv2_instance_get_descriptor(SLV2Instance* instance)
* The returned handle is shared and must not be deleted.
*/
static inline LV2_Handle
-slv2_instance_get_handle(SLV2Instance* instance)
+slv2_instance_get_handle(SLV2Instance instance)
{
assert(instance);
assert(instance->lv2_descriptor);
diff --git a/slv2/pluginlist.h b/slv2/pluginlist.h
index 1032a84..3e9b9d4 100644
--- a/slv2/pluginlist.h
+++ b/slv2/pluginlist.h
@@ -127,7 +127,7 @@ slv2_plugins_size(const SLV2Plugins list);
*
* \return NULL if plugin with \a url not found in \a list.
*/
-const SLV2Plugin*
+SLV2Plugin
slv2_plugins_get_by_uri(const SLV2Plugins list,
const char* uri);
@@ -144,7 +144,7 @@ slv2_plugins_get_by_uri(const SLV2Plugins list,
*
* \return NULL if \a index out of range.
*/
-const SLV2Plugin*
+SLV2Plugin
slv2_plugins_get_at(const SLV2Plugins list,
unsigned index);
diff --git a/slv2/port.h b/slv2/port.h
index 9106a9c..546a713 100644
--- a/slv2/port.h
+++ b/slv2/port.h
@@ -47,7 +47,7 @@ slv2_port_by_symbol(const char* symbol);
/** Port equivalent to slv2_plugin_get_value.
*/
SLV2Strings
-slv2_port_get_value(SLV2Plugin* plugin,
+slv2_port_get_value(SLV2Plugin plugin,
SLV2PortID id,
const char* property);
@@ -55,14 +55,14 @@ slv2_port_get_value(SLV2Plugin* plugin,
/** Port equivalent to slv2_plugin_get_properties.
*/
SLV2Strings
-slv2_port_get_properties(const SLV2Plugin* p,
+slv2_port_get_properties(SLV2Plugin p,
SLV2PortID id);
/** Port equivalent to slv2_plugin_get_hints.
*/
SLV2Strings
-slv2_port_get_hints(const SLV2Plugin* p,
+slv2_port_get_hints(SLV2Plugin p,
SLV2PortID id);
@@ -74,7 +74,7 @@ slv2_port_get_hints(const SLV2Plugin* p,
* \return NULL when index is out of range
*/
char*
-slv2_port_get_symbol(SLV2Plugin* plugin,
+slv2_port_get_symbol(SLV2Plugin plugin,
SLV2PortID id);
/** Get the name of a port.
@@ -84,14 +84,14 @@ slv2_port_get_symbol(SLV2Plugin* plugin,
* the caller.
*/
char*
-slv2_port_get_name(SLV2Plugin* plugin,
+slv2_port_get_name(SLV2Plugin plugin,
SLV2PortID id);
/** Get the class (input/output, data type, rate...) of a port.
*/
SLV2PortClass
-slv2_port_get_class(SLV2Plugin* plugin,
+slv2_port_get_class(SLV2Plugin plugin,
SLV2PortID id);
@@ -100,7 +100,7 @@ slv2_port_get_class(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_default_value(SLV2Plugin* plugin,
+slv2_port_get_default_value(SLV2Plugin plugin,
SLV2PortID id);
@@ -109,7 +109,7 @@ slv2_port_get_default_value(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_minimum_value(SLV2Plugin* plugin,
+slv2_port_get_minimum_value(SLV2Plugin plugin,
SLV2PortID id);
@@ -118,7 +118,7 @@ slv2_port_get_minimum_value(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_maximum_value(SLV2Plugin* plugin,
+slv2_port_get_maximum_value(SLV2Plugin plugin,
SLV2PortID id);
diff --git a/slv2/query.h b/slv2/query.h
deleted file mode 100644
index ea78735..0000000
--- a/slv2/query.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SLV2
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __SLV2_QUERY_H__
-#define __SLV2_QUERY_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rasqal.h>
-#include "plugin.h"
-#include "types.h"
-
-
-// FIXME: much of this should not be exposed
-
-
-/** \defgroup query SPARQL query helpers
- *
- * This part is in progress, incomplete, a random mishmash of crap that
- * evolved along with my understanding of this rasqal library. Nothing
- * to see here, move long now. Nothing to see here.
- *
- * Eventually this will contain functions that make it convenient for host
- * authors to query plugins in ways libslv2 doesn't nicely wrap (eg. for
- * extensions not (yet) supported by libslv2).
- *
- * @{
- */
-
-/** Return a header for a SPARQL query on the given plugin.
- *
- * The returned header defines the namespace prefixes used in the standard
- * (rdf: rdfs: doap: lv2:), plugin: as the plugin's URI, and data: as the
- * URL of the plugin's RDF (Turtle) data file.
- *
- * Example query to get a plugin's doap:name using this header:
- *
- * <code>
- * SELECT DISTINCT ?value FROM data: WHERE {
- * plugin: doap:name ?value
- * }
- * </code>
- *
- * \return an unsigned (UTF-8) string which must be free()'d.
- */
-char*
-slv2_query_header(const SLV2Plugin* p);
-
-
-/** Return a language filter for the given variable.
- *
- * If the environment variable $LANG is not set, returns NULL.
- *
- * \arg variable SPARQL variable, including "?" or "$" (eg "?value").
- *
- * This needs to be put inside the WHERE block, after the triples.
- *
- * eg. FILTER( LANG(?value) = "en" || LANG(?value) = "" )
- */
-char*
-slv2_query_lang_filter(const char* variable);
-
-
-rasqal_query_results*
-slv2_plugin_query(SLV2Plugin* plugin,
- const char* sparql_str);
-
-SLV2Strings
-slv2_plugin_simple_query(SLV2Plugin* plugin,
- const char* sparql_str,
- const char* variable);
-
-unsigned
-slv2_plugin_query_count(SLV2Plugin* plugin,
- const char* sparql_str);
-
-#if 0
-/** Run a SPARQL query on a plugin's data file and return variable matches.
- *
- * Header from slv2query_header will be prepended to passed query string (so
- * the default prefixes will be already defined, you don't need to add them
- * yourself).
- *
- * Returned is a list of all matches for the query variable \a var_name.
- */
-SLV2Strings
-slv2_query_get_results(const SLV2Plugin* p,
- const char* query_string,
- const char* var_name);
-
-/** Run a SPARQL query on a plugin's data file and just count the matches.
- *
- * Header from slv2query_header will be prepended to passed query string (so
- * the default prefixes will be already defined, you don't need to add them
- * yourself).
- *
- * Returned is the total of all variable matches resulting from the query.
- */
-size_t
-slv2_query_count_results(const SLV2Plugin* p,
- const char* query_string);
-#endif
-
-
-/** @} */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SLV2_QUERY_H__ */
-
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 07e9201..539ea47 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -23,8 +23,6 @@
extern "C" {
#endif
-#include <rasqal.h>
-
#include <slv2/library.h>
#include <slv2/types.h>
#include <slv2/plugin.h>
@@ -33,7 +31,6 @@ extern "C" {
#include <slv2/stringlist.h>
#include <slv2/port.h>
-
#ifdef __cplusplus
}
#endif
diff --git a/slv2/stringlist.h b/slv2/stringlist.h
index 4abb383..7414659 100644
--- a/slv2/stringlist.h
+++ b/slv2/stringlist.h
@@ -21,9 +21,6 @@
#include <stdbool.h>
-typedef void* SLV2Strings;
-
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -38,6 +35,9 @@ extern "C" {
*/
+typedef void* SLV2Strings;
+
+
/** Allocate a new, empty SLV2Strings
*/
SLV2Strings
@@ -47,21 +47,21 @@ slv2_strings_new();
/** Get the number of elements in a string list.
*/
unsigned
-slv2_strings_size(const SLV2Strings list);
+slv2_strings_size(SLV2Strings list);
/** Get a string from a string list at the given index.
*
* @return the element at @a index, or NULL if index is out of range.
*/
-char*
-slv2_strings_get_at(const SLV2Strings list, unsigned index);
+const char*
+slv2_strings_get_at(SLV2Strings list, unsigned index);
/** Return whether @a list contains @a uri.
*/
bool
-slv2_strings_contains(const SLV2Strings list, const char* uri);
+slv2_strings_contains(SLV2Strings list, const char* uri);
/** Free a string list. */
diff --git a/slv2/types.h b/slv2/types.h
index dd7480c..03c84e7 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -19,7 +19,6 @@
#ifndef __SLV2_TYPES_H__
#define __SLV2_TYPES_H__
-#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
diff --git a/slv2/util.h b/slv2/util.h
index eb8dea7..aa08dbf 100644
--- a/slv2/util.h
+++ b/slv2/util.h
@@ -19,13 +19,7 @@
#ifndef __SLV2_UTIL_H__
#define __SLV2_UTIL_H__
-#define _XOPEN_SOURCE 500
-#include <string.h>
#include <stdarg.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <slv2/types.h>
#ifdef __cplusplus
extern "C" {
@@ -41,7 +35,7 @@ extern "C" {
/** Convert a full URI (eg file://foo/bar/baz.ttl) to a local path (e.g. /foo/bar/baz.ttl).
*
* Return value is shared and must not be deleted by caller.
- * @return @uri converted to a path, or NULL on failure (URI is not local).
+ * @return @a uri converted to a path, or NULL on failure (URI is not local).
*/
const char* slv2_uri_to_path(const char* uri);