summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugin.c13
-rw-r--r--src/pluginclass.c15
-rw-r--r--src/port.c4
-rw-r--r--src/slv2_internal.h1
-rw-r--r--src/value.c57
-rw-r--r--src/world.c4
6 files changed, 46 insertions, 48 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 6ac5094..3b42f51 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -151,6 +151,11 @@ slv2_plugin_load(SLV2Plugin p)
librdf_node* class_node = librdf_query_results_get_binding_value(results, 0);
librdf_uri* class_uri = librdf_node_get_uri(class_node);
+ if (!class_uri) {
+ librdf_query_results_next(results);
+ continue;
+ }
+
SLV2Value class = slv2_value_new_librdf_uri(p->world, class_uri);
if ( ! slv2_value_equals(class, p->world->lv2_plugin_class->uri)) {
@@ -265,9 +270,11 @@ slv2_plugin_load(SLV2Plugin p)
if (!librdf_query_results_finished(results)) {
librdf_node* binary_node = librdf_query_results_get_binding_value(results, 0);
librdf_uri* binary_uri = librdf_node_get_uri(binary_node);
-
- SLV2Value binary = slv2_value_new_librdf_uri(p->world, binary_uri);
- p->binary_uri = binary;
+
+ if (binary_uri) {
+ SLV2Value binary = slv2_value_new_librdf_uri(p->world, binary_uri);
+ p->binary_uri = binary;
+ }
librdf_free_node(binary_node);
}
diff --git a/src/pluginclass.c b/src/pluginclass.c
index b3323a0..0ac9d05 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -30,15 +30,12 @@
SLV2PluginClass
slv2_plugin_class_new(SLV2World world, librdf_uri* parent_uri, librdf_uri* uri, const char* label)
{
- SLV2PluginClass plugin_class = (SLV2PluginClass)malloc(sizeof(struct _SLV2PluginClass));
- plugin_class->world = world;
- if (parent_uri)
- plugin_class->parent_uri = slv2_value_new_librdf_uri(world, parent_uri);
- else
- plugin_class->parent_uri = NULL;
- plugin_class->uri = slv2_value_new_librdf_uri(world, uri);
- plugin_class->label = slv2_value_new(world, SLV2_VALUE_STRING, label);
- return plugin_class;
+ SLV2PluginClass pc = (SLV2PluginClass)malloc(sizeof(struct _SLV2PluginClass));
+ pc->world = world;
+ pc->parent_uri = (parent_uri ? slv2_value_new_librdf_uri(world, parent_uri) : NULL);
+ pc->uri = slv2_value_new_librdf_uri(world, uri);
+ pc->label = slv2_value_new(world, SLV2_VALUE_STRING, label);
+ return pc;
}
diff --git a/src/port.c b/src/port.c
index 27cc297..6baf13c 100644
--- a/src/port.c
+++ b/src/port.c
@@ -321,14 +321,14 @@ slv2_port_get_scale_points(SLV2Plugin p,
ret = slv2_scale_points_new();
while (!librdf_query_results_finished(results)) {
-
librdf_node* value_node = librdf_query_results_get_binding_value(results, 0);
librdf_node* label_node = librdf_query_results_get_binding_value(results, 1);
SLV2Value value = slv2_value_new_librdf_node(p->world, value_node);
SLV2Value label = slv2_value_new_librdf_node(p->world, label_node);
- raptor_sequence_push(ret, slv2_scale_point_new(value, label));
+ if (value && label)
+ raptor_sequence_push(ret, slv2_scale_point_new(value, label));
librdf_query_results_next(results);
}
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 9d5b17a..bc1defe 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -210,7 +210,6 @@ struct _SLV2Value {
SLV2Value slv2_value_new(SLV2World world, SLV2ValueType type, const char* val);
SLV2Value slv2_value_new_librdf_node(SLV2World world, librdf_node* node);
SLV2Value slv2_value_new_librdf_uri(SLV2World world, librdf_uri* uri);
-void slv2_value_set_numerics_from_string(SLV2Value val);
librdf_uri* slv2_value_as_librdf_uri(SLV2Value value);
diff --git a/src/value.c b/src/value.c
index 08c27e5..ba39754 100644
--- a/src/value.c
+++ b/src/value.c
@@ -28,35 +28,9 @@
/* private */
-SLV2Value
-slv2_value_new(SLV2World world, SLV2ValueType type, const char* str)
-{
- SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
- val->type = type;
-
- if (type == SLV2_VALUE_URI) {
- val->val.uri_val = librdf_new_uri(world->world, (const unsigned char*)str);
- if (val->val.uri_val)
- val->str_val = (char*)librdf_uri_as_string(val->val.uri_val);
- else
- return NULL;
- } else {
- val->str_val = strdup(str);
- }
-
- slv2_value_set_numerics_from_string(val);
-
- return val;
-}
-
-
-/* private */
-void
+static void
slv2_value_set_numerics_from_string(SLV2Value val)
{
- if (!val)
- return;
-
// FIXME: locale kludges to work around librdf bug
char* locale = strdup(setlocale(LC_NUMERIC, NULL));
@@ -78,6 +52,27 @@ slv2_value_set_numerics_from_string(SLV2Value val)
/* private */
SLV2Value
+slv2_value_new(SLV2World world, SLV2ValueType type, const char* str)
+{
+ SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
+ val->type = type;
+
+ if (type == SLV2_VALUE_URI) {
+ val->val.uri_val = librdf_new_uri(world->world, (const unsigned char*)str);
+ assert(val->val.uri_val);
+ val->str_val = (char*)librdf_uri_as_string(val->val.uri_val);
+ } else {
+ val->str_val = strdup(str);
+ }
+
+ slv2_value_set_numerics_from_string(val);
+
+ return val;
+}
+
+
+/* private */
+SLV2Value
slv2_value_new_librdf_node(SLV2World world, librdf_node* node)
{
SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
@@ -113,7 +108,9 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node)
break;
}
- slv2_value_set_numerics_from_string(val);
+ if (val)
+ slv2_value_set_numerics_from_string(val);
+
return val;
}
@@ -122,9 +119,7 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node)
SLV2Value
slv2_value_new_librdf_uri(SLV2World world, librdf_uri* uri)
{
- if (!uri)
- return NULL;
-
+ assert(uri);
SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value));
val->type = SLV2_VALUE_URI;
val->val.uri_val = librdf_new_uri_from_uri(uri);
diff --git a/src/world.c b/src/world.c
index 6f90229..ec0744f 100644
--- a/src/world.c
+++ b/src/world.c
@@ -530,8 +530,8 @@ slv2_world_load_all(SLV2World world)
assert(plugin_uri);
assert(data_uri);
- SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri);
- SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins, uri);
+ SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri);
+ SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins, uri);
// Create a new SLV2Plugin
if (!plugin) {