Browse Source

Rename slv2 to lilv.

API breakage was proving too much of a hassle, and would be even further of a
mess after release and packaging.  Best to make a clean break now, and fix
installation to support parallel installs and prevent this kind of problem in
the future.


git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3217 a436a847-0d15-0410-975c-d299462d15a1
add_opts_to_lv2apply
David Robillard 11 years ago
parent
commit
809f5ae599
  1. 136
      ChangeLog
  2. 6
      README
  3. 12
      doc/reference.doxygen.in
  4. 10
      lilv.pc.in
  5. 14
      lilv.ttl
  6. 981
      lilv/lilv.h
  7. 264
      lilv/lilvmm.hpp
  8. 10
      slv2.pc.in
  9. 264
      slv2/slv2mm.hpp
  10. 182
      src/collections.c
  11. 407
      src/lilv_internal.h
  12. 576
      src/plugin.c
  13. 62
      src/pluginclass.c
  14. 46
      src/plugininstance.c
  15. 88
      src/pluginui.c
  16. 252
      src/port.c
  17. 100
      src/query.c
  18. 26
      src/scalepoint.c
  19. 428
      src/slv2_internal.h
  20. 16
      src/util.c
  21. 280
      src/value.c
  22. 504
      src/world.c
  23. 22
      swig/lilv.i
  24. 970
      test/lilv_test.c
  25. 976
      test/slv2_test.c
  26. 0
      utils/lilv.bash_completion
  27. 22
      utils/lilv_bench.c
  28. 250
      utils/lv2_inspect.c
  29. 150
      utils/lv2_jack_host.c
  30. 28
      utils/lv2_list.c
  31. BIN
      waf
  32. 159
      wscript

136
ChangeLog

@ -1,136 +1,4 @@
slv2 (UNRELEASED) unstable; urgency=low
* Parse all files with their own URI as a base URI (allowing proper
reference to other things in the same bundle)
* Support relative URIs returned from lv2_descriptor in libraries
* Remove nonsensical slv2_plugin_get_properties and slv2_plugin_get_hints
* Remove all use of SPARQL (including API that provided SPARQL support)
* Remove use of redland (librdf) in favour of Serd and Sord
* Remove slv2_world_new_using_rdf_world and slv2_plugin_query_sparql
* Remove separate i18n versions of functions and implement i18n everywhere
* Add slv2_world_set_option for runtime configuration of SLV2 features.
* Add SLV2_OPTION_FILTER_LANG option (to optionally disable i18n).
* Document entire API in single header file / page.
* Add new collections and iterator API (and deprecate index based API)
* Remove the questionable slv2_world_get_plugins_by_filter.
* Add slv2_plugin_is_replaced to allow hosts to hide old plugins.
* Switch to 2-clause BSD license.
* *** API BREAK ***
lilv (UNRELEASED) unstable; urgency=low
* Initial version (forked from SLV2)
-- David Robillard <d@drobilla.net> (UNRELEASED)
slv2 (0.6.6) unstable; urgency=low
* Add manual pages for utilities
* Reduce plugin load overhead (on-demand querying with finer granularity)
* Fix compilation on Mac OS X
-- David Robillard <d@drobilla.net> Mon, 25 May 2009 23:30:49 -0400
slv2 (0.6.4) unstable; urgency=low
* Add generic query interface to allow arbitrary querying of data
* Combine similar headers (reduce code duplication)
* Upgrade to waf 1.5.6
* Add man pages for utilities
-- David Robillard <d@drobilla.net> Mon, 04 May 2009 18:11:06 -0400
slv2 (0.6.3) unstable; urgency=low
* Fix illegal output of slv2_value_get_turtle_token for floats.
* Fix slv2_plugin_get_value_for_subject
* Add test suite and coverage instrumentation
* Upgrade to waf 1.5.1
-- David Robillard <d@drobilla.net> Sat, 13 Dec 2008 14:13:43 -0500
slv2 (0.6.2) unstable; urgency=high
* Fix bug introduced with I18N in 0.6.1 which broke feature detection.
* Add waf configure --no-jack option to avoid building Jack clients.
-- David Robillard <d@drobilla.net> Sun, 30 Nov 2008 19:40:27 -0500
slv2 (0.6.1) unstable; urgency=low
* I18N support.
* Add slv2_port_get_value (analogous to slv2_plugin_get_value).
* Add slv2_instance_get_extension_data.
* Fix slv2_plugin_get_supported_features (previously non-functional).
-- David Robillard <d@drobilla.net> Sat, 08 Nov 2008 14:27:10 -0500
slv2 (0.6.0) unstable; urgency=low
* Rework API to reduce dependence of SLV2 on specific LV2 features
* Use SLV2Value most everywhere in the API for type safety and
performance reasons
* Typical use case performance improvements
* Add support for scale points
* Use new Redland "trees" store for dramatic performance improvements
* *** API BREAK ***
-- David Robillard <d@drobilla.net> Sun, 06 Jul 2008 13:11:15 -0400
slv2 (0.5.0) unstable; urgency=low
* Update LV2 UI header (API break)
* *** API BREAK ***
-- David Robillard <d@drobilla.net> Thu, 17 Jan 2008 18:34:29 -0500
slv2 (0.4.5) unstable; urgency=low
* Fix redland librdf_free_query_results warning
* Use "memory" store instead of "hashes" store for plugin RDF data,
resulting in extreme speedups in some cases.
-- David Robillard <d@drobilla.net> Tue, 15 Jan 2008 19:22:21 -0500
slv2 (0.4.4) unstable; urgency=low
* Add slv2_port_has_property
* Add slv2_plugin_has_feature
* Add plugin template and port signature interface for much faster plugin
discovery with port input/output/type inspection.
-- David Robillard <d@drobilla.net> Tue, 15 Jan 2008 10:43:00 -0500
slv2 (0.4.3) unstable; urgency=low
* Fix lv2_inspect command line handling bug (always prints help)
* Fix case where multiple plugins are described in the same file
(avoid port symbol clashing).
-- David Robillard <d@drobilla.net> Thu, 10 Jan 2008 20:03:19 -0500
slv2 (0.4.2) unstable; urgency=low
* Update for LV2 specification release 1
-- David Robillard <d@drobilla.net> Tue, 08 Jan 2008 20:16:56 -0500
slv2 (0.4.1) unstable; urgency=low
* Debian packaging (no functional changes)
-- David Robillard <d@drobilla.net> Sun, 6 Jan 2008 18:39:57 -0500
slv2 (0.4.0) unstable; urgency=low
* Update for most recent LV2 GUI specification
* Fix plugin detection bugs
-- David Robillard <d@drobilla.net> Sun, 6 Jan 2008 17:11:18 -0500
slv2 (0.3.2) unstable; urgency=low
* Build man pages
-- David Robillard <d@drobilla.net> Wed, 30 Nov 2007 18:19:00 -0500
slv2 (0.3.1) unstable; urgency=low
* Initial Debian Release.
-- David Robillard <d@drobilla.net> Wed, 14 Nov 2007 22:29:49 -0500

