diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 16 | ||||
-rw-r--r-- | src/pluginguiinstance.c | 2 | ||||
-rw-r--r-- | src/slv2_internal.h | 17 | ||||
-rw-r--r-- | src/value.c | 30 |
4 files changed, 53 insertions, 12 deletions
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; +} + |