From 8c19e157e148efb59d6ea2f815783755b6075c7e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 18 Dec 2017 00:45:27 +0100 Subject: Rename Atom::get_body to Atom::body and use Atom::ptr consistently --- ingen/Atom.hpp | 10 +++++----- src/AtomWriter.cpp | 4 ++-- src/Configuration.cpp | 2 +- src/Forge.cpp | 6 +++--- src/Serialiser.cpp | 6 +++--- src/gui/NodeModule.cpp | 2 +- src/server/ControlBindings.cpp | 2 +- src/server/LV2Block.cpp | 2 +- src/server/RunContext.cpp | 2 +- src/server/events/SetPortValue.cpp | 2 +- tests/ingen_bench.cpp | 6 +++--- tests/ingen_test.cpp | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ingen/Atom.hpp b/ingen/Atom.hpp index 86528ea1..a0e30805 100644 --- a/ingen/Atom.hpp +++ b/ingen/Atom.hpp @@ -59,7 +59,7 @@ public: memcpy(_body.ptr, &_atom, sizeof(LV2_Atom)); } if (body) { - memcpy(get_body(), body, size); + memcpy(this->body(), body, size); } } @@ -132,21 +132,21 @@ public: inline LV2_URID type() const { return _atom.type; } inline bool is_valid() const { return _atom.type; } - inline const void* get_body() const { + inline const void* body() const { return is_reference() ? (void*)(_body.ptr + 1) : &_body.val; } - inline void* get_body() { + inline void* body() { return is_reference() ? (void*)(_body.ptr + 1) : &_body.val; } template const T& get() const { assert(size() == sizeof(T)); - return *static_cast(get_body()); + return *static_cast(body()); } template const T* ptr() const { - return static_cast(get_body()); + return static_cast(body()); } const LV2_Atom* atom() const { diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 015e5fc7..0cc90714 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -134,7 +134,7 @@ AtomWriter::forge_properties(ScopedObject& object, const Properties& properties) if (p.second.type() == _forge.URI) { forge_uri(URI(p.second.ptr())); } else { - _forge.atom(p.second.size(), p.second.type(), p.second.get_body()); + _forge.atom(p.second.size(), p.second.type(), p.second.body()); } } } @@ -360,7 +360,7 @@ AtomWriter::operator()(const SetProperty& message) const auto& value = message.value; msg.object.key(_uris.patch_value); - _forge.atom(value.size(), value.type(), value.get_body()); + _forge.atom(value.size(), value.type(), value.body()); } /** @page protocol diff --git a/src/Configuration.cpp b/src/Configuration.cpp index c05c516e..f6d02c18 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -327,7 +327,7 @@ Configuration::save(URIMap& uri_map, SerdNode pred = serd_node_from_string( SERD_CURIE, (const uint8_t*)key.c_str()); sratom_write(sratom, &uri_map.urid_unmap_feature()->urid_unmap, 0, - &base, &pred, value.type(), value.size(), value.get_body()); + &base, &pred, value.type(), value.size(), value.body()); } sratom_free(sratom); diff --git a/src/Forge.cpp b/src/Forge.cpp index fbebbeb5..f54a3cc4 100644 --- a/src/Forge.cpp +++ b/src/Forge.cpp @@ -48,7 +48,7 @@ Forge::str(const Atom& atom, bool quoted) ss << (atom.get() ? "true" : "false"); } else if (atom.type() == URI) { ss << (quoted ? "<" : "") - << atom.ptr() + << atom.ptr() << (quoted ? ">" : ""); } else if (atom.type() == URID) { ss << (quoted ? "<" : "") @@ -56,11 +56,11 @@ Forge::str(const Atom& atom, bool quoted) << (quoted ? ">" : ""); } else if (atom.type() == Path) { ss << (quoted ? "<" : "") - << atom.ptr() + << atom.ptr() << (quoted ? ">" : ""); } else if (atom.type() == String) { ss << (quoted ? "\"" : "") - << atom.ptr() + << atom.ptr() << (quoted ? "\"" : ""); } return ss.str(); diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 36d4a87f..858e7f2d 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -557,7 +557,7 @@ Serialiser::Impl::serialise_properties(Sord::Node id, const Sord::URI key(_model->world(), p.first); if (!skip_property(_world.uris(), key)) { if (p.second.type() == _world.uris().atom_URI && - !strncmp((const char*)p.second.get_body(), "ingen:/main/", 13)) { + !strncmp(p.second.ptr(), "ingen:/main/", 13)) { /* Value is a graph URI relative to the running engine. Chop the prefix and save the path relative to the graph file. This allows saving references to bundle resources. */ @@ -565,12 +565,12 @@ Serialiser::Impl::serialise_properties(Sord::Node id, sord_node_to_serd_node(id.c_obj()), sord_node_to_serd_node(key.c_obj()), p.second.type(), p.second.size(), - (const char*)p.second.get_body() + 13); + p.second.ptr() + 13); } else { sratom_write(_sratom, unmap, 0, sord_node_to_serd_node(id.c_obj()), sord_node_to_serd_node(key.c_obj()), - p.second.type(), p.second.size(), p.second.get_body()); + p.second.type(), p.second.size(), p.second.body()); } } } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 8605e91d..c73cb91e 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -222,7 +222,7 @@ NodeModule::port_value_changed(uint32_t index, const Atom& value) if (value.type() == uris.atom_Float && _block->get_port(index)->is_numeric()) { - _plugin_ui->port_event(index, sizeof(float), 0, value.ptr()); + _plugin_ui->port_event(index, sizeof(float), 0, value.body()); } else { _plugin_ui->port_event(index, lv2_atom_total_size(value.atom()), diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 2a269cac..67842291 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -69,7 +69,7 @@ ControlBindings::binding_key(const Atom& binding) const LV2_Atom* num = nullptr; if (binding.type() == uris.atom_Object) { const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*) - binding.get_body(); + binding.body(); if (obj->otype == uris.midi_Bender) { key = Key(Type::MIDI_BENDER); } else if (obj->otype == uris.midi_ChannelPressure) { diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 765643d6..fd555c7f 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -669,7 +669,7 @@ get_port_value(const char* port_symbol, if (port && port->is_input() && port->value().is_valid()) { *size = port->value().size(); *type = port->value().type(); - return port->value().get_body(); + return port->value().body(); } return nullptr; diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index ee272d46..6efc81ee 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -116,7 +116,7 @@ RunContext::emit_notifications(FrameTime end) if (_event_sink->read(sizeof(note), ¬e) == sizeof(note)) { Atom value = _engine.world()->forge().alloc( note.size, note.type, nullptr); - if (_event_sink->read(note.size, value.get_body()) == note.size) { + if (_event_sink->read(note.size, value.body()) == note.size) { i += note.size; const char* key = _engine.world()->uri_map().unmap_uri(note.key); if (key) { diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index fa36d739..c0087d8f 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -112,7 +112,7 @@ SetPortValue::apply(RunContext& context) if (!buf->append_event(_time - context.start(), _value.size(), _value.type(), - (const uint8_t*)_value.get_body())) { + (const uint8_t*)_value.body())) { _status = Status::NO_SPACE; } } else if (buf->type() == uris.atom_URID) { diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp index 2ac1f5f1..a21601f1 100644 --- a/tests/ingen_bench.cpp +++ b/tests/ingen_bench.cpp @@ -82,11 +82,11 @@ main(int argc, char** argv) } // Get start graph and output file options - const std::string start_graph = real_path((const char*)load.get_body()); - const std::string out_file = (const char*)out.get_body(); + const std::string start_graph = real_path(load.ptr()); + const std::string out_file = out.ptr(); if (start_graph.empty()) { cerr << "error: initial graph '" - << ((const char*)load.get_body()) + << load.ptr() << "' does not exist" << endl; return EXIT_FAILURE; } diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index 4c00799d..22b5b3dc 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -86,7 +86,7 @@ main(int argc, char** argv) } // Get start graph and commands file options - const char* load_path = (const char*)load.get_body(); + const char* load_path = load.ptr(); char* real_start_graph = realpath(load_path, nullptr); if (!real_start_graph) { cerr << "error: initial graph '" << load_path << "' does not exist" << endl; @@ -94,7 +94,7 @@ main(int argc, char** argv) } const std::string start_graph = real_start_graph; - const FilePath cmds_file_path = (const char*)execute.get_body(); + const FilePath cmds_file_path = execute.ptr(); free(real_start_graph); // Load modules -- cgit v1.2.1