diff options
author | David Robillard <d@drobilla.net> | 2011-01-31 00:33:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-31 00:33:19 +0000 |
commit | 8ab85a31c348a40858752a035a14ccb6df5fd6c2 (patch) | |
tree | 972c310181913bfb92776bc655cbbfa2e895eddb | |
parent | a81b9cdaa2c8d6cf4fcef2472ac0dfa2ca7e47e9 (diff) | |
download | lilv-8ab85a31c348a40858752a035a14ccb6df5fd6c2.tar.gz lilv-8ab85a31c348a40858752a035a14ccb6df5fd6c2.tar.bz2 lilv-8ab85a31c348a40858752a035a14ccb6df5fd6c2.zip |
Replace a bunch of explicit use of librdf_uri (which does not have a Sord equivalent) with librdf_node (which does).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2880 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/plugin.c | 17 | ||||
-rw-r--r-- | src/pluginclass.c | 9 | ||||
-rw-r--r-- | src/slv2_internal.h | 9 | ||||
-rw-r--r-- | src/value.c | 7 | ||||
-rw-r--r-- | src/world.c | 46 |
5 files changed, 46 insertions, 42 deletions
diff --git a/src/plugin.c b/src/plugin.c index d942106..9d08167 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -231,7 +231,7 @@ slv2_plugin_load_ports_if_necessary(SLV2Plugin p) if (librdf_node_is_resource(type)) { raptor_sequence_push( this_port->classes, - slv2_value_new_librdf_uri(p->world, librdf_node_get_uri(type))); + slv2_value_new_librdf_uri(p->world, type)); } else { SLV2_WARN("port has non-URI rdf:type\n"); } @@ -343,10 +343,8 @@ slv2_plugin_get_library_uri(SLV2Plugin p) NULL); FOREACH_MATCH(results) { librdf_node* binary_node = MATCH_OBJECT(results); - librdf_uri* binary_uri = librdf_node_get_uri(binary_node); - - if (binary_uri) { - p->binary_uri = slv2_value_new_librdf_uri(p->world, binary_uri); + if (librdf_node_is_resource(binary_node)) { + p->binary_uri = slv2_value_new_librdf_uri(p->world, binary_node); break; } } @@ -376,14 +374,11 @@ slv2_plugin_get_class(SLV2Plugin p) NULL); FOREACH_MATCH(results) { librdf_node* class_node = librdf_new_node_from_node(MATCH_OBJECT(results)); - librdf_uri* class_uri = librdf_node_get_uri(class_node); - - if (!class_uri) { + if (!librdf_node_is_resource(class_node)) { continue; } - SLV2Value class = slv2_value_new_librdf_uri(p->world, class_uri); - + SLV2Value class = slv2_value_new_librdf_uri(p->world, class_node); if ( ! slv2_value_equals(class, p->world->lv2_plugin_class->uri)) { SLV2PluginClass plugin_class = slv2_plugin_classes_get_by_uri( @@ -848,7 +843,7 @@ slv2_plugin_get_uis(SLV2Plugin p) SLV2UI slv2_ui = slv2_ui_new( p->world, - slv2_value_new_librdf_uri(p->world, librdf_node_get_uri(ui)), + slv2_value_new_librdf_uri(p->world, ui), type, binary); diff --git a/src/pluginclass.c b/src/pluginclass.c index 7d38a67..6f73083 100644 --- a/src/pluginclass.c +++ b/src/pluginclass.c @@ -29,11 +29,16 @@ /* private */ SLV2PluginClass -slv2_plugin_class_new(SLV2World world, librdf_uri* parent_uri, librdf_uri* uri, const char* label) +slv2_plugin_class_new(SLV2World world, + librdf_node* parent_node, + librdf_node* uri, + const char* label) { + assert(!parent_node || librdf_node_is_resource(parent_node)); + librdf_uri* parent_uri = parent_node ? librdf_node_get_uri(parent_node) : NULL; 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->parent_uri = (parent_uri ? slv2_value_new_librdf_uri(world, parent_node) : 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/slv2_internal.h b/src/slv2_internal.h index 5fab870..dd55aca 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -137,8 +137,11 @@ struct _SLV2PluginClass { SLV2Value label; }; -SLV2PluginClass slv2_plugin_class_new(SLV2World world, librdf_uri* parent_uri, - librdf_uri* uri, const char* label); +SLV2PluginClass slv2_plugin_class_new(SLV2World world, + librdf_node* parent_uri, + librdf_node* uri, + const char* label); + void slv2_plugin_class_free(SLV2PluginClass plugin_class); @@ -252,7 +255,7 @@ 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); +SLV2Value slv2_value_new_librdf_uri(SLV2World world, librdf_node* node); librdf_uri* slv2_value_as_librdf_uri(SLV2Value value); diff --git a/src/value.c b/src/value.c index 819e5fe..4799186 100644 --- a/src/value.c +++ b/src/value.c @@ -104,7 +104,7 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node) switch (librdf_node_get_type(node)) { case LIBRDF_NODE_TYPE_RESOURCE: type = SLV2_VALUE_URI; - result = slv2_value_new_librdf_uri(world, librdf_node_get_uri(node)); + result = slv2_value_new_librdf_uri(world, node); break; case LIBRDF_NODE_TYPE_LITERAL: datatype_uri = librdf_node_get_literal_value_datatype_uri(node); @@ -144,8 +144,11 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node) /* private */ SLV2Value -slv2_value_new_librdf_uri(SLV2World world, librdf_uri* uri) +slv2_value_new_librdf_uri(SLV2World world, librdf_node* node) { + assert(node); + assert(librdf_node_is_resource(node)); + librdf_uri* uri = librdf_node_get_uri(node); assert(uri); SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value)); val->type = SLV2_VALUE_URI; diff --git a/src/world.c b/src/world.c index f775601..d042643 100644 --- a/src/world.c +++ b/src/world.c @@ -81,8 +81,8 @@ slv2_world_new_internal(SLV2World world) world->xsd_integer_node = NEW_URI(SLV2_NS_XSD "integer"); world->xsd_decimal_node = NEW_URI(SLV2_NS_XSD "decimal"); - world->lv2_plugin_class = slv2_plugin_class_new(world, NULL, - librdf_node_get_uri(world->lv2_plugin_node), "Plugin"); + world->lv2_plugin_class = slv2_plugin_class_new( + world, NULL, world->lv2_plugin_node, "Plugin"); world->namespaces = librdf_new_hash_from_string( world->world, NULL, @@ -277,9 +277,8 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) } librdf_node* binary_node = librdf_new_node_from_node(MATCH_OBJECT(binaries)); - librdf_uri* binary_uri = librdf_node_get_uri(binary_node); - const uint8_t* lib_uri = librdf_uri_as_string(binary_uri); + const uint8_t* lib_uri = librdf_uri_as_string(librdf_node_get_uri(binary_node)); const char* lib_path = slv2_uri_to_path((const char*)lib_uri); if (!lib_path) continue; @@ -491,17 +490,14 @@ slv2_world_load_specifications(SLV2World world) librdf_new_node_from_node(world->lv2_specification_node)); FOREACH_MATCH(specs) { librdf_node* spec_node = MATCH_SUBJECT(specs); - - SLV2Matches files = slv2_world_find_statements( + SLV2Matches files = slv2_world_find_statements( world, world->model, librdf_new_node_from_node(spec_node), librdf_new_node_from_node(world->rdfs_seealso_node), NULL); FOREACH_MATCH(files) { librdf_node* file_node = MATCH_OBJECT(files); - librdf_uri* file_uri = librdf_node_get_uri(file_node); - - slv2_world_load_file(world, file_uri); + slv2_world_load_file(world, librdf_node_get_uri(file_node)); } END_MATCH(files); } @@ -525,7 +521,6 @@ slv2_world_load_plugin_classes(SLV2World world) librdf_new_node_from_node(world->rdfs_class_node)); FOREACH_MATCH(classes) { librdf_node* class_node = MATCH_SUBJECT(classes); - librdf_uri* class_uri = librdf_node_get_uri(class_node); // Get parents (superclasses) SLV2Matches parents = slv2_world_find_statements( @@ -535,13 +530,16 @@ slv2_world_load_plugin_classes(SLV2World world) NULL); if (slv2_matches_end(parents)) { - END_MATCH(parents); continue; } librdf_node* parent_node = librdf_new_node_from_node(MATCH_OBJECT(parents)); - librdf_uri* parent_uri = librdf_node_get_uri(parent_node); - librdf_free_stream(parents); + END_MATCH(parents); + + if (!librdf_node_is_resource(parent_node)) { + // Class parent is not a resource, ignore (e.g. owl restriction) + continue; + } // Get labels SLV2Matches labels = slv2_world_find_statements( @@ -567,13 +565,16 @@ slv2_world_load_plugin_classes(SLV2World world) SLV2PluginClass prev = raptor_sequence_get_at(classes, n_classes - 1); assert(strcmp( slv2_value_as_string(slv2_plugin_class_get_uri(prev)), - (const char*)librdf_uri_as_string(class_uri)) < 0); + (const char*)librdf_uri_as_string( + librdf_node_get_uri(class_node))) < 0); } #endif - raptor_sequence_push(classes, slv2_plugin_class_new( - world, parent_uri, class_uri, (const char*)label)); + raptor_sequence_push(classes, + slv2_plugin_class_new(world, + parent_node, + class_node, + (const char*)label)); - //librdf_free_node(class_node); librdf_free_node(parent_node); librdf_free_node(label_node); } @@ -655,7 +656,6 @@ slv2_world_load_all(SLV2World world) } librdf_node* bundle_node = librdf_new_node_from_node(MATCH_OBJECT(bundles)); - librdf_uri* bundle_uri = librdf_node_get_uri(bundle_node); slv2_matches_next(bundles); if (!slv2_matches_end(bundles)) { @@ -668,7 +668,7 @@ slv2_world_load_all(SLV2World world) librdf_free_stream(bundles); // Add a new plugin to the world - SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri); + SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_node); const unsigned n_plugins = raptor_sequence_size(world->plugins); #ifndef NDEBUG if (n_plugins > 0) { @@ -681,7 +681,7 @@ slv2_world_load_all(SLV2World world) #endif SLV2Plugin plugin = slv2_plugin_new( - world, uri, slv2_value_new_librdf_uri(world, bundle_uri)); + world, uri, slv2_value_new_librdf_uri(world, bundle_node)); raptor_sequence_push(world->plugins, plugin); @@ -699,7 +699,7 @@ slv2_world_load_all(SLV2World world) if (dlopen( slv2_uri_to_path((const char*)librdf_uri_as_string(lib_uri)), RTLD_LAZY)) { - plugin->dynman_uri = slv2_value_new_librdf_uri(world, lib_uri); + plugin->dynman_uri = slv2_value_new_librdf_uri(world, lib_node); } } END_MATCH(dmanifests); @@ -712,10 +712,8 @@ slv2_world_load_all(SLV2World world) NULL); FOREACH_MATCH(files) { librdf_node* file_node = MATCH_OBJECT(files); - librdf_uri* file_uri = librdf_node_get_uri(file_node); - raptor_sequence_push(plugin->data_uris, - slv2_value_new_librdf_uri(world, file_uri)); + slv2_value_new_librdf_uri(world, file_node)); } END_MATCH(files); |