Removed data type enumeration in favour of using the URI directly

git-svn-id: http://svn.drobilla.net/lad@100 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-07-22 19:19:05 +00:00
parent 429eef27b7
commit 98ad93e12b
9 changed files with 51 additions and 31 deletions

View File

@ -149,10 +149,11 @@ create_port(struct JackHost* host,
unsigned long port_index)
{
/* Make sure this is a float port */
enum SLV2DataType type = slv2_port_get_data_type(host->plugin, port_index);
if (type != SLV2_DATA_TYPE_FLOAT)
uchar* type = slv2_port_get_data_type(host->plugin, port_index);
if (strcmp(type, SLV2_DATA_TYPE_FLOAT))
die("Unrecognized data type, aborting.");
free(type);
/* Get the port symbol (label) for console printing */
char* symbol = slv2_port_get_symbol(host->plugin, port_index);

View File

@ -61,7 +61,7 @@ create_audio_output()
void
create_port(SLV2Plugin* plugin,
SLV2Instance* instance,
unsigned long port_index)
unsigned long port_index)
{
enum SLV2PortClass class = slv2_port_get_class(plugin, port_index);

View File

@ -46,7 +46,7 @@ extern "C" {
/** Get a property of a port, by port index.
*
* Return value must be free()'d by caller.
* Return value must be freed by caller with slv2_property_free.
*/
SLV2Property
slv2_port_get_property(SLV2Plugin* plugin,
@ -73,9 +73,12 @@ slv2_port_get_class(SLV2Plugin* plugin,
unsigned long index);
/** Get the data type of a port.
/** Get the data type of a port (as a URI).
*
* The only data type included in the core LV2 specification is lv2:float.
* Compare this return value with @ref SLV2_DATA_TYPE_FLOAT to check for it.
*/
enum SLV2DataType
uchar*
slv2_port_get_data_type(SLV2Plugin* plugin,
unsigned long index);

View File

@ -87,10 +87,13 @@ rasqal_query_results*
slv2_plugin_run_query(const SLV2Plugin* p,
const uchar* query_string, ...);
SLV2Property
slv2_query_get_results(rasqal_query_results* results);
/** Free an SLV2Property. */
void
slv2_property_free(SLV2Property);
/** @} */

View File

@ -51,11 +51,8 @@ enum SLV2PortClass {
};
/** Type contained in a port buffer. */
enum SLV2DataType {
SLV2_DATA_TYPE_FLOAT, /**< IEEE-754 32-bit floating point number */
SLV2_UNKNOWN_DATA_TYPE
};
/** lv2:float, IEEE-754 32-bit floating point number */
#define SLV2_DATA_TYPE_FLOAT "http://lv2plug.in/ontology#float"
#ifdef __cplusplus

View File

@ -90,23 +90,23 @@ bool
slv2_plugin_verify(const SLV2Plugin* plugin)
{
// FIXME: finish this (properly)
/*
size_t num_values = 0;
struct SLV2Property* prop = slv2_plugin_get_property(plugin, "doap:name");
struct _Property* prop = slv2_plugin_get_property(plugin, "doap:name");
if (prop) {
num_values = prop->num_values;
free(prop);
}
if (num_values < 1)
return false;
/*
prop = slv2_plugin_get_property(plugin, "doap:license");
num_values = prop->num_values;
free(prop);
if (num_values < 1)
return false;
*/
*/
return true;
}

View File

@ -141,7 +141,7 @@ slv2_list_load_bundle(SLV2List list,
// FIXME: leaks? rasqal really doesn't handle missing files well..
if (results) {
rasqal_free_query_results(results);
rasqal_free_query(rq);
//rasqal_free_query(rq); // FIXME: crashes? leak?
raptor_free_uri(base_uri); // FIXME: leak?
}
rasqal_finish();

View File

@ -34,6 +34,8 @@ slv2_port_get_class(SLV2Plugin* p,
assert(class->num_values == 1);
assert(class->values);
// FIXME FIXME FIXME: leak
if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateInputPort"))
return SLV2_CONTROL_RATE_INPUT;
else if (!strcmp((char*)class->values[0], "http://lv2plug.in/ontology#ControlRateOutputPort"))
@ -49,8 +51,8 @@ slv2_port_get_class(SLV2Plugin* p,
}
enum SLV2DataType
slv2_port_get_data_type(SLV2Plugin* p,
uchar*
slv2_port_get_data_type(SLV2Plugin* p,
unsigned long index)
{
SLV2Property type = slv2_port_get_property(p, index, U("lv2:datatype"));
@ -58,15 +60,14 @@ slv2_port_get_data_type(SLV2Plugin* p,
assert(type->num_values == 1);
assert(type->values);
if (!strcmp((char*)type->values[0], "http://lv2plug.in/ontology#float"))
return SLV2_DATA_TYPE_FLOAT;
else
return SLV2_UNKNOWN_DATA_TYPE;
uchar* ret = type->values[0];
slv2_property_free(type);
return ret;
}
SLV2Property
slv2_port_get_property(SLV2Plugin* p,
slv2_port_get_property(SLV2Plugin* p,
unsigned long index,
const uchar* property)
{
@ -94,7 +95,8 @@ slv2_port_get_property(SLV2Plugin* p,
uchar*
slv2_port_get_symbol(SLV2Plugin* p, unsigned long index)
slv2_port_get_symbol(SLV2Plugin* p,
unsigned long index)
{
// FIXME: leaks
uchar* result = NULL;
@ -104,7 +106,7 @@ slv2_port_get_symbol(SLV2Plugin* p, unsigned long index)
if (prop && prop->num_values == 1)
result = (uchar*)strdup((char*)prop->values[0]);
free(prop);
slv2_property_free(prop);
return result;
}
@ -124,12 +126,14 @@ slv2_port_get_default_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
slv2_property_free(prop);
return result;
}
float
slv2_port_get_minimum_value(SLV2Plugin* p,
slv2_port_get_minimum_value(SLV2Plugin* p,
unsigned long index)
{
// FIXME: do casting properly in the SPARQL query
@ -142,12 +146,14 @@ slv2_port_get_minimum_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
slv2_property_free(prop);
return result;
}
float
slv2_port_get_maximum_value(SLV2Plugin* p,
slv2_port_get_maximum_value(SLV2Plugin* p,
unsigned long index)
{
// FIXME: do casting properly in the SPARQL query
@ -160,6 +166,8 @@ slv2_port_get_maximum_value(SLV2Plugin* p,
if (prop && prop->num_values == 1)
result = atof((char*)prop->values[0]);
slv2_property_free(prop);
return result;
}

View File

@ -50,8 +50,8 @@ slv2_query_lang_filter(const uchar* variable)
// FILTER( LANG(?value) = "en" || LANG(?value) = "" )
result = ustrjoin(
//U("FILTER (lang(?value) = \""), lang, U("\")\n"), 0);
U("FILTER( lang(?value) = \""), lang,
U("\" || lang(?value) = \"\" )\n"), NULL);
U("FILTER( lang(?"), variable, U(") = \""), lang,
U("\" || lang(?"), variable, U(") = \"\" )\n"), NULL);
}
return result;
@ -122,3 +122,11 @@ slv2_query_get_results(rasqal_query_results* results)
return result;
}
void
slv2_property_free(struct _Property* prop)
{
//struct _Property* prop = (struct _Property*)property;
free(prop->values);
free(prop);
}