summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lilv_internal.h15
-rw-r--r--src/plugin.c17
-rw-r--r--src/port.c66
3 files changed, 34 insertions, 64 deletions
diff --git a/src/lilv_internal.h b/src/lilv_internal.h
index caa5fbc..c405a0d 100644
--- a/src/lilv_internal.h
+++ b/src/lilv_internal.h
@@ -48,13 +48,6 @@ static inline char* dlerror(void) { return "Unknown error"; }
# include "lv2/lv2plug.in/ns/ext/dyn-manifest/dyn-manifest.h"
#endif
-#define LILV_NS_DOAP "http://usefulinc.com/ns/doap#"
-#define LILV_NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
-#define LILV_NS_LILV "http://drobilla.net/ns/lilv#"
-#define LILV_NS_LV2 "http://lv2plug.in/ns/lv2core#"
-#define LILV_NS_XSD "http://www.w3.org/2001/XMLSchema#"
-#define LILV_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-
/*
*
* Types
@@ -66,6 +59,7 @@ typedef struct LilvSpecImpl LilvSpec;
typedef void LilvCollection;
struct LilvPortImpl {
+ SordNode* node; ///< RDF node
uint32_t index; ///< lv2:index
LilvNode* symbol; ///< lv2:symbol
LilvNodes* classes; ///< rdf:type
@@ -194,8 +188,11 @@ struct LilvUIImpl {
*
*/
-LilvPort* lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol);
-void lilv_port_free(LilvPort* port);
+LilvPort* lilv_port_new(LilvWorld* world,
+ const SordNode* node,
+ uint32_t index,
+ const char* symbol);
+void lilv_port_free(const LilvPlugin* plugin, LilvPort* port);
LilvPlugin* lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri);
void lilv_plugin_load_if_necessary(const LilvPlugin* p);
diff --git a/src/plugin.c b/src/plugin.c
index 32c40da..25ae481 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -69,8 +69,9 @@ lilv_plugin_free(LilvPlugin* p)
#endif
if (p->ports) {
- for (uint32_t i = 0; i < p->num_ports; ++i)
- lilv_port_free(p->ports[i]);
+ for (uint32_t i = 0; i < p->num_ports; ++i) {
+ lilv_port_free(p, p->ports[i]);
+ }
free(p->ports);
p->ports = NULL;
}
@@ -184,9 +185,9 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
NULL);
FOREACH_MATCH(ports) {
- LilvNode* index = NULL;
- const SordNode* port = lilv_match_object(ports);
- LilvNode* symbol = lilv_plugin_get_unique(
+ LilvNode* index = NULL;
+ const SordNode* port = lilv_match_object(ports);
+ LilvNode* symbol = lilv_plugin_get_unique(
p, port, p->world->lv2_symbol_node);
if (!lilv_node_is_string(symbol)) {
@@ -217,6 +218,7 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
// Havn't seen this port yet, add it to array
if (!this_port) {
this_port = lilv_port_new(p->world,
+ port,
this_index,
lilv_node_as_string(symbol));
p->ports[this_index] = this_port;
@@ -241,8 +243,9 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
lilv_node_free(index);
if (p->num_ports == 0) {
if (p->ports) {
- for (uint32_t i = 0; i < p->num_ports; ++i)
- lilv_port_free(p->ports[i]);
+ for (uint32_t i = 0; i < p->num_ports; ++i) {
+ lilv_port_free(p, p->ports[i]);
+ }
free(p->ports);
p->ports = NULL;
}
diff --git a/src/port.c b/src/port.c
index 48f169f..b11980a 100644
--- a/src/port.c
+++ b/src/port.c
@@ -25,18 +25,23 @@
#include "lilv_internal.h"
LilvPort*
-lilv_port_new(LilvWorld* world, uint32_t index, const char* symbol)
+lilv_port_new(LilvWorld* world,
+ const SordNode* node,
+ uint32_t index,
+ const char* symbol)
{
LilvPort* port = malloc(sizeof(struct LilvPortImpl));
- port->index = index;
- port->symbol = lilv_node_new(world, LILV_VALUE_STRING, symbol);
+ port->node = sord_node_copy(node);
+ port->index = index;
+ port->symbol = lilv_node_new(world, LILV_VALUE_STRING, symbol);
port->classes = lilv_nodes_new();
return port;
}
void
-lilv_port_free(LilvPort* port)
+lilv_port_free(const LilvPlugin* plugin, LilvPort* port)
{
+ sord_node_free(plugin->world->world, port->node);
lilv_nodes_free(port->classes);
lilv_node_free(port->symbol);
free(port);
@@ -55,37 +60,6 @@ lilv_port_is_a(const LilvPlugin* plugin,
return false;
}
-static const SordNode*
-lilv_port_get_node(const LilvPlugin* p,
- const LilvPort* port)
-{
- SordIter* ports = lilv_world_query(
- p->world,
- p->plugin_uri->val.uri_val,
- p->world->lv2_port_node,
- NULL);
- const SordNode* ret = NULL;
- FOREACH_MATCH(ports) {
- const SordNode* node = lilv_match_object(ports);
- LilvNode* symbol = lilv_plugin_get_unique(
- p,
- node,
- p->world->lv2_symbol_node);
-
- const bool matches = lilv_node_equals(symbol,
- lilv_port_get_symbol(p, port));
-
- lilv_node_free(symbol);
- if (matches) {
- ret = node;
- break;
- }
- }
- lilv_match_end(ports);
- assert(ret);
- return ret;
-}
-
LILV_API
bool
lilv_port_has_property(const LilvPlugin* p,
@@ -93,10 +67,9 @@ lilv_port_has_property(const LilvPlugin* p,
const LilvNode* property)
{
assert(property);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
p->world->lv2_portproperty_node,
lilv_node_as_node(property));
@@ -114,10 +87,9 @@ lilv_port_supports_event(const LilvPlugin* p,
#define NS_EV (const uint8_t*)"http://lv2plug.in/ns/ext/event#"
assert(event);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
sord_new_uri(p->world->world, NS_EV "supportsEvent"),
lilv_node_as_node(event));
@@ -129,14 +101,13 @@ lilv_port_supports_event(const LilvPlugin* p,
static LilvNodes*
lilv_port_get_value_by_node(const LilvPlugin* p,
const LilvPort* port,
- const SordNode* predicate)
+ const SordNode* predicate)
{
assert(sord_node_get_type(predicate) == SORD_URI);
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* results = lilv_world_query(
+ SordIter* results = lilv_world_query(
p->world,
- port_node,
+ port->node,
predicate,
NULL);
@@ -237,10 +208,9 @@ LilvScalePoints*
lilv_port_get_scale_points(const LilvPlugin* p,
const LilvPort* port)
{
- const SordNode* port_node = lilv_port_get_node(p, port);
- SordIter* points = lilv_world_query(
+ SordIter* points = lilv_world_query(
p->world,
- port_node,
+ port->node,
sord_new_uri(p->world->world, (const uint8_t*)LILV_NS_LV2 "scalePoint"),
NULL);