summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-12 04:25:39 +0000
committerDavid Robillard <d@drobilla.net>2011-02-12 04:25:39 +0000
commitc32c1593bc6b7c887e7c106531de2567b0da5aa1 (patch)
treefedac05f9957c298de652900646811a0b35b4815
parent4d75c4711b12747e37286f5c3cc5bf741d7b351e (diff)
downloadlilv-c32c1593bc6b7c887e7c106531de2567b0da5aa1.tar.gz
lilv-c32c1593bc6b7c887e7c106531de2567b0da5aa1.tar.bz2
lilv-c32c1593bc6b7c887e7c106531de2567b0da5aa1.zip
Make UI support a compile-time option, and separate UI functions into slv2/ui.h.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2930 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--slv2/slv2.h141
-rw-r--r--slv2/ui.h167
-rw-r--r--src/collections.c7
-rw-r--r--src/plugin.c3
-rw-r--r--src/slv2_internal.h9
-rw-r--r--test/slv2_test.c12
-rw-r--r--utils/lv2_inspect.c6
-rw-r--r--wscript10
8 files changed, 210 insertions, 145 deletions
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 8318564..2817fac 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -16,8 +16,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef SLV2_H__
-#define SLV2_H__
+#ifndef SLV2_SLV2_H__
+#define SLV2_SLV2_H__
#ifdef __cplusplus
extern "C" {
@@ -27,7 +27,6 @@ extern "C" {
#include <stdbool.h>
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
-#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
#if defined _WIN32 || defined __CYGWIN__
#define SLV2_LIB_IMPORT __declspec(dllimport)
@@ -60,14 +59,12 @@ typedef struct _SLV2Plugin* SLV2Plugin; /**< LV2 Plugin. */
typedef struct _SLV2PluginClass* SLV2PluginClass; /**< Plugin Class. */
typedef struct _SLV2Port* SLV2Port; /**< Port. */
typedef struct _SLV2ScalePoint* SLV2ScalePoint; /**< Scale Point (Notch). */
-typedef struct _SLV2UI* SLV2UI; /**< Plugin UI. */
typedef struct _SLV2Value* SLV2Value; /**< Typed Value. */
typedef struct _SLV2World* SLV2World; /**< SLV2 World. */
typedef void* SLV2PluginClasses; /**< set<PluginClass>. */
typedef void* SLV2Plugins; /**< set<Plugin>. */
typedef void* SLV2ScalePoints; /**< array<ScalePoint>. */
-typedef void* SLV2UIs; /**< set<UI>. */
typedef void* SLV2Values; /**< array<Value>. */
/** @defgroup slv2 SLV2
@@ -297,7 +294,6 @@ prefix ## _get_at(CollType collection, \
SLV2_COLLECTION(SLV2PluginClasses, SLV2PluginClass, slv2_plugin_classes)
SLV2_COLLECTION(SLV2ScalePoints, SLV2ScalePoint, slv2_scale_points)
SLV2_COLLECTION(SLV2Values, SLV2Value, slv2_values)
-SLV2_COLLECTION(SLV2UIs, SLV2UI, slv2_uis)
/** Free a plugin collection.
* Freeing a plugin collection does not destroy the plugins it contains
@@ -364,16 +360,6 @@ SLV2_API
bool
slv2_values_contains(SLV2Values values, SLV2Value value);
-/** Get a UI from @a uis by URI.
- * Return value is shared (stored in @a uis) and must not be freed or
- * modified by the caller in any way.
- * @return NULL if no UI with @a uri is found in @a list.
- */
-SLV2_API
-SLV2UI
-slv2_uis_get_by_uri(SLV2UIs uis,
- SLV2Value uri);
-
/** @} */
/** @name World
* The "world" represents all SLV2 state, and is used to discover/load/cache
@@ -735,17 +721,6 @@ SLV2Port
slv2_plugin_get_port_by_symbol(SLV2Plugin plugin,
SLV2Value symbol);
-/** Get a list of all UIs available for this plugin.
- * Note this returns the URI of the UI, and not the path/URI to its shared
- * library, use slv2_ui_get_library_uri with the values returned
- * here for that.
- *
- * Returned value must be freed by caller using slv2_uis_free.
- */
-SLV2_API
-SLV2UIs
-slv2_plugin_get_uis(SLV2Plugin plugin);
-
/** Get the full name of the plugin's author.
* Returns NULL if author name is not present.
* Returned value must be freed by caller.
@@ -936,51 +911,6 @@ SLV2PluginClasses
slv2_plugin_class_get_children(SLV2PluginClass plugin_class);
/** @} */
-/** @name Plugin UI
- * @{
- */
-
-/** Get the URI of a Plugin UI.
- * @param ui The Plugin UI
- * @return a shared value which must not be modified or freed.
- */
-SLV2_API
-SLV2Value
-slv2_ui_get_uri(SLV2UI ui);
-
-/** Get the types (URIs of RDF classes) of a Plugin UI.
- * @param ui The Plugin UI
- * @return a shared value which must not be modified or freed.
- */
-SLV2_API
-SLV2Values
-slv2_ui_get_classes(SLV2UI ui);
-
-/** Check whether a plugin UI is a given type.
- * @param ui The Plugin UI
- * @param class_uri The URI of the LV2 UI type to check this UI against
- */
-SLV2_API
-bool
-slv2_ui_is_a(SLV2UI ui, SLV2Value class_uri);
-
-/** Get the URI for a Plugin UI's bundle.
- * @param ui The Plugin UI
- * @return a shared value which must not be modified or freed.
- */
-SLV2_API
-SLV2Value
-slv2_ui_get_bundle_uri(SLV2UI ui);
-
-/** Get the URI for a Plugin UI's shared library.
- * @param ui The Plugin UI
- * @return a shared value which must not be modified or freed.
- */
-SLV2_API
-SLV2Value
-slv2_ui_get_binary_uri(SLV2UI ui);
-
-/** @} */
/** @name Plugin Instance
* @{
*/
@@ -1120,75 +1050,10 @@ slv2_instance_get_handle(SLV2Instance instance)
#endif /* SLV2_INTERNAL */
/** @} */
-/** @name Plugin UI Instance
- * @{
- */
-
-typedef struct _SLV2UIInstance* SLV2UIInstance;
-
-/** Instantiate a plugin UI.
- * The returned object represents shared library objects loaded into memory,
- * it must be cleaned up with slv2_ui_instance_free when no longer
- * needed.
- *
- * @a plugin is not modified or directly referenced by the returned object
- * (instances store only a copy of the plugin's URI).
- *
- * @a host_features NULL-terminated array of features the host supports.
- * NULL may be passed if the host supports no additional features (unlike
- * the LV2 specification - SLV2 takes care of it).
- *
- * @return NULL if instantiation failed.
- */
-SLV2_API
-SLV2UIInstance
-slv2_ui_instantiate(SLV2Plugin plugin,
- SLV2UI ui,
- LV2UI_Write_Function write_function,
- LV2UI_Controller controller,
- const LV2_Feature* const* features);
-
-/** Free a plugin UI instance.
- * @a instance is invalid after this call.
- * It is the caller's responsibility to ensure all references to the UI
- * instance (including any returned widgets) are cut before calling
- * this function.
- */
-SLV2_API
-void
-slv2_ui_instance_free(SLV2UIInstance instance);
-
-/** Get the widget for the UI instance.
- */
-SLV2_API
-LV2UI_Widget
-slv2_ui_instance_get_widget(SLV2UIInstance instance);
-
-/** Get the LV2UI_Descriptor of the plugin UI instance.
- * Normally hosts should not need to access the LV2UI_Descriptor directly,
- * use the slv2_ui_instance_* functions.
- *
- * The returned descriptor is shared and must not be deleted.
- */
-SLV2_API
-const LV2UI_Descriptor*
-slv2_ui_instance_get_descriptor(SLV2UIInstance instance);
-
-/** Get the LV2UI_Handle of the plugin UI instance.
- * Normally hosts should not need to access the LV2UI_Handle directly,
- * use the slv2_ui_instance_* functions.
- *
- * The returned handle is shared and must not be deleted.
- */
-SLV2_API
-LV2UI_Handle
-slv2_ui_instance_get_handle(SLV2UIInstance instance);
-
-/** @} */
/** @} */
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* SLV2_H__ */
+#endif /* SLV2_SLV2_H__ */
diff --git a/slv2/ui.h b/slv2/ui.h
new file mode 100644
index 0000000..369ed5e
--- /dev/null
+++ b/slv2/ui.h
@@ -0,0 +1,167 @@
+/* SLV2
+ * Copyright (C) 2007-2011 David 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_SLV2_UI_H__
+#define SLV2_SLV2_UI_H__
+
+#include "slv2/slv2.h"
+#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
+
+/** @addtogroup slv2
+ * @{
+ */
+
+typedef struct _SLV2UI* SLV2UI; /**< Plugin UI. */
+typedef void* SLV2UIs; /**< set<UI>. */
+
+SLV2_COLLECTION(SLV2UIs, SLV2UI, slv2_uis)
+
+/** Get a UI from @a uis by URI.
+ * Return value is shared (stored in @a uis) and must not be freed or
+ * modified by the caller in any way.
+ * @return NULL if no UI with @a uri is found in @a list.
+ */
+SLV2_API
+SLV2UI
+slv2_uis_get_by_uri(SLV2UIs uis,
+ SLV2Value uri);
+
+/** Get a list of all UIs available for this plugin.
+ * Note this returns the URI of the UI, and not the path/URI to its shared
+ * library, use slv2_ui_get_library_uri with the values returned
+ * here for that.
+ *
+ * Returned value must be freed by caller using slv2_uis_free.
+ */
+SLV2_API
+SLV2UIs
+slv2_plugin_get_uis(SLV2Plugin plugin);
+
+/** @name Plugin UI
+ * @{
+ */
+
+/** Get the URI of a Plugin UI.
+ * @param ui The Plugin UI
+ * @return a shared value which must not be modified or freed.
+ */
+SLV2_API
+SLV2Value
+slv2_ui_get_uri(SLV2UI ui);
+
+/** Get the types (URIs of RDF classes) of a Plugin UI.
+ * @param ui The Plugin UI
+ * @return a shared value which must not be modified or freed.
+ */
+SLV2_API
+SLV2Values
+slv2_ui_get_classes(SLV2UI ui);
+
+/** Check whether a plugin UI is a given type.
+ * @param ui The Plugin UI
+ * @param class_uri The URI of the LV2 UI type to check this UI against
+ */
+SLV2_API
+bool
+slv2_ui_is_a(SLV2UI ui, SLV2Value class_uri);
+
+/** Get the URI for a Plugin UI's bundle.
+ * @param ui The Plugin UI
+ * @return a shared value which must not be modified or freed.
+ */
+SLV2_API
+SLV2Value
+slv2_ui_get_bundle_uri(SLV2UI ui);
+
+/** Get the URI for a Plugin UI's shared library.
+ * @param ui The Plugin UI
+ * @return a shared value which must not be modified or freed.
+ */
+SLV2_API
+SLV2Value
+slv2_ui_get_binary_uri(SLV2UI ui);
+
+/** @} */
+/** @name Plugin UI Instance
+ * @{
+ */
+
+typedef struct _SLV2UIInstance* SLV2UIInstance;
+
+/** Instantiate a plugin UI.
+ * The returned object represents shared library objects loaded into memory,
+ * it must be cleaned up with slv2_ui_instance_free when no longer
+ * needed.
+ *
+ * @a plugin is not modified or directly referenced by the returned object
+ * (instances store only a copy of the plugin's URI).
+ *
+ * @a host_features NULL-terminated array of features the host supports.
+ * NULL may be passed if the host supports no additional features (unlike
+ * the LV2 specification - SLV2 takes care of it).
+ *
+ * @return NULL if instantiation failed.
+ */
+SLV2_API
+SLV2UIInstance
+slv2_ui_instantiate(SLV2Plugin plugin,
+ SLV2UI ui,
+ LV2UI_Write_Function write_function,
+ LV2UI_Controller controller,
+ const LV2_Feature* const* features);
+
+/** Free a plugin UI instance.
+ * @a instance is invalid after this call.
+ * It is the caller's responsibility to ensure all references to the UI
+ * instance (including any returned widgets) are cut before calling
+ * this function.
+ */
+SLV2_API
+void
+slv2_ui_instance_free(SLV2UIInstance instance);
+
+/** Get the widget for the UI instance.
+ */
+SLV2_API
+LV2UI_Widget
+slv2_ui_instance_get_widget(SLV2UIInstance instance);
+
+/** Get the LV2UI_Descriptor of the plugin UI instance.
+ * Normally hosts should not need to access the LV2UI_Descriptor directly,
+ * use the slv2_ui_instance_* functions.
+ *
+ * The returned descriptor is shared and must not be deleted.
+ */
+SLV2_API
+const LV2UI_Descriptor*
+slv2_ui_instance_get_descriptor(SLV2UIInstance instance);
+
+/** Get the LV2UI_Handle of the plugin UI instance.
+ * Normally hosts should not need to access the LV2UI_Handle directly,
+ * use the slv2_ui_instance_* functions.
+ *
+ * The returned handle is shared and must not be deleted.
+ */
+SLV2_API
+LV2UI_Handle
+slv2_ui_instance_get_handle(SLV2UIInstance instance);
+
+/** @} */
+/** @} */
+
+#endif /* SLV2_SLV2_UI_H__ */
diff --git a/src/collections.c b/src/collections.c
index 862a401..6ec004e 100644
--- a/src/collections.c
+++ b/src/collections.c
@@ -106,9 +106,12 @@ prefix ## _get_by_uri(CollType coll, SLV2Value uri) \
}
SLV2_SEQUENCE_IMPL(SLV2PluginClasses, SLV2PluginClass,
- slv2_plugin_classes, &slv2_plugin_class_free)
+ slv2_plugin_classes, &slv2_plugin_class_free)
+
+#ifdef SLV2_WITH_UI
SLV2_SEQUENCE_IMPL(SLV2UIs, SLV2UI,
- slv2_uis, &slv2_ui_free)
+ slv2_uis, &slv2_ui_free)
+#endif
/* VALUES */
diff --git a/src/plugin.c b/src/plugin.c
index 78c8b73..7e639d9 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -761,6 +761,7 @@ slv2_plugin_get_author_homepage(SLV2Plugin plugin)
return NULL;
}
+#ifdef SLV2_WITH_UI
SLV2_API
SLV2UIs
slv2_plugin_get_uis(SLV2Plugin p)
@@ -814,4 +815,4 @@ slv2_plugin_get_uis(SLV2Plugin p)
return NULL;
}
}
-
+#endif /* SLV2_WITH_UI */
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 8f69544..60ed023 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -42,6 +42,9 @@ extern "C" {
#endif
#include "slv2/slv2.h"
+#ifdef SLV2_WITH_UI
+#include "slv2/ui.h"
+#endif
#define SLV2_NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
#define SLV2_NS_RDFS (const uint8_t*)"http://www.w3.org/2000/01/rdf-schema#"
@@ -150,13 +153,14 @@ struct _SLV2InstanceImpl {
/* ********* UI Instance ********* */
+#ifdef SLV2_WITH_UI
struct _SLV2UIInstance {
void* lib_handle;
const LV2UI_Descriptor* lv2ui_descriptor;
LV2UI_Handle lv2ui_handle;
LV2UI_Widget widget;
};
-
+#endif
/* ********* Plugin Class ********* */
@@ -230,6 +234,8 @@ slv2_world_load_file(SLV2World world, const char* file_uri);
/* ********* Plugin UI ********* */
+#ifdef SLV2_WITH_UI
+
struct _SLV2UI {
struct _SLV2World* world;
SLV2Value uri;
@@ -247,6 +253,7 @@ slv2_ui_new(SLV2World world,
void slv2_ui_free(SLV2UI ui);
+#endif /* SLV2_WITH_UI */
/* ********* Value ********* */
diff --git a/test/slv2_test.c b/test/slv2_test.c
index 8c1f790..e1d61b7 100644
--- a/test/slv2_test.c
+++ b/test/slv2_test.c
@@ -28,7 +28,11 @@
#include <limits.h>
#include <float.h>
#include <math.h>
+
#include "slv2/slv2.h"
+#ifdef SLV2_WITH_UI
+#include "slv2/ui.h"
+#endif
#define TEST_PATH_MAX 1024
@@ -706,10 +710,12 @@ test_plugin()
TEST_ASSERT(slv2_value_is_string(thing_name));
TEST_ASSERT(!strcmp(slv2_value_as_string(thing_name), "Something else"));
+ #ifdef SLV2_WITH_UI
SLV2UIs uis = slv2_plugin_get_uis(plug);
TEST_ASSERT(slv2_uis_size(uis) == 0);
-
slv2_uis_free(uis);
+ #endif
+
slv2_values_free(thing_names);
slv2_value_free(thing_uri);
slv2_value_free(name_p);
@@ -914,6 +920,7 @@ test_port()
/*****************************************************************************/
+#ifdef SLV2_WITH_UI
int
test_ui()
{
@@ -1014,6 +1021,7 @@ test_ui()
cleanup_uris();
return 1;
}
+#endif /* SLV2_WITH_UI */
/*****************************************************************************/
@@ -1029,7 +1037,9 @@ static struct TestCase tests[] = {
TEST_CASE(plugin),
TEST_CASE(port),
TEST_CASE(plugin),
+#ifdef SLV2_WITH_UI
TEST_CASE(ui),
+#endif
{ NULL, NULL }
};
diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c
index b8a5c57..a63b5d0 100644
--- a/utils/lv2_inspect.c
+++ b/utils/lv2_inspect.c
@@ -22,7 +22,11 @@
#include <string.h>
#include <math.h>
#include <locale.h>
+
#include "slv2/slv2.h"
+#ifdef SLV2_WITH_UI
+#include "slv2/ui.h"
+#endif
SLV2Value event_class = NULL;
SLV2Value control_class = NULL;
@@ -169,6 +173,7 @@ print_plugin(SLV2Plugin p)
printf("\tBundle: %s\n", slv2_value_as_uri(slv2_plugin_get_bundle_uri(p)));
printf("\tBinary: %s\n", slv2_value_as_uri(slv2_plugin_get_library_uri(p)));
+#ifdef SLV2_WITH_UI
SLV2UIs uis = slv2_plugin_get_uis(p);
if (slv2_values_size(uis) > 0) {
printf("\tGUI: ");
@@ -192,6 +197,7 @@ print_plugin(SLV2Plugin p)
}
}
slv2_uis_free(uis);
+#endif
printf("\tData URIs: ");
SLV2Values data_uris = slv2_plugin_get_data_uris(p);
diff --git a/wscript b/wscript
index d1f579c..810da3c 100644
--- a/wscript
+++ b/wscript
@@ -72,6 +72,9 @@ def configure(conf):
autowaf.check_header(conf, 'lv2/lv2plug.in/ns/lv2core/lv2.h')
autowaf.check_header(conf, 'lv2/lv2plug.in/ns/extensions/ui/ui.h')
+ if conf.env['HAVE_LV2_LV2PLUG_IN_NS_EXTENSIONS_UI_UI_H']:
+ autowaf.define(conf, 'SLV2_WITH_UI', 1)
+
conf.env.append_value('CFLAGS', '-std=c99')
autowaf.define(conf, 'SLV2_VERSION', SLV2_VERSION)
if Options.options.dyn_manifest:
@@ -124,6 +127,8 @@ def configure(conf):
autowaf.display_msg(conf, "Unit tests", str(conf.env['BUILD_TESTS']))
autowaf.display_msg(conf, "Dynamic Manifest Support", str(conf.env['SLV2_DYN_MANIFEST'] == 1))
autowaf.display_msg(conf, "Default LV2_PATH", str(conf.env['SLV2_DEFAULT_LV2_PATH']))
+ autowaf.display_msg(conf, "UI support", str(conf.env['SLV2_WITH_UI'] == 1))
+
print
tests = '''
@@ -143,8 +148,6 @@ def build(bld):
src/pluginclass.c
src/plugininstance.c
src/plugins.c
- src/pluginui.c
- src/pluginuiinstance.c
src/port.c
src/query.c
src/scalepoint.c
@@ -153,6 +156,9 @@ def build(bld):
src/world.c
'''
+ if bld.env['SLV2_WITH_UI']:
+ lib_source += ' src/pluginui.c src/pluginuiinstance.c '
+
# Library
obj = bld(features = 'c cshlib')
obj.export_includes = ['.']