summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--slv2/Makefile.am1
-rw-r--r--slv2/plugin.h4
-rw-r--r--slv2/slv2.h1
-rw-r--r--slv2/types.h11
-rw-r--r--slv2/value.h25
-rw-r--r--src/plugin.c16
-rw-r--r--src/pluginguiinstance.c2
-rw-r--r--src/slv2_internal.h17
-rw-r--r--src/value.c30
-rw-r--r--utils/lv2_inspect.c9
11 files changed, 101 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index b5b90aa..6b96dea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,9 +8,9 @@ AC_PREREQ(2.59)
# interfaces current,current-1,...,current-age
#
# See libtool documentation for detailed documentation
-SLV2_API_CURRENT=0
-SLV2_API_REVISION=1
-SLV2_API_AGE=0
+SLV2_API_CURRENT=1
+SLV2_API_REVISION=0
+SLV2_API_AGE=1
AC_INIT([slv2],[0.0.2pre],[dave@drobilla.net])
AC_CONFIG_SRCDIR([src/plugin.c])
diff --git a/slv2/Makefile.am b/slv2/Makefile.am
index e0a9c0e..f090e22 100644
--- a/slv2/Makefile.am
+++ b/slv2/Makefile.am
@@ -1,6 +1,7 @@
slv2includedir = $(includedir)/slv2
slv2include_HEADERS = \
+ gui.h \
lv2.h \
lv2-gtk2gui.h \
plugin.h \
diff --git a/slv2/plugin.h b/slv2/plugin.h
index 9dc53e7..36add35 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -338,12 +338,12 @@ slv2_plugin_get_guis(SLV2Plugin plugin);
/** Get the URI for a GUI library.
*
* \param plugin The plugin that the GUI is for.
- * \param gui A GUI identifier as returned by slv2_plugin_get_guis().
+ * \param gui A GUI identifier as returned by slv2_plugin_get_guis() (with type SLV2_VALUE_GUI).
*
* Time = Query
*/
SLV2Value
-slv2_plugin_gui_get_library_uri(SLV2Plugin plugin,
+slv2_plugin_get_gui_library_uri(SLV2Plugin plugin,
SLV2Value gui);
diff --git a/slv2/slv2.h b/slv2/slv2.h
index e5c2b07..e575229 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -24,6 +24,7 @@ extern "C" {
#endif
#include <slv2/types.h>
+#include <slv2/gui.h>
#include <slv2/world.h>
#include <slv2/pluginclass.h>
#include <slv2/plugin.h>
diff --git a/slv2/types.h b/slv2/types.h
index e5c10e2..0eba199 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -55,6 +55,13 @@ typedef enum _SLV2URIType {
} SLV2URIType;
+/** A type of plugin GUI (corresponding to some LV2 GUI extension).
+ */
+typedef enum _SLV2GUIType {
+ SLV2_GTK2_GUI ///< http://ll-plugins.nongnu.org/lv2/ext/gtk2gui
+} SLV2GUIType;
+
+
/** A port on a plugin. Opaque, but valid to compare to NULL. */
typedef struct _SLV2Port* SLV2Port;
@@ -87,6 +94,10 @@ typedef struct _SLV2Value* SLV2Value;
typedef void* SLV2Values;
+/** A plugin GUI */
+typedef void* SLV2GUI;
+
+
#ifdef __cplusplus
}
#endif
diff --git a/slv2/value.h b/slv2/value.h
index 1470d36..4fd0cf4 100644
--- a/slv2/value.h
+++ b/slv2/value.h
@@ -74,7 +74,7 @@ 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.
+ * slv2_value_is_gui(\a value) returns true.
* Returned value is owned by \a value and must not be freed by caller.
*
* Time = O(1)
@@ -172,6 +172,29 @@ int
slv2_value_as_int(SLV2Value value);
+/** Return whether this value is a GUI (URI and type).
+ *
+ * If this returns true, slv2_value_as_uri will return the URI of the GUI,
+ * and slv2_value_as_gui_type will return the SLV2GUIType (which can be
+ * used to find the URI of the corresponding GUI spec itself, with
+ * slv2_gui_type_get_uri).
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_gui(SLV2Value value);
+
+
+/** Return \a value as an SLV2GUIType.
+ *
+ * Valid to call only if slv2_value_is_gui(\a value) returns true.
+ *
+ * Time = O(1)
+ */
+SLV2GUIType
+slv2_value_as_gui_type(SLV2Value value);
+
+
/** @} */
#ifdef __cplusplus
diff --git a/src/plugin.c b/src/plugin.c
index 1d63978..783ba23 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -377,7 +377,7 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p,
SLV2URIType predicate_type,
const char* predicate)
{
- if (subject->type != SLV2_VALUE_URI) {
+ if ( ! slv2_value_is_uri(subject)) {
fprintf(stderr, "slv2_plugin_get_value_for_subject error: "
"passed non-URI subject\n");
return NULL;
@@ -548,15 +548,25 @@ slv2_plugin_get_guis(SLV2Plugin plugin)
if (!plugin->rdf)
slv2_plugin_load(plugin);
- return slv2_plugin_get_value(plugin, SLV2_URI,
+ SLV2Values result = slv2_plugin_get_value(plugin, SLV2_URI,
"http://ll-plugins.nongnu.org/lv2/ext/gtk2gui#gui");
+
+ for (int i=0; i < raptor_sequence_size(result); ++i) {
+ SLV2Value val = (SLV2Value)raptor_sequence_get_at(result, i);
+ val->type = SLV2_VALUE_GUI;
+ val->val.gui_type_val = SLV2_GTK2_GUI;
+ }
+
+ return result;
}
SLV2Value
-slv2_plugin_gui_get_library_uri(SLV2Plugin plugin,
+slv2_plugin_get_gui_library_uri(SLV2Plugin plugin,
SLV2Value gui)
{
+ assert(gui->type == SLV2_VALUE_GUI);
+
if (!plugin->rdf)
slv2_plugin_load(plugin);
diff --git a/src/pluginguiinstance.c b/src/pluginguiinstance.c
index 985f253..ea4f9a7 100644
--- a/src/pluginguiinstance.c
+++ b/src/pluginguiinstance.c
@@ -45,7 +45,7 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
host_features[0] = NULL;
}
- const char* const lib_uri = slv2_value_as_uri(slv2_plugin_gui_get_library_uri(plugin, gui));
+ const char* const lib_uri = slv2_value_as_uri(slv2_plugin_get_gui_library_uri(plugin, gui));
const char* const lib_path = slv2_uri_to_path(lib_uri);
if (!lib_path)
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 4d20e4f..89325ca 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -161,6 +161,14 @@ slv2_world_load_path(SLV2World world,
const char* search_path);
+/* ********* GUI ********* */
+
+struct _SLV2GUI {
+ SLV2GUIType type;
+ char* uri;
+};
+
+
/* ********* Value ********* */
@@ -169,21 +177,24 @@ typedef enum _SLV2ValueType {
SLV2_VALUE_URI,
SLV2_VALUE_STRING,
SLV2_VALUE_INT,
- SLV2_VALUE_FLOAT
+ SLV2_VALUE_FLOAT,
+ SLV2_VALUE_GUI
} SLV2ValueType;
struct _SLV2Value {
SLV2ValueType type;
char* str_val; ///< always present
union {
- int int_val;
- float float_val;
+ int int_val;
+ float float_val;
+ SLV2GUIType gui_type_val;
} val;
};
SLV2Value slv2_value_new(SLV2ValueType type, const char* val);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/value.c b/src/value.c
index f4dc673..9a3254d 100644
--- a/src/value.c
+++ b/src/value.c
@@ -64,8 +64,10 @@ slv2_value_duplicate(SLV2Value val)
void
slv2_value_free(SLV2Value val)
{
- free(val->str_val);
- free(val);
+ if (val) {
+ free(val->str_val);
+ free(val);
+ }
}
@@ -74,8 +76,10 @@ slv2_value_equals(SLV2Value value, SLV2Value other)
{
if (value->type != other->type)
return false;
- else
+ else if (value && other)
return ! strcmp(value->str_val, other->str_val);
+ else
+ return true;
}
@@ -86,6 +90,7 @@ slv2_value_get_turtle_token(SLV2Value value)
char* result = NULL;
switch (value->type) {
+ case SLV2_VALUE_GUI:
case SLV2_VALUE_URI:
len = strlen(value->str_val) + 3;
result = calloc(len, sizeof(char));
@@ -114,14 +119,14 @@ slv2_value_get_turtle_token(SLV2Value value)
bool
slv2_value_is_uri(SLV2Value value)
{
- return (value->type == SLV2_VALUE_URI);
+ return (value->type == SLV2_VALUE_URI || value->type == SLV2_VALUE_GUI);
}
const char*
slv2_value_as_uri(SLV2Value value)
{
- assert(slv2_value_is_uri(value));
+ assert(slv2_value_is_uri(value) || slv2_value_is_gui(value));
return value->str_val;
}
@@ -180,3 +185,18 @@ slv2_value_as_float(SLV2Value value)
return (float)value->val.int_val;
}
+
+bool
+slv2_value_is_gui(SLV2Value value)
+{
+ return (value->type == SLV2_VALUE_GUI);
+}
+
+
+SLV2GUIType
+slv2_value_as_gui_type(SLV2Value value)
+{
+ assert(slv2_value_is_gui(value));
+ return value->val.gui_type_val;
+}
+
diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c
index a7a5bf0..a4ae66b 100644
--- a/utils/lv2_inspect.c
+++ b/utils/lv2_inspect.c
@@ -113,9 +113,12 @@ print_plugin(SLV2Plugin p)
if (slv2_values_size(gui) > 0) {
printf("\tGUI:\n");
for (unsigned i=0; i < slv2_values_size(gui); ++i) {
- printf("\t\t%s\n", slv2_value_as_string(slv2_values_get_at(gui, i)));
- SLV2Value binary = slv2_plugin_gui_get_library_uri(p,
- slv2_values_get_at(gui, i));
+ printf("\t\t%s\n", slv2_value_as_uri(slv2_values_get_at(gui, i)));
+
+ SLV2Value binary = slv2_plugin_get_gui_library_uri(p, slv2_values_get_at(gui, i));
+
+ printf("\t\t\tType: %s\n", slv2_gui_type_get_uri(slv2_value_as_gui_type(
+ slv2_values_get_at(gui, i))));
if (binary)
printf("\t\t\tBinary: %s\n", slv2_value_as_uri(binary));