[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src 3rdparty/slv2/slv2.pro 3rdparty/sl...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src 3rdparty/slv2/slv2.pro 3rdparty/sl... |
Date: |
Fri, 08 Jun 2007 09:29:09 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/06/08 09:29:08
Modified files:
src/3rdparty/slv2: slv2.pro
src/3rdparty/slv2/slv2: lv2.h plugin.h plugininstance.h port.h
slv2.h types.h util.h world.h
src/3rdparty/slv2/src: plugin.c plugininstance.c port.c query.c
world.c
src/plugins/LV2: LV2Plugin.cpp
Added files:
src/3rdparty/slv2: config.h
src/3rdparty/slv2/slv2: pluginclasses.h pluginclass.h plugins.h
value.h values.h
src/3rdparty/slv2/src: pluginclass.c pluginclasses.c plugins.c
slv2_internal.h value.c values.c
Removed files:
src/3rdparty/slv2/slv2: pluginlist.h stringlist.h
src/3rdparty/slv2/src: pluginlist.c private_types.h stringlist.c
Log message:
updated to slv2 version 0.0.1
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2.pro?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/config.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/lv2.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugin.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugininstance.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/port.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/slv2.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/types.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/util.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/world.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginclasses.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginclass.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/plugins.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/value.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/values.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/pluginlist.h?cvsroot=traverso&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/slv2/stringlist.h?cvsroot=traverso&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugin.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugininstance.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/port.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/query.c?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/world.c?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginclass.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginclasses.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/plugins.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/slv2_internal.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/value.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/values.c?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/pluginlist.c?cvsroot=traverso&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/private_types.h?cvsroot=traverso&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/3rdparty/slv2/src/stringlist.c?cvsroot=traverso&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/LV2/LV2Plugin.cpp?cvsroot=traverso&r1=1.9&r2=1.10
Patches:
Index: 3rdparty/slv2/slv2.pro
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2.pro,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- 3rdparty/slv2/slv2.pro 4 Jun 2007 10:11:23 -0000 1.2
+++ 3rdparty/slv2/slv2.pro 8 Jun 2007 09:29:06 -0000 1.3
@@ -14,12 +14,15 @@
SOURCES += \
src/plugin.c \
+ src/pluginclass.c \
+ src/pluginclasses.c \
src/plugininstance.c \
- src/pluginlist.c \
+ src/plugins.c \
src/port.c \
src/query.c \
- src/stringlist.c \
src/util.c \
+ src/value.c \
+ src/values.c \
src/world.c
}
Index: 3rdparty/slv2/slv2/lv2.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/lv2.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/lv2.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/lv2.h 8 Jun 2007 09:29:06 -0000 1.2
@@ -36,7 +36,7 @@
/** @file lv2.h
*
- * Revision: 1.0beta1
+ * Revision: 1.0beta3
*
* == Overview ==
*
Index: 3rdparty/slv2/slv2/plugin.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/plugin.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/plugin.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/plugin.h 8 Jun 2007 09:29:06 -0000 1.2
@@ -27,7 +27,7 @@
#include <stdbool.h>
#include <slv2/types.h>
#include <slv2/port.h>
-#include <slv2/stringlist.h>
+#include <slv2/values.h>
/** \defgroup data Plugin data access
*
@@ -60,20 +60,6 @@
slv2_plugin_verify(SLV2Plugin plugin);
-#if 0
-/** Duplicate a plugin.
- *
- * Use this if you want to keep an SLV2Plugin around but free the list it came
- * from. Freeing the returned plugin with slv2_plugin_free is the caller's
- * responsibility.
- *
- * \return a newly allocated deep copy of \a plugin.
- */
-SLV2Plugin
-slv2_plugin_duplicate(SLV2Plugin plugin);
-#endif
-
-
/** Get the URI of \a plugin.
*
* Any serialization that refers to plugins should refer to them by this.
@@ -104,7 +90,7 @@
*
* Time = O(1)
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_data_uris(SLV2Plugin plugin);
@@ -134,6 +120,12 @@
slv2_plugin_get_name(SLV2Plugin plugin);
+/** Get the class this plugin belongs to (ie Filters).
+ */
+SLV2PluginClass
+slv2_plugin_get_class(SLV2Plugin plugin);
+
+
/** Get a value associated with the plugin in a plugin's data files.
*
* Returns the ?object of all triples found of the form:
@@ -141,14 +133,18 @@
* <code><plugin-uri> predicate ?object</code>
*
* May return NULL if the property was not found, or if object is not
- * sensibly represented as an SLV2Strings (e.g. blank nodes).
+ * sensibly represented as an SLV2Values (e.g. blank nodes).
*
- * Return value must be freed by caller with slv2_strings_free.
+ * Return value must be freed by caller with slv2_values_free.
+ *
+ * \a predicate must be either a URI or a QName.
+ * See SLV2URIType documentation for examples.
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_value(SLV2Plugin p,
+ SLV2URIType predicate_type,
const char* predicate);
@@ -162,15 +158,19 @@
* (if information about it is contained in the plugin's data files).
*
* May return NULL if the property was not found, or if object is not
- * sensibly represented as an SLV2Strings (e.g. blank nodes).
+ * sensibly represented as an SLV2Values (e.g. blank nodes).
+ *
+ * \a predicate must be either a URI or a QName.
+ * See SLV2URIType documentation for examples.
*
- * Return value must be freed by caller with slv2_strings_free.
+ * Return value must be freed by caller with slv2_values_free.
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_value_for_subject(SLV2Plugin p,
- const char* subject,
+ SLV2Value subject,
+ SLV2URIType predicate_type,
const char* predicate);
@@ -184,7 +184,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_properties(SLV2Plugin p);
@@ -197,7 +197,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_hints(SLV2Plugin p);
@@ -242,7 +242,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_supported_features(SLV2Plugin p);
@@ -253,7 +253,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_required_features(SLV2Plugin p);
@@ -265,7 +265,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_get_optional_features(SLV2Plugin p);
@@ -273,15 +273,16 @@
*
* \param plugin The plugin to query.
* \param sparql_str A SPARQL SELECT query.
- * \param variable The variable to return results for.
+ * \param variable The index of the variable to return results for
+ * (i.e. with "<code>SELECT ?foo ?bar</code>" foo is 0, and bar is 1).
* \return All matches for \a variable.
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_plugin_simple_query(SLV2Plugin plugin,
const char* sparql_str,
- const char* variable);
+ unsigned variable);
/** Query a plugin and return the number of results found.
Index: 3rdparty/slv2/slv2/plugininstance.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/plugininstance.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/plugininstance.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/plugininstance.h 8 Jun 2007 09:29:06 -0000 1.2
@@ -28,11 +28,9 @@
#include <slv2/plugin.h>
#include <slv2/port.h>
-typedef struct _InstanceImpl* SLV2InstanceImpl;
-
-/** \defgroup lib Shared library access
+/** \defgroup lib Plugin library access
*
- * An SLV2Instance is an instantiated SLV2Plugin (eg a loaded dynamic
+ * An SLV2Instance is an instantiated SLV2Plugin (ie a loaded dynamic
* library). These functions interact with the binary library code only,
* they do not read data files in any way.
*
@@ -40,17 +38,20 @@
*/
+typedef struct _InstanceImpl* SLV2InstanceImpl;
+
+
/** 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
+ * performance critical functions like slv2_instance_run (which are exposed
+ * in lv2.h 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
+ SLV2InstanceImpl pimpl; ///< Private implementation
}* SLV2Instance;
@@ -83,10 +84,8 @@
void
slv2_instance_free(SLV2Instance instance);
-
#ifndef LIBSLV2_SOURCE
-
/** Get the URI of the plugin which \a instance is an instance of.
*
* Returned string is shared and must not be modified or deleted.
Index: 3rdparty/slv2/slv2/port.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/port.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/port.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/port.h 8 Jun 2007 09:29:06 -0000 1.2
@@ -26,7 +26,7 @@
#include <slv2/types.h>
#include <slv2/plugin.h>
#include <slv2/port.h>
-#include <slv2/stringlist.h>
+#include <slv2/values.h>
/** \addtogroup data
* @{
@@ -37,7 +37,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_port_get_value(SLV2Plugin plugin,
SLV2Port port,
const char* property);
@@ -47,7 +47,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_port_get_properties(SLV2Plugin plugin,
SLV2Port port);
@@ -56,7 +56,7 @@
*
* Time = Query
*/
-SLV2Strings
+SLV2Values
slv2_port_get_hints(SLV2Plugin plugin,
SLV2Port port);
Index: 3rdparty/slv2/slv2/slv2.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/slv2.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/slv2.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/slv2.h 8 Jun 2007 09:29:06 -0000 1.2
@@ -16,8 +16,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __SLV2_H
-#define __SLV2_H
+#ifndef __SLV2_H__
+#define __SLV2_H__
#ifdef __cplusplus
extern "C" {
@@ -25,15 +25,16 @@
#include <slv2/types.h>
#include <slv2/world.h>
+#include <slv2/pluginclass.h>
#include <slv2/plugin.h>
#include <slv2/port.h>
-#include <slv2/pluginlist.h>
+#include <slv2/plugins.h>
#include <slv2/plugininstance.h>
-#include <slv2/stringlist.h>
-
+#include <slv2/value.h>
+#include <slv2/values.h>
#ifdef __cplusplus
}
#endif
-#endif /* __SLV2_H */
+#endif /* __SLV2_H__ */
Index: 3rdparty/slv2/slv2/types.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/types.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/types.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/types.h 8 Jun 2007 09:29:07 -0000 1.2
@@ -33,7 +33,7 @@
* to make the most common case simple. Use slv2_port_get_value(p, "rdf:type")
* if you need further class information.
*/
-typedef enum _PortClass {
+typedef enum _SLV2PortClass {
SLV2_UNKNOWN_PORT_CLASS,
SLV2_CONTROL_INPUT, /**< One input float per block */
SLV2_CONTROL_OUTPUT, /**< One output float per block */
@@ -44,16 +44,47 @@
} SLV2PortClass;
+/** The format of a URI string.
+ *
+ * Full URI: http://example.org/foo
+ * QName: lv2:Plugin
+ */
+typedef enum _SLV2URIType {
+ SLV2_URI,
+ SLV2_QNAME
+} SLV2URIType;
+
+
/** A port on a plugin. Opaque, but valid to compare to NULL. */
-typedef struct _Port* SLV2Port;
+typedef struct _SLV2Port* SLV2Port;
/** A plugin. Opaque, but valid to compare to NULL. */
-typedef struct _Plugin* SLV2Plugin;
+typedef struct _SLV2Plugin* SLV2Plugin;
+
+
+/** A collection of plugins. Opaque, but valid to compare to NULL. */
+typedef void* SLV2Plugins;
/** The world. Opaque, but valid to compare to NULL. */
-typedef struct _World* SLV2World;
+typedef struct _SLV2World* SLV2World;
+
+
+/** A plugin class. Opaque, but valid to compare to NULL. */
+typedef struct _SLV2PluginClass* SLV2PluginClass;
+
+
+/** A collection of plugin classes. Opaque, but valid to compare to NULL. */
+typedef void* SLV2PluginClasses;
+
+
+/** A typed value */
+typedef struct _SLV2Value* SLV2Value;
+
+
+/** A collection of typed values. */
+typedef void* SLV2Values;
#ifdef __cplusplus
Index: 3rdparty/slv2/slv2/util.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/util.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/util.h 8 Jun 2007 09:29:07 -0000 1.2
@@ -25,7 +25,6 @@
extern "C" {
#endif
-
/** \defgroup util Utility functions
*
* @{
Index: 3rdparty/slv2/slv2/world.h
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/slv2/world.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/slv2/world.h 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/slv2/world.h 8 Jun 2007 09:29:07 -0000 1.2
@@ -19,14 +19,15 @@
#ifndef __SLV2_WORLD_H__
#define __SLV2_WORLD_H__
-#include <slv2/pluginlist.h>
+#include <slv2/plugins.h>
+#include <slv2/pluginclasses.h>
+#include <librdf.h>
#ifdef __cplusplus
extern "C" {
#endif
-
-/** \defgroup world Library context, data loading, etc.
+/** \defgroup world Library
*
* The "world" represents all library state, and the data found in bundles'
* manifest.ttl (ie it is an in-memory index of all things LV2 found).
@@ -52,6 +53,12 @@
slv2_world_new();
+/** Initialize a new, empty world, using an existing Redland context.
+ */
+SLV2World
+slv2_world_new_using_rdf_world(librdf_world* world);
+
+
/** Destroy the world, mwahaha.
*
* NB: Destroying the world will leave dangling references in any plugin lists,
@@ -102,6 +109,24 @@
const char* bundle_uri);
+/** Get the parent of all other plugin classes, lv2:Plugin.
+ *
+ * Time = O(1)
+ */
+SLV2PluginClass
+slv2_world_get_plugin_class(SLV2World world);
+
+
+/** Return a list of all found plugin classes.
+ *
+ * Returned list is owned by world and must not be freed by the caller.
+ *
+ * Time = O(1)
+ */
+SLV2PluginClasses
+slv2_world_get_plugin_classes(SLV2World world);
+
+
/** Return a list of all found plugins.
*
* The returned list contains just enough references to query
@@ -110,8 +135,8 @@
* a query (at which time the data is cached with the SLV2Plugin so future
* queries are very fast).
*
- * Returned plugins contain a reference to this world, world must not be
- * destroyed until plugins are finished with.
+ * Returned list must be freed by user with slv2_plugins_free. The contained
+ * plugins are owned by \a world and must not be freed by caller.
*
* Time = O(1)
*/
@@ -125,8 +150,8 @@
* \a include (a pointer to a function which takes an SLV2Plugin and returns
* a bool) will be in the returned list.
*
- * Returned plugins contain a reference to this world, world must not be
- * destroyed until plugins are finished with.
+ * Returned list must be freed by user with slv2_plugins_free. The contained
+ * plugins are owned by \a world and must not be freed by caller.
*
* Time = O(n * Time(include))
*/
@@ -136,6 +161,19 @@
#if 0
+/** Return a list of found plugins in a given class.
+ *
+ * Returned list must be freed by user with slv2_plugins_free. The contained
+ * plugins are owned by \a world and must not be freed by caller.
+ *
+ * Time = O(n)
+ */
+SLV2Plugins
+slv2_world_get_plugins_by_class(SLV2World world,
+ SLV2PluginClass plugin_class);
+#endif
+
+#if 0
/** Get plugins filtered by a user-defined SPARQL query.
*
* This is much faster than using slv2_world_get_plugins_by_filter with a
Index: 3rdparty/slv2/src/plugin.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/plugin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/src/plugin.c 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/src/plugin.c 8 Jun 2007 09:29:07 -0000 1.2
@@ -22,22 +22,25 @@
#include <stdlib.h>
#include <assert.h>
#include <librdf.h>
+#include "slv2_internal.h"
#include <slv2/plugin.h>
#include <slv2/types.h>
#include <slv2/util.h>
-#include <slv2/stringlist.h>
-#include "private_types.h"
+#include <slv2/values.h>
+#include <slv2/pluginclass.h>
+#include <slv2/pluginclasses.h>
/* private */
SLV2Plugin
slv2_plugin_new(SLV2World world, librdf_uri* uri, const char* binary_uri)
{
- struct _Plugin* plugin = malloc(sizeof(struct _Plugin));
+ struct _SLV2Plugin* plugin = malloc(sizeof(struct _SLV2Plugin));
plugin->world = world;
plugin->plugin_uri = librdf_new_uri_from_uri(uri);
plugin->binary_uri = strdup(binary_uri);
- plugin->data_uris = slv2_strings_new();
+ plugin->plugin_class = NULL;
+ plugin->data_uris = slv2_values_new();
plugin->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free,
NULL);
plugin->storage = NULL;
plugin->rdf = NULL;
@@ -69,7 +72,7 @@
p->storage = NULL;
}
- slv2_strings_free(p->data_uris);
+ slv2_values_free(p->data_uris);
free(p);
}
@@ -93,9 +96,9 @@
//result->bundle_url = strdup(p->bundle_url);
result->binary_uri = strdup(p->binary_uri);
- result->data_uris = slv2_strings_new();
- for (unsigned i=0; i < slv2_strings_size(p->data_uris); ++i)
- raptor_sequence_push(result->data_uris,
strdup(slv2_strings_get_at(p->data_uris, i)));
+ result->data_uris = slv2_values_new();
+ for (unsigned i=0; i < slv2_values_size(p->data_uris); ++i)
+ raptor_sequence_push(result->data_uris,
strdup(slv2_values_get_at(p->data_uris, i)));
result->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free,
NULL);
for (int i=0; i < raptor_sequence_size(p->ports); ++i)
@@ -138,15 +141,49 @@
}
// Parse all the plugin's data files into RDF model
- for (unsigned i=0; i < slv2_strings_size(p->data_uris); ++i) {
- const char* data_uri_str = slv2_strings_get_at(p->data_uris, i);
- librdf_uri* data_uri = librdf_new_uri(p->world->world, (const
unsigned char*)data_uri_str);
+ for (unsigned i=0; i < slv2_values_size(p->data_uris); ++i) {
+ SLV2Value data_uri_val = slv2_values_get_at(p->data_uris, i);
+ librdf_uri* data_uri = librdf_new_uri(p->world->world,
+ (const unsigned
char*)slv2_value_as_uri(data_uri_val));
librdf_parser_parse_into_model(p->world->parser, data_uri,
NULL, p->rdf);
librdf_free_uri(data_uri);
}
- // Load ports
+ // Load plugin_class
const unsigned char* query = (const unsigned char*)
+ "SELECT DISTINCT ?class WHERE { <> a ?class }";
+
+ librdf_query* q = librdf_new_query(p->world->world, "sparql",
+ NULL, query, p->plugin_uri);
+
+ 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);
+ const char* class_uri_str = (const
char*)librdf_uri_as_string(class_uri);
+
+ SLV2PluginClass plugin_class = slv2_plugin_classes_get_by_uri(
+ p->world->plugin_classes, class_uri_str);
+
+ librdf_free_node(class_node);
+
+ if (plugin_class) {
+ p->plugin_class = plugin_class;
+ break;
+ }
+
+ librdf_query_results_next(results);
+ }
+
+ if (p->plugin_class == NULL)
+ p->plugin_class =
raptor_sequence_get_at(p->world->plugin_classes, 0); // lv2:Plugin
+
+ librdf_free_query_results(results);
+ librdf_free_query(q);
+
+ // Load ports
+ query = (const unsigned char*)
"PREFIX : <http://lv2plug.in/ontology#>\n"
"SELECT DISTINCT ?port ?symbol ?index WHERE {\n"
"<> :port ?port .\n"
@@ -154,10 +191,10 @@
" :index ?index .\n"
"}";
- librdf_query* q = librdf_new_query(p->world->world, "sparql",
+ q = librdf_new_query(p->world->world, "sparql",
NULL, query, p->plugin_uri);
- librdf_query_results* results = librdf_query_execute(q, p->rdf);
+ results = librdf_query_execute(q, p->rdf);
while (!librdf_query_results_finished(results)) {
@@ -187,9 +224,7 @@
raptor_sequence_sort(p->ports, slv2_port_compare_by_index);
- if (results)
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));
@@ -203,7 +238,7 @@
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_data_uris(SLV2Plugin p)
{
return p->data_uris;
@@ -217,6 +252,19 @@
}
+SLV2PluginClass
+slv2_plugin_get_class(SLV2Plugin p)
+{
+ // FIXME: Typical use case this will bring every single plugin model
+ // into memory
+
+ if (!p->rdf)
+ slv2_plugin_load(p);
+
+ return p->plugin_class;
+}
+
+
bool
slv2_plugin_verify(SLV2Plugin plugin)
{
@@ -277,31 +325,45 @@
slv2_plugin_get_name(SLV2Plugin plugin)
{
char* result = NULL;
- SLV2Strings prop = slv2_plugin_get_value(plugin, "doap:name");
+ SLV2Values prop = slv2_plugin_get_value(plugin, SLV2_QNAME,
"doap:name");
- // FIXME: guaranteed to be the untagged one?
- if (prop && slv2_strings_size(prop) >= 1)
- result = strdup(slv2_strings_get_at(prop, 0));
+ // FIXME: lang? guaranteed to be the untagged one?
+ if (prop && slv2_values_size(prop) > 0) {
+ SLV2Value val = slv2_values_get_at(prop, 0);
+ if (slv2_value_is_string(val))
+ result = strdup(slv2_value_as_string(val));
+ }
if (prop)
- slv2_strings_free(prop);
+ slv2_values_free(prop);
return result;
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_value(SLV2Plugin p,
+ SLV2URIType predicate_type,
const char* predicate)
{
- assert(predicate);
+ char* query = NULL;
- char* query = slv2_strjoin(
- "SELECT DISTINCT ?value WHERE {"
- "<> ", predicate, " ?value .\n"
+ /* Hack around broken RASQAL, full URI predicates don't work :/ */
+
+ if (predicate_type == SLV2_URI) {
+ query = slv2_strjoin(
+ "PREFIX slv2predicate: <", predicate, ">",
+ "SELECT DISTINCT ?value WHERE { \n"
+ "<> slv2predicate: ?value \n"
+ "}\n", NULL);
+ } else {
+ query = slv2_strjoin(
+ "SELECT DISTINCT ?value WHERE { \n"
+ "<> ", predicate, " ?value \n"
"}\n", NULL);
+ }
- SLV2Strings result = slv2_plugin_simple_query(p, query, "value");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
free(query);
@@ -309,19 +371,36 @@
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_value_for_subject(SLV2Plugin p,
- const char* subject,
+ SLV2Value subject,
+ SLV2URIType predicate_type,
const char* predicate)
{
- assert(predicate);
+ if (subject->type != SLV2_VALUE_URI) {
+ fprintf(stderr, "slv2_plugin_get_value_for_subject error: "
+ "passed non-URI subject\n");
+ return NULL;
+ }
+
+ char* query = NULL;
+
+ /* Hack around broken RASQAL, full URI predicates don't work :/ */
- char* query = slv2_strjoin(
- "SELECT DISTINCT ?value WHERE {\n",
- subject, " ", predicate, " ?value .\n"
+ if (predicate_type == SLV2_URI) {
+ query = slv2_strjoin(
+ "PREFIX slv2predicate: <", predicate, ">",
+ "SELECT DISTINCT ?value WHERE { \n",
+ slv2_value_get_turtle_token(subject), " slv2predicate:
?value \n"
+ "}\n", NULL);
+ } else {
+ query = slv2_strjoin(
+ "SELECT DISTINCT ?value WHERE { \n",
+ slv2_value_get_turtle_token(subject), " ", predicate, "
?value \n"
"}\n", NULL);
+ }
- SLV2Strings result = slv2_plugin_simple_query(p, query, "value");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
free(query);
@@ -329,17 +408,17 @@
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_properties(SLV2Plugin p)
{
- return slv2_plugin_get_value(p, "lv2:pluginProperty");
+ return slv2_plugin_get_value(p, SLV2_QNAME, "lv2:pluginProperty");
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_hints(SLV2Plugin p)
{
- return slv2_plugin_get_value(p, "lv2:pluginHint");
+ return slv2_plugin_get_value(p, SLV2_QNAME, "lv2:pluginHint");
}
@@ -354,18 +433,15 @@
slv2_plugin_has_latency(SLV2Plugin p)
{
const char* const query =
- "SELECT DISTINCT ?port WHERE {\n"
+ "SELECT DISTINCT ?index WHERE {\n"
" <> lv2:port ?port .\n"
- " ?port lv2:portHint lv2:reportsLatency .\n"
+ " ?port lv2:portHint lv2:reportsLatency ;\n"
+ " lv2:index ?index .\n"
"}\n";
- SLV2Strings results = slv2_plugin_simple_query(p, query, "port");
-
- bool exists = (slv2_strings_size(results) > 0);
-
- slv2_strings_free(results);
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
- return exists;
+ return (slv2_values_size(result) > 0);
}
@@ -373,25 +449,24 @@
slv2_plugin_get_latency_port(SLV2Plugin p)
{
const char* const query =
- "SELECT DISTINCT ?value WHERE {\n"
+ "SELECT DISTINCT ?index WHERE {\n"
" <> lv2:port ?port .\n"
" ?port lv2:portHint lv2:reportsLatency ;\n"
" lv2:index ?index .\n"
"}\n";
- SLV2Strings result = slv2_plugin_simple_query(p, query, "index");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
// FIXME: need a sane error handling strategy
- assert(slv2_strings_size(result) == 1);
- char* endptr = 0;
- uint32_t index = strtol(slv2_strings_get_at(result, 0), &endptr, 10);
- // FIXME: check.. stuff..
+ assert(slv2_values_size(result) > 0);
+ SLV2Value val = slv2_values_get_at(result, 0);
+ assert(slv2_value_is_int(val));
- return index;
+ return slv2_value_as_int(val);
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_supported_features(SLV2Plugin p)
{
const char* const query =
@@ -401,35 +476,35 @@
" { <> lv2:requiredHostFeature ?feature }\n"
"}\n";
- SLV2Strings result = slv2_plugin_simple_query(p, query, "feature");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
return result;
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_optional_features(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
- " <> lv2:optionalHostFeature ?feature .\n"
+ " <> lv2:optionalHostFeature ?feature\n"
"}\n";
- SLV2Strings result = slv2_plugin_simple_query(p, query, "feature");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
return result;
}
-SLV2Strings
+SLV2Values
slv2_plugin_get_required_features(SLV2Plugin p)
{
const char* const query =
"SELECT DISTINCT ?feature WHERE {\n"
- " <> lv2:requiredHostFeature ?feature .\n"
+ " <> lv2:requiredHostFeature ?feature\n"
"}\n";
- SLV2Strings result = slv2_plugin_simple_query(p, query, "feature");
+ SLV2Values result = slv2_plugin_simple_query(p, query, 0);
return result;
}
Index: 3rdparty/slv2/src/plugininstance.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/plugininstance.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/src/plugininstance.c 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/src/plugininstance.c 8 Jun 2007 09:29:07 -0000 1.2
@@ -27,7 +27,7 @@
#include <slv2/plugin.h>
#include <slv2/plugininstance.h>
#include <slv2/util.h>
-#include "private_types.h"
+#include "slv2_internal.h"
SLV2Instance
Index: 3rdparty/slv2/src/port.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/port.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/src/port.c 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/src/port.c 8 Jun 2007 09:29:07 -0000 1.2
@@ -25,14 +25,15 @@
#include <slv2/port.h>
#include <slv2/types.h>
#include <slv2/util.h>
-#include "private_types.h"
+#include <slv2/values.h>
+#include "slv2_internal.h"
/* private */
SLV2Port
slv2_port_new(uint32_t index, const char* symbol/*, const char* node_id*/)
{
- struct _Port* port = malloc(sizeof(struct _Port));
+ struct _SLV2Port* port = malloc(sizeof(struct _SLV2Port));
port->index = index;
port->symbol = strdup(symbol);
//port->node_id = strdup(node_id);
@@ -54,7 +55,7 @@
SLV2Port
slv2_port_duplicate(SLV2Port port)
{
- struct _Port* result = malloc(sizeof(struct _Port));
+ SLV2Port result = malloc(sizeof(struct _SLV2Port));
result->index = port->index;
result->symbol = strdup(port->symbol);
//result->node_id = strdup(port->node_id);
@@ -66,7 +67,7 @@
slv2_port_get_class(SLV2Plugin p,
SLV2Port port)
{
- SLV2Strings class = slv2_port_get_value(p, port, "rdf:type");
+ SLV2Values class = slv2_port_get_value(p, port, "rdf:type");
assert(class);
SLV2PortClass ret = SLV2_UNKNOWN_PORT_CLASS;
@@ -74,19 +75,22 @@
int io = -1; // 0 = in, 1 = out
enum { UNKNOWN, AUDIO, CONTROL, MIDI } type = UNKNOWN;
- for (unsigned i=0; i < slv2_strings_size(class); ++i) {
- const char* value = slv2_strings_get_at(class, i);
- if (!strcmp(value, "http://lv2plug.in/ontology#InputPort"))
+ for (unsigned i=0; i < slv2_values_size(class); ++i) {
+ SLV2Value val = slv2_values_get_at(class, i);
+ if (slv2_value_is_uri(val)) {
+ const char* uri = slv2_value_as_uri(val);
+ if (!strcmp(uri,
"http://lv2plug.in/ontology#InputPort"))
io = 0;
- else if (!strcmp(value,
"http://lv2plug.in/ontology#OutputPort"))
+ else if (!strcmp(uri,
"http://lv2plug.in/ontology#OutputPort"))
io = 1;
- else if (!strcmp(value,
"http://lv2plug.in/ontology#ControlPort"))
+ else if (!strcmp(uri,
"http://lv2plug.in/ontology#ControlPort"))
type = CONTROL;
- else if (!strcmp(value, "http://lv2plug.in/ontology#AudioPort"))
+ else if (!strcmp(uri,
"http://lv2plug.in/ontology#AudioPort"))
type = AUDIO;
- else if (!strcmp(value,
"http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
+ else if (!strcmp(uri,
"http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
type = MIDI;
}
+ }
if (io == 0) {
if (type == AUDIO)
@@ -104,27 +108,27 @@
ret = SLV2_MIDI_OUTPUT;
}
- slv2_strings_free(class);
+ slv2_values_free(class);
return ret;
}
-SLV2Strings
+SLV2Values
slv2_port_get_value(SLV2Plugin p,
SLV2Port port,
const char* property)
{
assert(property);
- SLV2Strings result = NULL;
+ SLV2Values result = NULL;
char* query = slv2_strjoin(
"SELECT DISTINCT ?value WHERE {\n"
"?port lv2:symbol \"", port->symbol, "\";\n\t",
property, " ?value .\n}", 0);
- result = slv2_plugin_simple_query(p, query, "value");
+ result = slv2_plugin_simple_query(p, query, 0);
free(query);
@@ -138,12 +142,12 @@
{
char* symbol = NULL;
- SLV2Strings result = slv2_port_get_value(p, port, "lv2:symbol");
+ SLV2Values result = slv2_port_get_value(p, port, "lv2:symbol");
- if (result && slv2_strings_size(result) == 1)
- symbol = strdup(slv2_strings_get_at(result, 0));
+ if (result && slv2_values_size(result) == 1)
+ symbol = strdup(slv2_value_as_string(slv2_values_get_at(result,
0)));
- slv2_strings_free(result);
+ slv2_values_free(result);
return symbol;
}
@@ -155,12 +159,12 @@
{
char* name = NULL;
- SLV2Strings result = slv2_port_get_value(p, port, "lv2:name");
+ SLV2Values result = slv2_port_get_value(p, port, "lv2:name");
- if (result && slv2_strings_size(result) == 1)
- name = strdup(slv2_strings_get_at(result, 0));
+ if (result && slv2_values_size(result) == 1)
+ name = strdup(slv2_value_as_string(slv2_values_get_at(result,
0)));
- slv2_strings_free(result);
+ slv2_values_free(result);
return name;
}
@@ -170,16 +174,14 @@
slv2_port_get_default_value(SLV2Plugin p,
SLV2Port port)
{
- // FIXME: do casting properly in the SPARQL query
-
float value = 0.0f;
- SLV2Strings result = slv2_port_get_value(p, port, "lv2:default");
+ SLV2Values result = slv2_port_get_value(p, port, "lv2:default");
- if (result && slv2_strings_size(result) == 1)
- value = atof(slv2_strings_get_at(result, 0));
+ if (result && slv2_values_size(result) == 1)
+ value = slv2_value_as_float(slv2_values_get_at(result, 0));
- slv2_strings_free(result);
+ slv2_values_free(result);
return value;
}
@@ -189,16 +191,14 @@
slv2_port_get_minimum_value(SLV2Plugin p,
SLV2Port port)
{
- // FIXME: need better access to literal types
-
float value = 0.0f;
- SLV2Strings result = slv2_port_get_value(p, port, "lv2:minimum");
+ SLV2Values result = slv2_port_get_value(p, port, "lv2:minimum");
- if (result && slv2_strings_size(result) == 1)
- value = atof(slv2_strings_get_at(result, 0));
+ if (result && slv2_values_size(result) == 1)
+ value = slv2_value_as_float(slv2_values_get_at(result, 0));
- slv2_strings_free(result);
+ slv2_values_free(result);
return value;
}
@@ -208,22 +208,20 @@
slv2_port_get_maximum_value(SLV2Plugin p,
SLV2Port port)
{
- // FIXME: need better access to literal types
-
float value = 0.0f;
- SLV2Strings result = slv2_port_get_value(p, port, "lv2:maximum");
+ SLV2Values result = slv2_port_get_value(p, port, "lv2:maximum");
- if (result && slv2_strings_size(result) == 1)
- value = atof(slv2_strings_get_at(result, 0));
+ if (result && slv2_values_size(result) == 1)
+ value = slv2_value_as_float(slv2_values_get_at(result, 0));
- slv2_strings_free(result);
+ slv2_values_free(result);
return value;
}
-SLV2Strings
+SLV2Values
slv2_port_get_properties(SLV2Plugin p,
SLV2Port port)
{
@@ -231,7 +229,7 @@
}
-SLV2Strings
+SLV2Values
slv2_port_get_hints(SLV2Plugin p,
SLV2Port port)
{
Index: 3rdparty/slv2/src/query.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/query.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- 3rdparty/slv2/src/query.c 23 Apr 2007 11:59:21 -0000 1.1
+++ 3rdparty/slv2/src/query.c 8 Jun 2007 09:29:07 -0000 1.2
@@ -21,10 +21,11 @@
#include <stdlib.h>
#include <assert.h>
#include <librdf.h>
+#include <limits.h>
#include <slv2/plugin.h>
#include <slv2/util.h>
-#include <slv2/stringlist.h>
-#include "private_types.h"
+#include <slv2/values.h>
+#include "slv2_internal.h"
static const char* slv2_query_prefixes =
@@ -51,42 +52,55 @@
}
#endif
-SLV2Strings
+SLV2Values
slv2_query_get_variable_bindings(librdf_query_results* results,
- const char* variable)
+ int variable)
{
- SLV2Strings result = NULL;
+ SLV2Values result = NULL;
if (librdf_query_results_get_bindings_count(results) > 0)
- result = slv2_strings_new();
+ result = slv2_values_new();
while (!librdf_query_results_finished(results)) {
librdf_node* node =
- librdf_query_results_get_binding_value_by_name(results, variable);
+ librdf_query_results_get_binding_value(results, variable);
- char* str = NULL;
+ librdf_uri* datatype_uri = NULL;
+ SLV2ValueType type = SLV2_VALUE_STRING;
+
+ const char* str_val = NULL;
switch (librdf_node_get_type(node)) {
case LIBRDF_NODE_TYPE_RESOURCE:
- str = strdup((const
char*)librdf_uri_as_string(librdf_node_get_uri(node)));
+ type = SLV2_VALUE_URI;
+ str_val = (const
char*)librdf_uri_as_string(librdf_node_get_uri(node));
break;
case LIBRDF_NODE_TYPE_LITERAL:
- str = strdup((const
char*)librdf_node_get_literal_value(node));
+ datatype_uri =
librdf_node_get_literal_value_datatype_uri(node);
+ if (datatype_uri) {
+ if (!strcmp((const
char*)librdf_uri_as_string(datatype_uri),
+
"http://www.w3.org/2001/XMLSchema#integer"))
+ type = SLV2_VALUE_INT;
+ else if (!strcmp((const
char*)librdf_uri_as_string(datatype_uri),
+
"http://www.w3.org/2001/XMLSchema#decimal"))
+ type = SLV2_VALUE_FLOAT;
+ else
+ fprintf(stderr, "Unknown datatype
%s\n", librdf_uri_as_string(datatype_uri));
+ }
+ str_val = (const
char*)librdf_node_get_literal_value(node);
break;
case LIBRDF_NODE_TYPE_BLANK:
- str = strdup((const
char*)librdf_node_get_blank_identifier(node));
+ str_val = (const
char*)librdf_node_get_blank_identifier(node);
break;
case LIBRDF_NODE_TYPE_UNKNOWN:
default:
- fprintf(stderr, "Unknown variable binding type for
?%s\n", variable);
+ fprintf(stderr, "Unknown variable binding type %d\n",
variable);
break;
}
- if (str) {
- //printf("?%s = %s\n", variable, str);
- raptor_sequence_push(result, str);
- }
+ if (str_val)
+ raptor_sequence_push(result, slv2_value_new(type,
str_val));
librdf_free_node(node);
@@ -124,46 +138,35 @@
//printf("******** Query \n%s********\n", query_str);
- librdf_query *rq = librdf_new_query(plugin->world->world, "sparql",
NULL,
+ librdf_query* query = librdf_new_query(plugin->world->world, "sparql",
NULL,
(const unsigned char*)query_str, base_uri);
- if (!rq) {
+ if (!query) {
fprintf(stderr, "ERROR: Could not create query\n");
return NULL;
}
- // Add LV2 ontology to query sources
- //librdf_query_add_data_graph(rq, slv2_ontology_uri,
- // NULL, RASQAL_DATA_GRAPH_BACKGROUND);
-
- // Add all plugin data files to query sources
- /*for (unsigned i=0; i < slv2_strings_size(plugin->data_uris); ++i) {
- const char* file_uri_str =
slv2_strings_get_at(plugin->data_uris, i);
- raptor_uri* file_uri = raptor_new_uri((const unsigned
char*)file_uri_str);
- librdf_query_add_data_graph(rq, file_uri,
- NULL, RASQAL_DATA_GRAPH_BACKGROUND);
- raptor_free_uri(file_uri);
- }*/
-
- librdf_query_results* results = librdf_query_execute(rq, plugin->rdf);
-
- librdf_free_query(rq);
+ librdf_query_results* results = librdf_query_execute(query,
plugin->rdf);
+ librdf_free_query(query);
free(query_str);
- // FIXME: results leaked internally in places?
return results;
}
/** Query a single variable */
-SLV2Strings
+SLV2Values
slv2_plugin_simple_query(SLV2Plugin plugin,
const char* sparql_str,
- const char* variable)
+ unsigned variable)
{
+ assert(variable < INT_MAX);
+
librdf_query_results* results = slv2_plugin_query(plugin, sparql_str);
- SLV2Strings ret = slv2_query_get_variable_bindings(results, variable);
+
+ SLV2Values ret = slv2_query_get_variable_bindings(results,
(int)variable);
+
librdf_free_query_results(results);
return ret;
@@ -181,16 +184,17 @@
{
librdf_query_results* results = slv2_plugin_query(plugin, sparql_str);
+ unsigned ret = 0;
+
if (results) {
- unsigned ret = slv2_query_count_bindings(results);
+ ret = slv2_query_count_bindings(results);
librdf_free_query_results(results);
- return ret;
- } else {
- return 0;
}
-}
+ return ret;
+}
+/*
size_t
slv2_query_count_results(SLV2Plugin p,
const char* query)
@@ -205,10 +209,6 @@
//printf("Query: \n%s\n\n", query_str);
- // Add LV2 ontology to query sources
- //librdf_query_add_data_graph(rq, slv2_ontology_uri,
- // NULL, RASQAL_DATA_GRAPH_BACKGROUND);
-
librdf_query_results* results = librdf_query_execute(rq,
p->world->model);
assert(results);
@@ -221,4 +221,4 @@
return count;
}
-
+*/
Index: 3rdparty/slv2/src/world.c
===================================================================
RCS file: /sources/traverso/traverso/src/3rdparty/slv2/src/world.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- 3rdparty/slv2/src/world.c 4 Jun 2007 08:53:38 -0000 1.2
+++ 3rdparty/slv2/src/world.c 8 Jun 2007 09:29:08 -0000 1.3
@@ -25,14 +25,14 @@
#include <slv2/world.h>
#include <slv2/slv2.h>
#include <slv2/util.h>
-//#include "config.h"
-#include "private_types.h"
+#include "config.h"
+#include "slv2_internal.h"
SLV2World
slv2_world_new()
{
- struct _World* world = (struct _World*)malloc(sizeof(struct _World));
+ SLV2World world = (SLV2World)malloc(sizeof(struct _SLV2World));
world->world = librdf_new_world();
librdf_world_open(world->world);
@@ -44,10 +44,41 @@
world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
+ world->plugin_classes = slv2_plugin_classes_new();
+
+ // Add the ever-present lv2:Plugin to classes
+ static const char* lv2_plugin_uri = "http://lv2plug.in/ontology#Plugin";
+ raptor_sequence_push(world->plugin_classes, slv2_plugin_class_new(
+ world, NULL, lv2_plugin_uri, "Plugin"));
+
world->plugins = slv2_plugins_new();
- /*slv2_ontology_uri = raptor_new_uri((const unsigned char*)
- "file://" LV2_TTL_PATH);*/
+ return world;
+}
+
+
+SLV2World
+slv2_world_new_using_rdf_world(librdf_world* rdf_world)
+{
+ SLV2World world = (SLV2World)malloc(sizeof(struct _SLV2World));
+
+ world->world = rdf_world;
+
+ world->storage = librdf_new_storage(world->world, "hashes", NULL,
+ "hash-type='memory'");
+
+ world->model = librdf_new_model(world->world, world->storage, NULL);
+
+ world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
+
+ world->plugin_classes = slv2_plugin_classes_new();
+
+ // Add the ever-present lv2:Plugin to classes
+ static const char* lv2_plugin_uri = "http://lv2plug.in/ontology#Plugin";
+ raptor_sequence_push(world->plugin_classes, slv2_plugin_class_new(
+ world, NULL, lv2_plugin_uri, "Plugin"));
+
+ world->plugins = slv2_plugins_new();
return world;
}
@@ -56,14 +87,14 @@
void
slv2_world_free(SLV2World world)
{
- /*raptor_free_uri(slv2_ontology_uri);
- slv2_ontology_uri = NULL;*/
-
for (int i=0; i < raptor_sequence_size(world->plugins); ++i)
slv2_plugin_free(raptor_sequence_get_at(world->plugins, i));
raptor_free_sequence(world->plugins);
world->plugins = NULL;
+ slv2_plugin_classes_free(world->plugin_classes);
+ world->plugin_classes = NULL;
+
librdf_free_parser(world->parser);
world->parser = NULL;
@@ -89,8 +120,50 @@
librdf_uri* manifest_uri = librdf_new_uri_relative_to_base(
bundle_uri, (const unsigned char*)"manifest.ttl");
- librdf_parser_parse_into_model(world->parser, manifest_uri, NULL,
world->model);
+ /* Parse the manifest into a temporary model */
+ librdf_storage* manifest_storage = librdf_new_storage(world->world,
+ "hashes", NULL, "hash-type='memory'");
+ librdf_model* manifest_model = librdf_new_model(world->world,
+ manifest_storage, NULL);
+ librdf_parser_parse_into_model(world->parser, manifest_uri, NULL,
+ manifest_model);
+ /* Find any plugins declared in the manifest and add references
+ * to their manifest files as one of their data files */
+ unsigned char* query_string = (unsigned char*)
+ "PREFIX : <http://lv2plug.in/ontology#>\n"
+ "SELECT DISTINCT ?plugin\n"
+ "WHERE { ?plugin a :Plugin }\n";
+
+ librdf_query* q = librdf_new_query(world->world, "sparql",
+ NULL, query_string, NULL);
+
+ librdf_query_results* results = librdf_query_execute(q, manifest_model);
+
+ while (!librdf_query_results_finished(results)) {
+
+ librdf_node* plugin_node =
librdf_query_results_get_binding_value(results, 0);
+
+ librdf_node* subject = plugin_node;
+ librdf_node* predicate =
librdf_new_node_from_uri_string(world->world,
+ (unsigned
char*)"http://www.w3.org/2000/01/rdf-schema#seeAlso");
+ librdf_node* object = librdf_new_node_from_uri(world->world,
+ manifest_uri);
+
+ librdf_model_add(world->model, subject, predicate, object);
+
+ librdf_query_results_next(results);
+ }
+
+ /* Join the temporary model to the main model */
+ librdf_stream* manifest_stream = librdf_model_as_stream(manifest_model);
+ librdf_model_add_statements(world->model, manifest_stream);
+ librdf_free_stream(manifest_stream);
+
+ librdf_free_query(q);
+ librdf_free_query_results(results);
+ librdf_free_model(manifest_model);
+ librdf_free_storage(manifest_storage);
librdf_free_uri(manifest_uri);
librdf_free_uri(bundle_uri);
}
@@ -163,12 +236,80 @@
}
*/
+
+void
+slv2_world_load_plugin_classes(SLV2World world)
+{
+ // FIXME: This will need to be a bit more clever when more data is
around
+ // then the ontology (ie classes which aren't LV2 plugin_classes)
+
+ // FIXME: This loads things that aren't plugin categories
+
+ unsigned char* query_string = (unsigned char*)
+ "PREFIX : <http://lv2plug.in/ontology#>\n"
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
+ "SELECT DISTINCT ?class ?parent ?label WHERE {\n"
+ //" ?plugin a :Plugin; a ?class .\n"
+ " ?class a rdfs:Class; rdfs:subClassOf ?parent;
rdfs:label ?label\n"
+ "} ORDER BY ?class\n";
+
+ librdf_query* q = librdf_new_query(world->world, "sparql",
+ NULL, query_string, NULL);
+
+ librdf_query_results* results = librdf_query_execute(q, world->model);
+
+ 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* parent_node =
librdf_query_results_get_binding_value(results, 1);
+ librdf_uri* parent_uri = librdf_node_get_uri(parent_node);
+ librdf_node* label_node =
librdf_query_results_get_binding_value(results, 2);
+ const char* label = (const
char*)librdf_node_get_literal_value(label_node);
+
+ //printf("CLASS: %s / %s\n", librdf_uri_as_string(parent_uri),
librdf_uri_as_string(class_uri));
+
+ SLV2PluginClass plugin_class = slv2_plugin_class_new(world,
+ (const char*)librdf_uri_as_string(parent_uri),
+ (const char*)librdf_uri_as_string(class_uri),
+ label);
+ raptor_sequence_push(world->plugin_classes, plugin_class);
+
+ librdf_free_node(class_node);
+ librdf_free_node(parent_node);
+ librdf_free_node(label_node);
+
+ librdf_query_results_next(results);
+ }
+
+ // FIXME: filter list here
+
+ librdf_free_query_results(results);
+ librdf_free_query(q);
+}
+
+
void
slv2_world_load_all(SLV2World world)
{
char* lv2_path = getenv("LV2_PATH");
- /* 1. Read all manifest files into model */
+ /* 1. Read LV2 ontology into model */
+ const char* ontology_path = "/usr/local/share/slv2/lv2.ttl";
+ FILE* ontology = fopen(ontology_path, "r");
+ if (ontology == NULL) {
+ ontology_path = "/usr/share/slv2/lv2.ttl";
+ ontology = fopen(ontology_path, "r");
+ }
+
+ if (ontology) {
+ fclose(ontology);
+ librdf_uri* ontology_uri =
librdf_new_uri_from_filename(world->world,
+ ontology_path);
+ librdf_parser_parse_into_model(world->parser, ontology_uri,
NULL, world->model);
+ librdf_free_uri(ontology_uri);
+ }
+
+ /* 2. Read all manifest files into model */
if (lv2_path) {
slv2_world_load_path(world, lv2_path);
@@ -177,15 +318,15 @@
const char* const suffix =
"/.lv2:/usr/local/lib/lv2:/usr/lib/lv2";
lv2_path = slv2_strjoin(home, suffix, NULL);
- //fprintf(stderr, "$LV2_PATH is unset. Using default path
%s\n", lv2_path);
-
slv2_world_load_path(world, lv2_path);
free(lv2_path);
}
- /* 2. Query out things to cache */
+ /* 3. Query out things to cache */
+
+ slv2_world_load_plugin_classes(world);
// Find all plugins and associated data files
unsigned char* query_string = (unsigned char*)
@@ -214,17 +355,17 @@
(const char*)librdf_uri_as_string(plugin_uri));
// Create a new SLV2Plugin
- if (!plugin)
+ if (!plugin) {
plugin = slv2_plugin_new(world, plugin_uri,
(const
char*)librdf_uri_as_string(binary_uri));
+ raptor_sequence_push(world->plugins, plugin);
+ }
plugin->world = world;
// FIXME: check for duplicates
raptor_sequence_push(plugin->data_uris,
- strdup((const
char*)librdf_uri_as_string(data_uri)));
-
- raptor_sequence_push(world->plugins, plugin);
+ slv2_value_new(SLV2_VALUE_URI, (const
char*)librdf_uri_as_string(data_uri)));
librdf_free_node(plugin_node);
librdf_free_node(data_node);
@@ -233,7 +374,7 @@
librdf_query_results_next(results);
}
- // ORDER BY should (and appears to actually) guarantee this
+ // 'ORDER BY ?plugin' guarantees this
//raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri);
if (results)
@@ -264,6 +405,20 @@
#endif
+SLV2PluginClass
+slv2_world_get_plugin_class(SLV2World world)
+{
+ return raptor_sequence_get_at(world->plugin_classes, 0);
+}
+
+
+SLV2PluginClasses
+slv2_world_get_plugin_classes(SLV2World world)
+{
+ return world->plugin_classes;
+}
+
+
SLV2Plugins
slv2_world_get_all_plugins(SLV2World world)
{
Index: plugins/LV2/LV2Plugin.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/LV2/LV2Plugin.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- plugins/LV2/LV2Plugin.cpp 7 Jun 2007 11:33:42 -0000 1.9
+++ plugins/LV2/LV2Plugin.cpp 8 Jun 2007 09:29:08 -0000 1.10
@@ -365,10 +365,10 @@
QStringList LV2ControlPort::get_hints()
{
SLV2Port port =
slv2_plugin_get_port_by_index(m_lv2plugin->get_slv2_plugin(), m_index);
- SLV2Strings list = slv2_port_get_hints(m_lv2plugin->get_slv2_plugin(),
port);
+ SLV2Values values = slv2_port_get_hints(m_lv2plugin->get_slv2_plugin(),
port);
QStringList qslist;
- for (unsigned i=0; i < slv2_strings_size(list); ++i) {
- qslist << QString(slv2_strings_get_at(list, i));
+ for (unsigned i=0; i < slv2_values_size(values); ++i) {
+ qslist <<
QString(slv2_value_as_string(slv2_values_get_at(values, i)));
}
return qslist;
}
@@ -429,10 +429,10 @@
// TODO WHY THE HACK DO I NEED TO CALL THIS TO BE ABLE TO QUERY PLUGIN
RDF DATA ????
char* name = slv2_plugin_get_name(plugin);
Q_UNUSED(name);
-
- SLV2Strings list = slv2_plugin_get_value_for_subject(plugin, "<>",
"a");
- for (unsigned i=0; i < slv2_strings_size(list); ++i) {
- QString type = slv2_strings_get_at(list, i);
+ printf("using new functions\n");
+ SLV2Values values = slv2_plugin_get_value(plugin, SLV2_QNAME, "a");
+ for (unsigned i=0; i < slv2_values_size(values); ++i) {
+ QString type = slv2_value_as_string(slv2_values_get_at(values,
i));
if (type.contains("http://lv2plug.in/ontology#")) {
return type.remove("http://lv2plug.in/ontology#");
}
Index: 3rdparty/slv2/config.h
===================================================================
RCS file: 3rdparty/slv2/config.h
diff -N 3rdparty/slv2/config.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/config.h 8 Jun 2007 09:29:05 -0000 1.1
@@ -0,0 +1,83 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Has JACK */
+#define HAVE_JACK 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if the system has the type `_Bool'. */
+#define HAVE__BOOL 1
+
+/* Defined if we JACK MIDI functions need nframes parameter. */
+#define JACK_MIDI_NEEDS_NFRAMES 1
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "slv2"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "address@hidden"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "slv2"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "slv2 0.0.1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "slv2"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.0.1"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "0.0.1"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
Index: 3rdparty/slv2/slv2/pluginclasses.h
===================================================================
RCS file: 3rdparty/slv2/slv2/pluginclasses.h
diff -N 3rdparty/slv2/slv2/pluginclasses.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/slv2/pluginclasses.h 8 Jun 2007 09:29:06 -0000 1.1
@@ -0,0 +1,77 @@
+/* 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_PLUGIN_CLASSES_H__
+#define __SLV2_PLUGIN_CLASSES_H__
+
+#include <slv2/pluginclass.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup plugin_classes Plugin classes
+ *
+ * @{
+ */
+
+
+/** Get the number of plugins in the list.
+ */
+unsigned
+slv2_plugin_classes_size(SLV2PluginClasses list);
+
+
+/** Get a plugin class from the list by URI.
+ *
+ * Return value is shared (stored in \a list) and must not be freed or
+ * modified by the caller in any way.
+ *
+ * Time = O(log2(n))
+ *
+ * \return NULL if plugin with \a url not found in \a list.
+ */
+SLV2PluginClass
+slv2_plugin_classes_get_by_uri(SLV2PluginClasses list,
+ const char* uri);
+
+
+/** Get a plugin from the list by index.
+ *
+ * \a index has no significance other than as an index into this list.
+ * Any \a index not less than slv2_plugin_classes_get_length(list) will return
NULL,
+ * so all plugin_classes in a list can be enumerated by repeated calls
+ * to this function starting with \a index = 0.
+ *
+ * Time = O(1)
+ *
+ * \return NULL if \a index out of range.
+ */
+SLV2PluginClass
+slv2_plugin_classes_get_at(SLV2PluginClasses list,
+ unsigned index);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_PLUGIN_CLASSES_H__ */
+
Index: 3rdparty/slv2/slv2/pluginclass.h
===================================================================
RCS file: 3rdparty/slv2/slv2/pluginclass.h
diff -N 3rdparty/slv2/slv2/pluginclass.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/slv2/pluginclass.h 8 Jun 2007 09:29:06 -0000 1.1
@@ -0,0 +1,76 @@
+/* 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_PLUGIN_CLASS_H__
+#define __SLV2_PLUGIN_CLASS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <slv2/types.h>
+
+/** \addtogroup data
+ * @{
+ */
+
+
+/** Get the URI of this class' superclass.
+ *
+ * Returned value is owned by \a plugin_class and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char* slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class);
+
+
+/** Get the URI of this plugin class.
+ *
+ * Returned value is owned by \a plugin_class and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char* slv2_plugin_class_get_uri(SLV2PluginClass plugin_class);
+
+
+/** Get the label of this plugin class, ie "Oscillators".
+ *
+ * Returned value is owned by \a plugin_class and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char* slv2_plugin_class_get_label(SLV2PluginClass plugin_class);
+
+
+/** Get the subclasses of this plugin class.
+ *
+ * Returned value must be freed by caller with slv2_plugin_classes_free.
+ *
+ * Time = O(nclasses)
+ */
+SLV2PluginClasses
+slv2_plugin_class_get_children(SLV2PluginClass plugin_class);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_PLUGIN_CLASS_H__ */
Index: 3rdparty/slv2/slv2/plugins.h
===================================================================
RCS file: 3rdparty/slv2/slv2/plugins.h
diff -N 3rdparty/slv2/slv2/plugins.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/slv2/plugins.h 8 Jun 2007 09:29:06 -0000 1.1
@@ -0,0 +1,92 @@
+/* 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_PLUGINS_H__
+#define __SLV2_PLUGINS_H__
+
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup plugins Collections of plugins
+ *
+ * These functions work with lists of plugins which come from an
+ * SLV2World. These lists contain only a weak reference to an LV2 plugin
+ * in the Model.
+ *
+ * @{
+ */
+
+
+/** Free a plugin list.
+ *
+ * Freeing a plugin list does not destroy the plugins it contains (plugins
+ * are owned by the world). \a list is invalid after this call.
+ */
+void
+slv2_plugins_free(SLV2World world,
+ SLV2Plugins list);
+
+
+/** Get the number of plugins in the list.
+ */
+unsigned
+slv2_plugins_size(SLV2Plugins list);
+
+
+/** Get a plugin from the list by URI.
+ *
+ * Return value is shared (stored in \a list) and must not be freed or
+ * modified by the caller in any way.
+ *
+ * Time = O(log2(n))
+ *
+ * \return NULL if plugin with \a url not found in \a list.
+ */
+SLV2Plugin
+slv2_plugins_get_by_uri(SLV2Plugins list,
+ const char* uri);
+
+
+/** Get a plugin from the list by index.
+ *
+ * \a index has no significance other than as an index into this list.
+ * Any \a index not less than slv2_list_get_length(list) will return NULL,
+ * so all plugins in a list can be enumerated by repeated calls
+ * to this function starting with \a index = 0.
+ *
+ * Time = O(1)
+ *
+ * \return NULL if \a index out of range.
+ */
+SLV2Plugin
+slv2_plugins_get_at(SLV2Plugins list,
+ unsigned index);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_PLUGINS_H__ */
+
Index: 3rdparty/slv2/slv2/value.h
===================================================================
RCS file: 3rdparty/slv2/slv2/value.h
diff -N 3rdparty/slv2/slv2/value.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/slv2/value.h 8 Jun 2007 09:29:07 -0000 1.1
@@ -0,0 +1,175 @@
+/* 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_VALUE_H__
+#define __SLV2_VALUE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <slv2/types.h>
+
+/** \addtogroup data
+ * @{
+ */
+
+
+/** Free an SLV2Value.
+ */
+void
+slv2_value_free(SLV2Value val);
+
+
+/** Return whether two values are equivalent.
+ */
+bool
+slv2_value_equals(SLV2Value value, SLV2Value other);
+
+
+/** Return this value as a Turtle/SPARQL token.
+ * Examples:
+ * <http://example.org/foo>
+ * doap:name
+ * "this is a string"
+ * 1.0
+ * 1
+ *
+ * Returned string is newly allocation and must be freed by caller.
+ */
+char*
+slv2_value_get_turtle_token(SLV2Value value);
+
+
+/** Return whether the value is a URI (resource).
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_uri(SLV2Value value);
+
+
+/** Return this value as a URI string, e.g. "http://example.org/foo".
+ *
+ * Valid to call only if slv2_value_is_uri(\a value) or
+ * slv2_value_is_qname(\a value) returns true.
+ * Returned value is owned by \a value and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_value_as_uri(SLV2Value value);
+
+
+#if 0
+/** Return whether the value is a QName ("qualified name", a prefixed URI).
+ *
+ * A QName will return true for both this, and slv2_value_is_uri.
+ * slv2_value_as_uri and slv2_value_as_qname will both return appropriately.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_qname(SLV2Value value);
+
+
+/** Return this value as a QName string, e.g. "lv2:Plugin".
+ *
+ * Valid to call only if slv2_value_is_qname(\a value) returns true.
+ * Returned value is owned by \a value and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_value_as_qname(SLV2Value value);
+#endif
+
+
+/** Return whether this value is a literal (i.e. not a URI).
+ *
+ * Returns true if \a value is a string or numeric value.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_literal(SLV2Value value);
+
+
+/** Return whether this value is a string literal.
+ *
+ * Returns true if \a value is a string (but not numeric) value.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_string(SLV2Value value);
+
+
+/** Return whether this value is a string literal.
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_value_as_string(SLV2Value value);
+
+
+/** Return whether this value is a decimal literal.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_float(SLV2Value value);
+
+
+/** Return \a value as a float.
+ *
+ * Valid to call only if slv2_value_is_float(\a value) or
+ * slv2_value_is_int(\a value) returns true.
+ *
+ * Time = O(1)
+ */
+float
+slv2_value_as_float(SLV2Value value);
+
+
+/** Return whether this value is an integer literal.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_int(SLV2Value value);
+
+
+/** Return \a value as an integer.
+ *
+ * Valid to call only if slv2_value_is_int(\a value) returns true.
+ *
+ * Time = O(1)
+ */
+int
+slv2_value_as_int(SLV2Value value);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_VALUE_H__ */
Index: 3rdparty/slv2/slv2/values.h
===================================================================
RCS file: 3rdparty/slv2/slv2/values.h
diff -N 3rdparty/slv2/slv2/values.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/slv2/values.h 8 Jun 2007 09:29:07 -0000 1.1
@@ -0,0 +1,81 @@
+/* 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_VALUES_H__
+#define __SLV2_VALUES_H__
+
+#include <stdbool.h>
+#include <slv2/value.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup values Collections of values
+ *
+ * SLV2Values is an ordered collection of typed values which is fast for random
+ * access by index (i.e. a fancy array).
+ *
+ * @{
+ */
+
+
+/** Allocate a new, empty SLV2Values
+ */
+SLV2Values
+slv2_values_new();
+
+
+/** Get the number of elements in a string list.
+ */
+unsigned
+slv2_values_size(SLV2Values 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.
+ *
+ * Time = O(1)
+ */
+SLV2Value
+slv2_values_get_at(SLV2Values list, unsigned index);
+
+
+/** Return whether \a list contains \a string.
+ *
+ * Time = O(n)
+ */
+bool
+slv2_values_contains(SLV2Values list, SLV2Value value);
+
+
+/** Free a string list.
+ */
+void
+slv2_values_free(SLV2Values);
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_VALUES_H__ */
+
Index: 3rdparty/slv2/src/pluginclass.c
===================================================================
RCS file: 3rdparty/slv2/src/pluginclass.c
diff -N 3rdparty/slv2/src/pluginclass.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/pluginclass.c 8 Jun 2007 09:29:07 -0000 1.1
@@ -0,0 +1,87 @@
+/* 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.
+ */
+
+#define _XOPEN_SOURCE 500
+
+#include <stdlib.h>
+#include <string.h>
+#include <slv2/pluginclass.h>
+#include "slv2_internal.h"
+
+
+SLV2PluginClass
+slv2_plugin_class_new(SLV2World world, const char* parent_uri, const char*
uri, const char* label)
+{
+ SLV2PluginClass plugin_class = (SLV2PluginClass)malloc(sizeof(struct
_SLV2PluginClass));
+ plugin_class->world = world;
+ if (parent_uri)
+ plugin_class->parent_uri = strdup(parent_uri);
+ else
+ plugin_class->parent_uri = NULL;
+ plugin_class->uri = strdup(uri);
+ plugin_class->label = strdup(label);
+ return plugin_class;
+}
+
+
+void
+slv2_plugin_class_free(SLV2PluginClass plugin_class)
+{
+ free(plugin_class->uri);
+ free(plugin_class->parent_uri);
+ free(plugin_class->label);
+ free(plugin_class);
+}
+
+
+const char*
+slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class)
+{
+ return plugin_class->parent_uri;
+}
+
+
+const char*
+slv2_plugin_class_get_uri(SLV2PluginClass plugin_class)
+{
+ return plugin_class->uri;
+}
+
+
+const char*
+slv2_plugin_class_get_label(SLV2PluginClass plugin_class)
+{
+ return plugin_class->label;
+}
+
+
+SLV2PluginClasses
+slv2_plugin_class_get_children(SLV2PluginClass plugin_class)
+{
+ // Returned list doesn't own categories
+ SLV2PluginClasses result = raptor_new_sequence(NULL, NULL);
+
+ for (int i=0; i <
raptor_sequence_size(plugin_class->world->plugin_classes); ++i) {
+ SLV2PluginClass c =
raptor_sequence_get_at(plugin_class->world->plugin_classes, i);
+ const char* parent = slv2_plugin_class_get_parent_uri(c);
+ if (parent && !strcmp(slv2_plugin_class_get_uri(plugin_class),
parent))
+ raptor_sequence_push(result, c);
+ }
+
+ return result;
+}
Index: 3rdparty/slv2/src/pluginclasses.c
===================================================================
RCS file: 3rdparty/slv2/src/pluginclasses.c
diff -N 3rdparty/slv2/src/pluginclasses.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/pluginclasses.c 8 Jun 2007 09:29:07 -0000 1.1
@@ -0,0 +1,91 @@
+/* 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.
+ */
+
+#define _XOPEN_SOURCE 500
+
+#include <string.h>
+#include <limits.h>
+#include <librdf.h>
+#include "slv2_internal.h"
+#include <slv2/pluginclass.h>
+#include <slv2/pluginclasses.h>
+
+
+
+SLV2PluginClasses
+slv2_plugin_classes_new()
+{
+ return raptor_new_sequence((void (*)(void*))&slv2_plugin_class_free,
NULL);
+}
+
+
+void
+slv2_plugin_classes_free(SLV2PluginClasses list)
+{
+ //if (list != world->plugin_classes)
+ raptor_free_sequence(list);
+}
+
+
+unsigned
+slv2_plugin_classes_size(SLV2PluginClasses list)
+{
+ return raptor_sequence_size(list);
+}
+
+
+SLV2PluginClass
+slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, const char* uri)
+{
+ // good old fashioned binary search
+
+ int lower = 0;
+ int upper = raptor_sequence_size(list) - 1;
+ int i;
+
+ if (upper == 0)
+ return NULL;
+
+ while (upper >= lower) {
+ i = lower + ((upper - lower) / 2);
+
+ SLV2PluginClass p = raptor_sequence_get_at(list, i);
+
+ int cmp = strcmp(slv2_plugin_class_get_uri(p), uri);
+
+ if (cmp == 0)
+ return p;
+ else if (cmp > 0)
+ upper = i - 1;
+ else
+ lower = i + 1;
+ }
+
+ return NULL;
+}
+
+
+SLV2PluginClass
+slv2_plugin_classes_get_at(SLV2PluginClasses list, unsigned index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2PluginClass)raptor_sequence_get_at(list,
(int)index);
+}
+
Index: 3rdparty/slv2/src/plugins.c
===================================================================
RCS file: 3rdparty/slv2/src/plugins.c
diff -N 3rdparty/slv2/src/plugins.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/plugins.c 8 Jun 2007 09:29:07 -0000 1.1
@@ -0,0 +1,314 @@
+/* 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.
+ */
+
+#define _XOPEN_SOURCE 500
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <librdf.h>
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+#include <slv2/plugins.h>
+#include <slv2/values.h>
+#include <slv2/util.h>
+#include "slv2_internal.h"
+
+
+SLV2Plugins
+slv2_plugins_new()
+{
+ //return raptor_new_sequence((void (*)(void*))&slv2_plugin_free, NULL);
+ return raptor_new_sequence(NULL, NULL);
+}
+
+
+void
+slv2_plugins_free(SLV2World world, SLV2Plugins list)
+{
+ if (list != world->plugins)
+ raptor_free_sequence(list);
+}
+
+#if 0
+void
+slv2_plugins_filter(SLV2Plugins dest, SLV2Plugins source, bool
(*include)(SLV2Plugin))
+{
+ assert(dest);
+
+ for (int i=0; i < raptor_sequence_size(source); ++i) {
+ SLV2Plugin p = raptor_sequence_get_at(source, i);
+ if (include(p))
+ raptor_sequence_push(dest, slv2_plugin_duplicate(p));
+ }
+}
+
+
+void
+slv2_plugins_load_all(SLV2Plugins list)
+{
+ /* FIXME: this is much slower than it should be in many ways.. */
+
+ assert(list);
+
+ char* slv2_path = getenv("LV2_PATH");
+
+ SLV2Plugins load_list = slv2_plugins_new();
+
+ if (slv2_path) {
+ slv2_plugins_load_path(load_list, slv2_path);
+ } else {
+ const char* const home = getenv("HOME");
+ const char* const suffix = "/.lv2:/usr/local/lib/lv2:usr/lib/lv2";
+ slv2_path = slv2_strjoin(home, suffix, NULL);
+
+ fprintf(stderr, "$LV2_PATH is unset. Using default path %s\n",
slv2_path);
+
+ /* pass 1: find all plugins */
+ slv2_plugins_load_path(load_list, slv2_path);
+
+ /* pass 2: find all data files for plugins */
+ slv2_plugins_load_path(load_list, slv2_path);
+
+ free(slv2_path);
+ }
+
+ /* insert only valid plugins into list */
+ slv2_plugins_filter(list, load_list, slv2_plugin_verify);
+ slv2_plugins_free(load_list);
+}
+
+
+/* This is the parser for manifest.ttl
+ * This is called twice on each bundle in the discovery process, which is
(much) less
+ * efficient than it could be.... */
+void
+slv2_plugins_load_bundle(SLV2Plugins list,
+ const char* bundle_base_url)
+{
+ assert(list);
+
+ unsigned char* manifest_url = malloc(
+ (strlen((char*)bundle_base_url) + strlen("manifest.ttl") + 2) *
sizeof(unsigned char));
+ memcpy(manifest_url, bundle_base_url, strlen((char*)bundle_base_url)+1
* sizeof(unsigned char));
+ if (bundle_base_url[strlen(bundle_base_url)-1] == '/')
+ strcat((char*)manifest_url, "manifest.ttl");
+ else
+ strcat((char*)manifest_url, "/manifest.ttl");
+
+ librdf_query_results *results;
+ librdf_uri *base_uri = librdf_new_uri(slv2_rdf_world, manifest_url);
+
+ /* Get all plugins explicitly mentioned in the manifest (discovery pass
1) */
+ char* query_string =
+ "PREFIX : <http://lv2plug.in/ontology#>\n\n"
+ "SELECT DISTINCT ?plugin_uri FROM <>\n"
+ "WHERE { ?plugin_uri a :Plugin }\n";
+
+ librdf_query *rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
+ (unsigned char*)query_string, base_uri);
+
+
+
+ //printf("%s\n\n", query_string);
+
+ results = librdf_query_execute(rq, model->model);
+
+ while (!librdf_query_results_finished(results)) {
+
+ librdf_node* literal =
librdf_query_results_get_binding_value(results, 0);
+ assert(literal);
+
+ if (!slv2_plugins_get_by_uri(list, (const
char*)librdf_node_get_literal_value(literal))) {
+ /* Create a new plugin */
+ struct _Plugin* new_plugin = slv2_plugin_new();
+ new_plugin->plugin_uri = strdup((const
char*)librdf_node_get_literal_value(literal));
+ new_plugin->bundle_url = strdup(bundle_base_url);
+ raptor_sequence_push(new_plugin->data_uris,
strdup((const char*)manifest_url));
+
+ raptor_sequence_push(list, new_plugin);
+
+ }
+
+ librdf_query_results_next(results);
+ }
+
+ if (results)
+ librdf_free_query_results(results);
+
+ librdf_free_query(rq);
+
+ /* Get all data files linked to plugins (discovery pass 2) */
+ query_string =
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
+ "PREFIX : <http://lv2plug.in/ontology#>\n\n"
+ "SELECT DISTINCT ?subject ?data_uri ?binary FROM <>\n"
+ "WHERE { ?subject rdfs:seeAlso ?data_uri\n"
+ "OPTIONAL { ?subject :binary ?binary } }\n";
+
+ rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
+ (unsigned char*)query_string, base_uri);
+
+ //printf("%s\n\n", query_string);
+
+ results = librdf_query_execute(rq, slv2_model);
+
+ while (!librdf_query_results_finished(results)) {
+
+ const char* subject = (const
char*)librdf_node_get_literal_value(
+ librdf_query_results_get_binding_value(results,
0));
+
+ const char* data_uri = (const
char*)librdf_node_get_literal_value(
+ librdf_query_results_get_binding_value(results,
1));
+
+ const char* binary = (const char*)librdf_node_get_literal_value(
+ librdf_query_results_get_binding_value(results,
2));
+
+ SLV2Plugin plugin = slv2_plugins_get_by_uri(list, subject);
+
+ if (plugin && data_uri &&
!slv2_values_contains(plugin->data_uris, data_uri))
+ raptor_sequence_push(plugin->data_uris,
strdup(data_uri));
+
+ if (plugin && binary && !plugin->lib_uri)
+ ((struct _Plugin*)plugin)->lib_uri = strdup(binary);
+
+ librdf_query_results_next(results);
+
+ }
+
+ if (results)
+ librdf_free_query_results(results);
+
+ librdf_free_query(rq);
+
+ librdf_free_uri(base_uri);
+ free(manifest_url);
+}
+
+
+/* Add all the plugins found in dir to list.
+ * (Private helper function, not exposed in public API)
+ */
+void
+slv2_plugins_load_dir(SLV2Plugins list, const char* dir)
+{
+ assert(list);
+
+ DIR* pdir = opendir(dir);
+ if (!pdir)
+ return;
+
+ struct dirent* pfile;
+ while ((pfile = readdir(pdir))) {
+ if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
+ continue;
+
+ char* bundle_path = slv2_strjoin(dir, "/", pfile->d_name, NULL);
+ char* bundle_url = slv2_strjoin("file://", dir, "/",
pfile->d_name, NULL);
+ DIR* bundle_dir = opendir(bundle_path);
+
+ if (bundle_dir != NULL) {
+ closedir(bundle_dir);
+
+ slv2_plugins_load_bundle(list, bundle_url);
+ //printf("Loaded bundle %s\n", bundle_url);
+ }
+
+ free(bundle_path);
+ free(bundle_url);
+ }
+
+ closedir(pdir);
+}
+
+
+void
+slv2_plugins_load_path(SLV2Plugins list,
+ const char* lv2_path)
+{
+ assert(list);
+
+ char* path = slv2_strjoin(lv2_path, ":", NULL);
+ char* dir = path; // Pointer into path
+
+ // Go through string replacing ':' with '\0', using the substring,
+ // then replacing it with 'X' and moving on. i.e. strtok on crack.
+ while (strchr(path, ':') != NULL) {
+ char* delim = strchr(path, ':');
+ *delim = '\0';
+
+ slv2_plugins_load_dir(list, dir);
+
+ *delim = 'X';
+ dir = delim + 1;
+ }
+
+ //char* slv2_path = strdup(slv2
+
+ free(path);
+}
+#endif
+
+unsigned
+slv2_plugins_size(SLV2Plugins list)
+{
+ return raptor_sequence_size(list);
+}
+
+
+SLV2Plugin
+slv2_plugins_get_by_uri(SLV2Plugins list, const char* uri)
+{
+ // good old fashioned binary search
+
+ int lower = 0;
+ int upper = raptor_sequence_size(list) - 1;
+ int i;
+
+ if (upper == 0)
+ return NULL;
+
+ while (upper >= lower) {
+ i = lower + ((upper - lower) / 2);
+
+ SLV2Plugin p = raptor_sequence_get_at(list, i);
+
+ int cmp = strcmp(slv2_plugin_get_uri(p), uri);
+
+ if (cmp == 0)
+ return p;
+ else if (cmp > 0)
+ upper = i - 1;
+ else
+ lower = i + 1;
+ }
+
+ return NULL;
+}
+
+
+SLV2Plugin
+slv2_plugins_get_at(SLV2Plugins list, unsigned index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2Plugin)raptor_sequence_get_at(list, (int)index);
+}
+
Index: 3rdparty/slv2/src/slv2_internal.h
===================================================================
RCS file: 3rdparty/slv2/src/slv2_internal.h
diff -N 3rdparty/slv2/src/slv2_internal.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/slv2_internal.h 8 Jun 2007 09:29:08 -0000 1.1
@@ -0,0 +1,181 @@
+/* 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_INTERNAL_H__
+#define __SLV2_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <librdf.h>
+#include <slv2/types.h>
+
+
+
+/* ********* PORT ********* */
+
+
+/** Reference to a port on some plugin. */
+struct _SLV2Port {
+ uint32_t index; ///< LV2 index
+ char* symbol; ///< LV2 symbol
+};
+
+
+SLV2Port slv2_port_new(uint32_t index, const char* symbol);
+SLV2Port slv2_port_duplicate(SLV2Port port);
+void slv2_port_free(SLV2Port port);
+
+
+
+/* ********* Plugin ********* */
+
+
+/** Record of an installed/available plugin.
+ *
+ * A simple reference to a plugin somewhere on the system. This just holds
+ * paths of relevant files, the actual data therein isn't loaded into memory.
+ */
+struct _SLV2Plugin {
+ struct _SLV2World* world;
+ librdf_uri* plugin_uri;
+// char* bundle_url; ///< Bundle directory plugin was loaded
from
+ char* binary_uri; ///< lv2:binary
+ SLV2PluginClass plugin_class;
+ raptor_sequence* data_uris; ///< rdfs::seeAlso
+ raptor_sequence* ports;
+ librdf_storage* storage;
+ librdf_model* rdf;
+};
+
+SLV2Plugin slv2_plugin_new(SLV2World world, librdf_uri* uri, const char*
binary_uri);
+void slv2_plugin_load(SLV2Plugin p);
+void slv2_plugin_free(SLV2Plugin plugin);
+
+librdf_query_results* slv2_plugin_query(SLV2Plugin plugin,
+ const char* sparql_str);
+
+
+
+/* ********* Plugins ********* */
+
+
+/** Create a new, empty plugin list.
+ *
+ * Returned object must be freed with slv2_plugins_free.
+ */
+SLV2Plugins
+slv2_plugins_new();
+
+
+
+/* ********* Instance ********* */
+
+
+/** Pimpl portion of SLV2Instance */
+struct _InstanceImpl {
+ void* lib_handle;
+};
+
+
+
+/* ********* Plugin Class ********* */
+
+
+struct _SLV2PluginClass {
+ struct _SLV2World* world;
+ char* parent_uri;
+ char* uri;
+ char* label;
+};
+
+SLV2PluginClass slv2_plugin_class_new(SLV2World world, const char* parent_uri,
+ const char* uri, const char* label);
+void slv2_plugin_class_free(SLV2PluginClass class);
+
+
+
+/* ********* Plugin Classes ********* */
+
+
+SLV2PluginClasses slv2_plugin_classes_new();
+void slv2_plugin_classes_free();
+
+
+
+/* ********* World ********* */
+
+
+/** Model of LV2 (RDF) data loaded from bundles.
+ */
+struct _SLV2World {
+ librdf_world* world;
+ librdf_storage* storage;
+ librdf_model* model;
+ librdf_parser* parser;
+ SLV2PluginClasses plugin_classes;
+ SLV2Plugins plugins;
+};
+
+/** Load all bundles found in \a search_path.
+ *
+ * \param search_path A colon-delimited list of directories. These directories
+ * should contain LV2 bundle directories (ie the search path is a list of
+ * parent directories of bundles, not a list of bundle directories).
+ *
+ * If \a search_path is NULL, \a world will be unmodified.
+ * Use of this function is \b not recommended. Use \ref slv2_world_load_all.
+ */
+void
+slv2_world_load_path(SLV2World world,
+ const char* search_path);
+
+
+
+/* ********* Value ********* */
+
+
+typedef enum _SLV2ValueType {
+ SLV2_VALUE_URI,
+ SLV2_VALUE_STRING,
+ SLV2_VALUE_INT,
+ SLV2_VALUE_FLOAT
+} SLV2ValueType;
+
+struct _SLV2Value {
+ SLV2ValueType type;
+ char* str_val; ///< always present
+ union {
+ int int_val;
+ float float_val;
+ } val;
+};
+
+SLV2Value slv2_value_new(SLV2ValueType type, const char* val);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_INTERNAL_H__ */
+
Index: 3rdparty/slv2/src/value.c
===================================================================
RCS file: 3rdparty/slv2/src/value.c
diff -N 3rdparty/slv2/src/value.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/value.c 8 Jun 2007 09:29:08 -0000 1.1
@@ -0,0 +1,171 @@
+/* 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.
+ */
+
+#define _XOPEN_SOURCE 500
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <raptor.h>
+#include <slv2/value.h>
+#include "slv2_internal.h"
+
+
+/* private */
+SLV2Value
+slv2_value_new(SLV2ValueType type, const char* str)
+{
+ SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
+ val->str_val = strdup(str);
+ val->type = type;
+
+ //printf("New value, t=%d, %s\n", type, str);
+
+ if (type == SLV2_VALUE_INT) {
+ char* endptr = 0;
+ val->val.int_val = strtol(str, &endptr, 10);
+ } else if (type == SLV2_VALUE_FLOAT) {
+ char* endptr = 0;
+ val->val.float_val = strtod(str, &endptr);
+ } else {
+ val->val.int_val = 0;
+ }
+
+ return val;
+}
+
+
+void
+slv2_value_free(SLV2Value val)
+{
+ free(val->str_val);
+ free(val);
+}
+
+
+bool
+slv2_value_equals(SLV2Value value, SLV2Value other)
+{
+ if (value->type != other->type)
+ return false;
+ else
+ return ! strcmp(value->str_val, other->str_val);
+}
+
+
+char*
+slv2_value_get_turtle_token(SLV2Value value)
+{
+ size_t len = 0;
+ char* result = NULL;
+
+ switch (value->type) {
+ case SLV2_VALUE_URI:
+ len = strlen(value->str_val) + 3;
+ result = calloc(len, sizeof(char));
+ snprintf(result, len, "<%s>", value->str_val);
+ break;
+ case SLV2_VALUE_STRING:
+ result = strdup(value->str_val);
+ break;
+ case SLV2_VALUE_INT:
+ // INT64_MAX is 9223372036854775807 (19 digits) + 1 for sign
+ len = 20;
+ result = calloc(len, sizeof(char));
+ snprintf(result, len, "%d", value->val.int_val);
+ break;
+ case SLV2_VALUE_FLOAT:
+ len = 20; // FIXME: proper maximum value?
+ result = calloc(len, sizeof(char));
+ snprintf(result, len, ".1%f", value->val.float_val);
+ break;
+ }
+
+ return result;
+}
+
+
+bool
+slv2_value_is_uri(SLV2Value value)
+{
+ return (value->type == SLV2_VALUE_URI);
+}
+
+
+const char*
+slv2_value_as_uri(SLV2Value value)
+{
+ assert(slv2_value_is_uri(value));
+ return value->str_val;
+}
+
+
+bool
+slv2_value_is_literal(SLV2Value value)
+{
+ // No blank nodes
+ return (value->type != SLV2_VALUE_URI);
+}
+
+
+bool
+slv2_value_is_string(SLV2Value value)
+{
+ return (value->type == SLV2_VALUE_STRING);
+}
+
+
+const char*
+slv2_value_as_string(SLV2Value value)
+{
+ return value->str_val;
+}
+
+
+bool
+slv2_value_is_int(SLV2Value value)
+{
+ return (value->type == SLV2_VALUE_INT);
+}
+
+
+int
+slv2_value_as_int(SLV2Value value)
+{
+ assert(slv2_value_is_int(value));
+ return value->val.int_val;
+}
+
+
+bool
+slv2_value_is_float(SLV2Value value)
+{
+ return (value->type == SLV2_VALUE_FLOAT);
+}
+
+
+float
+slv2_value_as_float(SLV2Value value)
+{
+ assert(slv2_value_is_float(value) || slv2_value_is_int(value));
+ if (slv2_value_is_float(value))
+ return value->val.float_val;
+ else // slv2_value_is_int(value)
+ return (float)value->val.int_val;
+}
+
Index: 3rdparty/slv2/src/values.c
===================================================================
RCS file: 3rdparty/slv2/src/values.c
diff -N 3rdparty/slv2/src/values.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 3rdparty/slv2/src/values.c 8 Jun 2007 09:29:08 -0000 1.1
@@ -0,0 +1,67 @@
+/* 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.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <raptor.h>
+#include <slv2/values.h>
+#include "slv2_internal.h"
+
+
+SLV2Values
+slv2_values_new()
+{
+ return raptor_new_sequence((void (*)(void*))&slv2_value_free, NULL);
+}
+
+
+void
+slv2_values_free(SLV2Values list)
+{
+ raptor_free_sequence(list);
+}
+
+
+unsigned
+slv2_values_size(SLV2Values list)
+{
+ return raptor_sequence_size(list);
+}
+
+
+SLV2Value
+slv2_values_get_at(SLV2Values list, unsigned index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2Value)raptor_sequence_get_at(list, (int)index);
+}
+
+
+bool
+slv2_values_contains(SLV2Values list, SLV2Value value)
+{
+ for (unsigned i=0; i < slv2_values_size(list); ++i)
+ if (slv2_value_equals(slv2_values_get_at(list, i), value))
+ return true;
+
+ return false;
+}
+
Index: 3rdparty/slv2/slv2/pluginlist.h
===================================================================
RCS file: 3rdparty/slv2/slv2/pluginlist.h
diff -N 3rdparty/slv2/slv2/pluginlist.h
--- 3rdparty/slv2/slv2/pluginlist.h 23 Apr 2007 11:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,95 +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_PLUGINLIST_H__
-#define __SLV2_PLUGINLIST_H__
-
-#include <slv2/plugin.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef void* SLV2Plugins;
-
-
-/** \defgroup plugins Plugin lists
- *
- * These functions work with lists of plugins which come from an
- * SLV2World. These lists contain only a weak reference to an LV2 plugin
- * in the Model.
- *
- * @{
- */
-
-
-/** Free a plugin list.
- *
- * Freeing a plugin list does not destroy the plugins it contains (plugins
- * are owned by the world). \a list is invalid after this call.
- */
-void
-slv2_plugins_free(SLV2World world,
- SLV2Plugins list);
-
-
-/** Get the number of plugins in the list.
- */
-unsigned
-slv2_plugins_size(SLV2Plugins list);
-
-
-/** Get a plugin from the list by URI.
- *
- * Return value is shared (stored in \a list) and must not be freed or
- * modified by the caller in any way.
- *
- * Time = O(log2(n))
- *
- * \return NULL if plugin with \a url not found in \a list.
- */
-SLV2Plugin
-slv2_plugins_get_by_uri(SLV2Plugins list,
- const char* uri);
-
-
-/** Get a plugin from the list by index.
- *
- * \a index has no significance other than as an index into this list.
- * Any \a index not less than slv2_list_get_length(list) will return NULL,
- * so all plugins in a list can be enumerated by repeated calls
- * to this function starting with \a index = 0.
- *
- * Time = O(1)
- *
- * \return NULL if \a index out of range.
- */
-SLV2Plugin
-slv2_plugins_get_at(SLV2Plugins list,
- unsigned index);
-
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SLV2_PLUGINLIST_H__ */
-
Index: 3rdparty/slv2/slv2/stringlist.h
===================================================================
RCS file: 3rdparty/slv2/slv2/stringlist.h
diff -N 3rdparty/slv2/slv2/stringlist.h
--- 3rdparty/slv2/slv2/stringlist.h 23 Apr 2007 11:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +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_STRINGLIST_H__
-#define __SLV2_STRINGLIST_H__
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup strings Collections of strings
- *
- * SLV2Strings is an ordered collection of strings which is fast for random
- * access by index (i.e. a fancy array).
- *
- * @{
- */
-
-
-typedef void* SLV2Strings;
-
-
-/** Allocate a new, empty SLV2Strings
- */
-SLV2Strings
-slv2_strings_new();
-
-
-/** Get the number of elements in a string list.
- */
-unsigned
-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.
- *
- * Time = O(1)
- */
-const char*
-slv2_strings_get_at(SLV2Strings list, unsigned index);
-
-
-/** Return whether \a list contains \a string.
- *
- * Time = O(n)
- */
-bool
-slv2_strings_contains(SLV2Strings list, const char* string);
-
-
-/** Free a string list.
- */
-void
-slv2_strings_free(SLV2Strings);
-
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SLV2_STRINGLIST_H__ */
-
Index: 3rdparty/slv2/src/pluginlist.c
===================================================================
RCS file: 3rdparty/slv2/src/pluginlist.c
diff -N 3rdparty/slv2/src/pluginlist.c
--- 3rdparty/slv2/src/pluginlist.c 23 Apr 2007 11:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,318 +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.
- */
-
-#define _XOPEN_SOURCE 500
-#include <limits.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <assert.h>
-#include <dirent.h>
-#include <librdf.h>
-#include <slv2/types.h>
-#include <slv2/plugin.h>
-#include <slv2/pluginlist.h>
-#include <slv2/stringlist.h>
-#include <slv2/util.h>
-#include "private_types.h"
-
-
-SLV2Plugins
-slv2_plugins_new()
-{
- //return raptor_new_sequence((void (*)(void*))&slv2_plugin_free, NULL);
- return raptor_new_sequence(NULL, NULL);
-}
-
-
-void
-slv2_plugins_free(SLV2World world, SLV2Plugins list)
-{
- if (list != world->plugins)
- raptor_free_sequence(list);
-}
-
-#if 0
-void
-slv2_plugins_filter(SLV2Plugins dest, SLV2Plugins source, bool
(*include)(SLV2Plugin))
-{
- assert(dest);
-
- for (int i=0; i < raptor_sequence_size(source); ++i) {
- SLV2Plugin p = raptor_sequence_get_at(source, i);
- if (include(p))
- raptor_sequence_push(dest, slv2_plugin_duplicate(p));
- }
-}
-
-
-void
-slv2_plugins_load_all(SLV2Plugins list)
-{
- /* FIXME: this is much slower than it should be in many ways.. */
-
- assert(list);
-
- char* slv2_path = getenv("LV2_PATH");
-
- SLV2Plugins load_list = slv2_plugins_new();
-
- if (slv2_path) {
- slv2_plugins_load_path(load_list, slv2_path);
- } else {
- const char* const home = getenv("HOME");
- const char* const suffix = "/.lv2:/usr/local/lib/lv2:usr/lib/lv2";
- slv2_path = slv2_strjoin(home, suffix, NULL);
-
- fprintf(stderr, "$LV2_PATH is unset. Using default path %s\n",
slv2_path);
-
- /* pass 1: find all plugins */
- slv2_plugins_load_path(load_list, slv2_path);
-
- /* pass 2: find all data files for plugins */
- slv2_plugins_load_path(load_list, slv2_path);
-
- free(slv2_path);
- }
-
- /* insert only valid plugins into list */
- slv2_plugins_filter(list, load_list, slv2_plugin_verify);
- slv2_plugins_free(load_list);
-}
-
-
-/* This is the parser for manifest.ttl
- * This is called twice on each bundle in the discovery process, which is
(much) less
- * efficient than it could be.... */
-void
-slv2_plugins_load_bundle(SLV2Plugins list,
- const char* bundle_base_url)
-{
- assert(list);
-
- unsigned char* manifest_url = malloc(
- (strlen((char*)bundle_base_url) + strlen("manifest.ttl") + 2) *
sizeof(unsigned char));
- memcpy(manifest_url, bundle_base_url, strlen((char*)bundle_base_url)+1
* sizeof(unsigned char));
- if (bundle_base_url[strlen(bundle_base_url)-1] == '/')
- strcat((char*)manifest_url, "manifest.ttl");
- else
- strcat((char*)manifest_url, "/manifest.ttl");
-
- librdf_query_results *results;
- librdf_uri *base_uri = librdf_new_uri(slv2_rdf_world, manifest_url);
-
- /* Get all plugins explicitly mentioned in the manifest (discovery pass
1) */
- char* query_string =
- "PREFIX : <http://lv2plug.in/ontology#>\n\n"
- "SELECT DISTINCT ?plugin_uri FROM <>\n"
- "WHERE { ?plugin_uri a :Plugin }\n";
-
- librdf_query *rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
- (unsigned char*)query_string, base_uri);
-
-
-
- //printf("%s\n\n", query_string);
-
- results = librdf_query_execute(rq, model->model);
-
- while (!librdf_query_results_finished(results)) {
-
- librdf_node* literal =
librdf_query_results_get_binding_value(results, 0);
- assert(literal);
-
- if (!slv2_plugins_get_by_uri(list, (const
char*)librdf_node_get_literal_value(literal))) {
- /* Create a new plugin */
- struct _Plugin* new_plugin = slv2_plugin_new();
- new_plugin->plugin_uri = strdup((const
char*)librdf_node_get_literal_value(literal));
- new_plugin->bundle_url = strdup(bundle_base_url);
- raptor_sequence_push(new_plugin->data_uris,
strdup((const char*)manifest_url));
-
- raptor_sequence_push(list, new_plugin);
-
- }
-
- librdf_query_results_next(results);
- }
-
- if (results)
- librdf_free_query_results(results);
-
- librdf_free_query(rq);
-
- /* Get all data files linked to plugins (discovery pass 2) */
- query_string =
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- "PREFIX : <http://lv2plug.in/ontology#>\n\n"
- "SELECT DISTINCT ?subject ?data_uri ?binary FROM <>\n"
- "WHERE { ?subject rdfs:seeAlso ?data_uri\n"
- "OPTIONAL { ?subject :binary ?binary } }\n";
-
- rq = librdf_new_query(slv2_rdf_world, "sparql", NULL,
- (unsigned char*)query_string, base_uri);
-
- //printf("%s\n\n", query_string);
-
- results = librdf_query_execute(rq, slv2_model);
-
- while (!librdf_query_results_finished(results)) {
-
- const char* subject = (const
char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
0));
-
- const char* data_uri = (const
char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
1));
-
- const char* binary = (const char*)librdf_node_get_literal_value(
- librdf_query_results_get_binding_value(results,
2));
-
- 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));
-
- if (plugin && binary && !plugin->lib_uri)
- ((struct _Plugin*)plugin)->lib_uri = strdup(binary);
-
- librdf_query_results_next(results);
-
- }
-
- if (results)
- librdf_free_query_results(results);
-
- librdf_free_query(rq);
-
- librdf_free_uri(base_uri);
- free(manifest_url);
-}
-
-
-/* Add all the plugins found in dir to list.
- * (Private helper function, not exposed in public API)
- */
-void
-slv2_plugins_load_dir(SLV2Plugins list, const char* dir)
-{
- assert(list);
-
- DIR* pdir = opendir(dir);
- if (!pdir)
- return;
-
- struct dirent* pfile;
- while ((pfile = readdir(pdir))) {
- if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
- continue;
-
- char* bundle_path = slv2_strjoin(dir, "/", pfile->d_name, NULL);
- char* bundle_url = slv2_strjoin("file://", dir, "/",
pfile->d_name, NULL);
- DIR* bundle_dir = opendir(bundle_path);
-
- if (bundle_dir != NULL) {
- closedir(bundle_dir);
-
- slv2_plugins_load_bundle(list, bundle_url);
- //printf("Loaded bundle %s\n", bundle_url);
- }
-
- free(bundle_path);
- free(bundle_url);
- }
-
- closedir(pdir);
-}
-
-
-void
-slv2_plugins_load_path(SLV2Plugins list,
- const char* lv2_path)
-{
- assert(list);
-
- char* path = slv2_strjoin(lv2_path, ":", NULL);
- char* dir = path; // Pointer into path
-
- // Go through string replacing ':' with '\0', using the substring,
- // then replacing it with 'X' and moving on. i.e. strtok on crack.
- while (strchr(path, ':') != NULL) {
- char* delim = strchr(path, ':');
- *delim = '\0';
-
- slv2_plugins_load_dir(list, dir);
-
- *delim = 'X';
- dir = delim + 1;
- }
-
- //char* slv2_path = strdup(slv2
-
- free(path);
-}
-#endif
-
-unsigned
-slv2_plugins_size(SLV2Plugins list)
-{
- return raptor_sequence_size(list);
-}
-
-
-SLV2Plugin
-slv2_plugins_get_by_uri(SLV2Plugins list, const char* uri)
-{
- // good old fashioned binary search
-
- int lower = 0;
- int upper = raptor_sequence_size(list) - 1;
- int i;
-
- if (upper == 0)
- return NULL;
-
- while (upper >= lower) {
- i = lower + ((upper - lower) / 2);
-
- SLV2Plugin p = raptor_sequence_get_at(list, i);
-
- int cmp = strcmp(slv2_plugin_get_uri(p), uri);
-
- if (cmp == 0)
- return p;
- else if (cmp > 0)
- upper = i - 1;
- else
- lower = i + 1;
- }
-
- return NULL;
-}
-
-
-SLV2Plugin
-slv2_plugins_get_at(SLV2Plugins list, unsigned index)
-{
- assert(list);
-
- if (index > INT_MAX)
- return NULL;
- else
- return (SLV2Plugin)raptor_sequence_get_at(list, (int)index);
-}
-
Index: 3rdparty/slv2/src/private_types.h
===================================================================
RCS file: 3rdparty/slv2/src/private_types.h
diff -N 3rdparty/slv2/src/private_types.h
--- 3rdparty/slv2/src/private_types.h 23 Apr 2007 11:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +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_PRIVATE_TYPES_H__
-#define __SLV2_PRIVATE_TYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <librdf.h>
-#include <slv2/pluginlist.h>
-
-
-/** Reference to a port on some plugin.
- */
-struct _Port {
- uint32_t index; ///< LV2 index
- char* symbol; ///< LV2 symbol
- //char* node_id; ///< RDF Node ID
-};
-
-
-SLV2Port slv2_port_new(uint32_t index, const char* symbol/*, const char*
node_id*/);
-SLV2Port slv2_port_duplicate(SLV2Port port);
-void slv2_port_free(SLV2Port port);
-
-
-/** Record of an installed/available plugin.
- *
- * A simple reference to a plugin somewhere on the system. This just holds
- * paths of relevant files, the actual data therein isn't loaded into memory.
- */
-struct _Plugin {
- struct _World* world;
- librdf_uri* plugin_uri;
-// char* bundle_url; // Bundle directory plugin was loaded from
- char* binary_uri; // lv2:binary
- raptor_sequence* data_uris; // rdfs::seeAlso
- raptor_sequence* ports;
- librdf_storage* storage;
- librdf_model* rdf;
-};
-
-SLV2Plugin slv2_plugin_new(SLV2World world, librdf_uri* uri, const char*
binary_uri);
-void slv2_plugin_load(SLV2Plugin p);
-void slv2_plugin_free(SLV2Plugin plugin);
-
-
-/** Create a new, empty plugin list.
- *
- * Returned object must be freed with slv2_plugins_free.
- */
-SLV2Plugins
-slv2_plugins_new();
-
-
-/** Pimpl portion of SLV2Instance */
-struct _InstanceImpl {
- void* lib_handle;
-};
-
-
-/** Model of LV2 (RDF) data loaded from bundles.
- */
-struct _World {
- librdf_world* world;
- librdf_storage* storage;
- librdf_model* model;
- librdf_parser* parser;
- SLV2Plugins plugins;
-};
-
-/** Load all bundles found in \a search_path.
- *
- * \param search_path A colon-delimited list of directories. These directories
- * should contain LV2 bundle directories (ie the search path is a list of
- * parent directories of bundles, not a list of bundle directories).
- *
- * If \a search_path is NULL, \a world will be unmodified.
- * Use of this function is \b not recommended. Use \ref slv2_world_load_all.
- */
-void
-slv2_world_load_path(SLV2World world,
- const char* search_path);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SLV2_PRIVATE_TYPES_H__ */
-
Index: 3rdparty/slv2/src/stringlist.c
===================================================================
RCS file: 3rdparty/slv2/src/stringlist.c
diff -N 3rdparty/slv2/src/stringlist.c
--- 3rdparty/slv2/src/stringlist.c 23 Apr 2007 11:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +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.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <raptor.h>
-#include <slv2/stringlist.h>
-
-
-SLV2Strings
-slv2_strings_new()
-{
- return raptor_new_sequence(&free, NULL);
-}
-
-
-void
-slv2_strings_free(SLV2Strings list)
-{
- raptor_free_sequence(list);
-}
-
-
-unsigned
-slv2_strings_size(SLV2Strings list)
-{
- return raptor_sequence_size(list);
-}
-
-
-const char*
-slv2_strings_get_at(SLV2Strings list, unsigned index)
-{
- if (index > INT_MAX)
- return NULL;
- else
- return (const char*)raptor_sequence_get_at(list, (int)index);
-}
-
-
-bool
-slv2_strings_contains(SLV2Strings list, const char* str)
-{
- for (unsigned i=0; i < slv2_strings_size(list); ++i)
- if (!strcmp(slv2_strings_get_at(list, i), str))
- return true;
-
- return false;
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src 3rdparty/slv2/slv2.pro 3rdparty/sl...,
Remon Sijrier <=