diff options
author | David Robillard <d@drobilla.net> | 2015-10-26 16:29:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-26 16:29:11 +0000 |
commit | 965a74ae42dae3ff42f1dcc7c53dddb2b5a31b09 (patch) | |
tree | 10fddc515234d9a1fc5724d134b88eb8c124904f /src | |
parent | 06eb959bf1c249dd66a5a56b78df0ad0de7df29c (diff) | |
download | ingen-965a74ae42dae3ff42f1dcc7c53dddb2b5a31b09.tar.gz ingen-965a74ae42dae3ff42f1dcc7c53dddb2b5a31b09.tar.bz2 ingen-965a74ae42dae3ff42f1dcc7c53dddb2b5a31b09.zip |
Use URIDs almost everywhere
This fixes some issues where types are lost after saving and
re-loading many times.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5788 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/AtomReader.cpp | 9 | ||||
-rw-r--r-- | src/Parser.cpp | 13 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 2 | ||||
-rw-r--r-- | src/gui/GraphCanvas.cpp | 5 | ||||
-rw-r--r-- | src/gui/LoadPluginWindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/NodeMenu.cpp | 2 | ||||
-rw-r--r-- | src/gui/PropertiesWindow.cpp | 21 | ||||
-rw-r--r-- | src/server/LV2Block.cpp | 2 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 3 | ||||
-rw-r--r-- | src/server/events/CreateBlock.cpp | 2 | ||||
-rw-r--r-- | src/server/internals/Controller.cpp | 2 |
11 files changed, 24 insertions, 39 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index 12d2f1a5..ef59e1b5 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -44,9 +44,9 @@ AtomReader::get_atom(const LV2_Atom* in, Atom& out) if (in) { if (in->type == _uris.atom_URID) { const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in; - const char* uri = _map.unmap_uri(urid->body); + const char* uri = _map.unmap_uri(urid->body); if (uri) { - out = _forge.alloc_uri(_map.unmap_uri(urid->body)); + out = _forge.make_urid(urid->body); } else { _log.error(fmt("Unable to unmap URID %1%\n") % urid->body); } @@ -61,9 +61,8 @@ AtomReader::get_props(const LV2_Atom_Object* obj, Ingen::Resource::Properties& props) { if (obj->body.otype) { - props.insert( - std::make_pair(_uris.rdf_type, - _forge.alloc_uri(_map.unmap_uri(obj->body.otype)))); + props.insert(std::make_pair(_uris.rdf_type, + _forge.make_urid(obj->body.otype))); } LV2_ATOM_OBJECT_FOREACH(obj, p) { Atom val; diff --git a/src/Parser.cpp b/src/Parser.cpp index 376bb97d..da0e9376 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -145,15 +145,8 @@ get_properties(Ingen::World* world, model.c_obj(), i.get_object().c_obj()); const LV2_Atom* atom = (const LV2_Atom*)out.buf; Atom atomm; - // FIXME: Don't bloat out all URIs - if (atom->type == forge.URID) { - atomm = world->forge().alloc_uri( - unmap->unmap(unmap->handle, - ((const LV2_Atom_URID*)atom)->body)); - } else { - atomm = world->forge().alloc( - atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); - } + atomm = world->forge().alloc( + atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); props.insert(make_pair(Raul::URI(i.get_predicate().to_string()), Resource::Property(atomm, ctx))); } @@ -343,7 +336,7 @@ parse_block(Ingen::World* world, Resource::Properties props = get_properties( world, model, subject, Resource::Graph::DEFAULT); props.insert(make_pair(uris.rdf_type, - uris.forge.alloc_uri(uris.ingen_Block))); + uris.forge.make_urid(uris.ingen_Block))); target->put(Node::path_to_uri(path), props); } return path; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 5483b427..3c4d13de 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -125,7 +125,7 @@ PluginModel::get_property(const Raul::URI& key) const const LilvNode* val = lilv_nodes_get(values, i); if (lilv_node_is_uri(val)) { ret = set_property( - key, _uris.forge.alloc_uri(lilv_node_as_uri(val))); + key, _uris.forge.make_urid(Raul::URI(lilv_node_as_uri(val)))); break; } else if (lilv_node_is_string(val)) { ret = set_property( diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index be1b9de8..16739a55 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -756,8 +756,7 @@ GraphCanvas::menu_add_port(const string& sym_base, const string& name_base, const URIs& uris = _app.uris(); Resource::Properties props = get_initial_data(); - props.insert(make_pair(uris.rdf_type, - _app.forge().alloc_uri(type))); + props.insert(make_pair(uris.rdf_type, _app.forge().make_urid(type))); if (type == uris.atom_AtomPort) { props.insert(make_pair(uris.atom_bufferType, Resource::Property(uris.atom_Sequence))); @@ -796,7 +795,7 @@ GraphCanvas::load_plugin(WPtr<PluginModel> weak_plugin) props.insert(make_pair(uris.rdf_type, Resource::Property(uris.ingen_Block))); props.insert(make_pair(uris.lv2_prototype, - uris.forge.alloc_uri(plugin->uri()))); + uris.forge.make_urid(plugin->uri()))); _app.interface()->put(Node::path_to_uri(path), props); } diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 073936a8..5d66e7d6 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -396,7 +396,7 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) props.insert(make_pair(uris.rdf_type, Resource::Property(uris.ingen_Block))); props.insert(make_pair(uris.lv2_prototype, - _app->forge().alloc_uri(plugin->uri()))); + _app->forge().make_urid(plugin->uri()))); props.insert(make_pair(uris.ingen_polyphonic, _app->forge().make(polyphonic))); _app->interface()->put(Node::path_to_uri(path), props); diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 7d1d3274..9d827d59 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -234,7 +234,7 @@ NodeMenu::on_preset_activated(const std::string& uri) { _app->set_property(block()->uri(), _app->uris().pset_preset, - _app->forge().alloc_uri(uri)); + _app->forge().make_urid(Raul::URI(uri))); } bool diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index 0ae2709d..09474027 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -449,16 +449,16 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) if (check) { return _app->forge().make(check->get_active()); } - } else if (type == forge.URI) { + } else if (type == forge.URI || type == forge.URID) { URIEntry* uri_entry = dynamic_cast<URIEntry*>(value_widget); if (uri_entry) { - return _app->forge().alloc_uri(uri_entry->get_text()); - } - } else if (type == forge.URID) { - URIEntry* uri_entry = dynamic_cast<URIEntry*>(value_widget); - if (uri_entry) { - return _app->forge().make_urid( - _app->world()->uri_map().map_uri(uri_entry->get_text())); + if (Raul::URI::is_valid(uri_entry->get_text())) { + return _app->forge().make_urid( + _app->world()->uri_map().map_uri(uri_entry->get_text())); + } else { + _app->log().error(fmt("Invalid URI <%1%>\n\n") + % uri_entry->get_text()); + } } } else if (type == forge.String) { Gtk::Entry* entry = dynamic_cast<Gtk::Entry*>(value_widget); @@ -467,11 +467,6 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } } - URIEntry* uri_entry = dynamic_cast<URIEntry*>(value_widget); - if (uri_entry) { - return _app->forge().alloc_uri(uri_entry->get_text()); - } - return Atom(); } diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 14aa42ae..f7627416 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -396,7 +396,7 @@ LV2Block::instantiate(BufferFactory& bufs) const LilvNode* val = lilv_nodes_get(values, v); if (lilv_node_is_uri(val)) { port->add_property(Raul::URI(lilv_node_as_uri(preds[p])), - forge.alloc_uri(lilv_node_as_uri(val))); + forge.make_urid(Raul::URI(lilv_node_as_uri(val)))); } } lilv_nodes_free(values); diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 13eaa8e2..87edd1f5 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -110,8 +110,7 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type) remove_property(uris.rdf_type, uris.lv2_CVPort); remove_property(uris.rdf_type, uris.lv2_ControlPort); remove_property(uris.rdf_type, uris.atom_AtomPort); - add_property(uris.rdf_type, - world->forge().alloc_uri(port_type.uri().c_str())); + add_property(uris.rdf_type, world->forge().make_urid(port_type.uri())); // Update audio thread types _type = port_type; diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index e213f765..7ba35d1a 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -111,7 +111,7 @@ CreateBlock::pre_process() _properties.erase(uris.ingen_prototype); _properties.erase(uris.lv2_prototype); _properties.insert(std::make_pair(uris.lv2_prototype, - uris.forge.alloc_uri(ancestor->plugin()->uri()))); + uris.forge.make_urid(ancestor->plugin()->uri()))); } else { // Prototype is a plugin PluginImpl* const plugin = _engine.block_factory()->plugin(prototype); diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 8913d293..f6555a96 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -55,7 +55,7 @@ ControllerNode::ControllerNode(InternalPlugin* plugin, const Atom zero = bufs.forge().make(0.0f); const Atom one = bufs.forge().make(1.0f); - const Atom atom_Float = bufs.forge().alloc_uri(LV2_ATOM__Float); + const Atom atom_Float = bufs.forge().make_urid(Raul::URI(LV2_ATOM__Float)); _midi_in_port = new InputPort(bufs, this, Raul::Symbol("input"), 0, 1, PortType::ATOM, uris.atom_Sequence, Atom()); |