summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-13 04:37:57 +0000
committerDavid Robillard <d@drobilla.net>2008-12-13 04:37:57 +0000
commitc854c1f24f41844f0c95e8943738a820d8a283e5 (patch)
treecd192e47417aa4f6f9369b8f8922fb4af243cfc1 /src
parentcfaf7d029da6f66bddfd91c7874d4019c502ea5c (diff)
downloadlilv-c854c1f24f41844f0c95e8943738a820d8a283e5.tar.gz
lilv-c854c1f24f41844f0c95e8943738a820d8a283e5.tar.bz2
lilv-c854c1f24f41844f0c95e8943738a820d8a283e5.zip
Add constructors slv2_value_new_int, slv2_value_new_float, slv2_value_new_string.
Fix slv2_value_get_turtle_token for floats. Nearly complete test coverage for value stuff: 73.5% coverage git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1858 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/slv2_internal.h17
-rw-r--r--src/value.c27
2 files changed, 28 insertions, 16 deletions
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 48193c7..a3e8d04 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -32,10 +32,8 @@ extern "C" {
#include "slv2/lv2_ui.h"
-
/* ********* PORT ********* */
-
/** Reference to a port on some plugin. */
struct _SLV2Port {
uint32_t index; ///< lv2:index
@@ -49,10 +47,8 @@ SLV2Port slv2_port_new(SLV2World world, uint32_t index, const char* symbol);
void slv2_port_free(SLV2Port port);
-
/* ********* Plugin ********* */
-
/** Record of an installed/available plugin.
*
* A simple reference to a plugin somewhere on the system. This just holds
@@ -81,10 +77,8 @@ librdf_query_results* slv2_plugin_query(SLV2Plugin plugin,
const char* sparql_str);
-
/* ********* Plugins ********* */
-
/** Create a new, empty plugin list.
*
* Returned object must be freed with slv2_plugins_free.
@@ -93,10 +87,8 @@ SLV2Plugins
slv2_plugins_new();
-
/* ********* Instance ********* */
-
/** Pimpl portion of SLV2Instance */
struct _InstanceImpl {
void* lib_handle;
@@ -104,6 +96,7 @@ struct _InstanceImpl {
/* ********* UI Instance ********* */
+
struct _SLV2UIInstanceImpl {
void* lib_handle;
const LV2UI_Descriptor* lv2ui_descriptor;
@@ -114,7 +107,6 @@ struct _SLV2UIInstanceImpl {
/* ********* Plugin Class ********* */
-
struct _SLV2PluginClass {
struct _SLV2World* world;
SLV2Value parent_uri;
@@ -127,15 +119,12 @@ SLV2PluginClass slv2_plugin_class_new(SLV2World world, librdf_uri* parent_uri,
void slv2_plugin_class_free(SLV2PluginClass plugin_class);
-
/* ********* Plugin Classes ********* */
-
SLV2PluginClasses slv2_plugin_classes_new();
void slv2_plugin_classes_free();
-
/* ********* World ********* */
/** Model of LV2 (RDF) data loaded from bundles.
@@ -240,11 +229,9 @@ SLV2ScalePoint slv2_scale_point_new(SLV2Value value, SLV2Value label);
void slv2_scale_point_free(SLV2ScalePoint point);
-/* String utility functions */
+/* ********* Utilities ********* */
char* slv2_strjoin(const char* first, ...);
-
-/* I18N utility functions */
char* slv2_get_lang();
diff --git a/src/value.c b/src/value.c
index a8ef85a..0e474fb 100644
--- a/src/value.c
+++ b/src/value.c
@@ -141,6 +141,31 @@ slv2_value_new_uri(SLV2World world, const char* uri)
SLV2Value
+slv2_value_new_string(SLV2World world, const char* str)
+{
+ return slv2_value_new(world, SLV2_VALUE_STRING, str);
+}
+
+
+SLV2Value
+slv2_value_new_int(SLV2World world, int val)
+{
+ char str[32];
+ snprintf(str, 32, "%d", val);
+ return slv2_value_new(world, SLV2_VALUE_INT, str);
+}
+
+
+SLV2Value
+slv2_value_new_float(SLV2World world, float val)
+{
+ char str[32];
+ snprintf(str, 32, "%f", val);
+ return slv2_value_new(world, SLV2_VALUE_FLOAT, str);
+}
+
+
+SLV2Value
slv2_value_duplicate(SLV2Value val)
{
SLV2Value result = (SLV2Value)malloc(sizeof(struct _SLV2Value));
@@ -229,7 +254,7 @@ slv2_value_get_turtle_token(SLV2Value value)
len = 20; // FIXME: proper maximum value?
result = calloc(len, sizeof(char));
setlocale(LC_NUMERIC, "POSIX");
- snprintf(result, len, ".1%f", value->val.float_val);
+ snprintf(result, len, "%f", value->val.float_val);
setlocale(LC_NUMERIC, locale);
break;
}