6
README

@ -1,11 +1,11 @@
SLV2
Lilv
----
SLV2 is a library for LV2 hosts intended to make using LV2 Plugins as simple
Lilv is a library for LV2 hosts intended to make using LV2 Plugins as simple
as possible (without sacrificing capabilities).
More information about LV2 plugins can be found at <http://lv2plug.in>.
More information about SLV2 can be found at <http://drobilla.net/software/slv2>.
More information about Lilv can be found at <http://drobilla.net/software/lilv>.
-- David Robillard <d@drobilla.net>

12
doc/reference.doxygen.in

@ -25,20 +25,20 @@ DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = SLV2
PROJECT_NAME = Lilv
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = @SLV2_VERSION@
PROJECT_NUMBER = @LILV_VERSION@
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = @SLV2_DOC_DIR@
OUTPUT_DIRECTORY = @LILV_DOC_DIR@
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
@ -506,7 +506,7 @@ FILE_VERSION_FILTER =
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
LAYOUT_FILE = @SLV2_SRCDIR@/doc/layout.xml
LAYOUT_FILE = @LILV_SRCDIR@/doc/layout.xml
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
@ -568,7 +568,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = @SLV2_SRCDIR@/slv2/slv2.h
INPUT = @LILV_SRCDIR@/lilv/lilv.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@ -794,7 +794,7 @@ HTML_FOOTER =
# the style sheet file to the HTML output directory, so don't put your own
# stylesheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET = @SLV2_SRCDIR@/doc/style.css
HTML_STYLESHEET = @LILV_SRCDIR@/doc/style.css
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to

10
lilv.pc.in

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lilv
Version: @LILV_VERSION@
Description: Simple C library for hosting LV2 plugins
Libs: @GLIB_LIBS@ @SORD_LIBS@ -L${libdir} -llilv-@LILV_MAJOR_VERSION@ -ldl
Cflags: @GLIB_CFLAGS@ @SORD_CFLAGS@ -I${includedir}/lilv-@LILV_MAJOR_VERSION@

14
slv2.ttl → lilv.ttl

@ -3,9 +3,9 @@
@prefix : <http://usefulinc.com/ns/doap#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://drobilla.net/software/slv2>
<http://drobilla.net/software/lilv>
a :Project ;
:bug-database <http://dev.drobilla.net/query?status=new&status=assigned&status=reopened&component=SLV2&order=priority> ;
:bug-database <http://dev.drobilla.net/query?status=new&status=assigned&status=reopened&component=LILV&order=priority> ;
:developer [
a foaf:Person ;
rdfs:seeAlso <http://drobilla.net/drobilla.rdf> ;
@ -14,16 +14,16 @@
foaf:name "David Robillard"
] ;
:download-page <http://download.drobilla.net> ;
:homepage <http://drobilla.net/software/slv2> ;
:homepage <http://drobilla.net/software/lilv> ;
:license <http://usefulinc.com/doap/licenses/gpl> ;
:name "SLV2" ;
:name "LILV" ;
:programming-language "C", "Turtle" ;
:repository [
:browse <http://dev.drobilla.net/browser/trunk/slv2> ;
:location <http://svn.drobilla.net/lad/trunk/slv2> ;
:browse <http://dev.drobilla.net/browser/trunk/lilv> ;
:location <http://svn.drobilla.net/lad/trunk/lilv> ;
a :SVNRepository
] ;
:shortdesc "Library for simple use of LV2 plugins" ;
:shortname "SLV2" .
:shortname "LILV" .

981
lilv/lilv.h
File diff suppressed because it is too large
View File

264
lilv/lilvmm.hpp

