summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-18 02:36:59 +0000
committerDavid Robillard <d@drobilla.net>2012-07-18 02:36:59 +0000
commit5afdd1098140b9aba15ff470356bf73b9144501a (patch)
tree75c4bf825f1c61c773c2f75331c5bc7e1081624b
parent5dcac50655a6635352e4542888e091bef515f865 (diff)
downloadingen-5afdd1098140b9aba15ff470356bf73b9144501a.tar.gz
ingen-5afdd1098140b9aba15ff470356bf73b9144501a.tar.bz2
ingen-5afdd1098140b9aba15ff470356bf73b9144501a.zip
Factor out 'inherit plugin port properties' pattern.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4547 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/server/LV2Node.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp
index 88cfff73..b68fd1e3 100644
--- a/src/server/LV2Node.cpp
+++ b/src/server/LV2Node.cpp
@@ -338,27 +338,19 @@ LV2Node::instantiate(BufferFactory& bufs)
}
}
- // Set lv2:portProperty properties
- LilvNodes* properties = lilv_port_get_value(plug, id, info->lv2_portProperty);
- LILV_FOREACH(nodes, i, properties) {
- const LilvNode* p = lilv_nodes_get(properties, i);
- if (lilv_node_is_uri(p)) {
- port->add_property(uris.lv2_portProperty,
- forge.alloc_uri(lilv_node_as_uri(p)));
- }
- }
- lilv_nodes_free(properties);
-
- // Set atom:supports properties
- LilvNodes* types = lilv_port_get_value(plug, id, info->atom_supports);
- LILV_FOREACH(nodes, i, types) {
- const LilvNode* type = lilv_nodes_get(types, i);
- if (lilv_node_is_uri(type)) {
- port->add_property(uris.atom_supports,
- forge.alloc_uri(lilv_node_as_uri(type)));
+ // Inherit certain properties from plugin port
+ LilvNode* preds[] = { info->lv2_portProperty, info->atom_supports, 0 };
+ for (int p = 0; preds[p]; ++p) {
+ LilvNodes* values = lilv_port_get_value(plug, id, preds[p]);
+ LILV_FOREACH(nodes, v, values) {
+ const LilvNode* val = lilv_nodes_get(values, v);
+ if (lilv_node_is_uri(val)) {
+ port->add_property(lilv_node_as_uri(preds[p]),
+ forge.alloc_uri(lilv_node_as_uri(val)));
+ }
}
+ lilv_nodes_free(values);
}
- lilv_nodes_free(types);
_ports->at(j) = port;
}