summaryrefslogtreecommitdiffstats
path: root/src/value.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-06-30 23:33:36 +0000
committerDavid Robillard <d@drobilla.net>2007-06-30 23:33:36 +0000
commitf291f0a52c45c9ae14d031c1fc16d772c65d94ce (patch)
treedbe9701473c6cfe6fd3df50a6d4dc103c0ab9f26 /src/value.c
parent435bc2fc2c0eb78addac1e688411ad8fad02517a (diff)
downloadlilv-f291f0a52c45c9ae14d031c1fc16d772c65d94ce.tar.gz
lilv-f291f0a52c45c9ae14d031c1fc16d772c65d94ce.tar.bz2
lilv-f291f0a52c45c9ae14d031c1fc16d772c65d94ce.zip
Reworked GUI access in a safer way, anticipating various GUI specs (w/o breaking binary compatibility).
Increment libtool library version number accordingly (new methods added, still backwards compatible). git-svn-id: http://svn.drobilla.net/lad/slv2@547 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/value.c')
-rw-r--r--src/value.c30
1 files changed, 25 insertions, 5 deletions
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;
+}
+