diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/collections.c | 54 | ||||
-rw-r--r-- | src/node.c | 6 | ||||
-rw-r--r-- | src/plugin.c | 8 | ||||
-rw-r--r-- | src/port.c | 2 | ||||
-rw-r--r-- | src/state.c | 42 | ||||
-rw-r--r-- | src/world.c | 15 |
6 files changed, 64 insertions, 63 deletions
diff --git a/src/collections.c b/src/collections.c index a7b6923..508f69c 100644 --- a/src/collections.c +++ b/src/collections.c @@ -167,33 +167,33 @@ lilv_nodes_merge(const LilvNodes* a, const LilvNodes* b) /* Iterator */ -#define LILV_COLLECTION_IMPL(prefix, CT, ET) \ - \ - unsigned prefix##_size(const CT* collection) \ - { \ - return lilv_collection_size(collection); \ - } \ - \ - LilvIter* prefix##_begin(const CT* collection) \ - { \ - return lilv_collection_begin(collection); \ - } \ - \ - const ET* prefix##_get(const CT* collection, LilvIter* i) \ - { \ - return (ET*)lilv_collection_get(collection, i); \ - } \ - \ - LilvIter* prefix##_next(const CT* collection, LilvIter* i) \ - { \ - (void)collection; \ - return zix_tree_iter_next((ZixTreeIter*)i); \ - } \ - \ - bool prefix##_is_end(const CT* collection, LilvIter* i) \ - { \ - (void)collection; \ - return zix_tree_iter_is_end((ZixTreeIter*)i); \ +#define LILV_COLLECTION_IMPL(prefix, CT, ET) \ + \ + unsigned prefix##_size(const CT* collection) \ + { \ + return lilv_collection_size(collection); \ + } \ + \ + LilvIter* prefix##_begin(const CT* collection) \ + { \ + return lilv_collection_begin(collection); \ + } \ + \ + const ET* prefix##_get(const CT* collection, const LilvIter* i) \ + { \ + return (ET*)lilv_collection_get(collection, i); \ + } \ + \ + LilvIter* prefix##_next(const CT* collection, LilvIter* i) \ + { \ + (void)collection; \ + return zix_tree_iter_next((ZixTreeIter*)i); \ + } \ + \ + bool prefix##_is_end(const CT* collection, const LilvIter* i) \ + { \ + (void)collection; \ + return zix_tree_iter_is_end((const ZixTreeIter*)i); \ } LILV_COLLECTION_IMPL(lilv_plugin_classes, LilvPluginClasses, LilvPluginClass) @@ -97,9 +97,9 @@ lilv_node_new_from_node(LilvWorld* world, const SordNode* node) return NULL; } - LilvNode* result = NULL; - SordNode* datatype_uri = NULL; - LilvNodeType type = LILV_VALUE_STRING; + LilvNode* result = NULL; + const SordNode* datatype_uri = NULL; + LilvNodeType type = LILV_VALUE_STRING; switch (sord_node_get_type(node)) { case SORD_URI: diff --git a/src/plugin.c b/src/plugin.c index 46a09e3..bd31920 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -489,7 +489,7 @@ lilv_plugin_get_name(const LilvPlugin* plugin) LilvNode* ret = NULL; if (results) { - LilvNode* val = lilv_nodes_get_first(results); + const LilvNode* val = lilv_nodes_get_first(results); if (lilv_node_is_string(val)) { ret = lilv_node_duplicate(val); } @@ -588,7 +588,7 @@ lilv_plugin_get_num_ports_of_class_va( // Check each port against every type for (unsigned i = 0; i < plugin->num_ports; ++i) { - LilvPort* port = plugin->ports[i]; + const LilvPort* port = plugin->ports[i]; if (port && lilv_port_is_a(plugin, port, class_1)) { bool matches = true; for (size_t j = 0; j < n_classes; ++j) { @@ -997,7 +997,7 @@ lilv_plugin_get_related(const LilvPlugin* plugin, const LilvNode* type) LilvNodes* matches = lilv_nodes_new(); LILV_FOREACH (nodes, i, related) { - LilvNode* node = (LilvNode*)lilv_collection_get((ZixTree*)related, i); + const LilvNode* node = (LilvNode*)lilv_collection_get((ZixTree*)related, i); if (lilv_world_ask_internal( world, node->node, world->uris.rdf_a, type->node)) { zix_tree_insert( @@ -1028,7 +1028,7 @@ new_lv2_env(const SerdNode* base) } static void -maybe_write_prefixes(SerdWriter* writer, SerdEnv* env, FILE* file) +maybe_write_prefixes(SerdWriter* writer, const SerdEnv* env, FILE* file) { fseek(file, 0, SEEK_END); if (ftell(file) == 0) { @@ -160,7 +160,7 @@ lilv_port_get_name(const LilvPlugin* plugin, const LilvPort* port) LilvNode* ret = NULL; if (results) { - LilvNode* val = lilv_nodes_get_first(results); + const LilvNode* val = lilv_nodes_get_first(results); if (lilv_node_is_string(val)) { ret = lilv_node_duplicate(val); } diff --git a/src/state.c b/src/state.c index 964691e..35cdb15 100644 --- a/src/state.c +++ b/src/state.c @@ -153,13 +153,13 @@ lilv_state_rel2abs(const LilvState* state, const char* path) } static void -append_property(LilvState* state, - PropertyArray* array, - uint32_t key, - const void* value, - size_t size, - uint32_t type, - uint32_t flags) +append_property(const LilvState* state, + PropertyArray* array, + uint32_t key, + const void* value, + size_t size, + uint32_t type, + uint32_t flags) { array->props = (Property*)realloc(array->props, (++array->n) * sizeof(Property)); @@ -257,7 +257,7 @@ lilv_state_has_path(const char* path, const void* state) static char* make_path(LV2_State_Make_Path_Handle handle, const char* path) { - LilvState* state = (LilvState*)handle; + const LilvState* state = (const LilvState*)handle; zix_create_directories(NULL, state->dir); return zix_path_join(NULL, state->dir, path); @@ -269,7 +269,7 @@ path_is_child(const char* path, const char* dir) if (path && dir) { const size_t path_len = strlen(path); const size_t dir_len = strlen(dir); - return dir && path_len >= dir_len && !strncmp(path, dir, dir_len); + return path_len >= dir_len && !strncmp(path, dir, dir_len); } return false; } @@ -293,7 +293,7 @@ abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path) if (!zix_tree_find(state->abs2rel, &key, &iter)) { // Already mapped path in a previous call - PathMap* pm = (PathMap*)zix_tree_get(iter); + const PathMap* pm = (const PathMap*)zix_tree_get(iter); zix_free(NULL, real_path); return lilv_strdup(pm->rel); } @@ -353,8 +353,8 @@ abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path) static char* absolute_path(LV2_State_Map_Path_Handle handle, const char* state_path) { - LilvState* state = (LilvState*)handle; - char* path = NULL; + const LilvState* state = (const LilvState*)handle; + char* path = NULL; if (zix_path_is_absolute(state_path)) { // Absolute path, return identical path path = lilv_strdup(state_path); @@ -777,7 +777,7 @@ lilv_state_new_from_file(LilvWorld* world, serd_reader_read_file(reader, (const uint8_t*)node.buf); - SordNode* subject_node = + const SordNode* subject_node = (subject) ? subject->node : sord_node_from_serd_node(world->world, env, &node, NULL, NULL); @@ -1148,7 +1148,7 @@ lilv_state_write(LilvWorld* world, serd_writer_write_statement(writer, 0, NULL, &subject, &p, &o, NULL, NULL); } - SerdEnv* env = serd_writer_get_env(writer); + const SerdEnv* env = serd_writer_get_env(writer); const SerdNode* base = serd_env_get_base_uri(env, NULL); Sratom* sratom = sratom_new(map); @@ -1166,7 +1166,7 @@ lilv_state_write(LilvWorld* world, // Write port values sratom_set_pretty_numbers(sratom, true); // Use pretty numbers for (uint32_t i = 0; i < state->n_values; ++i) { - PortValue* const value = &state->values[i]; + const PortValue* const value = &state->values[i]; const SerdNode port = serd_node_from_string(SERD_BLANK, USTR(value->symbol)); @@ -1399,7 +1399,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state) } if (state->uri) { - SordNode* file = + const SordNode* file = sord_get(model, state->uri->node, world->uris.rdfs_seeAlso, NULL, NULL); if (file) { // Remove state file @@ -1472,7 +1472,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state) } static void -free_property_array(LilvState* state, PropertyArray* array) +free_property_array(const LilvState* state, PropertyArray* array) { for (uint32_t i = 0; i < array->n; ++i) { Property* prop = &array->props[i]; @@ -1518,8 +1518,8 @@ lilv_state_equals(const LilvState* a, const LilvState* b) } for (uint32_t i = 0; i < a->n_values; ++i) { - PortValue* const av = &a->values[i]; - PortValue* const bv = &b->values[i]; + const PortValue* const av = &a->values[i]; + const PortValue* const bv = &b->values[i]; if (av->atom->size != bv->atom->size || av->atom->type != bv->atom->type || !!strcmp(av->symbol, bv->symbol) || !!memcmp(av->atom + 1, bv->atom + 1, av->atom->size)) { @@ -1528,8 +1528,8 @@ lilv_state_equals(const LilvState* a, const LilvState* b) } for (uint32_t i = 0; i < a->props.n; ++i) { - Property* const ap = &a->props.props[i]; - Property* const bp = &b->props.props[i]; + const Property* const ap = &a->props.props[i]; + const Property* const bp = &b->props.props[i]; if (ap->key != bp->key || ap->type != bp->type || ap->flags != bp->flags) { return false; } diff --git a/src/world.c b/src/world.c index b6bdf85..d4d7f8b 100644 --- a/src/world.c +++ b/src/world.c @@ -391,7 +391,7 @@ lilv_collection_find_by_uri(const ZixTree* seq, const LilvNode* uri) struct LilvHeader* lilv_collection_get_by_uri(const ZixTree* seq, const LilvNode* uri) { - ZixTreeIter* const i = lilv_collection_find_by_uri(seq, uri); + const ZixTreeIter* const i = lilv_collection_find_by_uri(seq, uri); return i ? (struct LilvHeader*)zix_tree_get(i) : NULL; } @@ -688,10 +688,10 @@ load_plugin_model(LilvWorld* world, const LilvNode* plugin_uri) { // Create model and reader for loading into it - SordNode* bundle_node = bundle_uri->node; - SordModel* model = sord_new(world->world, SORD_SPO | SORD_OPS, false); - SerdEnv* env = serd_env_new(sord_node_to_serd_node(bundle_node)); - SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL); + const SordNode* bundle_node = bundle_uri->node; + SordModel* model = sord_new(world->world, SORD_SPO | SORD_OPS, false); + SerdEnv* env = serd_env_new(sord_node_to_serd_node(bundle_node)); + SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL); // Load manifest LilvNode* manifest_uri = lilv_world_get_manifest_uri(world, bundle_uri); @@ -723,7 +723,7 @@ load_plugin_model(LilvWorld* world, } static LilvVersion -get_version(LilvWorld* world, SordModel* model, const LilvNode* subject) +get_version(const LilvWorld* world, SordModel* model, const LilvNode* subject) { const SordNode* minor_node = sord_get(model, subject->node, world->uris.lv2_minorVersion, NULL, NULL); @@ -1014,7 +1014,8 @@ lilv_world_load_specifications(LilvWorld* world) { for (LilvSpec* spec = world->specs; spec; spec = spec->next) { LILV_FOREACH (nodes, f, spec->data_uris) { - LilvNode* file = (LilvNode*)lilv_collection_get(spec->data_uris, f); + const LilvNode* file = + (const LilvNode*)lilv_collection_get(spec->data_uris, f); lilv_world_load_graph(world, NULL, file); } } |