From 1e7b27c7b322476c437a8524cff4a88245c5efbf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 Apr 2011 17:30:30 +0000 Subject: LilvValue => LilvNode. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3234 a436a847-0d15-0410-975c-d299462d15a1 --- src/collections.c | 28 +++---- src/instance.c | 12 +-- src/lilv_internal.h | 88 +++++++++----------- src/plugin.c | 234 ++++++++++++++++++++++++++-------------------------- src/pluginclass.c | 22 ++--- src/port.c | 98 +++++++++++----------- src/query.c | 26 +++--- src/scalepoint.c | 10 +-- src/ui.c | 46 +++++------ src/value.c | 110 ++++++++++++------------ src/world.c | 126 ++++++++++++++-------------- 11 files changed, 396 insertions(+), 404 deletions(-) (limited to 'src') diff --git a/src/collections.c b/src/collections.c index 58207f9..11f3bfc 100644 --- a/src/collections.c +++ b/src/collections.c @@ -60,10 +60,10 @@ lilv_scale_points_new(void) return lilv_collection_new((GDestroyNotify)lilv_scale_point_free); } -LilvValues* -lilv_values_new(void) +LilvNodes* +lilv_nodes_new(void) { - return lilv_collection_new((GDestroyNotify)lilv_value_free); + return lilv_collection_new((GDestroyNotify)lilv_node_free); } LilvUIs* @@ -82,14 +82,14 @@ lilv_plugin_classes_new(void) LILV_API const LilvPluginClass* -lilv_plugin_classes_get_by_uri(const LilvPluginClasses* coll, const LilvValue* uri) +lilv_plugin_classes_get_by_uri(const LilvPluginClasses* coll, const LilvNode* uri) { return (LilvPluginClass*)lilv_sequence_get_by_uri(coll, uri); } LILV_API const LilvUI* -lilv_uis_get_by_uri(const LilvUIs* coll, const LilvValue* uri) +lilv_uis_get_by_uri(const LilvUIs* coll, const LilvNode* uri) { return (LilvUI*)lilv_sequence_get_by_uri((LilvUIs*)coll, uri); } @@ -104,7 +104,7 @@ lilv_plugins_new() LILV_API const LilvPlugin* -lilv_plugins_get_by_uri(const LilvPlugins* list, const LilvValue* uri) +lilv_plugins_get_by_uri(const LilvPlugins* list, const LilvNode* uri) { return (LilvPlugin*)lilv_sequence_get_by_uri((LilvPlugins*)list, uri); } @@ -113,10 +113,10 @@ lilv_plugins_get_by_uri(const LilvPlugins* list, const LilvValue* uri) LILV_API bool -lilv_values_contains(const LilvValues* list, const LilvValue* value) +lilv_nodes_contains(const LilvNodes* list, const LilvNode* value) { - LILV_FOREACH(values, i, list) - if (lilv_value_equals(lilv_values_get(list, i), value)) + LILV_FOREACH(nodes, i, list) + if (lilv_node_equals(lilv_nodes_get(list, i), value)) return true; return false; @@ -170,7 +170,7 @@ prefix##_is_end(const CT* collection, LilvIter* i) { \ LILV_COLLECTION_IMPL(lilv_plugin_classes, LilvPluginClasses, LilvPluginClass) LILV_COLLECTION_IMPL(lilv_scale_points, LilvScalePoints, LilvScalePoint) LILV_COLLECTION_IMPL(lilv_uis, LilvUIs, LilvUI) -LILV_COLLECTION_IMPL(lilv_values, LilvValues, LilvValue) +LILV_COLLECTION_IMPL(lilv_nodes, LilvNodes, LilvNode) LILV_COLLECTION_IMPL(lilv_plugins, LilvPlugins, LilvPlugin) LILV_API @@ -193,13 +193,13 @@ lilv_uis_free(LilvUIs* collection) { LILV_API void -lilv_values_free(LilvValues* collection) { +lilv_nodes_free(LilvNodes* collection) { lilv_collection_free(collection); } LILV_API -LilvValue* -lilv_values_get_first(const LilvValues* collection) { - return (LilvValue*)lilv_collection_get(collection, +LilvNode* +lilv_nodes_get_first(const LilvNodes* collection) { + return (LilvNode*)lilv_collection_get(collection, lilv_collection_begin(collection)); } diff --git a/src/instance.c b/src/instance.c index 55e0f99..9f99534 100644 --- a/src/instance.c +++ b/src/instance.c @@ -37,7 +37,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, local_features[0] = NULL; } - const char* const lib_uri = lilv_value_as_uri(lilv_plugin_get_library_uri(plugin)); + const char* const lib_uri = lilv_node_as_uri(lilv_plugin_get_library_uri(plugin)); const char* const lib_path = lilv_uri_to_path(lib_uri); if (!lib_path) @@ -61,20 +61,20 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, } else { // Search for plugin by URI - const char* bundle_path = lilv_uri_to_path(lilv_value_as_uri( + const char* bundle_path = lilv_uri_to_path(lilv_node_as_uri( lilv_plugin_get_bundle_uri(plugin))); for (uint32_t i = 0; true; ++i) { const LV2_Descriptor* ld = df(i); if (!ld) { LILV_ERRORF("Did not find plugin %s in %s\n", - lilv_value_as_uri(lilv_plugin_get_uri(plugin)), lib_path); + lilv_node_as_uri(lilv_plugin_get_uri(plugin)), lib_path); dlclose(lib); break; // return NULL } else { // Parse bundle URI to use as base URI - const LilvValue* bundle_uri = lilv_plugin_get_bundle_uri(plugin); - const char* bundle_uri_str = lilv_value_as_uri(bundle_uri); + const LilvNode* bundle_uri = lilv_plugin_get_bundle_uri(plugin); + const char* bundle_uri_str = lilv_node_as_uri(bundle_uri); SerdURI base_uri; if (!serd_uri_parse((const uint8_t*)bundle_uri_str, &base_uri)) { dlclose(lib); @@ -92,7 +92,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, } if (!strcmp((const char*)abs_uri_node.buf, - lilv_value_as_uri(lilv_plugin_get_uri(plugin)))) { + lilv_node_as_uri(lilv_plugin_get_uri(plugin)))) { // Create LilvInstance to return result = malloc(sizeof(struct LilvInstanceImpl)); result->lv2_descriptor = ld; diff --git a/src/lilv_internal.h b/src/lilv_internal.h index 774f5fd..78b377d 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -83,8 +83,8 @@ lilv_match_end(SordIter* iter) /** Reference to a port on some plugin. */ struct LilvPortImpl { uint32_t index; ///< lv2:index - LilvValue* symbol; ///< lv2:symbol - LilvValues* classes; ///< rdf:type + LilvNode* symbol; ///< lv2:symbol + LilvNodes* classes; ///< rdf:type }; LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol); @@ -95,7 +95,7 @@ void lilv_port_free(LilvPort* port); struct LilvSpecImpl { SordNode* spec; SordNode* bundle; - LilvValues* data_uris; + LilvNodes* data_uris; }; typedef struct LilvSpecImpl LilvSpec; @@ -108,7 +108,7 @@ typedef struct LilvSpecImpl LilvSpec; */ struct LilvHeader { LilvWorld* world; - LilvValue* uri; + LilvNode* uri; }; /** Record of an installed/available plugin. @@ -118,23 +118,23 @@ struct LilvHeader { */ struct LilvPluginImpl { LilvWorld* world; - LilvValue* plugin_uri; - LilvValue* bundle_uri; ///< Bundle directory plugin was loaded from - LilvValue* binary_uri; ///< lv2:binary - LilvValue* dynman_uri; ///< dynamic manifest binary + LilvNode* plugin_uri; + LilvNode* bundle_uri; ///< Bundle directory plugin was loaded from + LilvNode* binary_uri; ///< lv2:binary + LilvNode* dynman_uri; ///< dynamic manifest binary const LilvPluginClass* plugin_class; - LilvValues* data_uris; ///< rdfs::seeAlso + LilvNodes* data_uris; ///< rdfs::seeAlso LilvPort** ports; uint32_t num_ports; bool loaded; bool replaced; }; -LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri); +LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri); void lilv_plugin_load_if_necessary(const LilvPlugin* p); void lilv_plugin_free(LilvPlugin* plugin); -LilvValue* +LilvNode* lilv_plugin_get_unique(const LilvPlugin* p, const SordNode* subject, const SordNode* predicate); @@ -178,17 +178,17 @@ lilv_collection_free(LilvCollection* collection); unsigned lilv_collection_size(const LilvCollection* collection); -LilvValues* -lilv_values_new(void); +LilvNodes* +lilv_nodes_new(void); LilvScalePoints* lilv_scale_points_new(void); struct LilvPluginClassImpl { LilvWorld* world; - LilvValue* uri; - LilvValue* parent_uri; - LilvValue* label; + LilvNode* uri; + LilvNode* parent_uri; + LilvNode* label; }; LilvPluginClass* lilv_plugin_class_new(LilvWorld* world, @@ -245,10 +245,10 @@ struct LilvWorldImpl { SordNode* xsd_decimal_node; SordNode* xsd_double_node; SordNode* xsd_integer_node; - LilvValue* doap_name_val; - LilvValue* lv2_name_val; - LilvValue* lv2_optionalFeature_val; - LilvValue* lv2_requiredFeature_val; + LilvNode* doap_name_val; + LilvNode* lv2_name_val; + LilvNode* lv2_optionalFeature_val; + LilvNode* lv2_requiredFeature_val; LilvOptions opt; }; @@ -261,34 +261,34 @@ lilv_world_load_file(LilvWorld* world, const char* file_uri); struct LilvUIImpl { LilvWorld* world; - LilvValue* uri; - LilvValue* bundle_uri; - LilvValue* binary_uri; - LilvValues* classes; + LilvNode* uri; + LilvNode* bundle_uri; + LilvNode* binary_uri; + LilvNodes* classes; }; LilvUIs* lilv_uis_new(); LilvUI* lilv_ui_new(LilvWorld* world, - LilvValue* uri, - LilvValue* type_uri, - LilvValue* binary_uri); + LilvNode* uri, + LilvNode* type_uri, + LilvNode* binary_uri); void lilv_ui_free(LilvUI* ui); /* ********* Value ********* */ -typedef enum _LilvValueType { +typedef enum _LilvNodeType { LILV_VALUE_URI, LILV_VALUE_STRING, LILV_VALUE_INT, LILV_VALUE_FLOAT, LILV_VALUE_BOOL, LILV_VALUE_BLANK -} LilvValueType; +} LilvNodeType; -struct LilvValueImpl { +struct LilvNodeImpl { LilvWorld* world; char* str_val; ///< always present union { @@ -297,12 +297,12 @@ struct LilvValueImpl { bool bool_val; SordNode* uri_val; } val; - LilvValueType type; + LilvNodeType type; }; -LilvValue* lilv_value_new(LilvWorld* world, LilvValueType type, const char* val); -LilvValue* lilv_value_new_from_node(LilvWorld* world, const SordNode* node); -const SordNode* lilv_value_as_node(const LilvValue* value); +LilvNode* lilv_node_new(LilvWorld* world, LilvNodeType type, const char* val); +LilvNode* lilv_node_new_from_node(LilvWorld* world, const SordNode* node); +const SordNode* lilv_node_as_node(const LilvNode* value); int lilv_header_compare_by_uri(const void* a, const void* b, void* user_data); @@ -319,24 +319,16 @@ lilv_array_append(GSequence* seq, void* value) { } struct LilvHeader* -lilv_sequence_get_by_uri(const GSequence* seq, const LilvValue* uri); - -static inline SordNode* lilv_node_copy(const SordNode* node) { - return sord_node_copy(node); -} - -static inline void lilv_node_free(LilvWorld* world, SordNode* node) { - sord_node_free(world->world, node); -} +lilv_sequence_get_by_uri(const GSequence* seq, const LilvNode* uri); /* ********* Scale Points ********* */ struct LilvScalePointImpl { - LilvValue* value; - LilvValue* label; + LilvNode* value; + LilvNode* label; }; -LilvScalePoint* lilv_scale_point_new(LilvValue* value, LilvValue* label); +LilvScalePoint* lilv_scale_point_new(LilvNode* value, LilvNode* label); void lilv_scale_point_free(LilvScalePoint* point); /* ********* Query Results ********* */ @@ -347,7 +339,7 @@ lilv_world_query(LilvWorld* world, const SordNode* predicate, const SordNode* object); -LilvValues* +LilvNodes* lilv_world_query_values(LilvWorld* world, const SordNode* subject, const SordNode* predicate, @@ -361,7 +353,7 @@ static inline bool lilv_matches_end(SordIter* matches) { return sord_iter_end(matches); } -LilvValues* lilv_values_from_stream_objects(LilvWorld* w, +LilvNodes* lilv_nodes_from_stream_objects(LilvWorld* w, SordIter* stream); /* ********* Utilities ********* */ diff --git a/src/plugin.c b/src/plugin.c index 3703ed6..3682896 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -30,7 +30,7 @@ /** Ownership of @a uri is taken */ LilvPlugin* -lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri) +lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri) { assert(bundle_uri); LilvPlugin* plugin = malloc(sizeof(struct LilvPluginImpl)); @@ -42,7 +42,7 @@ lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri) plugin->dynman_uri = NULL; #endif plugin->plugin_class = NULL; - plugin->data_uris = lilv_values_new(); + plugin->data_uris = lilv_nodes_new(); plugin->ports = NULL; plugin->num_ports = 0; plugin->loaded = false; @@ -54,17 +54,17 @@ lilv_plugin_new(LilvWorld* world, LilvValue* uri, LilvValue* bundle_uri) void lilv_plugin_free(LilvPlugin* p) { - lilv_value_free(p->plugin_uri); + lilv_node_free(p->plugin_uri); p->plugin_uri = NULL; - lilv_value_free(p->bundle_uri); + lilv_node_free(p->bundle_uri); p->bundle_uri = NULL; - lilv_value_free(p->binary_uri); + lilv_node_free(p->binary_uri); p->binary_uri = NULL; #ifdef LILV_DYN_MANIFEST - lilv_value_free(p->dynman_uri); + lilv_node_free(p->dynman_uri); p->dynman_uri = NULL; #endif @@ -75,37 +75,37 @@ lilv_plugin_free(LilvPlugin* p) p->ports = NULL; } - lilv_values_free(p->data_uris); + lilv_nodes_free(p->data_uris); p->data_uris = NULL; free(p); } -LilvValue* +LilvNode* lilv_plugin_get_unique(const LilvPlugin* p, const SordNode* subject, const SordNode* predicate) { - LilvValues* values = lilv_world_query_values(p->world, - subject, predicate, NULL); - if (!values || lilv_values_size(values) != 1) { + LilvNodes* values = lilv_world_query_values(p->world, + subject, predicate, NULL); + if (!values || lilv_nodes_size(values) != 1) { LILV_ERRORF("Port does not have exactly one `%s' property\n", sord_node_get_string(predicate)); return NULL; } - LilvValue* ret = lilv_value_duplicate(lilv_values_get_first(values)); - lilv_values_free(values); + LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values)); + lilv_nodes_free(values); return ret; } -static LilvValue* +static LilvNode* lilv_plugin_get_one(const LilvPlugin* p, const SordNode* subject, const SordNode* predicate) { - LilvValues* values = lilv_world_query_values(p->world, - subject, predicate, NULL); + LilvNodes* values = lilv_world_query_values(p->world, + subject, predicate, NULL); if (!values) { return NULL; } - LilvValue* ret = lilv_value_duplicate(lilv_values_get_first(values)); - lilv_values_free(values); + LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values)); + lilv_nodes_free(values); return ret; } @@ -113,8 +113,8 @@ static void lilv_plugin_load(LilvPlugin* p) { // Parse all the plugin's data files into RDF model - LILV_FOREACH(values, i, p->data_uris) { - const LilvValue* data_uri_val = lilv_values_get(p->data_uris, i); + LILV_FOREACH(nodes, i, p->data_uris) { + const LilvNode* data_uri_val = lilv_nodes_get(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, @@ -125,11 +125,11 @@ lilv_plugin_load(LilvPlugin* p) 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 = lilv_uri_to_path(lilv_value_as_string(p->dynman_uri)); + const char* lib_path = lilv_uri_to_path(lilv_node_as_string(p->dynman_uri)); void* lib = dlopen(lib_path, RTLD_LAZY); if (!lib) { LILV_WARNF("Unable to open dynamic manifest %s\n", - lilv_value_as_string(p->dynman_uri)); + lilv_node_as_string(p->dynman_uri)); return; } @@ -146,11 +146,11 @@ lilv_plugin_load(LilvPlugin* p) lib, "lv2_dyn_manifest_get_data"); if (get_data_func) { FILE* fd = tmpfile(); - get_data_func(handle, fd, lilv_value_as_string(p->plugin_uri)); + get_data_func(handle, fd, lilv_node_as_string(p->plugin_uri)); rewind(fd); sord_read_file_handle(p->world->model, fd, - (const uint8_t*)lilv_value_as_uri(p->dynman_uri), + (const uint8_t*)lilv_node_as_uri(p->dynman_uri), p->bundle_uri->val.uri_val, lilv_world_blank_node_prefix(p->world)); fclose(fd); @@ -184,12 +184,12 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) NULL); FOREACH_MATCH(ports) { - LilvValue* index = NULL; + LilvNode* index = NULL; const SordNode* port = lilv_match_object(ports); - LilvValue* symbol = lilv_plugin_get_unique( + LilvNode* symbol = lilv_plugin_get_unique( p, port, p->world->lv2_symbol_node); - if (!lilv_value_is_string(symbol)) { + if (!lilv_node_is_string(symbol)) { LILV_ERROR("port has a non-string symbol\n"); p->num_ports = 0; goto error; @@ -197,13 +197,13 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) index = lilv_plugin_get_unique(p, port, p->world->lv2_index_node); - if (!lilv_value_is_int(index)) { + if (!lilv_node_is_int(index)) { LILV_ERROR("port has a non-integer index\n"); p->num_ports = 0; goto error; } - uint32_t this_index = lilv_value_as_int(index); + uint32_t this_index = lilv_node_as_int(index); LilvPort* this_port = NULL; if (p->num_ports > this_index) { this_port = p->ports[this_index]; @@ -218,7 +218,7 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) if (!this_port) { this_port = lilv_port_new(p->world, this_index, - lilv_value_as_string(symbol)); + lilv_node_as_string(symbol)); p->ports[this_index] = this_port; } @@ -229,7 +229,7 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) if (sord_node_get_type(type) == SORD_URI) { lilv_array_append( this_port->classes, - lilv_value_new_from_node(p->world, type)); + lilv_node_new_from_node(p->world, type)); } else { LILV_WARN("port has non-URI rdf:type\n"); } @@ -237,8 +237,8 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) lilv_match_end(types); error: - lilv_value_free(symbol); - lilv_value_free(index); + lilv_node_free(symbol); + lilv_node_free(index); if (p->num_ports == 0) { if (p->ports) { for (uint32_t i = 0; i < p->num_ports; ++i) @@ -261,7 +261,7 @@ lilv_plugin_load_if_necessary(const LilvPlugin* p) } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_get_uri(const LilvPlugin* p) { assert(p); @@ -270,7 +270,7 @@ lilv_plugin_get_uri(const LilvPlugin* p) } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_get_bundle_uri(const LilvPlugin* p) { assert(p); @@ -279,7 +279,7 @@ lilv_plugin_get_bundle_uri(const LilvPlugin* p) } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_get_library_uri(const LilvPlugin* const_p) { LilvPlugin* p = (LilvPlugin*)const_p; @@ -294,7 +294,7 @@ lilv_plugin_get_library_uri(const LilvPlugin* const_p) FOREACH_MATCH(results) { const SordNode* binary_node = lilv_match_object(results); if (sord_node_get_type(binary_node) == SORD_URI) { - p->binary_uri = lilv_value_new_from_node(p->world, binary_node); + p->binary_uri = lilv_node_new_from_node(p->world, binary_node); break; } } @@ -302,13 +302,13 @@ lilv_plugin_get_library_uri(const LilvPlugin* const_p) } if (!p->binary_uri) { LILV_WARNF("Plugin <%s> has no lv2:binary\n", - lilv_value_as_uri(lilv_plugin_get_uri(p))); + lilv_node_as_uri(lilv_plugin_get_uri(p))); } return p->binary_uri; } LILV_API -const LilvValues* +const LilvNodes* lilv_plugin_get_data_uris(const LilvPlugin* p) { return p->data_uris; @@ -333,20 +333,20 @@ lilv_plugin_get_class(const LilvPlugin* const_p) continue; } - LilvValue* class = lilv_value_new_from_node(p->world, class_node); - if ( ! lilv_value_equals(class, p->world->lv2_plugin_class->uri)) { + LilvNode* class = lilv_node_new_from_node(p->world, class_node); + if ( ! lilv_node_equals(class, p->world->lv2_plugin_class->uri)) { const LilvPluginClass* plugin_class = lilv_plugin_classes_get_by_uri( p->world->plugin_classes, class); if (plugin_class) { ((LilvPlugin*)p)->plugin_class = plugin_class; - lilv_value_free(class); + lilv_node_free(class); break; } } - lilv_value_free(class); + lilv_node_free(class); } lilv_match_end(results); @@ -360,88 +360,88 @@ LILV_API bool lilv_plugin_verify(const LilvPlugin* plugin) { - LilvValue* rdf_type = lilv_new_uri(plugin->world, LILV_NS_RDF "type"); - LilvValues* results = lilv_plugin_get_value(plugin, rdf_type); - lilv_value_free(rdf_type); + LilvNode* rdf_type = lilv_new_uri(plugin->world, LILV_NS_RDF "type"); + LilvNodes* results = lilv_plugin_get_value(plugin, rdf_type); + lilv_node_free(rdf_type); if (!results) { return false; } - lilv_values_free(results); + lilv_nodes_free(results); results = lilv_plugin_get_value(plugin, plugin->world->doap_name_val); if (!results) { return false; } - lilv_values_free(results); - LilvValue* lv2_port = lilv_new_uri(plugin->world, LILV_NS_LV2 "port"); + lilv_nodes_free(results); + LilvNode* lv2_port = lilv_new_uri(plugin->world, LILV_NS_LV2 "port"); results = lilv_plugin_get_value(plugin, lv2_port); - lilv_value_free(lv2_port); + lilv_node_free(lv2_port); if (!results) { return false; } - lilv_values_free(results); + lilv_nodes_free(results); return true; } LILV_API -LilvValue* +LilvNode* lilv_plugin_get_name(const LilvPlugin* plugin) { - LilvValues* results = lilv_plugin_get_value(plugin, + LilvNodes* results = lilv_plugin_get_value(plugin, plugin->world->doap_name_val); - LilvValue* ret = NULL; + LilvNode* ret = NULL; if (results) { - LilvValue* val = lilv_values_get_first(results); - if (lilv_value_is_string(val)) - ret = lilv_value_duplicate(val); - lilv_values_free(results); + LilvNode* val = lilv_nodes_get_first(results); + if (lilv_node_is_string(val)) + ret = lilv_node_duplicate(val); + lilv_nodes_free(results); } if (!ret) LILV_WARNF("<%s> has no (mandatory) doap:name\n", - lilv_value_as_string(lilv_plugin_get_uri(plugin))); + lilv_node_as_string(lilv_plugin_get_uri(plugin))); return ret; } LILV_API -LilvValues* +LilvNodes* lilv_plugin_get_value(const LilvPlugin* p, - const LilvValue* predicate) + const LilvNode* predicate) { return lilv_plugin_get_value_for_subject(p, p->plugin_uri, predicate); } LILV_API -LilvValues* +LilvNodes* lilv_plugin_get_value_for_subject(const LilvPlugin* p, - const LilvValue* subject, - const LilvValue* predicate) + const LilvNode* subject, + const LilvNode* predicate) { lilv_plugin_load_ports_if_necessary(p); - if ( ! lilv_value_is_uri(subject) && ! lilv_value_is_blank(subject)) { + if ( ! lilv_node_is_uri(subject) && ! lilv_node_is_blank(subject)) { LILV_ERROR("Subject is not a resource\n"); return NULL; } - if ( ! lilv_value_is_uri(predicate)) { + if ( ! lilv_node_is_uri(predicate)) { LILV_ERROR("Predicate is not a URI\n"); return NULL; } - SordNode* subject_node = (lilv_value_is_uri(subject)) - ? lilv_node_copy(subject->val.uri_val) + SordNode* subject_node = (lilv_node_is_uri(subject)) + ? sord_node_copy(subject->val.uri_val) : sord_new_blank(p->world->world, - (const uint8_t*)lilv_value_as_blank(subject)); + (const uint8_t*)lilv_node_as_blank(subject)); - LilvValues* ret = lilv_world_query_values(p->world, + LilvNodes* ret = lilv_world_query_values(p->world, subject_node, predicate->val.uri_val, NULL); - lilv_node_free(p->world, subject_node); + sord_node_free(p->world->world, subject_node); return ret; } @@ -456,34 +456,34 @@ lilv_plugin_get_num_ports(const LilvPlugin* p) LILV_API void lilv_plugin_get_port_ranges_float(const LilvPlugin* p, - float* min_values, - float* max_values, - float* def_values) + float* min_values, + float* max_values, + float* def_values) { lilv_plugin_load_ports_if_necessary(p); for (uint32_t i = 0; i < p->num_ports; ++i) { - LilvValue *def, *min, *max; + LilvNode *def, *min, *max; lilv_port_get_range(p, p->ports[i], &def, &min, &max); if (min_values) - min_values[i] = min ? lilv_value_as_float(min) : NAN; + min_values[i] = min ? lilv_node_as_float(min) : NAN; if (max_values) - max_values[i] = max ? lilv_value_as_float(max) : NAN; + max_values[i] = max ? lilv_node_as_float(max) : NAN; if (def_values) - def_values[i] = def ? lilv_value_as_float(def) : NAN; + def_values[i] = def ? lilv_node_as_float(def) : NAN; - lilv_value_free(def); - lilv_value_free(min); - lilv_value_free(max); + lilv_node_free(def); + lilv_node_free(min); + lilv_node_free(max); } } LILV_API uint32_t lilv_plugin_get_num_ports_of_class(const LilvPlugin* p, - const LilvValue* class_1, ...) + const LilvNode* class_1, ...) { lilv_plugin_load_ports_if_necessary(p); @@ -498,7 +498,7 @@ lilv_plugin_get_num_ports_of_class(const LilvPlugin* p, va_start(args, class_1); bool matches = true; - for (LilvValue* class_i = NULL; (class_i = va_arg(args, LilvValue*)) != NULL ; ) { + for (LilvNode* class_i = NULL; (class_i = va_arg(args, LilvNode*)) != NULL ; ) { if (!lilv_port_is_a(p, port, class_i)) { va_end(args); matches = false; @@ -566,11 +566,11 @@ lilv_plugin_get_latency_port_index(const LilvPlugin* p) p->world->lv2_portproperty_node, p->world->lv2_reportslatency_node); if (!lilv_matches_end(reports_latency)) { - LilvValue* index = lilv_plugin_get_unique( + LilvNode* index = lilv_plugin_get_unique( p, port, p->world->lv2_index_node); - ret = lilv_value_as_int(index); - lilv_value_free(index); + ret = lilv_node_as_int(index); + lilv_node_free(index); lilv_match_end(reports_latency); break; } @@ -584,46 +584,46 @@ lilv_plugin_get_latency_port_index(const LilvPlugin* p) LILV_API bool lilv_plugin_has_feature(const LilvPlugin* p, - const LilvValue* feature) + const LilvNode* feature) { - LilvValues* features = lilv_plugin_get_supported_features(p); + LilvNodes* features = lilv_plugin_get_supported_features(p); - const bool ret = features && feature && lilv_values_contains(features, feature); + const bool ret = features && feature && lilv_nodes_contains(features, feature); - lilv_values_free(features); + lilv_nodes_free(features); return ret; } LILV_API -LilvValues* +LilvNodes* lilv_plugin_get_supported_features(const LilvPlugin* p) { - LilvValues* optional = lilv_plugin_get_optional_features(p); - LilvValues* required = lilv_plugin_get_required_features(p); - LilvValues* result = lilv_values_new(); + LilvNodes* optional = lilv_plugin_get_optional_features(p); + LilvNodes* required = lilv_plugin_get_required_features(p); + LilvNodes* result = lilv_nodes_new(); - LILV_FOREACH(values, i, optional) + LILV_FOREACH(nodes, i, optional) lilv_array_append( - result, lilv_value_duplicate(lilv_values_get(optional, i))); - LILV_FOREACH(values, i, required) + result, lilv_node_duplicate(lilv_nodes_get(optional, i))); + LILV_FOREACH(nodes, i, required) lilv_array_append( - result, lilv_value_duplicate(lilv_values_get(required, i))); + result, lilv_node_duplicate(lilv_nodes_get(required, i))); - lilv_values_free(optional); - lilv_values_free(required); + lilv_nodes_free(optional); + lilv_nodes_free(required); return result; } LILV_API -LilvValues* +LilvNodes* lilv_plugin_get_optional_features(const LilvPlugin* p) { return lilv_plugin_get_value(p, p->world->lv2_optionalFeature_val); } LILV_API -LilvValues* +LilvNodes* lilv_plugin_get_required_features(const LilvPlugin* p) { return lilv_plugin_get_value(p, p->world->lv2_requiredFeature_val); @@ -644,12 +644,12 @@ lilv_plugin_get_port_by_index(const LilvPlugin* p, LILV_API const LilvPort* lilv_plugin_get_port_by_symbol(const LilvPlugin* p, - const LilvValue* symbol) + const LilvNode* symbol) { lilv_plugin_load_ports_if_necessary(p); for (uint32_t i = 0; i < p->num_ports; ++i) { LilvPort* port = p->ports[i]; - if (lilv_value_equals(port->symbol, symbol)) + if (lilv_node_equals(port->symbol, symbol)) return port; } @@ -670,7 +670,7 @@ lilv_plugin_get_author(const LilvPlugin* p) doap_maintainer, NULL); - lilv_node_free(p->world, doap_maintainer); + sord_node_free(p->world->world, doap_maintainer); if (lilv_matches_end(maintainers)) { return NULL; @@ -683,7 +683,7 @@ lilv_plugin_get_author(const LilvPlugin* p) } LILV_API -LilvValue* +LilvNode* lilv_plugin_get_author_name(const LilvPlugin* plugin) { const SordNode* author = lilv_plugin_get_author(plugin); @@ -696,7 +696,7 @@ lilv_plugin_get_author_name(const LilvPlugin* plugin) } LILV_API -LilvValue* +LilvNode* lilv_plugin_get_author_email(const LilvPlugin* plugin) { const SordNode* author = lilv_plugin_get_author(plugin); @@ -709,7 +709,7 @@ lilv_plugin_get_author_email(const LilvPlugin* plugin) } LILV_API -LilvValue* +LilvNode* lilv_plugin_get_author_homepage(const LilvPlugin* plugin) { const SordNode* author = lilv_plugin_get_author(plugin); @@ -746,21 +746,21 @@ lilv_plugin_get_uis(const LilvPlugin* p) FOREACH_MATCH(uis) { const SordNode* ui = lilv_match_object(uis); - LilvValue* type = lilv_plugin_get_unique(p, ui, p->world->rdf_a_node); - LilvValue* binary = lilv_plugin_get_unique(p, ui, ui_binary_node); + LilvNode* type = lilv_plugin_get_unique(p, ui, p->world->rdf_a_node); + LilvNode* binary = lilv_plugin_get_unique(p, ui, ui_binary_node); if (sord_node_get_type(ui) != SORD_URI - || !lilv_value_is_uri(type) - || !lilv_value_is_uri(binary)) { - lilv_value_free(binary); - lilv_value_free(type); + || !lilv_node_is_uri(type) + || !lilv_node_is_uri(binary)) { + lilv_node_free(binary); + lilv_node_free(type); LILV_ERROR("Corrupt UI\n"); continue; } LilvUI* lilv_ui = lilv_ui_new( p->world, - lilv_value_new_from_node(p->world, ui), + lilv_node_new_from_node(p->world, ui), type, binary); @@ -768,8 +768,8 @@ lilv_plugin_get_uis(const LilvPlugin* p) } lilv_match_end(uis); - lilv_node_free(p->world, ui_binary_node); - lilv_node_free(p->world, ui_ui_node); + sord_node_free(p->world->world, ui_binary_node); + sord_node_free(p->world->world, ui_ui_node); if (lilv_uis_size(result) > 0) { return result; diff --git a/src/pluginclass.c b/src/pluginclass.c index 60e57dc..cceda49 100644 --- a/src/pluginclass.c +++ b/src/pluginclass.c @@ -33,10 +33,10 @@ lilv_plugin_class_new(LilvWorld* world, } LilvPluginClass* pc = malloc(sizeof(struct LilvPluginClassImpl)); pc->world = world; - pc->uri = lilv_value_new_from_node(world, uri); - pc->label = lilv_value_new(world, LILV_VALUE_STRING, label); + pc->uri = lilv_node_new_from_node(world, uri); + pc->label = lilv_node_new(world, LILV_VALUE_STRING, label); pc->parent_uri = (parent_node) - ? lilv_value_new_from_node(world, parent_node) + ? lilv_node_new_from_node(world, parent_node) : NULL; return pc; } @@ -45,14 +45,14 @@ void lilv_plugin_class_free(LilvPluginClass* plugin_class) { assert(plugin_class->uri); - lilv_value_free(plugin_class->uri); - lilv_value_free(plugin_class->parent_uri); - lilv_value_free(plugin_class->label); + lilv_node_free(plugin_class->uri); + lilv_node_free(plugin_class->parent_uri); + lilv_node_free(plugin_class->label); free(plugin_class); } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_class_get_parent_uri(const LilvPluginClass* plugin_class) { if (plugin_class->parent_uri) @@ -62,7 +62,7 @@ lilv_plugin_class_get_parent_uri(const LilvPluginClass* plugin_class) } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_class_get_uri(const LilvPluginClass* plugin_class) { assert(plugin_class->uri); @@ -70,7 +70,7 @@ lilv_plugin_class_get_uri(const LilvPluginClass* plugin_class) } LILV_API -const LilvValue* +const LilvNode* lilv_plugin_class_get_label(const LilvPluginClass* plugin_class) { return plugin_class->label; @@ -88,8 +88,8 @@ lilv_plugin_class_get_children(const LilvPluginClass* plugin_class) i != g_sequence_get_end_iter(all); i = g_sequence_iter_next(i)) { const LilvPluginClass* c = g_sequence_get(i); - const LilvValue* parent = lilv_plugin_class_get_parent_uri(c); - if (parent && lilv_value_equals(lilv_plugin_class_get_uri(plugin_class), + const LilvNode* parent = lilv_plugin_class_get_parent_uri(c); + if (parent && lilv_node_equals(lilv_plugin_class_get_uri(plugin_class), parent)) lilv_sequence_insert(result, (LilvPluginClass*)c); } diff --git a/src/port.c b/src/port.c index 6f3f560..ba80749 100644 --- a/src/port.c +++ b/src/port.c @@ -29,16 +29,16 @@ lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol) { LilvPort* port = malloc(sizeof(struct LilvPortImpl)); port->index = index; - port->symbol = lilv_value_new(world, LILV_VALUE_STRING, symbol); - port->classes = lilv_values_new(); + port->symbol = lilv_node_new(world, LILV_VALUE_STRING, symbol); + port->classes = lilv_nodes_new(); return port; } void lilv_port_free(LilvPort* port) { - lilv_values_free(port->classes); - lilv_value_free(port->symbol); + lilv_nodes_free(port->classes); + lilv_node_free(port->symbol); free(port); } @@ -46,10 +46,10 @@ LILV_API bool lilv_port_is_a(const LilvPlugin* plugin, const LilvPort* port, - const LilvValue* port_class) + const LilvNode* port_class) { - LILV_FOREACH(values, i, port->classes) - if (lilv_value_equals(lilv_values_get(port->classes, i), port_class)) + LILV_FOREACH(nodes, i, port->classes) + if (lilv_node_equals(lilv_nodes_get(port->classes, i), port_class)) return true; return false; @@ -67,15 +67,15 @@ lilv_port_get_node(const LilvPlugin* p, const SordNode* ret = NULL; FOREACH_MATCH(ports) { const SordNode* node = lilv_match_object(ports); - LilvValue* symbol = lilv_plugin_get_unique( + LilvNode* symbol = lilv_plugin_get_unique( p, node, p->world->lv2_symbol_node); - const bool matches = lilv_value_equals(symbol, + const bool matches = lilv_node_equals(symbol, lilv_port_get_symbol(p, port)); - lilv_value_free(symbol); + lilv_node_free(symbol); if (matches) { ret = node; break; @@ -90,7 +90,7 @@ LILV_API bool lilv_port_has_property(const LilvPlugin* p, const LilvPort* port, - const LilvValue* property) + const LilvNode* property) { assert(property); const SordNode* port_node = lilv_port_get_node(p, port); @@ -98,7 +98,7 @@ lilv_port_has_property(const LilvPlugin* p, p->world, port_node, p->world->lv2_portproperty_node, - lilv_value_as_node(property)); + lilv_node_as_node(property)); const bool ret = !lilv_matches_end(results); lilv_match_end(results); @@ -109,7 +109,7 @@ LILV_API bool lilv_port_supports_event(const LilvPlugin* p, const LilvPort* port, - const LilvValue* event) + const LilvNode* event) { #define NS_EV (const uint8_t*)"http://lv2plug.in/ns/ext/event#" @@ -119,14 +119,14 @@ lilv_port_supports_event(const LilvPlugin* p, p->world, port_node, sord_new_uri(p->world->world, NS_EV "supportsEvent"), - lilv_value_as_node(event)); + lilv_node_as_node(event)); const bool ret = !lilv_matches_end(results); lilv_match_end(results); return ret; } -static LilvValues* +static LilvNodes* lilv_port_get_value_by_node(const LilvPlugin* p, const LilvPort* port, const SordNode* predicate) @@ -140,27 +140,27 @@ lilv_port_get_value_by_node(const LilvPlugin* p, predicate, NULL); - return lilv_values_from_stream_objects(p->world, results); + return lilv_nodes_from_stream_objects(p->world, results); } LILV_API -LilvValues* +LilvNodes* lilv_port_get_value(const LilvPlugin* p, const LilvPort* port, - const LilvValue* predicate) + const LilvNode* predicate) { - if ( ! lilv_value_is_uri(predicate)) { + if ( ! lilv_node_is_uri(predicate)) { LILV_ERROR("Predicate is not a URI\n"); return NULL; } return lilv_port_get_value_by_node( p, port, - lilv_value_as_node(predicate)); + lilv_node_as_node(predicate)); } LILV_API -const LilvValue* +const LilvNode* lilv_port_get_symbol(const LilvPlugin* p, const LilvPort* port) { @@ -168,30 +168,30 @@ lilv_port_get_symbol(const LilvPlugin* p, } LILV_API -LilvValue* +LilvNode* lilv_port_get_name(const LilvPlugin* p, const LilvPort* port) { - LilvValues* results = lilv_port_get_value(p, port, + LilvNodes* results = lilv_port_get_value(p, port, p->world->lv2_name_val); - LilvValue* ret = NULL; + LilvNode* ret = NULL; if (results) { - LilvValue* val = lilv_values_get_first(results); - if (lilv_value_is_string(val)) - ret = lilv_value_duplicate(val); - lilv_values_free(results); + LilvNode* val = lilv_nodes_get_first(results); + if (lilv_node_is_string(val)) + ret = lilv_node_duplicate(val); + lilv_nodes_free(results); } if (!ret) LILV_WARNF("<%s> has no (mandatory) doap:name\n", - lilv_value_as_string(lilv_plugin_get_uri(p))); + lilv_node_as_string(lilv_plugin_get_uri(p))); return ret; } LILV_API -const LilvValues* +const LilvNodes* lilv_port_get_classes(const LilvPlugin* p, const LilvPort* port) { @@ -202,33 +202,33 @@ LILV_API void lilv_port_get_range(const LilvPlugin* p, const LilvPort* port, - LilvValue** def, - LilvValue** min, - LilvValue** max) + LilvNode** def, + LilvNode** min, + LilvNode** max) { if (def) { - LilvValues* defaults = lilv_port_get_value_by_node( + LilvNodes* defaults = lilv_port_get_value_by_node( p, port, p->world->lv2_default_node); *def = defaults - ? lilv_value_duplicate(lilv_values_get_first(defaults)) + ? lilv_node_duplicate(lilv_nodes_get_first(defaults)) : NULL; - lilv_values_free(defaults); + lilv_nodes_free(defaults); } if (min) { - LilvValues* minimums = lilv_port_get_value_by_node( + LilvNodes* minimums = lilv_port_get_value_by_node( p, port, p->world->lv2_minimum_node); *min = minimums - ? lilv_value_duplicate(lilv_values_get_first(minimums)) + ? lilv_node_duplicate(lilv_nodes_get_first(minimums)) : NULL; - lilv_values_free(minimums); + lilv_nodes_free(minimums); } if (max) { - LilvValues* maximums = lilv_port_get_value_by_node( + LilvNodes* maximums = lilv_port_get_value_by_node( p, port, p->world->lv2_maximum_node); *max = maximums - ? lilv_value_duplicate(lilv_values_get_first(maximums)) + ? lilv_node_duplicate(lilv_nodes_get_first(maximums)) : NULL; - lilv_values_free(maximums); + lilv_nodes_free(maximums); } } @@ -251,12 +251,12 @@ lilv_port_get_scale_points(const LilvPlugin* p, FOREACH_MATCH(points) { const SordNode* point = lilv_match_object(points); - LilvValue* value = lilv_plugin_get_unique( + LilvNode* value = lilv_plugin_get_unique( p, point, p->world->rdf_value_node); - LilvValue* label = lilv_plugin_get_unique( + LilvNode* label = lilv_plugin_get_unique( p, point, p->world->rdfs_label_node); @@ -267,18 +267,18 @@ lilv_port_get_scale_points(const LilvPlugin* p, } lilv_match_end(points); - assert(!ret || lilv_values_size(ret) > 0); + assert(!ret || lilv_nodes_size(ret) > 0); return ret; } LILV_API -LilvValues* +LilvNodes* lilv_port_get_properties(const LilvPlugin* p, const LilvPort* port) { - LilvValue* pred = lilv_value_new_from_node( + LilvNode* pred = lilv_node_new_from_node( p->world, p->world->lv2_portproperty_node); - LilvValues* ret = lilv_port_get_value(p, port, pred); - lilv_value_free(pred); + LilvNodes* ret = lilv_port_get_value(p, port, pred); + lilv_node_free(pred); return ret; } diff --git a/src/query.c b/src/query.c index c55fe5b..c64b8c4 100644 --- a/src/query.c +++ b/src/query.c @@ -53,11 +53,11 @@ lilv_lang_matches(const char* a, const char* b) return LILV_LANG_MATCH_NONE; } -LilvValues* -lilv_values_from_stream_objects_i18n(LilvWorld* world, +LilvNodes* +lilv_nodes_from_stream_objects_i18n(LilvWorld* world, SordIter* stream) { - LilvValues* values = lilv_values_new(); + LilvNodes* values = lilv_nodes_new(); const SordNode* nolang = NULL; // Untranslated value const SordNode* partial = NULL; // Partial language match char* syslang = lilv_get_lang(); @@ -79,19 +79,19 @@ lilv_values_from_stream_objects_i18n(LilvWorld* world, if (lm == LILV_LANG_MATCH_EXACT) { // Exact language match, add to results - lilv_array_append(values, lilv_value_new_from_node(world, value)); + lilv_array_append(values, lilv_node_new_from_node(world, value)); } else if (lm == LILV_LANG_MATCH_PARTIAL) { // Partial language match, save in case we find no exact partial = value; } } else { - lilv_array_append(values, lilv_value_new_from_node(world, value)); + lilv_array_append(values, lilv_node_new_from_node(world, value)); } } lilv_match_end(stream); free(syslang); - if (lilv_values_size(values) > 0) { + if (lilv_nodes_size(values) > 0) { return values; } @@ -106,29 +106,29 @@ lilv_values_from_stream_objects_i18n(LilvWorld* world, } if (best) { - lilv_array_append(values, lilv_value_new_from_node(world, best)); + lilv_array_append(values, lilv_node_new_from_node(world, best)); } else { // No matches whatsoever - lilv_values_free(values); + lilv_nodes_free(values); values = NULL; } return values; } -LilvValues* -lilv_values_from_stream_objects(LilvWorld* world, +LilvNodes* +lilv_nodes_from_stream_objects(LilvWorld* world, SordIter* stream) { if (lilv_matches_end(stream)) { lilv_match_end(stream); return NULL; } else if (world->opt.filter_language) { - return lilv_values_from_stream_objects_i18n(world, stream); + return lilv_nodes_from_stream_objects_i18n(world, stream); } else { - LilvValues* values = lilv_values_new(); + LilvNodes* values = lilv_nodes_new(); FOREACH_MATCH(stream) { - LilvValue* value = lilv_value_new_from_node( + LilvNode* value = lilv_node_new_from_node( world, lilv_match_object(stream)); if (value) { lilv_array_append(values, value); diff --git a/src/scalepoint.c b/src/scalepoint.c index 0f3c7f6..6995b85 100644 --- a/src/scalepoint.c +++ b/src/scalepoint.c @@ -18,7 +18,7 @@ /** Ownership of value and label is taken */ LilvScalePoint* -lilv_scale_point_new(LilvValue* value, LilvValue* label) +lilv_scale_point_new(LilvNode* value, LilvNode* label) { LilvScalePoint* point = (LilvScalePoint*)malloc( sizeof(struct LilvScalePointImpl)); @@ -30,20 +30,20 @@ lilv_scale_point_new(LilvValue* value, LilvValue* label) void lilv_scale_point_free(LilvScalePoint* point) { - lilv_value_free(point->value); - lilv_value_free(point->label); + lilv_node_free(point->value); + lilv_node_free(point->label); free(point); } LILV_API -const LilvValue* +const LilvNode* lilv_scale_point_get_value(const LilvScalePoint* p) { return p->value; } LILV_API -const LilvValue* +const LilvNode* lilv_scale_point_get_label(const LilvScalePoint* p) { return p->label; diff --git a/src/ui.c b/src/ui.c index a2df5f2..36287e1 100644 --- a/src/ui.c +++ b/src/ui.c @@ -24,9 +24,9 @@ LilvUI* lilv_ui_new(LilvWorld* world, - LilvValue* uri, - LilvValue* type_uri, - LilvValue* binary_uri) + LilvNode* uri, + LilvNode* type_uri, + LilvNode* binary_uri) { assert(uri); assert(type_uri); @@ -38,13 +38,13 @@ lilv_ui_new(LilvWorld* world, ui->binary_uri = binary_uri; // FIXME: kludge - char* bundle = lilv_strdup(lilv_value_as_string(ui->binary_uri)); + char* bundle = lilv_strdup(lilv_node_as_string(ui->binary_uri)); char* last_slash = strrchr(bundle, '/') + 1; *last_slash = '\0'; ui->bundle_uri = lilv_new_uri(world, bundle); free(bundle); - ui->classes = lilv_values_new(); + ui->classes = lilv_nodes_new(); lilv_array_append(ui->classes, type_uri); return ui; @@ -53,22 +53,22 @@ lilv_ui_new(LilvWorld* world, void lilv_ui_free(LilvUI* ui) { - lilv_value_free(ui->uri); + lilv_node_free(ui->uri); ui->uri = NULL; - lilv_value_free(ui->bundle_uri); + lilv_node_free(ui->bundle_uri); ui->bundle_uri = NULL; - lilv_value_free(ui->binary_uri); + lilv_node_free(ui->binary_uri); ui->binary_uri = NULL; - lilv_values_free(ui->classes); + lilv_nodes_free(ui->classes); free(ui); } LILV_API -const LilvValue* +const LilvNode* lilv_ui_get_uri(const LilvUI* ui) { assert(ui); @@ -80,18 +80,18 @@ LILV_API unsigned lilv_ui_is_supported(const LilvUI* ui, LilvUISupportedFunc supported_func, - const LilvValue* container_type, - const LilvValue** ui_type) + const LilvNode* container_type, + const LilvNode** ui_type) { #ifdef HAVE_SUIL - const LilvValues* classes = lilv_ui_get_classes(ui); - LILV_FOREACH(values, c, classes) { - const LilvValue* type = lilv_values_get(classes, c); - const unsigned q = supported_func(lilv_value_as_uri(container_type), - lilv_value_as_uri(type)); + const LilvNodes* classes = lilv_ui_get_classes(ui); + LILV_FOREACH(nodes, c, classes) { + const LilvNode* type = lilv_nodes_get(classes, c); + const unsigned q = supported_func(lilv_node_as_uri(container_type), + lilv_node_as_uri(type)); if (q) { if (ui_type) { - *ui_type = lilv_value_duplicate(type); + *ui_type = lilv_node_duplicate(type); } return q; } @@ -101,7 +101,7 @@ lilv_ui_is_supported(const LilvUI* ui, } LILV_API -const LilvValues* +const LilvNodes* lilv_ui_get_classes(const LilvUI* ui) { return ui->classes; @@ -109,13 +109,13 @@ lilv_ui_get_classes(const LilvUI* ui) LILV_API bool -lilv_ui_is_a(const LilvUI* ui, const LilvValue* ui_class_uri) +lilv_ui_is_a(const LilvUI* ui, const LilvNode* ui_class_uri) { - return lilv_values_contains(ui->classes, ui_class_uri); + return lilv_nodes_contains(ui->classes, ui_class_uri); } LILV_API -const LilvValue* +const LilvNode* lilv_ui_get_bundle_uri(const LilvUI* ui) { assert(ui); @@ -124,7 +124,7 @@ lilv_ui_get_bundle_uri(const LilvUI* ui) } LILV_API -const LilvValue* +const LilvNode* lilv_ui_get_binary_uri(const LilvUI* ui) { assert(ui); diff --git a/src/value.c b/src/value.c index f50c6bd..8fbf5b1 100644 --- a/src/value.c +++ b/src/value.c @@ -26,7 +26,7 @@ #include "lilv_internal.h" static void -lilv_value_set_numerics_from_string(LilvValue* val) +lilv_node_set_numerics_from_string(LilvNode* val) { char* locale; char* endptr; @@ -59,14 +59,14 @@ lilv_value_set_numerics_from_string(LilvValue* val) } /** Note that if @a type is numeric or boolean, the returned value is corrupt - * until lilv_value_set_numerics_from_string is called. It is not + * until lilv_node_set_numerics_from_string is called. It is not * automatically called from here to avoid overhead and imprecision when the * exact string value is known. */ -LilvValue* -lilv_value_new(LilvWorld* world, LilvValueType type, const char* str) +LilvNode* +lilv_node_new(LilvWorld* world, LilvNodeType type, const char* str) { - LilvValue* val = malloc(sizeof(struct LilvValueImpl)); + LilvNode* val = malloc(sizeof(struct LilvNodeImpl)); val->world = world; val->type = type; @@ -88,21 +88,21 @@ lilv_value_new(LilvWorld* world, LilvValueType type, const char* str) return val; } -/** Create a new LilvValue from @a node, or return NULL if impossible */ -LilvValue* -lilv_value_new_from_node(LilvWorld* world, const SordNode* node) +/** Create a new LilvNode from @a node, or return NULL if impossible */ +LilvNode* +lilv_node_new_from_node(LilvWorld* world, const SordNode* node) { - LilvValue* result = NULL; + LilvNode* result = NULL; SordNode* datatype_uri = NULL; - LilvValueType type = LILV_VALUE_STRING; + LilvNodeType type = LILV_VALUE_STRING; switch (sord_node_get_type(node)) { case SORD_URI: type = LILV_VALUE_URI; - result = malloc(sizeof(struct LilvValueImpl)); + result = malloc(sizeof(struct LilvNodeImpl)); result->world = world; result->type = LILV_VALUE_URI; - result->val.uri_val = lilv_node_copy(node); + result->val.uri_val = sord_node_copy(node); result->str_val = (char*)sord_node_get_string(result->val.uri_val); break; case SORD_LITERAL: @@ -118,19 +118,19 @@ lilv_value_new_from_node(LilvWorld* world, const SordNode* node) else LILV_ERRORF("Unknown datatype %s\n", sord_node_get_string(datatype_uri)); } - result = lilv_value_new(world, type, (const char*)sord_node_get_string(node)); + result = lilv_node_new(world, type, (const char*)sord_node_get_string(node)); switch (result->type) { case LILV_VALUE_INT: case LILV_VALUE_FLOAT: case LILV_VALUE_BOOL: - lilv_value_set_numerics_from_string(result); + lilv_node_set_numerics_from_string(result); default: break; } break; case SORD_BLANK: type = LILV_VALUE_BLANK; - result = lilv_value_new(world, type, (const char*)sord_node_get_string(node)); + result = lilv_node_new(world, type, (const char*)sord_node_get_string(node)); break; default: assert(false); @@ -140,63 +140,63 @@ lilv_value_new_from_node(LilvWorld* world, const SordNode* node) } LILV_API -LilvValue* +LilvNode* lilv_new_uri(LilvWorld* world, const char* uri) { - return lilv_value_new(world, LILV_VALUE_URI, uri); + return lilv_node_new(world, LILV_VALUE_URI, uri); } LILV_API -LilvValue* +LilvNode* lilv_new_string(LilvWorld* world, const char* str) { - return lilv_value_new(world, LILV_VALUE_STRING, str); + return lilv_node_new(world, LILV_VALUE_STRING, str); } LILV_API -LilvValue* +LilvNode* lilv_new_int(LilvWorld* world, int val) { char str[32]; snprintf(str, sizeof(str), "%d", val); - LilvValue* ret = lilv_value_new(world, LILV_VALUE_INT, str); + LilvNode* ret = lilv_node_new(world, LILV_VALUE_INT, str); ret->val.int_val = val; return ret; } LILV_API -LilvValue* +LilvNode* lilv_new_float(LilvWorld* world, float val) { char str[32]; snprintf(str, sizeof(str), "%f", val); - LilvValue* ret = lilv_value_new(world, LILV_VALUE_FLOAT, str); + LilvNode* ret = lilv_node_new(world, LILV_VALUE_FLOAT, str); ret->val.float_val = val; return ret; } LILV_API -LilvValue* +LilvNode* lilv_new_bool(LilvWorld* world, bool val) { - LilvValue* ret = lilv_value_new(world, LILV_VALUE_BOOL, val ? "true" : "false"); + LilvNode* ret = lilv_node_new(world, LILV_VALUE_BOOL, val ? "true" : "false"); ret->val.bool_val = val; return ret; } LILV_API -LilvValue* -lilv_value_duplicate(const LilvValue* val) +LilvNode* +lilv_node_duplicate(const LilvNode* val) { if (val == NULL) return NULL; - LilvValue* result = malloc(sizeof(struct LilvValueImpl)); + LilvNode* result = malloc(sizeof(struct LilvNodeImpl)); result->world = val->world; result->type = val->type; if (val->type == LILV_VALUE_URI) { - result->val.uri_val = lilv_node_copy(val->val.uri_val); + result->val.uri_val = sord_node_copy(val->val.uri_val); result->str_val = (char*)sord_node_get_string(result->val.uri_val); } else { result->str_val = lilv_strdup(val->str_val); @@ -208,11 +208,11 @@ lilv_value_duplicate(const LilvValue* val) LILV_API void -lilv_value_free(LilvValue* val) +lilv_node_free(LilvNode* val) { if (val) { if (val->type == LILV_VALUE_URI) { - lilv_node_free(val->world, val->val.uri_val); + sord_node_free(val->world->world, val->val.uri_val); } else { free(val->str_val); } @@ -222,7 +222,7 @@ lilv_value_free(LilvValue* val) LILV_API bool -lilv_value_equals(const LilvValue* value, const LilvValue* other) +lilv_node_equals(const LilvNode* value, const LilvNode* other) { if (value == NULL && other == NULL) return true; @@ -250,7 +250,7 @@ lilv_value_equals(const LilvValue* value, const LilvValue* other) LILV_API char* -lilv_value_get_turtle_token(const LilvValue* value) +lilv_node_get_turtle_token(const LilvNode* value) { size_t len = 0; char* result = NULL; @@ -299,44 +299,44 @@ lilv_value_get_turtle_token(const LilvValue* value) LILV_API bool -lilv_value_is_uri(const LilvValue* value) +lilv_node_is_uri(const LilvNode* value) { return (value && value->type == LILV_VALUE_URI); } LILV_API const char* -lilv_value_as_uri(const LilvValue* value) +lilv_node_as_uri(const LilvNode* value) { - assert(lilv_value_is_uri(value)); + assert(lilv_node_is_uri(value)); return value->str_val; } const SordNode* -lilv_value_as_node(const LilvValue* value) +lilv_node_as_node(const LilvNode* value) { - assert(lilv_value_is_uri(value)); + assert(lilv_node_is_uri(value)); return value->val.uri_val; } LILV_API bool -lilv_value_is_blank(const LilvValue* value) +lilv_node_is_blank(const LilvNode* value) { return (value && value->type == LILV_VALUE_BLANK); } LILV_API const char* -lilv_value_as_blank(const LilvValue* value) +lilv_node_as_blank(const LilvNode* value) { - assert(lilv_value_is_blank(value)); + assert(lilv_node_is_blank(value)); return value->str_val; } LILV_API bool -lilv_value_is_literal(const LilvValue* value) +lilv_node_is_literal(const LilvNode* value) { if (!value) return false; @@ -353,64 +353,64 @@ lilv_value_is_literal(const LilvValue* value) LILV_API bool -lilv_value_is_string(const LilvValue* value) +lilv_node_is_string(const LilvNode* value) { return (value && value->type == LILV_VALUE_STRING); } LILV_API const char* -lilv_value_as_string(const LilvValue* value) +lilv_node_as_string(const LilvNode* value) { return value->str_val; } LILV_API bool -lilv_value_is_int(const LilvValue* value) +lilv_node_is_int(const LilvNode* value) { return (value && value->type == LILV_VALUE_INT); } LILV_API int -lilv_value_as_int(const LilvValue* value) +lilv_node_as_int(const LilvNode* value) { assert(value); - assert(lilv_value_is_int(value)); + assert(lilv_node_is_int(value)); return value->val.int_val; } LILV_API bool -lilv_value_is_float(const LilvValue* value) +lilv_node_is_float(const LilvNode* value) { return (value && value->type == LILV_VALUE_FLOAT); } LILV_API float -lilv_value_as_float(const LilvValue* value) +lilv_node_as_float(const LilvNode* value) { - assert(lilv_value_is_float(value) || lilv_value_is_int(value)); - if (lilv_value_is_float(value)) + assert(lilv_node_is_float(value) || lilv_node_is_int(value)); + if (lilv_node_is_float(value)) return value->val.float_val; - else // lilv_value_is_int(value) + else // lilv_node_is_int(value) return (float)value->val.int_val; } LILV_API bool -lilv_value_is_bool(const LilvValue* value) +lilv_node_is_bool(const LilvNode* value) { return (value && value->type == LILV_VALUE_BOOL); } LILV_API bool -lilv_value_as_bool(const LilvValue* value) +lilv_node_as_bool(const LilvNode* value) { assert(value); - assert(lilv_value_is_bool(value)); + assert(lilv_node_is_bool(value)); return value->val.bool_val; } diff --git a/src/world.c b/src/world.c index 8bc4b49..9d6ac45 100644 --- a/src/world.c +++ b/src/world.c @@ -121,39 +121,39 @@ lilv_world_free(LilvWorld* world) lilv_plugin_class_free(world->lv2_plugin_class); world->lv2_plugin_class = NULL; - lilv_node_free(world, world->dc_replaces_node); - lilv_node_free(world, world->dyn_manifest_node); - lilv_node_free(world, world->lv2_binary_node); - lilv_node_free(world, world->lv2_default_node); - lilv_node_free(world, world->lv2_index_node); - lilv_node_free(world, world->lv2_maximum_node); - lilv_node_free(world, world->lv2_minimum_node); - lilv_node_free(world, world->lv2_plugin_node); - lilv_node_free(world, world->lv2_port_node); - lilv_node_free(world, world->lv2_portproperty_node); - lilv_node_free(world, world->lv2_reportslatency_node); - lilv_node_free(world, world->lv2_specification_node); - lilv_node_free(world, world->lv2_symbol_node); - lilv_node_free(world, world->rdf_a_node); - lilv_node_free(world, world->rdf_value_node); - lilv_node_free(world, world->rdfs_class_node); - lilv_node_free(world, world->rdfs_label_node); - lilv_node_free(world, world->rdfs_seealso_node); - lilv_node_free(world, world->rdfs_subclassof_node); - lilv_node_free(world, world->xsd_boolean_node); - lilv_node_free(world, world->xsd_decimal_node); - lilv_node_free(world, world->xsd_double_node); - lilv_node_free(world, world->xsd_integer_node); - lilv_value_free(world->doap_name_val); - lilv_value_free(world->lv2_name_val); - lilv_value_free(world->lv2_optionalFeature_val); - lilv_value_free(world->lv2_requiredFeature_val); + sord_node_free(world->world, world->dc_replaces_node); + sord_node_free(world->world, world->dyn_manifest_node); + sord_node_free(world->world, world->lv2_binary_node); + sord_node_free(world->world, world->lv2_default_node); + sord_node_free(world->world, world->lv2_index_node); + sord_node_free(world->world, world->lv2_maximum_node); + sord_node_free(world->world, world->lv2_minimum_node); + sord_node_free(world->world, world->lv2_plugin_node); + sord_node_free(world->world, world->lv2_port_node); + sord_node_free(world->world, world->lv2_portproperty_node); + sord_node_free(world->world, world->lv2_reportslatency_node); + sord_node_free(world->world, world->lv2_specification_node); + sord_node_free(world->world, world->lv2_symbol_node); + sord_node_free(world->world, world->rdf_a_node); + sord_node_free(world->world, world->rdf_value_node); + sord_node_free(world->world, world->rdfs_class_node); + sord_node_free(world->world, world->rdfs_label_node); + sord_node_free(world->world, world->rdfs_seealso_node); + sord_node_free(world->world, world->rdfs_subclassof_node); + sord_node_free(world->world, world->xsd_boolean_node); + sord_node_free(world->world, world->xsd_decimal_node); + sord_node_free(world->world, world->xsd_double_node); + sord_node_free(world->world, world->xsd_integer_node); + lilv_node_free(world->doap_name_val); + lilv_node_free(world->lv2_name_val); + lilv_node_free(world->lv2_optionalFeature_val); + lilv_node_free(world->lv2_requiredFeature_val); for (GSList* l = world->specs; l; l = l->next) { LilvSpec* spec = (LilvSpec*)l->data; - lilv_node_free(world, spec->spec); - lilv_node_free(world, spec->bundle); - lilv_values_free(spec->data_uris); + sord_node_free(world->world, spec->spec); + sord_node_free(world->world, spec->bundle); + lilv_nodes_free(spec->data_uris); free(spec); } g_slist_free(world->specs); @@ -184,16 +184,16 @@ LILV_API void lilv_world_set_option(LilvWorld* world, const char* option, - const LilvValue* value) + const LilvNode* value) { if (!strcmp(option, LILV_OPTION_DYN_MANIFEST)) { - if (lilv_value_is_bool(value)) { - world->opt.dyn_manifest = lilv_value_as_bool(value); + if (lilv_node_is_bool(value)) { + world->opt.dyn_manifest = lilv_node_as_bool(value); return; } } else if (!strcmp(option, LILV_OPTION_FILTER_LANG)) { - if (lilv_value_is_bool(value)) { - world->opt.filter_language = lilv_value_as_bool(value); + if (lilv_node_is_bool(value)) { + world->opt.filter_language = lilv_node_as_bool(value); return; } } @@ -222,13 +222,13 @@ lilv_world_query(LilvWorld* world, subject, predicate, object, NULL); } -LilvValues* +LilvNodes* lilv_world_query_values(LilvWorld* world, const SordNode* subject, const SordNode* predicate, const SordNode* object) { - return lilv_values_from_stream_objects(world, + return lilv_nodes_from_stream_objects(world, lilv_world_query(world, subject, predicate, object)); } @@ -259,17 +259,17 @@ lilv_header_compare_by_uri(const void* a, const void* b, void* user_data) { const struct LilvHeader* const header_a = (const struct LilvHeader*)a; const struct LilvHeader* const header_b = (const struct LilvHeader*)b; - return strcmp(lilv_value_as_uri(header_a->uri), - lilv_value_as_uri(header_b->uri)); + return strcmp(lilv_node_as_uri(header_a->uri), + lilv_node_as_uri(header_b->uri)); } /** Get an element of a sequence of any object with an LilvHeader by URI. */ struct LilvHeader* lilv_sequence_get_by_uri(const GSequence* const_seq, - const LilvValue* uri) + const LilvNode* uri) { GSequence* seq = (GSequence*)const_seq; - struct LilvHeader key = { NULL, (LilvValue*)uri }; + struct LilvHeader key = { NULL, (LilvNode*)uri }; GSequenceIter* i = g_sequence_search( seq, &key, lilv_header_compare_by_uri, NULL); @@ -277,7 +277,7 @@ lilv_sequence_get_by_uri(const GSequence* const_seq, if (!g_sequence_iter_is_end(i)) { LilvPlugin* p = g_sequence_get(i); - if (lilv_value_equals(lilv_plugin_get_uri(p), uri)) { + if (lilv_node_equals(lilv_plugin_get_uri(p), uri)) { return (struct LilvHeader*)p; } } @@ -286,7 +286,7 @@ lilv_sequence_get_by_uri(const GSequence* const_seq, // Check if i is just past a match i = g_sequence_iter_prev(i); LilvPlugin* p = g_sequence_get(i); - if (lilv_value_equals(lilv_plugin_get_uri(p), uri)) { + if (lilv_node_equals(lilv_plugin_get_uri(p), uri)) { return (struct LilvHeader*)p; } } @@ -300,9 +300,9 @@ lilv_world_add_spec(LilvWorld* world, const SordNode* bundle_node) { LilvSpec* spec = malloc(sizeof(struct LilvSpecImpl)); - spec->spec = lilv_node_copy(specification_node); - spec->bundle = lilv_node_copy(bundle_node); - spec->data_uris = lilv_values_new(); + spec->spec = sord_node_copy(specification_node); + spec->bundle = sord_node_copy(bundle_node); + spec->data_uris = lilv_nodes_new(); // Add all plugin data files (rdfs:seeAlso) SordIter* files = lilv_world_find_statements( @@ -314,7 +314,7 @@ lilv_world_add_spec(LilvWorld* world, FOREACH_MATCH(files) { const SordNode* file_node = lilv_match_object(files); lilv_array_append(spec->data_uris, - lilv_value_new_from_node(world, file_node)); + lilv_node_new_from_node(world, file_node)); } lilv_match_end(files); @@ -329,20 +329,20 @@ lilv_world_add_plugin(LilvWorld* world, const SordNode* dyn_manifest_lib, const SordNode* bundle_node) { - LilvValue* plugin_uri = lilv_value_new_from_node(world, plugin_node); + LilvNode* plugin_uri = lilv_node_new_from_node(world, plugin_node); const LilvPlugin* last = lilv_plugins_get_by_uri(world->plugins, plugin_uri); if (last) { - LILV_ERRORF("Duplicate plugin <%s>\n", lilv_value_as_uri(plugin_uri)); - LILV_ERRORF("... found in %s\n", lilv_value_as_string( + LILV_ERRORF("Duplicate plugin <%s>\n", lilv_node_as_uri(plugin_uri)); + LILV_ERRORF("... found in %s\n", lilv_node_as_string( lilv_plugin_get_bundle_uri(last))); LILV_ERRORF("... and %s\n", sord_node_get_string(bundle_node)); - lilv_value_free(plugin_uri); + lilv_node_free(plugin_uri); return; } // Create LilvPlugin - LilvValue* bundle_uri = lilv_value_new_from_node(world, bundle_node); + LilvNode* bundle_uri = lilv_node_new_from_node(world, bundle_node); LilvPlugin* plugin = lilv_plugin_new(world, plugin_uri, bundle_uri); // Add manifest as plugin data file (as if it were rdfs:seeAlso) @@ -351,7 +351,7 @@ lilv_world_add_plugin(LilvWorld* world, // Set dynamic manifest library URI, if applicable if (dyn_manifest_lib) { - plugin->dynman_uri = lilv_value_new_from_node(world, dyn_manifest_lib); + plugin->dynman_uri = lilv_node_new_from_node(world, dyn_manifest_lib); } // Add all plugin data files (rdfs:seeAlso) @@ -364,7 +364,7 @@ lilv_world_add_plugin(LilvWorld* world, FOREACH_MATCH(files) { const SordNode* file_node = lilv_match_object(files); lilv_array_append(plugin->data_uris, - lilv_value_new_from_node(world, file_node)); + lilv_node_new_from_node(world, file_node)); } lilv_match_end(files); @@ -478,9 +478,9 @@ lilv_world_load_dyn_manifest(LilvWorld* world, LILV_API void -lilv_world_load_bundle(LilvWorld* world, LilvValue* bundle_uri) +lilv_world_load_bundle(LilvWorld* world, LilvNode* bundle_uri) { - if (!lilv_value_is_uri(bundle_uri)) { + if (!lilv_node_is_uri(bundle_uri)) { LILV_ERROR("Bundle 'URI' is not a URI\n"); return; } @@ -591,9 +591,9 @@ lilv_world_load_directory(LilvWorld* world, const char* dir_path) DIR* const bundle_dir = opendir(uri + file_scheme_len); if (bundle_dir) { closedir(bundle_dir); - LilvValue* uri_val = lilv_new_uri(world, uri); + LilvNode* uri_val = lilv_new_uri(world, uri); lilv_world_load_bundle(world, uri_val); - lilv_value_free(uri_val); + lilv_node_free(uri_val); } else { LILV_WARNF("failed to open bundle `%s'\n", uri); } @@ -653,10 +653,10 @@ lilv_world_load_specifications(LilvWorld* world) { for (GSList* l = world->specs; l; l = l->next) { LilvSpec* spec = (LilvSpec*)l->data; - LILV_FOREACH(values, f, spec->data_uris) { - LilvValue* file = lilv_collection_get(spec->data_uris, f); + LILV_FOREACH(nodes, f, spec->data_uris) { + LilvNode* file = lilv_collection_get(spec->data_uris, f); sord_read_file(world->model, - (const uint8_t*)lilv_value_as_uri(file), + (const uint8_t*)lilv_node_as_uri(file), NULL, lilv_world_blank_node_prefix(world)); } @@ -743,14 +743,14 @@ lilv_world_load_all(LilvWorld* world) LILV_FOREACH(plugins, p, world->plugins) { const LilvPlugin* plugin = lilv_collection_get(world->plugins, p); - const LilvValue* plugin_uri = lilv_plugin_get_uri(plugin); + const LilvNode* plugin_uri = lilv_plugin_get_uri(plugin); // ?new dc:replaces plugin SordIter* replacement = lilv_world_find_statements( world, world->model, NULL, world->dc_replaces_node, - lilv_value_as_node(plugin_uri), + lilv_node_as_node(plugin_uri), NULL); if (!sord_iter_end(replacement)) { /* TODO: Check if replacement is actually a known plugin, -- cgit v1.2.1