@ -0,0 +1,264 @@
/*
Copyright 2007-2011 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef LILV_LILVMM_HPP
#define LILV_LILVMM_HPP
#include "lilv/lilv.h"
namespace Lilv {
const char* uri_to_path(const char* uri) { return lilv_uri_to_path(uri); }
#define LILV_WRAP0(RT, prefix, name) \
inline RT name () { return lilv_ ## prefix ## _ ## name (me); }
#define LILV_WRAP0_VOID(prefix, name) \
inline void name () { lilv_ ## prefix ## _ ## name (me); }
#define LILV_WRAP1(RT, prefix, name, T1, a1) \
inline RT name (T1 a1) { return lilv_ ## prefix ## _ ## name (me, a1); }
#define LILV_WRAP1_VOID(prefix, name, T1, a1) \
inline void name (T1 a1) { lilv_ ## prefix ## _ ## name (me, a1); }
#define LILV_WRAP2(RT, prefix, name, T1, a1, T2, a2) \
inline RT name (T1 a1, T2 a2) { return lilv_ ## prefix ## _ ## name (me, a1, a2); }
#define LILV_WRAP2_VOID(prefix, name, T1, a1, T2, a2) \
inline void name (T1 a1, T2 a2) { lilv_ ## prefix ## _ ## name (me, a1, a2); }
#ifndef SWIG
#define LILV_WRAP_CONVERSION(CT) \
inline operator CT() const { return me; }
#else
#define LILV_WRAP_CONVERSION(CT)
#endif
struct Value {
inline Value(LilvValue value) : me(value) {}
inline Value(const Value& copy) : me(lilv_value_duplicate(copy.me)) {}
inline ~Value() { /*lilv_value_free(me);*/ }
inline bool equals(const Value& other) const {
return lilv_value_equals(me, other.me);
}
inline bool operator==(const Value& other) const { return equals(other); }
LILV_WRAP_CONVERSION(LilvValue);
LILV_WRAP0(char*, value, get_turtle_token);
LILV_WRAP0(bool, value, is_uri);
LILV_WRAP0(const char*, value, as_uri);
LILV_WRAP0(bool, value, is_blank);
LILV_WRAP0(const char*, value, as_blank);
LILV_WRAP0(bool, value, is_literal);
LILV_WRAP0(bool, value, is_string);
LILV_WRAP0(const char*, value, as_string);
LILV_WRAP0(bool, value, is_float);
LILV_WRAP0(float, value, as_float);
LILV_WRAP0(bool, value, is_int);
LILV_WRAP0(int, value, as_int);
LILV_WRAP0(bool, value, is_bool);
LILV_WRAP0(bool, value, as_bool);
LilvValue me;
};
struct ScalePoint {
inline ScalePoint(LilvScalePoint c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(LilvScalePoint);
LILV_WRAP0(LilvValue, scale_point, get_label);
LILV_WRAP0(LilvValue, scale_point, get_value);
LilvScalePoint me;
};
struct PluginClass {
inline PluginClass(LilvPluginClass c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(LilvPluginClass);
LILV_WRAP0(Value, plugin_class, get_parent_uri);
LILV_WRAP0(Value, plugin_class, get_uri);
LILV_WRAP0(Value, plugin_class, get_label);
inline LilvPluginClasses get_children() {
return lilv_plugin_class_get_children(me);
}
LilvPluginClass me;
};
#define LILV_WRAP_COLL(CT, ET, prefix) \
struct CT { \
inline CT(Lilv ## CT c_obj) : me(c_obj) {} \
LILV_WRAP_CONVERSION(Lilv ## CT); \
LILV_WRAP0(unsigned, prefix, size); \
LILV_WRAP1(ET, prefix, get, LilvIter, i); \
Lilv ## CT me; \
}; \
LILV_WRAP_COLL(PluginClasses, PluginClass, plugin_classes);
LILV_WRAP_COLL(ScalePoints, ScalePoint, scale_points);
LILV_WRAP_COLL(Values, Value, values);
struct Plugins {
inline Plugins(LilvPlugins c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(LilvPlugins);
LilvPlugins me;
};
struct World {
inline World() : me(lilv_world_new()) {}
inline ~World() { /*lilv_world_free(me);*/ }
inline LilvValue new_uri(const char* uri) {
return lilv_value_new_uri(me, uri);
}
inline LilvValue new_string(const char* str) {
return lilv_value_new_string(me, str);
}
inline LilvValue new_int(int val) {
return lilv_value_new_int(me, val);
}
inline LilvValue new_float(float val) {
return lilv_value_new_float(me, val);
}
inline LilvValue new_bool(bool val) {
return lilv_value_new_bool(me, val);
}
LILV_WRAP2_VOID(world, set_option, const char*, uri, LilvValue, value);
LILV_WRAP0_VOID(world, free);
LILV_WRAP0_VOID(world, load_all);
LILV_WRAP1_VOID(world, load_bundle, LilvValue, bundle_uri);
LILV_WRAP0(LilvPluginClass, world, get_plugin_class);
LILV_WRAP0(LilvPluginClasses, world, get_plugin_classes);
LILV_WRAP0(Plugins, world, get_all_plugins);
//LILV_WRAP1(Plugin, world, get_plugin_by_uri_string, const char*, uri);
LilvWorld me;
};
struct Port {
inline Port(LilvPlugin p, LilvPort c_obj) : parent(p), me(c_obj) {}
LILV_WRAP_CONVERSION(LilvPort);
#define LILV_PORT_WRAP0(RT, name) \
inline RT name () { return lilv_port_ ## name (parent, me); }
#define LILV_PORT_WRAP1(RT, name, T1, a1) \
inline RT name (T1 a1) { return lilv_port_ ## name (parent, me, a1); }
LILV_PORT_WRAP1(LilvValues, get_value, LilvValue, predicate);
LILV_PORT_WRAP1(LilvValues, get_value_by_qname, const char*, predicate);
LILV_PORT_WRAP0(LilvValues, get_properties)
LILV_PORT_WRAP1(bool, has_property, LilvValue, property_uri);
LILV_PORT_WRAP1(bool, supports_event, LilvValue, event_uri);
LILV_PORT_WRAP0(LilvValue, get_symbol);
LILV_PORT_WRAP0(LilvValue, get_name);
LILV_PORT_WRAP0(LilvValues, get_classes);
LILV_PORT_WRAP1(bool, is_a, LilvValue, port_class);
LILV_PORT_WRAP0(LilvScalePoints, get_scale_points);
// TODO: get_range (output parameters)
LilvPlugin parent;
LilvPort me;
};
struct Plugin {
inline Plugin(LilvPlugin c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(LilvPlugin);
LILV_WRAP0(bool, plugin, verify);
LILV_WRAP0(Value, plugin, get_uri);
LILV_WRAP0(Value, plugin, get_bundle_uri);
LILV_WRAP0(Values, plugin, get_data_uris);
LILV_WRAP0(Value, plugin, get_library_uri);
LILV_WRAP0(Value, plugin, get_name);
LILV_WRAP0(PluginClass, plugin, get_class);
LILV_WRAP1(Values, plugin, get_value, Value, pred);
LILV_WRAP1(Values, plugin, get_value_by_qname, const char*, predicate);
LILV_WRAP2(Values, plugin, get_value_for_subject, Value, subject,
Value, predicate);
LILV_WRAP1(bool, plugin, has_feature, Value, feature_uri);
LILV_WRAP0(Values, plugin, get_supported_features);
LILV_WRAP0(Values, plugin, get_required_features);
LILV_WRAP0(Values, plugin, get_optional_features);
LILV_WRAP0(unsigned, plugin, get_num_ports);
LILV_WRAP0(bool, plugin, has_latency);
LILV_WRAP0(unsigned, plugin, get_latency_port_index);
LILV_WRAP0(Value, plugin, get_author_name);
LILV_WRAP0(Value, plugin, get_author_email);
LILV_WRAP0(Value, plugin, get_author_homepage);
inline Port get_port_by_index(unsigned index) {
return Port(me, lilv_plugin_get_port_by_index(me, index));
}
inline Port get_port_by_symbol(LilvValue symbol) {
return Port(me, lilv_plugin_get_port_by_symbol(me, symbol));
}
inline void get_port_ranges_float(float* min_values,
float* max_values,
float* def_values) {
return lilv_plugin_get_port_ranges_float(
me, min_values, max_values, def_values);
}
inline unsigned get_num_ports_of_class(LilvValue class_1,
LilvValue class_2) {
// TODO: varargs
return lilv_plugin_get_num_ports_of_class(me, class_1, class_2, NULL);
}
LilvPlugin me;
};
struct Instance {
inline Instance(Plugin plugin, double sample_rate) {
// TODO: features
me = lilv_plugin_instantiate(plugin, sample_rate, NULL);
}
LILV_WRAP_CONVERSION(LilvInstance);
LILV_WRAP2_VOID(instance, connect_port,
unsigned, port_index,
void*, data_location);
LILV_WRAP0_VOID(instance, activate);
LILV_WRAP1_VOID(instance, run, unsigned, sample_count);
LILV_WRAP0_VOID(instance, deactivate);
// TODO: get_extension_data
inline const LV2_Descriptor* get_descriptor() {
return lilv_instance_get_descriptor(me);
}
LilvInstance me;
};
} /* namespace Lilv */
#endif /* LILV_LILVMM_HPP */

10
slv2.pc.in

@ -1,10 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libslv2
Version: @SLV2_VERSION@
Description: Simple C library for hosting LV2 plugins
Libs: @GLIB_LIBS@ @SORD_LIBS@ -lsuil -L${libdir} -lslv2 -ldl
Cflags: @GLIB_CFLAGS@ @SORD_CFLAGS@ -I${includedir}

264
slv2/slv2mm.hpp

@ -1,264 +0,0 @@
/*
Copyright 2007-2011 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef SLV2_SLV2MM_HPP
#define SLV2_SLV2MM_HPP
#include "slv2/slv2.h"
namespace SLV2 {
const char* uri_to_path(const char* uri) { return slv2_uri_to_path(uri); }
#define SLV2_WRAP0(RT, prefix, name) \
inline RT name () { return slv2_ ## prefix ## _ ## name (me); }
#define SLV2_WRAP0_VOID(prefix, name) \
inline void name () { slv2_ ## prefix ## _ ## name (me); }
#define SLV2_WRAP1(RT, prefix, name, T1, a1) \
inline RT name (T1 a1) { return slv2_ ## prefix ## _ ## name (me, a1); }
#define SLV2_WRAP1_VOID(prefix, name, T1, a1) \
inline void name (T1 a1) { slv2_ ## prefix ## _ ## name (me, a1); }
#define SLV2_WRAP2(RT, prefix, name, T1, a1, T2, a2) \
inline RT name (T1 a1, T2 a2) { return slv2_ ## prefix ## _ ## name (me, a1, a2); }
#define SLV2_WRAP2_VOID(prefix, name, T1, a1, T2, a2) \
inline void name (T1 a1, T2 a2) { slv2_ ## prefix ## _ ## name (me, a1, a2); }
#ifndef SWIG
#define SLV2_WRAP_CONVERSION(CT) \
inline operator CT() const { return me; }
#else
#define SLV2_WRAP_CONVERSION(CT)
#endif
struct Value {
inline Value(SLV2Value value) : me(value) {}
inline Value(const Value& copy) : me(slv2_value_duplicate(copy.me)) {}
inline ~Value() { /*slv2_value_free(me);*/ }
inline bool equals(const Value& other) const {
return slv2_value_equals(me, other.me);
}
inline bool operator==(const Value& other) const { return equals(other); }
SLV2_WRAP_CONVERSION(SLV2Value);
SLV2_WRAP0(char*, value, get_turtle_token);
SLV2_WRAP0(bool, value, is_uri);
SLV2_WRAP0(const char*, value, as_uri);
SLV2_WRAP0(bool, value, is_blank);
SLV2_WRAP0(const char*, value, as_blank);
SLV2_WRAP0(bool, value, is_literal);
SLV2_WRAP0(bool, value, is_string);
SLV2_WRAP0(const char*, value, as_string);
SLV2_WRAP0(bool, value, is_float);
SLV2_WRAP0(float, value, as_float);
SLV2_WRAP0(bool, value, is_int);
SLV2_WRAP0(int, value, as_int);
SLV2_WRAP0(bool, value, is_bool);
SLV2_WRAP0(bool, value, as_bool);
SLV2Value me;
};
struct ScalePoint {
inline ScalePoint(SLV2ScalePoint c_obj) : me(c_obj) {}
SLV2_WRAP_CONVERSION(SLV2ScalePoint);
SLV2_WRAP0(SLV2Value, scale_point, get_label);
SLV2_WRAP0(SLV2Value, scale_point, get_value);
SLV2ScalePoint me;
};
struct PluginClass {
inline PluginClass(SLV2PluginClass c_obj) : me(c_obj) {}
SLV2_WRAP_CONVERSION(SLV2PluginClass);
SLV2_WRAP0(Value, plugin_class, get_parent_uri);
SLV2_WRAP0(Value, plugin_class, get_uri);
SLV2_WRAP0(Value, plugin_class, get_label);
inline SLV2PluginClasses get_children() {
return slv2_plugin_class_get_children(me);
}
SLV2PluginClass me;
};
#define SLV2_WRAP_COLL(CT, ET, prefix) \
struct CT { \
inline CT(SLV2 ## CT c_obj) : me(c_obj) {} \
SLV2_WRAP_CONVERSION(SLV2 ## CT); \
SLV2_WRAP0(unsigned, prefix, size); \
SLV2_WRAP1(ET, prefix, get, SLV2Iter, i); \
SLV2 ## CT me; \
}; \
SLV2_WRAP_COLL(PluginClasses, PluginClass, plugin_classes);
SLV2_WRAP_COLL(ScalePoints, ScalePoint, scale_points);
SLV2_WRAP_COLL(Values, Value, values);
struct Plugins {
inline Plugins(SLV2Plugins c_obj) : me(c_obj) {}
SLV2_WRAP_CONVERSION(SLV2Plugins);
SLV2Plugins me;
};
struct World {
inline World() : me(slv2_world_new()) {}
inline ~World() { /*slv2_world_free(me);*/ }
inline SLV2Value new_uri(const char* uri) {
return slv2_value_new_uri(me, uri);
}
inline SLV2Value new_string(const char* str) {
return slv2_value_new_string(me, str);
}
inline SLV2Value new_int(int val) {
return slv2_value_new_int(me, val);
}
inline SLV2Value new_float(float val) {
return slv2_value_new_float(me, val);
}
inline SLV2Value new_bool(bool val) {
return slv2_value_new_bool(me, val);
}
SLV2_WRAP2_VOID(world, set_option, const char*, uri, SLV2Value, value);
SLV2_WRAP0_VOID(world, free);
SLV2_WRAP0_VOID(world, load_all);
SLV2_WRAP1_VOID(world, load_bundle, SLV2Value, bundle_uri);
SLV2_WRAP0(SLV2PluginClass, world, get_plugin_class);
SLV2_WRAP0(SLV2PluginClasses, world, get_plugin_classes);
SLV2_WRAP0(Plugins, world, get_all_plugins);
//SLV2_WRAP1(Plugin, world, get_plugin_by_uri_string, const char*, uri);
SLV2World me;
};
struct Port {
inline Port(SLV2Plugin p, SLV2Port c_obj) : parent(p), me(c_obj) {}
SLV2_WRAP_CONVERSION(SLV2Port);
#define SLV2_PORT_WRAP0(RT, name) \
inline RT name () { return slv2_port_ ## name (parent, me); }
#define SLV2_PORT_WRAP1(RT, name, T1, a1) \
inline RT name (T1 a1) { return slv2_port_ ## name (parent, me, a1); }
SLV2_PORT_WRAP1(SLV2Values, get_value, SLV2Value, predicate);
SLV2_PORT_WRAP1(SLV2Values, get_value_by_qname, const char*, predicate);
SLV2_PORT_WRAP0(SLV2Values, get_properties)
SLV2_PORT_WRAP1(bool, has_property, SLV2Value, property_uri);
SLV2_PORT_WRAP1(bool, supports_event, SLV2Value, event_uri);
SLV2_PORT_WRAP0(SLV2Value, get_symbol);
SLV2_PORT_WRAP0(SLV2Value, get_name);
SLV2_PORT_WRAP0(SLV2Values, get_classes);
SLV2_PORT_WRAP1(bool, is_a, SLV2Value, port_class);
SLV2_PORT_WRAP0(SLV2ScalePoints, get_scale_points);
// TODO: get_range (output parameters)
SLV2Plugin parent;
SLV2Port me;
};
struct Plugin {
inline Plugin(SLV2Plugin c_obj) : me(c_obj) {}
SLV2_WRAP_CONVERSION(SLV2Plugin);
SLV2_WRAP0(bool, plugin, verify);
SLV2_WRAP0(Value, plugin, get_uri);
SLV2_WRAP0(Value, plugin, get_bundle_uri);
SLV2_WRAP0(Values, plugin, get_data_uris);
SLV2_WRAP0(Value, plugin, get_library_uri);
SLV2_WRAP0(Value, plugin, get_name);
SLV2_WRAP0(PluginClass, plugin, get_class);
SLV2_WRAP1(Values, plugin, get_value, Value, pred);
SLV2_WRAP1(Values, plugin, get_value_by_qname, const char*, predicate);
SLV2_WRAP2(Values, plugin, get_value_for_subject, Value, subject,
Value, predicate);
SLV2_WRAP1(bool, plugin, has_feature, Value, feature_uri);
SLV2_WRAP0(Values, plugin, get_supported_features);
SLV2_WRAP0(Values, plugin, get_required_features);
SLV2_WRAP0(Values, plugin, get_optional_features);
SLV2_WRAP0(unsigned, plugin, get_num_ports);
SLV2_WRAP0(bool, plugin, has_latency);
SLV2_WRAP0(unsigned, plugin, get_latency_port_index);
SLV2_WRAP0(Value, plugin, get_author_name);
SLV2_WRAP0(Value, plugin, get_author_email);
SLV2_WRAP0(Value, plugin, get_author_homepage);
inline Port get_port_by_index(unsigned index) {
return Port(me, slv2_plugin_get_port_by_index(me, index));
}
inline Port get_port_by_symbol(SLV2Value symbol) {
return Port(me, slv2_plugin_get_port_by_symbol(me, symbol));
}
inline void get_port_ranges_float(float* min_values,
float* max_values,
float* def_values) {
return slv2_plugin_get_port_ranges_float(
me, min_values, max_values, def_values);
}
inline unsigned get_num_ports_of_class(SLV2Value class_1,
SLV2Value class_2) {
// TODO: varargs
return slv2_plugin_get_num_ports_of_class(me, class_1, class_2, NULL);
}
SLV2Plugin me;
};
struct Instance {
inline Instance(Plugin plugin, double sample_rate) {
// TODO: features
me = slv2_plugin_instantiate(plugin, sample_rate, NULL);
}
SLV2_WRAP_CONVERSION(SLV2Instance);
SLV2_WRAP2_VOID(instance, connect_port,
unsigned, port_index,
void*, data_location);
SLV2_WRAP0_VOID(instance, activate);
SLV2_WRAP1_VOID(instance, run, unsigned, sample_count);
SLV2_WRAP0_VOID(instance, deactivate);
// TODO: get_extension_data
inline const LV2_Descriptor* get_descriptor() {
return slv2_instance_get_descriptor(me);
}
SLV2Instance me;
};
} /* namespace SLV2 */
#endif /* SLV2_SLV2MM_HPP */

182
src/collections.c

@ -16,118 +16,107 @@
#include <glib.h>
#include "slv2_internal.h"
#include "lilv_internal.h"
/* Generic collection functions */
static inline SLV2Collection
slv2_collection_new(GDestroyNotify destructor)
static inline LilvCollection
lilv_collection_new(GDestroyNotify destructor)
{
return g_sequence_new(destructor);
}
void
slv2_collection_free(SLV2Collection coll)
lilv_collection_free(LilvCollection coll)
{
if (coll)
g_sequence_free((GSequence*)coll);
}
unsigned
slv2_collection_size(SLV2Collection coll)
lilv_collection_size(LilvCollection coll)
{
return (coll ? g_sequence_get_length((GSequence*)coll) : 0);
}
void*
slv2_collection_get_at(SLV2Collection coll, unsigned index)
{
if (!coll || index >= slv2_collection_size(coll)) {
return NULL;
} else {
GSequenceIter* i = g_sequence_get_iter_at_pos((GSequence*)coll, (int)index);
return g_sequence_get(i);
}
}
SLV2Iter
slv2_collection_begin(SLV2Collection collection)
LilvIter
lilv_collection_begin(LilvCollection collection)
{
return collection ? g_sequence_get_begin_iter(collection) : NULL;
}
void*
slv2_collection_get(SLV2Collection collection,
SLV2Iter i)
lilv_collection_get(LilvCollection collection,
LilvIter i)
{
return g_sequence_get((GSequenceIter*)i);
}
/* Constructors */
SLV2ScalePoints
slv2_scale_points_new(void)
LilvScalePoints
lilv_scale_points_new(void)
{
return slv2_collection_new((GDestroyNotify)slv2_scale_point_free);
return lilv_collection_new((GDestroyNotify)lilv_scale_point_free);
}
SLV2Values
slv2_values_new(void)
LilvValues
lilv_values_new(void)
{
return slv2_collection_new((GDestroyNotify)slv2_value_free);
return lilv_collection_new((GDestroyNotify)lilv_value_free);
}
SLV2UIs
slv2_uis_new(void)
LilvUIs
lilv_uis_new(void)
{
return slv2_collection_new((GDestroyNotify)slv2_ui_free);
return lilv_collection_new((GDestroyNotify)lilv_ui_free);
}
SLV2PluginClasses
slv2_plugin_classes_new(void)
LilvPluginClasses
lilv_plugin_classes_new(void)
{
return slv2_collection_new((GDestroyNotify)slv2_plugin_class_free);
return lilv_collection_new((GDestroyNotify)lilv_plugin_class_free);
}
/* URI based accessors (for collections of things with URIs) */
SLV2_API
SLV2PluginClass
slv2_plugin_classes_get_by_uri(SLV2PluginClasses coll, SLV2Value uri)
LILV_API
LilvPluginClass
lilv_plugin_classes_get_by_uri(LilvPluginClasses coll, LilvValue uri)
{
return (SLV2PluginClass)slv2_sequence_get_by_uri(coll, uri);
return (LilvPluginClass)lilv_sequence_get_by_uri(coll, uri);
}
SLV2_API
SLV2UI
slv2_uis_get_by_uri(SLV2UIs coll, SLV2Value uri)
LILV_API
LilvUI
lilv_uis_get_by_uri(LilvUIs coll, LilvValue uri)
{
return (SLV2UIs)slv2_sequence_get_by_uri(coll, uri);
return (LilvUIs)lilv_sequence_get_by_uri(coll, uri);
}
/* Plugins */
SLV2Plugins
slv2_plugins_new()
LilvPlugins
lilv_plugins_new()
{
return g_sequence_new(NULL);
}
SLV2_API
SLV2Plugin
slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri)
LILV_API
LilvPlugin
lilv_plugins_get_by_uri(LilvPlugins list, LilvValue uri)
{
return (SLV2Plugin)slv2_sequence_get_by_uri(list, uri);
return (LilvPlugin)lilv_sequence_get_by_uri(list, uri);
}
/* Values */
SLV2_API
LILV_API
bool
slv2_values_contains(SLV2Values list, SLV2Value value)
lilv_values_contains(LilvValues list, LilvValue value)
{
SLV2_FOREACH(values, i, list)
if (slv2_value_equals(slv2_values_get(list, i), value))
LILV_FOREACH(values, i, list)
if (lilv_value_equals(lilv_values_get(list, i), value))
return true;
return false;
@ -135,94 +124,87 @@ slv2_values_contains(SLV2Values list, SLV2Value value)
/* Iterator */
SLV2Iter
slv2_iter_next(SLV2Iter i)
LilvIter
lilv_iter_next(LilvIter i)
{
return g_sequence_iter_next((GSequenceIter*)i);
}
bool
slv2_iter_end(SLV2Iter i)
lilv_iter_end(LilvIter i)
{
return !i || g_sequence_iter_is_end((GSequenceIter*)i);
}
#define SLV2_COLLECTION_IMPL(prefix, CT, ET) \
SLV2_API \
#define LILV_COLLECTION_IMPL(prefix, CT, ET) \
LILV_API \
unsigned \
prefix##_size(CT collection) { \
return slv2_collection_size(collection); \
return lilv_collection_size(collection); \
} \
\
SLV2_API \
SLV2Iter \
LILV_API \
LilvIter \
prefix##_begin(CT collection) { \
return slv2_collection_begin(collection); \
return lilv_collection_begin(collection); \
} \
\
SLV2_API \
LILV_API \
ET \
prefix##_get(CT collection, SLV2Iter i) { \
return (ET)slv2_collection_get(collection, i); \
prefix##_get(CT collection, LilvIter i) { \
return (ET)lilv_collection_get(collection, i); \
} \
\
SLV2_API \
SLV2Iter \
prefix##_next(CT collection, SLV2Iter i) { \
return slv2_iter_next(i); \
LILV_API \
LilvIter \
prefix##_next(CT collection, LilvIter i) { \
return lilv_iter_next(i); \
} \
\
SLV2_API \
LILV_API \
bool \
prefix##_is_end(CT collection, SLV2Iter i) { \
return slv2_iter_end(i); \
} \
\
SLV2_DEPRECATED \
SLV2_API \
ET \
prefix##_get_at(CT collection, unsigned index) { \
return (ET)slv2_collection_get_at(collection, index); \
prefix##_is_end(CT collection, LilvIter i) { \
return lilv_iter_end(i); \
}
SLV2_COLLECTION_IMPL(slv2_plugin_classes, SLV2PluginClasses, SLV2PluginClass)
SLV2_COLLECTION_IMPL(slv2_scale_points, SLV2ScalePoints, SLV2ScalePoint)
SLV2_COLLECTION_IMPL(slv2_uis, SLV2UIs, SLV2UI)
SLV2_COLLECTION_IMPL(slv2_values, SLV2Values, SLV2Value)
SLV2_COLLECTION_IMPL(slv2_plugins, SLV2Plugins, SLV2Plugin)
LILV_COLLECTION_IMPL(lilv_plugin_classes, LilvPluginClasses, LilvPluginClass)
LILV_COLLECTION_IMPL(lilv_scale_points, LilvScalePoints, LilvScalePoint)
LILV_COLLECTION_IMPL(lilv_uis, LilvUIs, LilvUI)
LILV_COLLECTION_IMPL(lilv_values, LilvValues, LilvValue)
LILV_COLLECTION_IMPL(lilv_plugins, LilvPlugins, LilvPlugin)
SLV2_API
LILV_API
void
slv2_plugin_classes_free(SLV2PluginClasses collection) {
slv2_collection_free(collection);
lilv_plugin_classes_free(LilvPluginClasses collection) {
lilv_collection_free(collection);
}
SLV2_API
LILV_API
void
slv2_scale_points_free(SLV2ScalePoints collection) {
slv2_collection_free(collection);
lilv_scale_points_free(LilvScalePoints collection) {
lilv_collection_free(collection);
}
SLV2_API
LILV_API
void
slv2_uis_free(SLV2UIs collection) {
slv2_collection_free(collection);
lilv_uis_free(LilvUIs collection) {
lilv_collection_free(collection);
}
SLV2_API
LILV_API
void
slv2_values_free(SLV2Values collection) {
slv2_collection_free(collection);
lilv_values_free(LilvValues collection) {
lilv_collection_free(collection);
}
SLV2_API
LILV_API
void
slv2_plugins_free(SLV2World world, SLV2Plugins plugins){
lilv_plugins_free(LilvWorld world, LilvPlugins plugins){
}
SLV2_API
SLV2Value
slv2_values_get_first(SLV2Values collection) {
return (SLV2Value)slv2_collection_get(collection,
slv2_collection_begin(collection));
LILV_API
LilvValue
lilv_values_get_first(LilvValues collection) {
return (LilvValue)lilv_collection_get(collection,
lilv_collection_begin(collection));
}

407
src/lilv_internal.h

@ -0,0 +1,407 @@
/*
Copyright 2007-2011 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef LILV_INTERNAL_H
#define LILV_INTERNAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef __WIN32__
#include <windows.h>
#define dlopen(path, flags) LoadLibrary(path)
#define dlclose(lib) FreeLibrary(lib)
#define dlsym GetProcAddress
static inline char* dlerror(void) { return "Unknown error"; }
#else
#include <dlfcn.h>
#endif
#include <glib.h>
#include "serd/serd.h"
#include "sord/sord.h"
#include "lilv-config.h"
#ifdef LILV_DYN_MANIFEST
#include "lv2/lv2plug.in/ns/ext/dyn-manifest/dyn-manifest.h"
#endif
#include "lilv/lilv.h"
#define LILV_NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
#define LILV_NS_RDFS (const uint8_t*)"http://www.w3.org/2000/01/rdf-schema#"
#define LILV_NS_LILV (const uint8_t*)"http://drobilla.net/ns/lilv#"
#define LILV_NS_LV2 (const uint8_t*)"http://lv2plug.in/ns/lv2core#"
#define LILV_NS_XSD (const uint8_t*)"http://www.w3.org/2001/XMLSchema#"
#define LILV_NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
typedef SordIter* LilvMatches;
typedef const SordNode* LilvNode;
#define FOREACH_MATCH(iter) \
for (; !sord_iter_end(iter); sord_iter_next(iter))
static inline const SordNode*
lilv_match_subject(LilvMatches iter) {
SordQuad tup;
sord_iter_get(iter, tup);
return tup[SORD_SUBJECT];
}
static inline const SordNode*
lilv_match_object(LilvMatches iter) {
SordQuad tup;
sord_iter_get(iter, tup);
return tup[SORD_OBJECT];
}
static inline void
lilv_match_end(LilvMatches iter)
{
sord_iter_free(iter);
}
/* ********* PORT ********* */
/** Reference to a port on some plugin. */
struct _LilvPort {
uint32_t index; ///< lv2:index
LilvValue symbol; ///< lv2:symbol
LilvValues classes; ///< rdf:type
};
LilvPort lilv_port_new(LilvWorld world, uint32_t index, const char* symbol);
void lilv_port_free(LilvPort port);
/* ********* Spec ********* */
struct _LilvSpec {
SordNode* spec;
SordNode* bundle;
LilvValues data_uris;
};
typedef struct _LilvSpec* LilvSpec;
/* ********* Plugin ********* */
/** Header of an LilvPlugin, LilvPluginClass, or LilvUI.
* Any of these structs may be safely casted to _LilvHeader, which is used to
* implement sequences without code duplication (see lilv_sequence_get_by_uri).
*/
struct _LilvHeader {
struct _LilvWorld* world;
LilvValue uri;
};
/** 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 _LilvPlugin {
struct _LilvWorld* world;
LilvValue plugin_uri;
LilvValue bundle_uri; ///< Bundle directory plugin was loaded from
LilvValue binary_uri; ///< lv2:binary
LilvValue dynman_uri; ///< dynamic manifest binary
LilvPluginClass plugin_class;
LilvValues data_uris; ///< rdfs::seeAlso
LilvPort* ports;
uint32_t num_ports;
bool loaded;
bool replaced;
};
LilvPlugin lilv_plugin_new(LilvWorld world, LilvValue uri, LilvValue bundle_uri);
void lilv_plugin_load_if_necessary(LilvPlugin p);
void lilv_plugin_free(LilvPlugin plugin);
LilvValue
lilv_plugin_get_unique(LilvPlugin p,
LilvNode subject,
LilvNode predicate);
/* ********* Plugins ********* */
typedef void* LilvCollection;
LilvPlugins
lilv_plugins_new();
/**
Increment @a i to point at the next element in the collection.
*/
LilvIter
lilv_iter_next(LilvIter i);
/**
Return true iff @a i is at the end of the collection.
*/
bool
lilv_iter_end(LilvIter i);
LilvIter
lilv_collection_begin(LilvCollection collection);
void*
lilv_collection_get(LilvCollection collection,
LilvIter i);
/**
Free @a collection.
*/
void
lilv_collection_free(LilvCollection collection);
/**
Get the number of elements in @a collection.
*/
unsigned
lilv_collection_size(LilvCollection collection);
LilvValues
lilv_values_new(void);
LilvScalePoints
lilv_scale_points_new(void);
/* ********* Instance ********* */
/** Pimpl portion of LilvInstance */
struct _LilvInstanceImpl {
void* lib_handle;
};
/* ********* Plugin Class ********* */
struct _LilvPluginClass {
struct _LilvWorld* world;
LilvValue uri;
LilvValue parent_uri;
LilvValue label;
};
LilvPluginClass lilv_plugin_class_new(LilvWorld world,
LilvNode parent_uri,
LilvNode uri,
const char* label);
void lilv_plugin_class_free(LilvPluginClass plugin_class);
/* ********* Plugin Classes ********* */
LilvPluginClasses lilv_plugin_classes_new();
void lilv_plugin_classes_free();
/* ********* World ********* */
typedef struct {
bool dyn_manifest;
bool filter_language;
} LilvOptions;
/** Model of LV2 (RDF) data loaded from bundles.
*/
struct _LilvWorld {
SordWorld* world;
SordModel* model;
SerdReader* reader;
SerdEnv* namespaces;
unsigned n_read_files;
LilvPluginClass lv2_plugin_class;
LilvPluginClasses plugin_classes;
GSList* specs;
LilvPlugins plugins;
SordNode* dc_replaces_node;
SordNode* dyn_manifest_node;
SordNode* lv2_specification_node;
SordNode* lv2_plugin_node;
SordNode* lv2_binary_node;
SordNode* lv2_default_node;
SordNode* lv2_minimum_node;
SordNode* lv2_maximum_node;
SordNode* lv2_port_node;
SordNode* lv2_portproperty_node;
SordNode* lv2_reportslatency_node;
SordNode* lv2_index_node;
SordNode* lv2_symbol_node;
SordNode* rdf_a_node;
SordNode* rdf_value_node;
SordNode* rdfs_class_node;
SordNode* rdfs_label_node;
SordNode* rdfs_seealso_node;
SordNode* rdfs_subclassof_node;
SordNode* lilv_dmanifest_node;
SordNode* xsd_boolean_node;
SordNode* xsd_decimal_node;
SordNode* xsd_double_node;
SordNode* xsd_integer_node;
LilvValue doap_name_val;
LilvValue lv2_name_val;
LilvOptions opt;
};
const uint8_t*
lilv_world_blank_node_prefix(LilvWorld world);
void
lilv_world_load_file(LilvWorld world, const char* file_uri);
/* ********* Plugin UI ********* */
struct _LilvUI {
struct _LilvWorld* world;
LilvValue uri;
LilvValue bundle_uri;
LilvValue binary_uri;
LilvValues classes;
};
LilvUIs lilv_uis_new();
LilvUI
lilv_ui_new(LilvWorld world,
LilvValue uri,
LilvValue type_uri,
LilvValue binary_uri);
void lilv_ui_free(LilvUI ui);
/* ********* Value ********* */
typedef enum _LilvValueType {
LILV_VALUE_URI,
LILV_VALUE_QNAME_UNUSED, ///< FIXME: APIBREAK: remove
LILV_VALUE_STRING,
LILV_VALUE_INT,
LILV_VALUE_FLOAT,
LILV_VALUE_BOOL,
LILV_VALUE_BLANK
} LilvValueType;
struct _LilvValue {
LilvWorld world;
char* str_val; ///< always present
union {
int int_val;
float float_val;
bool bool_val;
SordNode* uri_val;
} val;
LilvValueType type;
};
LilvValue lilv_value_new(LilvWorld world, LilvValueType type, const char* val);
LilvValue lilv_value_new_from_node(LilvWorld world, LilvNode node);
LilvNode lilv_value_as_node(LilvValue value);
int
lilv_header_compare_by_uri(const void* a, const void* b, void* user_data);
static inline void
lilv_sequence_insert(GSequence* seq, void* value)
{
g_sequence_insert_sorted(seq, value, lilv_header_compare_by_uri, NULL);
}
static inline void
lilv_array_append(GSequence* seq, void* value) {
g_sequence_append(seq, value);
}
struct _LilvHeader*
lilv_sequence_get_by_uri(GSequence* seq, LilvValue uri);
static inline SordNode* lilv_node_copy(LilvNode node) {
return sord_node_copy(node);
}
static inline void lilv_node_free(LilvWorld world, SordNode* node) {
sord_node_free(world->world, node);
}
/* ********* Scale Points ********* */
struct _LilvScalePoint {
LilvValue value;
LilvValue label;
};
LilvScalePoint lilv_scale_point_new(LilvValue value, LilvValue label);
void lilv_scale_point_free(LilvScalePoint point);
/* ********* Query Results ********* */
LilvMatches lilv_plugin_find_statements(LilvPlugin plugin,
LilvNode subject,
LilvNode predicate,
LilvNode object);
static inline bool lilv_matches_next(LilvMatches matches) {
return sord_iter_next(matches);
}
static inline bool lilv_matches_end(LilvMatches matches) {
return sord_iter_end(matches);
}
LilvValues lilv_values_from_stream_objects(LilvPlugin p,
LilvMatches stream);
/* ********* Utilities ********* */
char* lilv_strjoin(const char* first, ...);
char* lilv_strdup(const char* str);
char* lilv_get_lang();
uint8_t* lilv_qname_expand(LilvPlugin p, const char* qname);
typedef void (*VoidFunc)();
/** dlsym wrapper to return a function pointer (without annoying warning) */
static inline VoidFunc
lilv_dlfunc(void* handle, const char* symbol)
{
typedef VoidFunc (*VoidFuncGetter)(void*, const char*);
VoidFuncGetter dlfunc = (VoidFuncGetter)dlsym;
return dlfunc(handle, symbol);
}
/* ********* Dynamic Manifest ********* */
#ifdef LILV_DYN_MANIFEST
static const LV2_Feature* const dman_features = { NULL };
#endif
#define LILV_ERROR(str) fprintf(stderr, "ERROR: %s: " str, __func__)
#define LILV_ERRORF(fmt, ...) fprintf(stderr, "ERROR: %s: " fmt, __func__, __VA_ARGS__)
#define LILV_WARN(str) fprintf(stderr, "WARNING: %s: " str, __func__)
#define LILV_WARNF(fmt, ...) fprintf(stderr, "WARNING: %s: " fmt, __func__, __VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif /* LILV_INTERNAL_H */

576
src/plugin.c
File diff suppressed because it is too large
View File

62
src/pluginclass.c

@ -20,40 +20,40 @@
#include <stdlib.h>
#include <string.h>
#include "slv2_internal.h"
#include "lilv_internal.h"
SLV2PluginClass
slv2_plugin_class_new(SLV2World world,
SLV2Node parent_node,
SLV2Node uri,
LilvPluginClass
lilv_plugin_class_new(LilvWorld world,
LilvNode parent_node,
LilvNode uri,
const char* label)
{
if (parent_node && sord_node_get_type(parent_node) != SORD_URI) {
return NULL; // Not an LV2 plugin superclass (FIXME: discover properly)
}
SLV2PluginClass pc = (SLV2PluginClass)malloc(sizeof(struct _SLV2PluginClass));
LilvPluginClass pc = (LilvPluginClass)malloc(sizeof(struct _LilvPluginClass));
pc->world = world;
pc->uri = slv2_value_new_from_node(world, uri);
pc->label = slv2_value_new(world, SLV2_VALUE_STRING, label);
pc->uri = lilv_value_new_from_node(world, uri);
pc->label = lilv_value_new(world, LILV_VALUE_STRING, label);
pc->parent_uri = (parent_node)
? slv2_value_new_from_node(world, parent_node)
? lilv_value_new_from_node(world, parent_node)
: NULL;
return pc;
}
void
slv2_plugin_class_free(SLV2PluginClass plugin_class)
lilv_plugin_class_free(LilvPluginClass plugin_class)
{
assert(plugin_class->uri);
slv2_value_free(plugin_class->uri);
slv2_value_free(plugin_class->parent_uri);
slv2_value_free(plugin_class->label);
lilv_value_free(plugin_class->uri);
lilv_value_free(plugin_class->parent_uri);
lilv_value_free(plugin_class->label);
free(plugin_class);
}
SLV2_API
SLV2Value
slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class)
LILV_API
LilvValue
lilv_plugin_class_get_parent_uri(LilvPluginClass plugin_class)
{
if (plugin_class->parent_uri)
return plugin_class->parent_uri;
@ -61,36 +61,36 @@ slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class)
return NULL;
}
SLV2_API
SLV2Value
slv2_plugin_class_get_uri(SLV2PluginClass plugin_class)
LILV_API
LilvValue
lilv_plugin_class_get_uri(LilvPluginClass plugin_class)
{
assert(plugin_class->uri);
return plugin_class->uri;
}
SLV2_API
SLV2Value
slv2_plugin_class_get_label(SLV2PluginClass plugin_class)
LILV_API
LilvValue
lilv_plugin_class_get_label(LilvPluginClass plugin_class)
{
return plugin_class->label;
}
SLV2_API
SLV2PluginClasses
slv2_plugin_class_get_children(SLV2PluginClass plugin_class)
LILV_API
LilvPluginClasses
lilv_plugin_class_get_children(LilvPluginClass plugin_class)
{