From e45691df6be3f9a14cab019437ce2f2e8a54427e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 6 Mar 2012 05:05:40 +0000 Subject: Use raw type/size/value instead of LilvNode for port values. Remove use of half-baked node_to_serd() and use sratom for port values as well. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4023 a436a847-0d15-0410-975c-d299462d15a1 --- test/lilv_test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/lilv_test.c b/test/lilv_test.c index 2352150..db2dca5 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -1070,32 +1070,43 @@ test_ui(void) /*****************************************************************************/ -float in = 1.0; -float out = 42.0; - -LilvNode* -get_port_value(const char* port_symbol, void* user_data) +uint32_t atom_Float = 0; +float in = 1.0; +float out = 42.0; + +const void* +get_port_value(const char* port_symbol, + void* user_data, + uint32_t* size, + uint32_t* type) { if (!strcmp(port_symbol, "input")) { - return lilv_new_float((LilvWorld*)user_data, in); + *size = sizeof(float); + *type = atom_Float; + return ∈ } else if (!strcmp(port_symbol, "output")) { - return lilv_new_float((LilvWorld*)user_data, out); + *size = sizeof(float); + *type = atom_Float; + return &out; } else { fprintf(stderr, "error: get_port_value for nonexistent port `%s'\n", port_symbol); + *size = *type = 0; return NULL; } } void set_port_value(const char* port_symbol, - const LilvNode* value, - void* user_data) + void* user_data, + const void* value, + uint32_t size, + uint32_t type) { if (!strcmp(port_symbol, "input")) { - in = lilv_node_as_float(value); + in = *(float*)value; } else if (!strcmp(port_symbol, "output")) { - out = lilv_node_as_float(value); + out = *(float*)value; } else { fprintf(stderr, "error: set_port_value for nonexistent port `%s'\n", port_symbol); @@ -1158,6 +1169,8 @@ test_state(void) LV2_Feature unmap_feature = { LV2_URID_UNMAP_URI, &unmap }; const LV2_Feature* features[] = { &map_feature, &unmap_feature, NULL }; + atom_Float = map.map(map.handle, "http://lv2plug.in/ns/ext/atom#Float"); + LilvNode* num = lilv_new_int(world, 5); LilvState* nostate = lilv_state_new_from_file(world, &map, num, "/junk"); TEST_ASSERT(!nostate); -- cgit v1.2.1