diff options
-rw-r--r-- | src/sratom.c | 28 | ||||
-rw-r--r-- | tests/sratom_test.c | 14 |
2 files changed, 20 insertions, 22 deletions
diff --git a/src/sratom.c b/src/sratom.c index fa502b6..7c88db0 100644 --- a/src/sratom.c +++ b/src/sratom.c @@ -24,7 +24,6 @@ #include "sratom/sratom.h" -#define NS_ATOM (const uint8_t*)"http://lv2plug.in/ns/ext/atom#" #define NS_MIDI (const uint8_t*)"http://lv2plug.in/ns/ext/midi#" #define NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#" #define NS_XSD (const uint8_t*)"http://www.w3.org/2001/XMLSchema#" @@ -67,8 +66,7 @@ sratom_new(LV2_URID_Map* map) { Sratom* sratom = (Sratom*)malloc(sizeof(Sratom)); sratom->map = map; - sratom->atom_Event = map->map(map->handle, - (const char*)NS_ATOM "Event"); + sratom->atom_Event = map->map(map->handle, LV2_ATOM__Event); sratom->midi_MidiEvent = map->map(map->handle, (const char*)NS_MIDI "MidiEvent"); sratom->next_id = 0; @@ -226,11 +224,11 @@ sratom_write(Sratom* sratom, } else if (type_urid == sratom->forge.URI) { const uint8_t* str = USTR(body); object = serd_node_from_string(SERD_URI, str); - } else if (type_urid == sratom->forge.Int32) { + } else if (type_urid == sratom->forge.Int) { new_node = true; object = serd_node_new_integer(*(int32_t*)body); datatype = serd_node_from_string(SERD_URI, NS_XSD "int"); - } else if (type_urid == sratom->forge.Int64) { + } else if (type_urid == sratom->forge.Long) { new_node = true; object = serd_node_new_integer(*(int64_t*)body); datatype = serd_node_from_string(SERD_URI, NS_XSD "long"); @@ -440,9 +438,9 @@ read_list_value(Sratom* sratom, static uint32_t atom_size(Sratom* sratom, uint32_t type_urid) { - if (type_urid == sratom->forge.Int32) { + if (type_urid == sratom->forge.Int) { return sizeof(int32_t); - } else if (type_urid == sratom->forge.Int64) { + } else if (type_urid == sratom->forge.Long) { return sizeof(int64_t); } else if (type_urid == sratom->forge.Float) { return sizeof(float); @@ -484,8 +482,8 @@ read_node(Sratom* sratom, lv2_atom_forge_double(forge, serd_strtod(str, &endptr)); } else if (!strcmp(type_uri, (char*)NS_XSD "boolean")) { lv2_atom_forge_bool(forge, !strcmp(str, "true")); - } else if (!strcmp(type_uri, (char*)NS_ATOM "Path")) { - lv2_atom_forge_path(forge, (const uint8_t*)str, len); + } else if (!strcmp(type_uri, LV2_ATOM__Path)) { + lv2_atom_forge_path(forge, str, len); } else if (!strcmp(type_uri, (char*)NS_MIDI "MidiEvent")) { lv2_atom_forge_atom(forge, len / 2, sratom->midi_MidiEvent); for (const char* s = str; s < str + len; s += 2) { @@ -498,7 +496,7 @@ read_node(Sratom* sratom, lv2_atom_forge_pad(forge, len / 2); } else { lv2_atom_forge_literal( - forge, (const uint8_t*)str, len, + forge, str, len, sratom->map->map(sratom->map->handle, type_uri), 0); } @@ -508,18 +506,18 @@ read_node(Sratom* sratom, char* lang_uri = calloc(lang_len + 1, 1); snprintf(lang_uri, lang_len + 1, "%s%s", prefix, language); lv2_atom_forge_literal( - forge, (const uint8_t*)str, len, 0, + forge, str, len, 0, sratom->map->map(sratom->map->handle, lang_uri)); free(lang_uri); } else { - lv2_atom_forge_string(forge, (const uint8_t*)str, len); + lv2_atom_forge_string(forge, str, len); } } else if (sord_node_get_type(node) == SORD_URI) { if (!strcmp(str, (const char*)NS_RDF "nil")) { lv2_atom_forge_atom(forge, 0, 0); } else if (!strncmp(str, "file://", 7)) { uint8_t* path = serd_file_uri_parse((const uint8_t*)str, NULL); - lv2_atom_forge_path(forge, path, strlen((const char*)path)); + lv2_atom_forge_path(forge, (const char*)path, strlen((const char*)path)); free(path); } else { lv2_atom_forge_urid(forge, map->map(map->handle, str)); @@ -603,8 +601,8 @@ sratom_read(Sratom* sratom, SordModel* model, const SordNode* node) { - sratom->nodes.atom_childType = sord_new_uri(world, NS_ATOM "childType"); - sratom->nodes.atom_frameTime = sord_new_uri(world, NS_ATOM "frameTime"); + sratom->nodes.atom_childType = sord_new_uri(world, USTR(LV2_ATOM__childType)); + sratom->nodes.atom_frameTime = sord_new_uri(world, USTR(LV2_ATOM__frameTime)); sratom->nodes.rdf_first = sord_new_uri(world, NS_RDF "first"); sratom->nodes.rdf_rest = sord_new_uri(world, NS_RDF "rest"); sratom->nodes.rdf_type = sord_new_uri(world, NS_RDF "type"); diff --git a/tests/sratom_test.c b/tests/sratom_test.c index c3eb70b..b13def9 100644 --- a/tests/sratom_test.c +++ b/tests/sratom_test.c @@ -135,8 +135,8 @@ main() lv2_atom_forge_bool(&forge, false); // eg_path = (Path)"/absolute/path" - const uint8_t* pstr = (const uint8_t*)"/absolute/path"; - const size_t pstr_len = strlen((const char*)pstr); + const char* pstr = "/absolute/path"; + const size_t pstr_len = strlen(pstr); lv2_atom_forge_property_head(&forge, eg_path, 0); lv2_atom_forge_path(&forge, pstr, pstr_len); @@ -147,18 +147,18 @@ main() // eg_string = (String)"hello" lv2_atom_forge_property_head(&forge, eg_string, 0); - lv2_atom_forge_string(&forge, (const uint8_t*)"hello", strlen("hello")); + lv2_atom_forge_string(&forge, "hello", strlen("hello")); // eg_langlit = (Literal)"bonjour"@fr lv2_atom_forge_property_head(&forge, eg_langlit, 0); lv2_atom_forge_literal( - &forge, (const uint8_t*)"bonjour", strlen("bonjour"), + &forge, "bonjour", strlen("bonjour"), 0, urid_map(NULL, "http://lexvo.org/id/iso639-3/fra")); // eg_typelit = (Literal)"bonjour"@fr lv2_atom_forge_property_head(&forge, eg_typelit, 0); lv2_atom_forge_literal( - &forge, (const uint8_t*)"value", strlen("value"), + &forge, "value", strlen("value"), urid_map(NULL, "http://example.org/Type"), 0); // eg_null = null @@ -182,14 +182,14 @@ main() lv2_atom_forge_property_head(&forge, eg_tuple, 0); LV2_Atom_Forge_Frame tuple_frame; lv2_atom_forge_tuple(&forge, &tuple_frame); - lv2_atom_forge_string(&forge, (const uint8_t*)"foo", strlen("foo")); + lv2_atom_forge_string(&forge, "foo", strlen("foo")); lv2_atom_forge_bool(&forge, true); lv2_atom_forge_pop(&forge, &tuple_frame); // eg_vector = (Vector<Int32>)1,2,3,4 lv2_atom_forge_property_head(&forge, eg_vector, 0); int32_t elems[] = { 1, 2, 3, 4 }; - lv2_atom_forge_vector(&forge, 4, forge.Int32, sizeof(int32_t), elems); + lv2_atom_forge_vector(&forge, 4, forge.Int, sizeof(int32_t), elems); // eg_seq = (Sequence)1, 2 LV2_URID midi_midiEvent = map.map(map.handle, NS_MIDI "MidiEvent"); |