diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/collections.c | 16 | ||||
-rw-r--r-- | src/plugin.c | 145 | ||||
-rw-r--r-- | src/pluginclass.c | 5 | ||||
-rw-r--r-- | src/plugininstance.c | 3 | ||||
-rw-r--r-- | src/plugins.c | 4 | ||||
-rw-r--r-- | src/pluginui.c | 7 | ||||
-rw-r--r-- | src/pluginuiinstance.c | 15 | ||||
-rw-r--r-- | src/port.c | 14 | ||||
-rw-r--r-- | src/scalepoint.c | 5 | ||||
-rw-r--r-- | src/slv2_internal.h | 23 | ||||
-rw-r--r-- | src/value.c | 37 | ||||
-rw-r--r-- | src/world.c | 33 |
12 files changed, 177 insertions, 130 deletions
diff --git a/src/collections.c b/src/collections.c index 4ea14fd..7e778a6 100644 --- a/src/collections.c +++ b/src/collections.c @@ -33,7 +33,7 @@ prefix ## _new() \ return g_ptr_array_new_with_free_func((GDestroyNotify)free_func); \ } \ \ -\ +SLV2_API \ void \ prefix ## _free(CollType coll) \ { \ @@ -41,14 +41,14 @@ prefix ## _free(CollType coll) \ g_ptr_array_unref((GPtrArray*)coll); \ } \ \ -\ +SLV2_API \ unsigned \ prefix ## _size(CollType coll) \ { \ return (coll ? ((GPtrArray*)coll)->len : 0); \ } \ \ -\ +SLV2_API \ ElemType \ prefix ## _get_at(CollType coll, unsigned index) \ { \ @@ -69,6 +69,7 @@ SLV2_COLLECTION_IMPL(SLV2UIs, SLV2UI, /* **** PLUGIN CLASSES **** */ +SLV2_API SLV2PluginClass slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, SLV2Value uri) { @@ -99,6 +100,7 @@ slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, SLV2Value uri) /* **** VALUES **** */ +SLV2_API bool slv2_values_contains(SLV2Values list, SLV2Value value) { @@ -109,15 +111,9 @@ slv2_values_contains(SLV2Values list, SLV2Value value) return false; } -void -slv2_values_set_at(SLV2Values list, unsigned index, void* value) -{ - if (index <= INT_MAX) - ((GPtrArray*)list)->pdata[index] = value; -} - /* **** PLUGIN UIS **** */ +SLV2_API SLV2UI slv2_uis_get_by_uri(SLV2UIs list, SLV2Value uri) { diff --git a/src/plugin.c b/src/plugin.c index cf4c2cf..cb3d630 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,8 +32,7 @@ #include "slv2/util.h" #include "slv2_internal.h" -/* private - * ownership of uri is taken */ +/** Ownership of @a uri is taken */ SLV2Plugin slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri) { @@ -55,7 +54,6 @@ slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri) return plugin; } -/* private */ void slv2_plugin_free(SLV2Plugin p) { @@ -86,14 +84,6 @@ slv2_plugin_free(SLV2Plugin p) free(p); } -/* private */ -void -slv2_plugin_load_if_necessary(SLV2Plugin p) -{ - if (!p->loaded) - slv2_plugin_load(p); -} - static SLV2Values slv2_plugin_query_node(SLV2Plugin p, SLV2Node subject, SLV2Node predicate) { @@ -144,10 +134,59 @@ slv2_plugin_get_one(SLV2Plugin p, SLV2Node subject, SLV2Node predicate) slv2_values_free(values); return ret; } - - -/* private */ -void + +static void +slv2_plugin_load(SLV2Plugin p) +{ + // Parse all the plugin's data files into RDF model + for (unsigned i = 0; i < slv2_values_size(p->data_uris); ++i) { + SLV2Value data_uri_val = slv2_values_get_at(p->data_uris, i); + sord_read_file(p->world->model, + sord_node_get_string(data_uri_val->val.uri_val), + p->bundle_uri->val.uri_val, + slv2_world_blank_node_prefix(p->world)); + } + +#ifdef SLV2_DYN_MANIFEST + typedef void* LV2_Dyn_Manifest_Handle; + // Load and parse dynamic manifest data, if this is a library + if (p->dynman_uri) { + const char* lib_path = slv2_uri_to_path(slv2_value_as_string(p->dynman_uri)); + void* lib = dlopen(lib_path, RTLD_LAZY); + if (!lib) { + SLV2_WARNF("Unable to open dynamic manifest %s\n", + slv2_value_as_string(p->dynman_uri)); + return; + } + + typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature *const *); + OpenFunc open_func = (OpenFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_open"); + LV2_Dyn_Manifest_Handle handle = NULL; + if (open_func) + open_func(&handle, &dman_features); + + typedef int (*GetDataFunc)(LV2_Dyn_Manifest_Handle handle, + FILE* fp, + const char* uri); + GetDataFunc get_data_func = (GetDataFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_get_data"); + if (get_data_func) { + FILE* fd = tmpfile(); + get_data_func(handle, fd, slv2_value_as_string(p->plugin_uri)); + rewind(fd); + sord_read_file_handle(p->world->model, fd, p->bundle_uri); + fclose(fd); + } + + typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle); + CloseFunc close_func = (CloseFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_close"); + if (close_func) + close_func(handle); + } +#endif + p->loaded = true; +} + +static void slv2_plugin_load_ports_if_necessary(SLV2Plugin p) { if (!p->loaded) @@ -234,56 +273,13 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p) } void -slv2_plugin_load(SLV2Plugin p) +slv2_plugin_load_if_necessary(SLV2Plugin p) { - // Parse all the plugin's data files into RDF model - for (unsigned i = 0; i < slv2_values_size(p->data_uris); ++i) { - SLV2Value data_uri_val = slv2_values_get_at(p->data_uris, i); - sord_read_file(p->world->model, - sord_node_get_string(data_uri_val->val.uri_val), - p->bundle_uri->val.uri_val, - slv2_world_blank_node_prefix(p->world)); - } - -#ifdef SLV2_DYN_MANIFEST - typedef void* LV2_Dyn_Manifest_Handle; - // Load and parse dynamic manifest data, if this is a library - if (p->dynman_uri) { - const char* lib_path = slv2_uri_to_path(slv2_value_as_string(p->dynman_uri)); - void* lib = dlopen(lib_path, RTLD_LAZY); - if (!lib) { - SLV2_WARNF("Unable to open dynamic manifest %s\n", - slv2_value_as_string(p->dynman_uri)); - return; - } - - typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature *const *); - OpenFunc open_func = (OpenFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_open"); - LV2_Dyn_Manifest_Handle handle = NULL; - if (open_func) - open_func(&handle, &dman_features); - - typedef int (*GetDataFunc)(LV2_Dyn_Manifest_Handle handle, - FILE* fp, - const char* uri); - GetDataFunc get_data_func = (GetDataFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_get_data"); - if (get_data_func) { - FILE* fd = tmpfile(); - get_data_func(handle, fd, slv2_value_as_string(p->plugin_uri)); - rewind(fd); - sord_read_file_handle(p->world->model, fd, p->bundle_uri); - fclose(fd); - } - - typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle); - CloseFunc close_func = (CloseFunc)slv2_dlfunc(lib, "lv2_dyn_manifest_close"); - if (close_func) - close_func(handle); - } -#endif - p->loaded = true; + if (!p->loaded) + slv2_plugin_load(p); } +SLV2_API SLV2Value slv2_plugin_get_uri(SLV2Plugin p) { @@ -292,6 +288,7 @@ slv2_plugin_get_uri(SLV2Plugin p) return p->plugin_uri; } +SLV2_API SLV2Value slv2_plugin_get_bundle_uri(SLV2Plugin p) { @@ -300,6 +297,7 @@ slv2_plugin_get_bundle_uri(SLV2Plugin p) return p->bundle_uri; } +SLV2_API SLV2Value slv2_plugin_get_library_uri(SLV2Plugin p) { @@ -323,12 +321,14 @@ slv2_plugin_get_library_uri(SLV2Plugin p) return p->binary_uri; } +SLV2_API SLV2Values slv2_plugin_get_data_uris(SLV2Plugin p) { return p->data_uris; } +SLV2_API SLV2PluginClass slv2_plugin_get_class(SLV2Plugin p) { @@ -371,6 +371,7 @@ slv2_plugin_get_class(SLV2Plugin p) return p->plugin_class; } +SLV2_API bool slv2_plugin_verify(SLV2Plugin plugin) { @@ -401,6 +402,7 @@ slv2_plugin_verify(SLV2Plugin plugin) return true; } +SLV2_API SLV2Value slv2_plugin_get_name(SLV2Plugin plugin) { @@ -427,6 +429,7 @@ slv2_plugin_get_name(SLV2Plugin plugin) return ret; } +SLV2_API SLV2Values slv2_plugin_get_value(SLV2Plugin p, SLV2Value predicate) @@ -434,6 +437,7 @@ slv2_plugin_get_value(SLV2Plugin p, return slv2_plugin_get_value_for_subject(p, p->plugin_uri, predicate); } +SLV2_API SLV2Values slv2_plugin_get_value_by_qname(SLV2Plugin p, const char* predicate) @@ -450,6 +454,7 @@ slv2_plugin_get_value_by_qname(SLV2Plugin p, return ret; } +SLV2_API SLV2Values slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p, const char* predicate) @@ -473,6 +478,7 @@ slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p, return slv2_values_from_stream_i18n(p, results); } +SLV2_API SLV2Values slv2_plugin_get_value_for_subject(SLV2Plugin p, SLV2Value subject, @@ -502,6 +508,7 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p, predicate->val.uri_val); } +SLV2_API uint32_t slv2_plugin_get_num_ports(SLV2Plugin p) { @@ -509,6 +516,7 @@ slv2_plugin_get_num_ports(SLV2Plugin p) return p->num_ports; } +SLV2_API void slv2_plugin_get_port_ranges_float(SLV2Plugin p, float* min_values, @@ -536,6 +544,7 @@ slv2_plugin_get_port_ranges_float(SLV2Plugin p, } } +SLV2_API uint32_t slv2_plugin_get_num_ports_of_class(SLV2Plugin p, SLV2Value class_1, ...) @@ -570,6 +579,7 @@ slv2_plugin_get_num_ports_of_class(SLV2Plugin p, return ret; } +SLV2_API bool slv2_plugin_has_latency(SLV2Plugin p) { @@ -599,6 +609,7 @@ slv2_plugin_has_latency(SLV2Plugin p) return ret; } +SLV2_API uint32_t slv2_plugin_get_latency_port_index(SLV2Plugin p) { @@ -632,6 +643,7 @@ slv2_plugin_get_latency_port_index(SLV2Plugin p) return ret; // FIXME: error handling } +SLV2_API bool slv2_plugin_has_feature(SLV2Plugin p, SLV2Value feature) @@ -644,6 +656,7 @@ slv2_plugin_has_feature(SLV2Plugin p, return ret; } +SLV2_API SLV2Values slv2_plugin_get_supported_features(SLV2Plugin p) { @@ -667,18 +680,21 @@ slv2_plugin_get_supported_features(SLV2Plugin p) return result; } +SLV2_API SLV2Values slv2_plugin_get_optional_features(SLV2Plugin p) { return slv2_plugin_get_value_by_qname(p, "lv2:optionalFeature"); } +SLV2_API SLV2Values slv2_plugin_get_required_features(SLV2Plugin p) { return slv2_plugin_get_value_by_qname(p, "lv2:requiredFeature"); } +SLV2_API SLV2Port slv2_plugin_get_port_by_index(SLV2Plugin p, uint32_t index) @@ -690,6 +706,7 @@ slv2_plugin_get_port_by_index(SLV2Plugin p, return NULL; } +SLV2_API SLV2Port slv2_plugin_get_port_by_symbol(SLV2Plugin p, SLV2Value symbol) @@ -731,6 +748,7 @@ slv2_plugin_get_author(SLV2Plugin p) return author; } +SLV2_API SLV2Value slv2_plugin_get_author_name(SLV2Plugin plugin) { @@ -743,6 +761,7 @@ slv2_plugin_get_author_name(SLV2Plugin plugin) return NULL; } +SLV2_API SLV2Value slv2_plugin_get_author_email(SLV2Plugin plugin) { @@ -755,6 +774,7 @@ slv2_plugin_get_author_email(SLV2Plugin plugin) return NULL; } +SLV2_API SLV2Value slv2_plugin_get_author_homepage(SLV2Plugin plugin) { @@ -767,6 +787,7 @@ slv2_plugin_get_author_homepage(SLV2Plugin plugin) return NULL; } +SLV2_API SLV2UIs slv2_plugin_get_uis(SLV2Plugin p) { diff --git a/src/pluginclass.c b/src/pluginclass.c index e588595..27486ea 100644 --- a/src/pluginclass.c +++ b/src/pluginclass.c @@ -26,7 +26,6 @@ #include "slv2/value.h" #include "slv2_internal.h" -/* private */ SLV2PluginClass slv2_plugin_class_new(SLV2World world, SLV2Node parent_node, @@ -56,6 +55,7 @@ slv2_plugin_class_free(SLV2PluginClass plugin_class) free(plugin_class); } +SLV2_API SLV2Value slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class) { @@ -65,6 +65,7 @@ slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class) return NULL; } +SLV2_API SLV2Value slv2_plugin_class_get_uri(SLV2PluginClass plugin_class) { @@ -72,12 +73,14 @@ slv2_plugin_class_get_uri(SLV2PluginClass plugin_class) return plugin_class->uri; } +SLV2_API SLV2Value slv2_plugin_class_get_label(SLV2PluginClass plugin_class) { return plugin_class->label; } +SLV2_API SLV2PluginClasses slv2_plugin_class_get_children(SLV2PluginClass plugin_class) { diff --git a/src/plugininstance.c b/src/plugininstance.c index 209b98c..7416dc3 100644 --- a/src/plugininstance.c +++ b/src/plugininstance.c @@ -29,7 +29,7 @@ #include "slv2/value.h" #include "slv2_internal.h" - +SLV2_API SLV2Instance slv2_plugin_instantiate(SLV2Plugin plugin, double sample_rate, @@ -135,6 +135,7 @@ slv2_plugin_instantiate(SLV2Plugin plugin, return result; } +SLV2_API void slv2_instance_free(SLV2Instance instance) { diff --git a/src/plugins.c b/src/plugins.c index a8c7e81..0f9587f 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -34,6 +34,7 @@ slv2_plugins_new() return g_ptr_array_new(); } +SLV2_API void slv2_plugins_free(SLV2World world, SLV2Plugins list) { @@ -41,12 +42,14 @@ slv2_plugins_free(SLV2World world, SLV2Plugins list) g_ptr_array_unref(list); } +SLV2_API unsigned slv2_plugins_size(SLV2Plugins list) { return (list ? ((GPtrArray*)list)->len : 0); } +SLV2_API SLV2Plugin slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri) { @@ -75,6 +78,7 @@ slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri) return NULL; } +SLV2_API SLV2Plugin slv2_plugins_get_at(SLV2Plugins list, unsigned index) { diff --git a/src/pluginui.c b/src/pluginui.c index 08490b7..f4c2980 100644 --- a/src/pluginui.c +++ b/src/pluginui.c @@ -26,7 +26,6 @@ #include "slv2/pluginui.h" #include "slv2_internal.h" -/* private */ SLV2UI slv2_ui_new(SLV2World world, SLV2Value uri, @@ -55,7 +54,6 @@ slv2_ui_new(SLV2World world, return ui; } -/* private */ void slv2_ui_free(SLV2UI ui) { @@ -73,6 +71,7 @@ slv2_ui_free(SLV2UI ui) free(ui); } +SLV2_API SLV2Value slv2_ui_get_uri(SLV2UI ui) { @@ -81,18 +80,21 @@ slv2_ui_get_uri(SLV2UI ui) return ui->uri; } +SLV2_API SLV2Values slv2_ui_get_classes(SLV2UI ui) { return ui->classes; } +SLV2_API bool slv2_ui_is_a(SLV2UI ui, SLV2Value ui_class_uri) { return slv2_values_contains(ui->classes, ui_class_uri); } +SLV2_API SLV2Value slv2_ui_get_bundle_uri(SLV2UI ui) { @@ -101,6 +103,7 @@ slv2_ui_get_bundle_uri(SLV2UI ui) return ui->bundle_uri; } +SLV2_API SLV2Value slv2_ui_get_binary_uri(SLV2UI ui) { diff --git a/src/pluginuiinstance.c b/src/pluginuiinstance.c index b7357f9..3fee84b 100644 --- a/src/pluginuiinstance.c +++ b/src/pluginuiinstance.c @@ -31,12 +31,13 @@ #include "slv2/util.h" #include "slv2_internal.h" +SLV2_API SLV2UIInstance -slv2_ui_instantiate(SLV2Plugin plugin, - SLV2UI ui, - LV2UI_Write_Function write_function, - LV2UI_Controller controller, - const LV2_Feature* const* features) +slv2_ui_instantiate(SLV2Plugin plugin, + SLV2UI ui, + LV2UI_Write_Function write_function, + LV2UI_Controller controller, + const LV2_Feature* const* features) { struct _SLV2UIInstance* result = NULL; @@ -119,6 +120,7 @@ slv2_ui_instantiate(SLV2Plugin plugin, return result; } +SLV2_API void slv2_ui_instance_free(SLV2UIInstance instance) { @@ -135,16 +137,19 @@ slv2_ui_instance_free(SLV2UIInstance instance) free(i); } +SLV2_API LV2UI_Widget slv2_ui_instance_get_widget(SLV2UIInstance instance) { return instance->pimpl->widget; } +SLV2_API const LV2UI_Descriptor* slv2_ui_instance_get_descriptor(SLV2UIInstance instance) { return instance->pimpl->lv2ui_descriptor; } +SLV2_API LV2UI_Handle slv2_ui_instance_get_handle(SLV2UIInstance instance) { return instance->pimpl->lv2ui_handle; @@ -28,7 +28,6 @@ #include "slv2/util.h" #include "slv2_internal.h" -/* private */ SLV2Port slv2_port_new(SLV2World world, uint32_t index, const char* symbol) { @@ -39,7 +38,6 @@ slv2_port_new(SLV2World world, uint32_t index, const char* symbol) return port; } -/* private */ void slv2_port_free(SLV2Port port) { @@ -48,6 +46,7 @@ slv2_port_free(SLV2Port port) free(port); } +SLV2_API bool slv2_port_is_a(SLV2Plugin plugin, SLV2Port port, @@ -91,6 +90,7 @@ slv2_port_get_node(SLV2Plugin p, return ret; } +SLV2_API bool slv2_port_has_property(SLV2Plugin p, SLV2Port port, @@ -109,6 +109,7 @@ slv2_port_has_property(SLV2Plugin p, return ret; } +SLV2_API bool slv2_port_supports_event(SLV2Plugin p, SLV2Port port, @@ -149,6 +150,7 @@ slv2_values_from_stream_objects(SLV2Plugin p, SLV2Matches stream) return values; } +SLV2_API SLV2Values slv2_port_get_value_by_qname(SLV2Plugin p, SLV2Port port, @@ -188,6 +190,7 @@ slv2_port_get_value_by_node(SLV2Plugin p, return slv2_values_from_stream_objects(p, results); } +SLV2_API SLV2Values slv2_port_get_value(SLV2Plugin p, SLV2Port port, @@ -203,6 +206,7 @@ slv2_port_get_value(SLV2Plugin p, slv2_value_as_node(predicate)); } +SLV2_API SLV2Values slv2_port_get_value_by_qname_i18n(SLV2Plugin p, SLV2Port port, @@ -225,6 +229,7 @@ slv2_port_get_value_by_qname_i18n(SLV2Plugin p, return slv2_values_from_stream_i18n(p, results); } +SLV2_API SLV2Value slv2_port_get_symbol(SLV2Plugin p, SLV2Port port) @@ -232,6 +237,7 @@ slv2_port_get_symbol(SLV2Plugin p, return port->symbol; } +SLV2_API SLV2Value slv2_port_get_name(SLV2Plugin p, SLV2Port port) @@ -252,6 +258,7 @@ slv2_port_get_name(SLV2Plugin p, return ret; } +SLV2_API SLV2Values slv2_port_get_classes(SLV2Plugin p, SLV2Port port) @@ -259,6 +266,7 @@ slv2_port_get_classes(SLV2Plugin p, return port->classes; } +SLV2_API void slv2_port_get_range(SLV2Plugin p, SLV2Port port, @@ -292,6 +300,7 @@ slv2_port_get_range(SLV2Plugin p, } } +SLV2_API SLV2ScalePoints slv2_port_get_scale_points(SLV2Plugin p, SLV2Port port) @@ -330,6 +339,7 @@ slv2_port_get_scale_points(SLV2Plugin p, return ret; } +SLV2_API SLV2Values slv2_port_get_properties(SLV2Plugin p, SLV2Port port) diff --git a/src/scalepoint.c b/src/scalepoint.c index 39c5a37..55056c8 100644 --- a/src/scalepoint.c +++ b/src/scalepoint.c @@ -27,7 +27,7 @@ #include "slv2/value.h" #include "slv2_internal.h" -/* private - ownership of value and label is taken */ +/** Ownership of value and label is taken */ SLV2ScalePoint slv2_scale_point_new(SLV2Value value, SLV2Value label) { @@ -37,7 +37,6 @@ slv2_scale_point_new(SLV2Value value, SLV2Value label) return point; } -/* private */ void slv2_scale_point_free(SLV2ScalePoint point) { @@ -46,12 +45,14 @@ slv2_scale_point_free(SLV2ScalePoint point) free(point); } +SLV2_API SLV2Value slv2_scale_point_get_value(SLV2ScalePoint p) { return p->value; } +SLV2_API SLV2Value slv2_scale_point_get_label(SLV2ScalePoint p) { diff --git a/src/slv2_internal.h b/src/slv2_internal.h index 45a38d2..7cf8d11 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -109,9 +109,7 @@ struct _SLV2Plugin { }; SLV2Plugin slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri); -void slv2_plugin_load(SLV2Plugin p); void slv2_plugin_load_if_necessary(SLV2Plugin p); -void slv2_plugin_load_ports_if_necessary(SLV2Plugin p); void slv2_plugin_free(SLV2Plugin plugin); SLV2Value @@ -209,23 +207,6 @@ struct _SLV2World { const uint8_t* slv2_world_blank_node_prefix(SLV2World world); -/** 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); - - -void -slv2_world_load_specifications(SLV2World world); - void slv2_world_load_file(SLV2World world, const char* file_uri); @@ -282,10 +263,6 @@ static inline SLV2Node slv2_node_copy(SLV2Node node) { static inline void slv2_node_free(SLV2Node node) { } -/* ********* Values ********* */ - -void slv2_values_set_at(SLV2Values list, unsigned index, void* value); - /* ********* Scale Points ********* */ diff --git a/src/value.c b/src/value.c index ff74f9e..6e11004 100644 --- a/src/value.c +++ b/src/value.c @@ -27,7 +27,6 @@ #include "slv2/value.h" #include "slv2_internal.h" -/* private */ static void slv2_value_set_numerics_from_string(SLV2Value val) { @@ -59,8 +58,7 @@ slv2_value_set_numerics_from_string(SLV2Value val) } } -/* private - * Note that if type is numeric, slv2_value_set_numerics_from_string MUST be +/** Note that if @a type is numeric, slv2_value_set_numerics_from_string MUST be * called or the returned value will be corrupt! It is not automatically * called from here to avoid the parsing overhead and imprecision when the * true numeric value is already known. @@ -135,18 +133,21 @@ slv2_value_new_from_node(SLV2World world, SordNode node) return result; } +SLV2_API SLV2Value slv2_value_new_uri(SLV2World world, const char* uri) { return slv2_value_new(world, SLV2_VALUE_URI, uri); } +SLV2_API SLV2Value slv2_value_new_string(SLV2World world, const char* str) { return slv2_value_new(world, SLV2_VALUE_STRING, str); } +SLV2_API SLV2Value slv2_value_new_int(SLV2World world, int val) { @@ -157,6 +158,7 @@ slv2_value_new_int(SLV2World world, int val) return ret; } +SLV2_API SLV2Value slv2_value_new_float(SLV2World world, float val) { @@ -167,6 +169,7 @@ slv2_value_new_float(SLV2World world, float val) return ret; } +SLV2_API SLV2Value slv2_value_duplicate(SLV2Value val) { @@ -187,6 +190,7 @@ slv2_value_duplicate(SLV2Value val) return result; } +SLV2_API void slv2_value_free(SLV2Value val) { @@ -200,6 +204,7 @@ slv2_value_free(SLV2Value val) } } +SLV2_API bool slv2_value_equals(SLV2Value value, SLV2Value other) { @@ -226,6 +231,7 @@ slv2_value_equals(SLV2Value value, SLV2Value other) return false; /* shouldn't get here */ } +SLV2_API char* slv2_value_get_turtle_token(SLV2Value value) { @@ -274,12 +280,14 @@ slv2_value_get_turtle_token(SLV2Value value) return result; } +SLV2_API bool slv2_value_is_uri(SLV2Value value) { return (value && value->type == SLV2_VALUE_URI); } +SLV2_API const char* slv2_value_as_uri(SLV2Value value) { @@ -294,12 +302,14 @@ slv2_value_as_node(SLV2Value value) return value->val.uri_val; } +SLV2_API bool slv2_value_is_blank(SLV2Value value) { return (value && value->type == SLV2_VALUE_BLANK); } +SLV2_API const char* slv2_value_as_blank(SLV2Value value) { @@ -307,31 +317,45 @@ slv2_value_as_blank(SLV2Value value) return value->str_val; } +SLV2_API bool slv2_value_is_literal(SLV2Value value) { - // No blank nodes - return (value && value->type != SLV2_VALUE_URI); + if (!value) + return false; + + switch (value->type) { + case SLV2_VALUE_STRING: + case SLV2_VALUE_INT: + case SLV2_VALUE_FLOAT: + return true; + default: + return false; + } } +SLV2_API bool slv2_value_is_string(SLV2Value value) { return (value && value->type == SLV2_VALUE_STRING); } +SLV2_API const char* slv2_value_as_string(SLV2Value value) { return value->str_val; } +SLV2_API bool slv2_value_is_int(SLV2Value value) { return (value && value->type == SLV2_VALUE_INT); } +SLV2_API int slv2_value_as_int(SLV2Value value) { @@ -340,12 +364,14 @@ slv2_value_as_int(SLV2Value value) return value->val.int_val; } +SLV2_API bool slv2_value_is_float(SLV2Value value) { return (value && value->type == SLV2_VALUE_FLOAT); } +SLV2_API float slv2_value_as_float(SLV2Value value) { @@ -355,4 +381,3 @@ slv2_value_as_float(SLV2Value value) else // slv2_value_is_int(value) return (float)value->val.int_val; } - diff --git a/src/world.c b/src/world.c index dc2ead7..4c612ee 100644 --- a/src/world.c +++ b/src/world.c @@ -41,6 +41,7 @@ slv2_world_set_prefix(SLV2World world, const char* name, const char* uri) serd_env_add(world->namespaces, &name_node, &uri_node); } +SLV2_API SLV2World slv2_world_new() { @@ -101,6 +102,7 @@ fail: return NULL; } +SLV2_API void slv2_world_free(SLV2World world) { @@ -179,7 +181,7 @@ slv2_world_blank_node_prefix(SLV2World world) } /** Comparator for sorting SLV2Plugins */ -int +static int slv2_plugin_compare_by_uri(const void* a, const void* b) { SLV2Plugin plugin_a = *(SLV2Plugin*)a; @@ -189,17 +191,7 @@ slv2_plugin_compare_by_uri(const void* a, const void* b) slv2_value_as_uri(plugin_b->plugin_uri)); } -/** Comparator for sorting SLV2PluginClasses */ -int -slv2_plugin_class_compare_by_uri(const void* a, const void* b) -{ - SLV2PluginClass class_a = *(SLV2PluginClass*)a; - SLV2PluginClass class_b = *(SLV2PluginClass*)b; - - return strcmp(slv2_value_as_uri(class_a->uri), - slv2_value_as_uri(class_b->uri)); -} - +SLV2_API void slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) { @@ -447,7 +439,12 @@ slv2_world_load_directory(SLV2World world, const char* dir_path) closedir(pdir); } -void +/** Load all bundles found in @a lv2_path. + * @param lv2_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). + */ +static void slv2_world_load_path(SLV2World world, const char* lv2_path) { @@ -468,7 +465,7 @@ slv2_world_load_path(SLV2World world, } } -void +static void slv2_world_load_specifications(SLV2World world) { SLV2Matches specs = slv2_world_find_statements( @@ -497,7 +494,7 @@ slv2_world_load_specifications(SLV2World world) slv2_match_end(specs); } -void +static void slv2_world_load_plugin_classes(SLV2World world) { /* FIXME: This loads all classes, not just lv2:Plugin subclasses. @@ -578,6 +575,7 @@ slv2_world_load_plugin_classes(SLV2World world) slv2_match_end(classes); } +SLV2_API void slv2_world_load_all(SLV2World world) { @@ -615,24 +613,28 @@ slv2_world_load_all(SLV2World world) */ } +SLV2_API SLV2PluginClass slv2_world_get_plugin_class(SLV2World world) { return world->lv2_plugin_class; } +SLV2_API SLV2PluginClasses slv2_world_get_plugin_classes(SLV2World world) { return world->plugin_classes; } +SLV2_API SLV2Plugins slv2_world_get_all_plugins(SLV2World world) { return world->plugins; } +SLV2_API SLV2Plugins slv2_world_get_plugins_by_filter(SLV2World world, bool (*include)(SLV2Plugin)) { @@ -647,4 +649,3 @@ slv2_world_get_plugins_by_filter(SLV2World world, bool (*include)(SLV2Plugin)) return result; } - |