summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-01 11:50:31 +0200
committerDavid Robillard <d@drobilla.net>2020-08-01 16:48:06 +0200
commit358c0a4140406c8c38138a88aa03a4fc0ec6e7ee (patch)
tree21a0c0397ca9bd8e67136c472d8146bb3a22a204
parentb453818f17a84c01d679088e5a377e244a231981 (diff)
downloadingen-358c0a4140406c8c38138a88aa03a4fc0ec6e7ee.tar.gz
ingen-358c0a4140406c8c38138a88aa03a4fc0ec6e7ee.tar.bz2
ingen-358c0a4140406c8c38138a88aa03a4fc0ec6e7ee.zip
Use modern casts
-rw-r--r--.clang-tidy1
-rw-r--r--ingen/Atom.hpp14
-rw-r--r--ingen/AtomForge.hpp13
-rw-r--r--ingen/Clock.hpp3
-rw-r--r--ingen/DataAccess.hpp5
-rw-r--r--ingen/URI.hpp25
-rw-r--r--src/AtomReader.cpp63
-rw-r--r--src/AtomWriter.cpp3
-rw-r--r--src/ColorContext.cpp2
-rw-r--r--src/Configuration.cpp35
-rw-r--r--src/LV2Features.cpp4
-rw-r--r--src/Parser.cpp23
-rw-r--r--src/Serialiser.cpp30
-rw-r--r--src/SocketReader.cpp22
-rw-r--r--src/TurtleWriter.cpp14
-rw-r--r--src/URI.cpp27
-rw-r--r--src/URIMap.cpp4
-rw-r--r--src/World.cpp7
-rw-r--r--src/client/BlockModel.cpp4
-rw-r--r--src/client/PluginUI.cpp14
-rw-r--r--src/gui/App.cpp2
-rw-r--r--src/gui/GraphBox.cpp3
-rw-r--r--src/gui/GraphCanvas.cpp23
-rw-r--r--src/gui/GraphPortModule.cpp2
-rw-r--r--src/gui/GraphTreeWindow.cpp2
-rw-r--r--src/gui/GraphView.cpp5
-rw-r--r--src/gui/MessagesWindow.cpp4
-rw-r--r--src/gui/NodeModule.cpp10
-rw-r--r--src/gui/Port.cpp2
-rw-r--r--src/gui/ingen_gui_lv2.cpp12
-rw-r--r--src/gui/rgba.hpp18
-rw-r--r--src/ingen/ingen.cpp18
-rw-r--r--src/server/BlockFactory.cpp2
-rw-r--r--src/server/BlockImpl.cpp2
-rw-r--r--src/server/BlockImpl.hpp5
-rw-r--r--src/server/Buffer.cpp31
-rw-r--r--src/server/Buffer.hpp11
-rw-r--r--src/server/BufferFactory.cpp3
-rw-r--r--src/server/ClientUpdate.cpp2
-rw-r--r--src/server/ControlBindings.cpp27
-rw-r--r--src/server/FrameTimer.hpp16
-rw-r--r--src/server/JackDriver.cpp38
-rw-r--r--src/server/JackDriver.hpp10
-rw-r--r--src/server/LV2Block.cpp14
-rw-r--r--src/server/LV2Block.hpp2
-rw-r--r--src/server/LV2Options.hpp2
-rw-r--r--src/server/Load.hpp4
-rw-r--r--src/server/NodeImpl.cpp2
-rw-r--r--src/server/PortAudioDriver.cpp9
-rw-r--r--src/server/PortAudioDriver.hpp2
-rw-r--r--src/server/PortImpl.cpp16
-rw-r--r--src/server/PortImpl.hpp2
-rw-r--r--src/server/PreProcessor.cpp6
-rw-r--r--src/server/RunContext.hpp2
-rw-r--r--src/server/SocketListener.cpp2
-rw-r--r--src/server/ThreadManager.hpp4
-rw-r--r--src/server/UndoStack.cpp58
-rw-r--r--src/server/UndoStack.hpp2
-rw-r--r--src/server/Worker.cpp11
-rw-r--r--src/server/events/CreatePort.cpp4
-rw-r--r--src/server/events/Delete.cpp6
-rw-r--r--src/server/events/Delta.cpp2
-rw-r--r--src/server/events/SetPortValue.cpp2
-rw-r--r--src/server/ingen_jack.cpp17
-rw-r--r--src/server/ingen_lv2.cpp112
-rw-r--r--src/server/ingen_portaudio.cpp11
-rw-r--r--src/server/internals/Controller.cpp2
-rw-r--r--src/server/internals/Note.cpp19
-rw-r--r--src/server/internals/Trigger.cpp4
-rw-r--r--src/server/mix.cpp4
-rw-r--r--tests/ingen_bench.cpp8
-rw-r--r--tests/ingen_test.cpp15
-rw-r--r--wscript2
73 files changed, 532 insertions, 375 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 1580361b..fbab6d47 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -27,7 +27,6 @@ Checks: >
-fuchsia-*,
-google-build-using-namespace,
-google-default-arguments,
- -google-readability-casting,
-google-readability-todo,
-google-runtime-references,
-hicpp-multiway-paths-covered,
diff --git a/ingen/Atom.hpp b/ingen/Atom.hpp
index f028088d..c4020b91 100644
--- a/ingen/Atom.hpp
+++ b/ingen/Atom.hpp
@@ -55,7 +55,7 @@ public:
_atom.type = type;
_body.ptr = nullptr;
if (is_reference()) {
- _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + size);
+ _body.ptr = static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + size));
memcpy(_body.ptr, &_atom, sizeof(LV2_Atom));
}
if (body) {
@@ -67,7 +67,9 @@ public:
: _atom(copy._atom)
{
if (is_reference()) {
- _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size);
+ _body.ptr =
+ static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + _atom.size));
+
memcpy(_body.ptr, copy._body.ptr, sizeof(LV2_Atom) + _atom.size);
} else {
_body.val = copy._body.val;
@@ -81,7 +83,9 @@ public:
dealloc();
_atom = other._atom;
if (is_reference()) {
- _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size);
+ _body.ptr =
+ static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + _atom.size));
+
memcpy(_body.ptr, other._body.ptr, sizeof(LV2_Atom) + _atom.size);
} else {
_body.val = other._body.val;
@@ -133,11 +137,11 @@ public:
inline bool is_valid() const { return _atom.type; }
inline const void* get_body() const {
- return is_reference() ? (void*)(_body.ptr + 1) : &_body.val;
+ return is_reference() ? static_cast<void*>(_body.ptr + 1) : &_body.val;
}
inline void* get_body() {
- return is_reference() ? (void*)(_body.ptr + 1) : &_body.val;
+ return is_reference() ? static_cast<void*>(_body.ptr + 1) : &_body.val;
}
template <typename T> const T& get() const {
diff --git a/ingen/AtomForge.hpp b/ingen/AtomForge.hpp
index acb24fac..10517894 100644
--- a/ingen/AtomForge.hpp
+++ b/ingen/AtomForge.hpp
@@ -39,7 +39,7 @@ public:
: _size{0}
, _capacity{8 * sizeof(LV2_Atom)}
, _sratom{sratom_new(&map)}
- , _buf{(LV2_Atom*)calloc(8, sizeof(LV2_Atom))}
+ , _buf{static_cast<LV2_Atom*>(calloc(8, sizeof(LV2_Atom)))}
{
lv2_atom_forge_init(this, &map);
lv2_atom_forge_set_sink(this, c_append, c_deref, this);
@@ -79,11 +79,12 @@ private:
// Update size and reallocate if necessary
if (lv2_atom_pad_size(_size + len) > _capacity) {
_capacity = lv2_atom_pad_size(_size + len);
- _buf = AtomPtr{(LV2_Atom*)realloc(_buf.release(), _capacity)};
+ _buf = AtomPtr{
+ static_cast<LV2_Atom*>(realloc(_buf.release(), _capacity))};
}
// Append new data
- memcpy((uint8_t*)_buf.get() + _size, buf, len);
+ memcpy(reinterpret_cast<uint8_t*>(_buf.get()) + _size, buf, len);
_size += len;
return ref;
}
@@ -94,7 +95,7 @@ private:
-Wcast-align. This is questionable at best, though the forge should
only dereference references to aligned atoms. */
assert((ref - 1) % sizeof(LV2_Atom) == 0);
- return (LV2_Atom*)(_buf.get() + (ref - 1) / sizeof(LV2_Atom));
+ return static_cast<LV2_Atom*>(_buf.get() + (ref - 1) / sizeof(LV2_Atom));
// Alternatively:
// return (LV2_Atom*)((uint8_t*)_buf + ref - 1);
@@ -102,12 +103,12 @@ private:
static LV2_Atom_Forge_Ref
c_append(void* handle, const void* buf, uint32_t len) {
- return ((AtomForge*)handle)->append(buf, len);
+ return static_cast<AtomForge*>(handle)->append(buf, len);
}
static LV2_Atom*
c_deref(void* handle, LV2_Atom_Forge_Ref ref) {
- return ((AtomForge*)handle)->deref(ref);
+ return static_cast<AtomForge*>(handle)->deref(ref);
}
size_t _size; ///< Current atom size
diff --git a/ingen/Clock.hpp b/ingen/Clock.hpp
index ac940fab..40204a6b 100644
--- a/ingen/Clock.hpp
+++ b/ingen/Clock.hpp
@@ -52,7 +52,8 @@ private:
# else
clock_gettime(CLOCK_MONOTONIC, &time);
# endif
- return (uint64_t)time.tv_sec * 1e6 + (uint64_t)time.tv_nsec / 1e3;
+ return static_cast<uint64_t>(time.tv_sec) * 1e6 +
+ static_cast<uint64_t>(time.tv_nsec) / 1e3;
}
#endif
diff --git a/ingen/DataAccess.hpp b/ingen/DataAccess.hpp
index a0c9fdf7..99847896 100644
--- a/ingen/DataAccess.hpp
+++ b/ingen/DataAccess.hpp
@@ -52,8 +52,9 @@ struct DataAccess : public ingen::LV2Features::Feature
}
const LV2_Descriptor* desc = lilv_instance_get_descriptor(inst);
- LV2_Extension_Data_Feature* data = (LV2_Extension_Data_Feature*)
- malloc(sizeof(LV2_Extension_Data_Feature));
+ LV2_Extension_Data_Feature* data =
+ static_cast<LV2_Extension_Data_Feature*>(
+ malloc(sizeof(LV2_Extension_Data_Feature)));
data->data_access = desc->extension_data;
diff --git a/ingen/URI.hpp b/ingen/URI.hpp
index cbbfd46a..78577d90 100644
--- a/ingen/URI.hpp
+++ b/ingen/URI.hpp
@@ -58,7 +58,11 @@ public:
std::string string() const { return std::string(c_str(), _node.n_bytes); }
size_t length() const { return _node.n_bytes; }
- const char* c_str() const { return (const char*)_node.buf; }
+
+ const char* c_str() const
+ {
+ return reinterpret_cast<const char*>(_node.buf);
+ }
FilePath file_path() const {
return scheme() == "file" ? FilePath(path()) : FilePath();
@@ -66,8 +70,15 @@ public:
operator std::string() const { return string(); }
- const char* begin() const { return (const char*)_node.buf; }
- const char* end() const { return (const char*)_node.buf + _node.n_bytes; }
+ const char* begin() const
+ {
+ return reinterpret_cast<const char*>(_node.buf);
+ }
+
+ const char* end() const
+ {
+ return reinterpret_cast<const char*>(_node.buf) + _node.n_bytes;
+ }
Chunk scheme() const { return make_chunk(_uri.scheme); }
Chunk authority() const { return make_chunk(_uri.authority); }
@@ -75,8 +86,10 @@ public:
Chunk query() const { return make_chunk(_uri.query); }
Chunk fragment() const { return make_chunk(_uri.fragment); }
- static bool is_valid(const char* str) {
- return serd_uri_string_has_scheme((const uint8_t*)str);
+ static bool is_valid(const char* str)
+ {
+ return serd_uri_string_has_scheme(
+ reinterpret_cast<const uint8_t*>(str));
}
static bool is_valid(const std::string& str)
@@ -88,7 +101,7 @@ private:
URI(SerdNode node, SerdURI uri);
static Chunk make_chunk(const SerdChunk& chunk) {
- return Chunk((const char*)chunk.buf, chunk.len);
+ return Chunk(reinterpret_cast<const char*>(chunk.buf), chunk.len);
}
SerdURI _uri;
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 13cd9470..4c8cd4ef 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -85,21 +85,22 @@ AtomReader::atom_to_uri(const LV2_Atom* atom)
if (!atom) {
return boost::optional<URI>();
} else if (atom->type == _uris.atom_URI) {
- const char* str = (const char*)LV2_ATOM_BODY_CONST(atom);
+ const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (URI::is_valid(str)) {
return URI(str);
} else {
_log.warn("Invalid URI <%1%>\n", str);
}
} else if (atom->type == _uris.atom_Path) {
- const char* str = (const char*)LV2_ATOM_BODY_CONST(atom);
+ const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (!strncmp(str, "file://", 5)) {
return URI(str);
} else {
return URI(std::string("file://") + str);
}
} else if (atom->type == _uris.atom_URID) {
- const char* str = _map.unmap_uri(((const LV2_Atom_URID*)atom)->body);
+ const char* str =
+ _map.unmap_uri(reinterpret_cast<const LV2_Atom_URID*>(atom)->body);
if (str) {
return URI(str);
} else {
@@ -141,7 +142,7 @@ AtomReader::is_message(const URIs& uris, const LV2_Atom* msg)
return false;
}
- const auto* obj = (const LV2_Atom_Object*)msg;
+ const auto* obj = reinterpret_cast<const LV2_Atom_Object*>(msg);
return (obj->body.otype == uris.patch_Get ||
obj->body.otype == uris.patch_Delete ||
obj->body.otype == uris.patch_Put ||
@@ -159,19 +160,19 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
return false;
}
- const auto* obj = (const LV2_Atom_Object*)msg;
+ const auto* obj = reinterpret_cast<const LV2_Atom_Object*>(msg);
const LV2_Atom* subject = nullptr;
const LV2_Atom* number = nullptr;
lv2_atom_object_get(obj,
- (LV2_URID)_uris.patch_subject, &subject,
- (LV2_URID)_uris.patch_sequenceNumber, &number,
+ _uris.patch_subject.urid(), &subject,
+ _uris.patch_sequenceNumber.urid(), &number,
nullptr);
const boost::optional<URI> subject_uri = atom_to_uri(subject);
const int32_t seq = ((number && number->type == _uris.atom_Int)
- ? ((const LV2_Atom_Int*)number)->body
+ ? reinterpret_cast<const LV2_Atom_Int*>(number)->body
: default_id);
if (obj->body.otype == _uris.patch_Get) {
@@ -188,7 +189,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
_iface(Redo{seq});
} else if (obj->body.otype == _uris.patch_Delete) {
const LV2_Atom_Object* body = nullptr;
- lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
+ lv2_atom_object_get(obj,
+ _uris.patch_body.urid(), &body,
+ 0);
if (subject_uri && !body) {
_iface(Del{seq, *subject_uri});
@@ -198,9 +201,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const LV2_Atom* head = nullptr;
const LV2_Atom* incidentTo = nullptr;
lv2_atom_object_get(body,
- (LV2_URID)_uris.ingen_tail, &tail,
- (LV2_URID)_uris.ingen_head, &head,
- (LV2_URID)_uris.ingen_incidentTo, &incidentTo,
+ _uris.ingen_tail.urid(), &tail,
+ _uris.ingen_head.urid(), &head,
+ _uris.ingen_incidentTo.urid(), &incidentTo,
nullptr);
boost::optional<Raul::Path> subject_path(atom_to_path(subject));
@@ -220,8 +223,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const LV2_Atom_Object* body = nullptr;
const LV2_Atom* context = nullptr;
lv2_atom_object_get(obj,
- (LV2_URID)_uris.patch_body, &body,
- (LV2_URID)_uris.patch_context, &context,
+ _uris.patch_body.urid(), &body,
+ _uris.patch_context.urid(), &context,
0);
if (!body) {
_log.warn("Put message has no body\n");
@@ -235,8 +238,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
LV2_Atom* tail = nullptr;
LV2_Atom* head = nullptr;
lv2_atom_object_get(body,
- (LV2_URID)_uris.ingen_tail, &tail,
- (LV2_URID)_uris.ingen_head, &head,
+ _uris.ingen_tail.urid(), &tail,
+ _uris.ingen_head.urid(), &head,
nullptr);
if (!tail || !head) {
_log.warn("Arc has no tail or head\n");
@@ -265,11 +268,12 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const LV2_Atom* value = nullptr;
const LV2_Atom* context = nullptr;
lv2_atom_object_get(obj,
- (LV2_URID)_uris.patch_property, &prop,
- (LV2_URID)_uris.patch_value, &value,
- (LV2_URID)_uris.patch_context, &context,
+ _uris.patch_property.urid(), &prop,
+ _uris.patch_value.urid(), &value,
+ _uris.patch_context.urid(), &context,
0);
- if (!prop || ((const LV2_Atom*)prop)->type != _uris.atom_URID) {
+ if (!prop ||
+ reinterpret_cast<const LV2_Atom*>(prop)->type != _uris.atom_URID) {
_log.warn("Set message missing property\n");
return false;
} else if (!value) {
@@ -294,9 +298,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const LV2_Atom_Object* add = nullptr;
const LV2_Atom* context = nullptr;
lv2_atom_object_get(obj,
- (LV2_URID)_uris.patch_remove, &remove,
- (LV2_URID)_uris.patch_add, &add,
- (LV2_URID)_uris.patch_context, &context,
+ _uris.patch_remove.urid(), &remove,
+ _uris.patch_add.urid(), &add,
+ _uris.patch_context.urid(), &context,
0);
if (!remove) {
_log.warn("Patch message has no remove\n");
@@ -321,7 +325,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
}
const LV2_Atom* dest = nullptr;
- lv2_atom_object_get(obj, (LV2_URID)_uris.patch_destination, &dest, 0);
+ lv2_atom_object_get(obj, _uris.patch_destination.urid(), &dest, 0);
if (!dest) {
_log.warn("Copy message has no destination\n");
return false;
@@ -347,7 +351,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
}
const LV2_Atom* dest = nullptr;
- lv2_atom_object_get(obj, (LV2_URID)_uris.patch_destination, &dest, 0);
+ lv2_atom_object_get(obj, _uris.patch_destination.urid(), &dest, 0);
if (!dest) {
_log.warn("Move message has no destination\n");
return false;
@@ -370,8 +374,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const LV2_Atom* seq = nullptr;
const LV2_Atom* body = nullptr;
lv2_atom_object_get(obj,
- (LV2_URID)_uris.patch_sequenceNumber, &seq,
- (LV2_URID)_uris.patch_body, &body,
+ _uris.patch_sequenceNumber.urid(), &seq,
+ _uris.patch_body.urid(), &body,
0);
if (!seq || seq->type != _uris.atom_Int) {
_log.warn("Response message has no sequence number\n");
@@ -380,8 +384,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
_log.warn("Response message body is not integer\n");
return false;
}
- _iface(Response{((const LV2_Atom_Int*)seq)->body,
- (ingen::Status)((const LV2_Atom_Int*)body)->body,
+ _iface(Response{reinterpret_cast<const LV2_Atom_Int*>(seq)->body,
+ static_cast<ingen::Status>(
+ reinterpret_cast<const LV2_Atom_Int*>(body)->body),
subject_uri ? subject_uri->c_str() : ""});
} else {
_log.warn("Unknown object type <%1%>\n",
diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index 27f224fc..365c955d 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -135,7 +135,8 @@ AtomWriter::operator()(const BundleEnd& message)
void
AtomWriter::forge_uri(const URI& uri)
{
- if (serd_uri_string_has_scheme((const uint8_t*)uri.c_str())) {
+ if (serd_uri_string_has_scheme(
+ reinterpret_cast<const uint8_t*>(uri.c_str()))) {
lv2_atom_forge_urid(&_forge, _map.map_uri(uri.c_str()));
} else {
lv2_atom_forge_uri(&_forge, uri.c_str(), uri.length());
diff --git a/src/ColorContext.cpp b/src/ColorContext.cpp
index 9794e8ce..ac797518 100644
--- a/src/ColorContext.cpp
+++ b/src/ColorContext.cpp
@@ -29,7 +29,7 @@ ColorContext::ColorContext(FILE* stream, Color color)
: _stream(stream)
{
if (isatty(fileno(_stream))) {
- fprintf(_stream, "\033[0;%dm", (int)color);
+ fprintf(_stream, "\033[0;%dm", static_cast<int>(color));
}
}
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 5178e97a..6ddec134 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -233,15 +233,16 @@ Configuration::load(const FilePath& path)
}
SerdNode node = serd_node_new_file_uri(
- (const uint8_t*)path.c_str(), nullptr, nullptr, true);
- const std::string uri((const char*)node.buf);
+ reinterpret_cast<const uint8_t*>(path.c_str()), nullptr, nullptr, true);
+
+ const std::string uri(reinterpret_cast<const char*>(node.buf));
Sord::World world;
Sord::Model model(world, uri, SORD_SPO, false);
SerdEnv* env = serd_env_new(&node);
model.load_file(env, SERD_TURTLE, uri, uri);
- Sord::Node nodemm(world, Sord::Node::URI, (const char*)node.buf);
+ Sord::Node nodemm(world, Sord::Node::URI, reinterpret_cast<const char*>(node.buf));
Sord::Node nil;
for (Sord::Iter i = model.find(nodemm, nil, nil); !i.end(); ++i) {
const Sord::Node& pred = i.get_predicate();
@@ -290,31 +291,41 @@ Configuration::save(URIMap& uri_map,
// Use the file's URI as the base URI
SerdURI base_uri;
- SerdNode base = serd_node_new_file_uri(
- (const uint8_t*)path.c_str(), nullptr, &base_uri, true);
+ SerdNode base =
+ serd_node_new_file_uri(reinterpret_cast<const uint8_t*>(path.c_str()),
+ nullptr,
+ &base_uri,
+ true);
// Create environment with ingen prefix
SerdEnv* env = serd_env_new(&base);
- serd_env_set_prefix_from_strings(
- env, (const uint8_t*)"ingen", (const uint8_t*)INGEN_NS);
+ serd_env_set_prefix_from_strings(env,
+ reinterpret_cast<const uint8_t*>("ingen"),
+ reinterpret_cast<const uint8_t*>(
+ INGEN_NS));
// Create Turtle writer
SerdWriter* writer = serd_writer_new(
SERD_TURTLE,
- (SerdStyle)(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED),
+ static_cast<SerdStyle>(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED),
env,
&base_uri,
serd_file_sink,
file.get());
// Write a prefix directive for each prefix in the environment
- serd_env_foreach(env, (SerdPrefixSink)serd_writer_set_prefix, writer);
+ serd_env_foreach(env,
+ reinterpret_cast<SerdPrefixSink>(serd_writer_set_prefix),
+ writer);
// Create an atom serialiser and connect it to the Turtle writer
Sratom* sratom = sratom_new(&uri_map.urid_map_feature()->urid_map);
sratom_set_pretty_numbers(sratom, true);
- sratom_set_sink(sratom, (const char*)base.buf,
- (SerdStatementSink)serd_writer_write_statement, nullptr,
+ sratom_set_sink(sratom,
+ reinterpret_cast<const char*>(base.buf),
+ reinterpret_cast<SerdStatementSink>(
+ serd_writer_write_statement),
+ nullptr,
writer);
// Write a statement for each valid option
@@ -328,7 +339,7 @@ Configuration::save(URIMap& uri_map,
const std::string key(std::string("ingen:") + o.second.key);
SerdNode pred = serd_node_from_string(
- SERD_CURIE, (const uint8_t*)key.c_str());
+ SERD_CURIE, reinterpret_cast<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());
}
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index cd03cccd..43470d94 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -38,7 +38,9 @@ LV2Features::add_feature(const SPtr<Feature>& feature)
LV2Features::FeatureArray::FeatureArray(FeatureVector& features)
: _features(features)
{
- _array = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * (features.size() + 1));
+ _array = static_cast<LV2_Feature**>(
+ malloc(sizeof(LV2_Feature*) * (features.size() + 1)));
+
_array[features.size()] = nullptr;
for (size_t i = 0; i < features.size(); ++i) {
_array[i] = features[i].get();
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 5cc1dedd..e7bd0163 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -75,7 +75,7 @@ Parser::find_resources(Sord::World& world,
std::string file_path;
if (!f.end()) {
uint8_t* p = serd_file_uri_parse(f.get_object().to_u_string(), nullptr);
- file_path = (const char*)p;
+ file_path = reinterpret_cast<const char*>(p);
serd_free(p);
}
resources.insert(ResourceRecord(resource, file_path));
@@ -274,12 +274,15 @@ parse_block(ingen::World& world,
return boost::optional<Raul::Path>();
}
- const auto* type_uri = (const uint8_t*)prototype.to_c_string();
+ const auto* type_uri =
+ reinterpret_cast<const uint8_t*>(prototype.to_c_string());
+
if (!serd_uri_string_has_scheme(type_uri) ||
- !strncmp((const char*)type_uri, "file:", 5)) {
+ !strncmp(reinterpret_cast<const char*>(type_uri), "file:", 5)) {
// Prototype is a file, subgraph
SerdURI base_uri_parts;
- serd_uri_parse((const uint8_t*)base_uri.c_str(), &base_uri_parts);
+ serd_uri_parse(reinterpret_cast<const uint8_t*>(base_uri.c_str()),
+ &base_uri_parts);
SerdURI ignored;
SerdNode sub_uri = serd_node_new_uri_from_string(
@@ -287,11 +290,11 @@ parse_block(ingen::World& world,
&base_uri_parts,
&ignored);
- const std::string sub_uri_str = (const char*)sub_uri.buf;
+ const std::string sub_uri_str = reinterpret_cast<const char*>(sub_uri.buf);
const std::string sub_file = sub_uri_str + "/main.ttl";
const SerdNode sub_base = serd_node_from_string(
- SERD_URI, (const uint8_t*)sub_file.c_str());
+ SERD_URI, reinterpret_cast<const uint8_t*>(sub_file.c_str()));
Sord::Model sub_model(*world.rdf_world(), sub_file);
SerdEnv* env = serd_env_new(&sub_base);
@@ -632,7 +635,7 @@ Parser::parse_file(ingen::World& world,
// Initialise parsing environment
const URI file_uri = URI(file_path);
- const auto* uri_c_str = (const uint8_t*)uri.c_str();
+ const auto* uri_c_str = reinterpret_cast<const uint8_t*>(uri.c_str());
SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str);
SerdEnv* env = serd_env_new(&base_node);
@@ -680,12 +683,14 @@ Parser::parse_string(ingen::World& world,
SerdEnv* env = serd_env_new(nullptr);
if (!base_uri.empty()) {
const SerdNode base = serd_node_from_string(
- SERD_URI, (const uint8_t*)base_uri.c_str());
+ SERD_URI, reinterpret_cast<const uint8_t*>(base_uri.c_str()));
serd_env_set_base_uri(env, &base);
}
model.load_string(env, SERD_TURTLE, str.c_str(), str.length(), base_uri);
- URI actual_base((const char*)serd_env_get_base_uri(env, nullptr)->buf);
+ URI actual_base(reinterpret_cast<const char*>(
+ serd_env_get_base_uri(env, nullptr)->buf));
+
serd_env_free(env);
world.log().info("Parsing string (base %1%)\n", base_uri);
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index f0b5009e..b6545e0d 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -353,17 +353,20 @@ Serialiser::Impl::serialise_graph(const SPtr<const Node>& graph,
SPtr<Node> subgraph = n->second;
SerdURI base_uri;
- serd_uri_parse((const uint8_t*)_base_uri.c_str(), &base_uri);
+ serd_uri_parse(reinterpret_cast<const uint8_t*>(_base_uri.c_str()),
+ &base_uri);
const std::string sub_bundle_path = subgraph->path().substr(1) + ".ingen";
SerdURI subgraph_uri;
SerdNode subgraph_node = serd_node_new_uri_from_string(
- (const uint8_t*)sub_bundle_path.c_str(),
+ reinterpret_cast<const uint8_t*>(sub_bundle_path.c_str()),
&base_uri,
&subgraph_uri);
- const Sord::URI subgraph_id(world, (const char*)subgraph_node.buf);
+ const Sord::URI subgraph_id(world,
+ reinterpret_cast<const char*>(
+ subgraph_node.buf));
// Save our state
URI my_base_uri = _base_uri;
@@ -552,14 +555,19 @@ void
Serialiser::Impl::serialise_properties(Sord::Node id,
const Properties& props)
{
- LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap_feature()->urid_unmap;
- SerdNode base = serd_node_from_string(SERD_URI,
- (const uint8_t*)_base_uri.c_str());
+ LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap_feature()->urid_unmap;
+ SerdNode base = serd_node_from_string(SERD_URI,
+ reinterpret_cast<const uint8_t*>(
+ _base_uri.c_str()));
+
SerdEnv* env = serd_env_new(&base);
SordInserter* inserter = sord_inserter_new(_model->c_obj(), env);
- sratom_set_sink(_sratom, _base_uri.c_str(),
- (SerdStatementSink)sord_inserter_write_statement, nullptr,
+ sratom_set_sink(_sratom,
+ _base_uri.c_str(),
+ reinterpret_cast<SerdStatementSink>(
+ sord_inserter_write_statement),
+ nullptr,
inserter);
sratom_set_pretty_numbers(_sratom, true);
@@ -568,7 +576,9 @@ 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(reinterpret_cast<const char*>(p.second.get_body()),
+ "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. */
@@ -576,7 +586,7 @@ 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);
+ reinterpret_cast<const char*>(p.second.get_body()) + 13);
} else {
sratom_write(_sratom, unmap, 0,
sord_node_to_serd_node(id.c_obj()),
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index 409a1d86..88aad63f 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -97,7 +97,7 @@ SocketReader::write_statement(SocketReader* iface,
size_t
SocketReader::c_recv(void* buf, size_t size, size_t nmemb, void* stream)
{
- SocketReader* self = (SocketReader*)stream;
+ SocketReader* self = static_cast<SocketReader*>(stream);
const ssize_t c = recv(self->_socket->fd(), buf, size * nmemb, MSG_WAITALL);
if (c < 0) {
@@ -111,7 +111,7 @@ SocketReader::c_recv(void* buf, size_t size, size_t nmemb, void* stream)
int
SocketReader::c_err(void* stream)
{
- SocketReader* self = (SocketReader*)stream;
+ SocketReader* self = static_cast<SocketReader*>(stream);
return self->_socket_error;
}
@@ -131,7 +131,8 @@ SocketReader::run()
std::lock_guard<std::mutex> lock(_world.rdf_mutex());
// Use <ingen:/> as base URI, so relative URIs are like bundle paths
- base_uri = sord_new_uri(world->c_obj(), (const uint8_t*)"ingen:/");
+ base_uri = sord_new_uri(world->c_obj(),
+ reinterpret_cast<const uint8_t*>("ingen:/"));
// Make a model and reader to parse the next Turtle message
_env = world->prefixes().c_obj();
@@ -143,14 +144,19 @@ SocketReader::run()
SerdReader* reader = serd_reader_new(
SERD_TURTLE, this, nullptr,
- (SerdBaseSink)set_base_uri,
- (SerdPrefixSink)set_prefix,
- (SerdStatementSink)write_statement,
+ reinterpret_cast<SerdBaseSink>(set_base_uri),
+ reinterpret_cast<SerdPrefixSink>(set_prefix),
+ reinterpret_cast<SerdStatementSink>(write_statement),
nullptr);
serd_env_set_base_uri(_env, sord_node_to_serd_node(base_uri));
- serd_reader_start_source_stream(
- reader, c_recv, c_err, this, (const uint8_t*)"(socket)", 1);
+ serd_reader_start_source_stream(reader,
+ c_recv,
+ c_err,
+ this,
+ reinterpret_cast<const uint8_t*>(
+ "(socket)"),
+ 1);
// Make an AtomReader to call Ingen Interface methods based on Atom
AtomReader ar(_world.uri_map(), _world.uris(), _world.log(), _iface);
diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp
index 1deb2e13..4e0e55da 100644
--- a/src/TurtleWriter.cpp
+++ b/src/TurtleWriter.cpp
@@ -19,7 +19,7 @@
#include "ingen/URIMap.hpp"
#include "lv2/atom/atom.h"
-#define USTR(s) ((const uint8_t*)(s))
+#define USTR(s) reinterpret_cast<const uint8_t*>(s)
namespace ingen {
@@ -33,7 +33,7 @@ c_text_sink(const void* buf, size_t len, void* stream)
static SerdStatus
write_prefix(void* handle, const SerdNode* name, const SerdNode* uri)
{
- serd_writer_set_prefix((SerdWriter*)handle, name, uri);
+ serd_writer_set_prefix(static_cast<SerdWriter*>(handle), name, uri);
return SERD_SUCCESS;
}
@@ -47,7 +47,7 @@ TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri)
, _wrote_prefixes(false)
{
// Use <ingen:/> as base URI, so relative URIs are like bundle paths
- _base = serd_node_from_string(SERD_URI, (const uint8_t*)"ingen:/");
+ _base = serd_node_from_string(SERD_URI, USTR("ingen:/"));
serd_uri_parse(_base.buf, &_base_uri);
// Set up serialisation environment
@@ -66,7 +66,7 @@ TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri)
// Make a Turtle writer that writes to text_sink
_writer = serd_writer_new(
SERD_TURTLE,
- (SerdStyle)(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED|SERD_STYLE_CURIED),
+ static_cast<SerdStyle>(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED|SERD_STYLE_CURIED),
_env,
&_base_uri,
c_text_sink,
@@ -74,9 +74,9 @@ TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri)
// Configure sratom to write directly to the writer (and thus text_sink)
sratom_set_sink(_sratom,
- (const char*)_base.buf,
- (SerdStatementSink)serd_writer_write_statement,
- (SerdEndSink)serd_writer_end_anon,
+ reinterpret_cast<const char*>(_base.buf),
+ reinterpret_cast<SerdStatementSink>(serd_writer_write_statement),
+ reinterpret_cast<SerdEndSink>(serd_writer_end_anon),
_writer);
}
diff --git a/src/URI.cpp b/src/URI.cpp
index f7b64209..45d264f0 100644
--- a/src/URI.cpp
+++ b/src/URI.cpp
@@ -28,20 +28,24 @@ URI::URI()
{}
URI::URI(const std::string& str)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(),
+ : _uri(SERD_URI_NULL)
+ , _node(serd_node_new_uri_from_string(reinterpret_cast<const uint8_t*>(
+ str.c_str()),
nullptr,
&_uri))
{}
URI::URI(const char* str)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_uri_from_string((const uint8_t*)str, nullptr, &_uri))
+ : _uri(SERD_URI_NULL)
+ , _node(serd_node_new_uri_from_string(reinterpret_cast<const uint8_t*>(str),
+ nullptr,
+ &_uri))
{}
URI::URI(const std::string& str, const URI& base)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(),
+ : _uri(SERD_URI_NULL)
+ , _node(serd_node_new_uri_from_string(reinterpret_cast<const uint8_t*>(
+ str.c_str()),
&base._uri,
&_uri))
{}
@@ -66,11 +70,12 @@ URI::URI(const Sord::Node& node)
}
URI::URI(const FilePath& path)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_file_uri((const uint8_t*)path.c_str(),
- nullptr,
- &_uri,
- true))
+ : _uri(SERD_URI_NULL)
+ , _node(
+ serd_node_new_file_uri(reinterpret_cast<const uint8_t*>(path.c_str()),
+ nullptr,
+ &_uri,
+ true))
{}
URI::URI(const URI& uri)
diff --git a/src/URIMap.cpp b/src/URIMap.cpp
index 0d43deed..abab309b 100644
--- a/src/URIMap.cpp
+++ b/src/URIMap.cpp
@@ -51,7 +51,7 @@ LV2_URID
URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle h,
const char* c_uri)
{
- auto* const map((URIMap*)h);
+ auto* const map(static_cast<URIMap*>(h));
std::string uri(c_uri);
std::lock_guard<std::mutex> lock(map->_mutex);
@@ -92,7 +92,7 @@ const char*
URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle h,
LV2_URID urid)
{
- auto* const map((URIMap*)h);
+ auto* const map(static_cast<URIMap*>(h));
std::lock_guard<std::mutex> lock(map->_mutex);
return (urid > 0 && urid <= map->_unmap.size()
diff --git a/src/World.cpp b/src/World.cpp
index 41e69826..b9d1ba1f 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -264,9 +264,12 @@ World::load_module(const char* name)
}
log().info("Loading %1% module\n", name);
std::unique_ptr<ingen::Library> lib = ingen_load_library(log(), name);
+
ingen::Module* (*module_load)() =
- lib ? (ingen::Module* (*)())lib->get_function("ingen_module_load")
- : nullptr;
+ lib ? reinterpret_cast<ingen::Module* (*)()>(
+ lib->get_function("ingen_module_load"))
+ : nullptr;
+
if (module_load) {
Module* module = module_load();
if (module) {
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index f9eaa26e..a3018939 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -56,8 +56,8 @@ BlockModel::BlockModel(const BlockModel& copy)
: ObjectModel(copy)
, _plugin_uri(copy._plugin_uri)
, _num_values(copy._num_values)
- , _min_values((float*)malloc(sizeof(float) * _num_values))
- , _max_values((float*)malloc(sizeof(float) * _num_values))
+ , _min_values(static_cast<float*>(malloc(sizeof(float) * _num_values)))
+ , _max_values(static_cast<float*>(malloc(sizeof(float) * _num_values)))
{
memcpy(_min_values, copy._min_values, sizeof(float) * _num_values);
memcpy(_max_values, copy._max_values, sizeof(float) * _num_values);
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index 07d37404..bc58020a 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -52,7 +52,7 @@ lv2_ui_write(SuilController controller,
uint32_t format,
const void* buffer)
{
- PluginUI* const ui = (PluginUI*)controller;
+ PluginUI* const ui = static_cast<PluginUI*>(controller);
const URIs& uris = ui->world().uris();
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
@@ -67,7 +67,7 @@ lv2_ui_write(SuilController controller,
ui->block()->plugin()->uri().c_str());
return;
}
- const float value = *(const float*)buffer;
+ const float value = *static_cast<const float*>(buffer);
if (port->value().type() == uris.atom_Float &&
value == port->value().get<float>()) {
return; // Ignore feedback
@@ -80,7 +80,7 @@ lv2_ui_write(SuilController controller,
Resource::Graph::DEFAULT);
} else if (format == uris.atom_eventTransfer.urid()) {
- const LV2_Atom* atom = (const LV2_Atom*)buffer;
+ const LV2_Atom* atom = static_cast<const LV2_Atom*>(buffer);
Atom val = ui->world().forge().alloc(
atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
ui->signal_property_changed()(port->uri(),
@@ -97,7 +97,7 @@ lv2_ui_write(SuilController controller,
static uint32_t
lv2_ui_port_index(SuilController controller, const char* port_symbol)
{
- PluginUI* const ui = (PluginUI*)controller;
+ PluginUI* const ui = static_cast<PluginUI*>(controller);
const BlockModel::Ports& ports = ui->block()->ports();
for (uint32_t i = 0; i < ports.size(); ++i) {
@@ -114,7 +114,7 @@ lv2_ui_subscribe(SuilController controller,
uint32_t protocol,
const LV2_Feature* const* features)
{
- PluginUI* const ui = (PluginUI*)controller;
+ PluginUI* const ui = static_cast<PluginUI*>(controller);
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
return 1;
@@ -135,7 +135,7 @@ lv2_ui_unsubscribe(SuilController controller,
uint32_t protocol,
const LV2_Feature* const* features)
{
- PluginUI* const ui = (PluginUI*)controller;
+ PluginUI* const ui = static_cast<PluginUI*>(controller);
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
return 1;
@@ -299,7 +299,7 @@ PluginUI::instantiate()
SuilWidget
PluginUI::get_widget()
{
- return (SuilWidget*)suil_instance_get_widget(_instance);
+ return suil_instance_get_widget(_instance);
}
void
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index dfa34998..92279906 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -354,7 +354,7 @@ App::status_text() const
return fmt(
"%2.1f kHz / %.1f ms, %s, %s DSP",
(_sample_rate / 1e3f),
- (_block_length * 1e3f / (float)_sample_rate),
+ (_block_length * 1e3f / static_cast<float>(_sample_rate)),
((_n_threads == 1) ? "1 thread" : fmt("%1% threads", _n_threads)),
fraction_label(_max_run_load));
}
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 5ce54d99..7fe1a643 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -873,7 +873,8 @@ GraphBox::event_animate_signals_toggled()
_app->interface()->set_property(
URI("ingen:/clients/this"),
_app->uris().ingen_broadcast,
- _app->forge().make((bool)_menu_animate_signals->get_active()));
+ _app->forge().make(
+ static_cast<bool>(_menu_animate_signals->get_active())));
}
void
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index 40a0c675..391b8729 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -67,7 +67,8 @@ port_order(const GanvPort* a, const GanvPort* b, void* data)
const Port* pa = dynamic_cast<const Port*>(Glib::wrap(a));
const Port* pb = dynamic_cast<const Port*>(Glib::wrap(b));
if (pa && pb) {
- return ((int)pa->model()->index() - (int)pb->model()->index());
+ return (static_cast<int>(pa->model()->index()) -
+ static_cast<int>(pb->model()->index()));
}
return 0;
}
@@ -261,7 +262,7 @@ GraphCanvas::build()
static void
show_module_human_names(GanvNode* node, void* data)
{
- bool b = *(bool*)data;
+ bool b = *static_cast<bool*>(data);
if (GANV_IS_MODULE(node)) {
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
NodeModule* nmod = dynamic_cast<NodeModule*>(module);
@@ -518,8 +519,8 @@ GraphCanvas::on_event(GdkEvent* event)
case GDK_BUTTON_PRESS:
if (event->button.button == 3) {
_auto_position_count = 1;
- _menu_x = (int)event->button.x_root;
- _menu_y = (int)event->button.y_root;
+ _menu_x = static_cast<int>(event->button.x_root);
+ _menu_y = static_cast<int>(event->button.y_root);
show_menu(false, event->button.button, event->button.time);
ret = true;
}
@@ -569,7 +570,7 @@ destroy_node(GanvNode* node, void* data)
return;
}
- App* app = (App*)data;
+ App* app = static_cast<App*>(data);
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
NodeModule* node_module = dynamic_cast<NodeModule*>(module);
@@ -588,7 +589,7 @@ destroy_node(GanvNode* node, void* data)
static void
destroy_arc(GanvEdge* arc, void* data)
{
- App* app = (App*)data;
+ App* app = static_cast<App*>(data);
Ganv::Edge* arcmm = Glib::wrap(arc);
Port* tail = dynamic_cast<Port*>(arcmm->get_tail());
@@ -611,7 +612,7 @@ GraphCanvas::destroy_selection()
static void
serialise_node(GanvNode* node, void* data)
{
- Serialiser* serialiser = (Serialiser*)data;
+ Serialiser* serialiser = static_cast<Serialiser*>(data);
if (!GANV_IS_MODULE(node)) {
return;
}
@@ -632,7 +633,7 @@ serialise_node(GanvNode* node, void* data)
static void
serialise_arc(GanvEdge* arc, void* data)
{
- Serialiser* serialiser = (Serialiser*)data;
+ Serialiser* serialiser = static_cast<Serialiser*>(data);
if (!GANV_IS_EDGE(arc)) {
return;
}
@@ -879,9 +880,11 @@ GraphCanvas::get_initial_data(Resource::Graph ctx)
Properties result;
const URIs& uris = _app.uris();
result.emplace(uris.ingen_canvasX,
- Property(_app.forge().make((float)_menu_x), ctx));
+ Property(_app.forge().make(static_cast<float>(_menu_x)),
+ ctx));
result.emplace(uris.ingen_canvasY,
- Property(_app.forge().make((float)_menu_y), ctx));
+ Property(_app.forge().make(static_cast<float>(_menu_y)),
+ ctx));
return result;
}
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index 1947f355..336dced7 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -83,7 +83,7 @@ GraphPortModule::create(GraphCanvas& canvas, const SPtr<const PortModel>& model)
App&
GraphPortModule::app() const
{
- return ((GraphCanvas*)canvas())->app();
+ return static_cast<GraphCanvas*>(canvas())->app();
}
bool
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp
index 68f6e392..dd80c906 100644
--- a/src/gui/GraphTreeWindow.cpp
+++ b/src/gui/GraphTreeWindow.cpp
@@ -188,7 +188,7 @@ GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str)
if (_enable_signal) {
_app->set_property(pm->uri(),
_app->uris().ingen_enabled,
- _app->forge().make((bool)!pm->enabled()));
+ _app->forge().make(static_cast<bool>(!pm->enabled())));
}
}
diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp
index 36c6caed..ca12e1ef 100644
--- a/src/gui/GraphView.cpp
+++ b/src/gui/GraphView.cpp
@@ -120,14 +120,15 @@ GraphView::process_toggled()
_app->set_property(_graph->uri(),
_app->uris().ingen_enabled,
- _app->forge().make((bool)_process_but->get_active()));
+ _app->forge().make(
+ static_cast<bool>(_process_but->get_active())));
}
void
GraphView::poly_changed()
{
const int poly = _poly_spin->get_value_as_int();
- if (_enable_signal && poly != (int)_graph->internal_poly()) {
+ if (_enable_signal && poly != static_cast<int>(_graph->internal_poly())) {
_app->set_property(_graph->uri(),
_app->uris().ingen_polyphony,
_app->forge().make(poly));
diff --git a/src/gui/MessagesWindow.cpp b/src/gui/MessagesWindow.cpp
index 84d29679..d8003a33 100644
--- a/src/gui/MessagesWindow.cpp
+++ b/src/gui/MessagesWindow.cpp
@@ -41,8 +41,8 @@ MessagesWindow::MessagesWindow(BaseObjectType* cobject,
_close_button->signal_clicked().connect(sigc::mem_fun(this, &Window::hide));
for (int s = Gtk::STATE_NORMAL; s <= Gtk::STATE_INSENSITIVE; ++s) {
- _textview->modify_base((Gtk::StateType)s, Gdk::Color("#000000"));
- _textview->modify_text((Gtk::StateType)s, Gdk::Color("#EEEEEC"));
+ _textview->modify_base(static_cast<Gtk::StateType>(s), Gdk::Color("#000000"));
+ _textview->modify_text(static_cast<Gtk::StateType>(s), Gdk::Color("#EEEEEC"));
}
}
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 5984dbe1..7cecfd46 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -163,7 +163,7 @@ NodeModule::create(GraphCanvas& canvas,
App&
NodeModule::app() const
{
- return ((GraphCanvas*)canvas())->app();
+ return static_cast<GraphCanvas*>(canvas())->app();
}
void
@@ -268,7 +268,9 @@ NodeModule::embed_gui(bool embed)
if (!_plugin_ui->instantiate()) {
app().log().error("Failed to instantiate LV2 UI\n");
} else {
- GtkWidget* c_widget = (GtkWidget*)_plugin_ui->get_widget();
+ GtkWidget* c_widget =
+ static_cast<GtkWidget*>(_plugin_ui->get_widget());
+
_gui_widget = Glib::wrap(c_widget);
Gtk::Container* container = new Gtk::EventBox();
@@ -362,7 +364,9 @@ NodeModule::popup_gui()
return false;
}
- GtkWidget* c_widget = (GtkWidget*)_plugin_ui->get_widget();
+ GtkWidget* c_widget =
+ static_cast<GtkWidget*>(_plugin_ui->get_widget());
+
_gui_widget = Glib::wrap(c_widget);
_gui_window = new Gtk::Window();
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 14f87fc1..73ad837a 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -194,7 +194,7 @@ Port::on_value_changed(double value)
return; // Non-float, unsupported
}
- if (current_value.get<float>() == (float)value) {
+ if (current_value.get<float>() == static_cast<float>(value)) {
return; // No change
}
diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp
index 4817e9ae..e1c1eef7 100644
--- a/src/gui/ingen_gui_lv2.cpp
+++ b/src/gui/ingen_gui_lv2.cpp
@@ -119,11 +119,11 @@ instantiate(const LV2UI_Descriptor* descriptor,
LV2_Log_Log* log = nullptr;
for (int i = 0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID__map)) {
- map = (LV2_URID_Map*)features[i]->data;
+ map = static_cast<LV2_URID_Map*>(features[i]->data);
} else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
- unmap = (LV2_URID_Unmap*)features[i]->data;
+ unmap = static_cast<LV2_URID_Unmap*>(features[i]->data);
} else if (!strcmp(features[i]->URI, LV2_LOG__log)) {
- log = (LV2_Log_Log*)features[i]->data;
+ log = static_cast<LV2_Log_Log*>(features[i]->data);
}
}
@@ -183,7 +183,7 @@ instantiate(const LV2UI_Descriptor* descriptor,
static void
cleanup(LV2UI_Handle handle)
{
- ingen::IngenLV2UI* ui = (ingen::IngenLV2UI*)handle;
+ ingen::IngenLV2UI* ui = static_cast<ingen::IngenLV2UI*>(handle);
delete ui;
}
@@ -194,8 +194,8 @@ port_event(LV2UI_Handle handle,
uint32_t format,
const void* buffer)
{
- ingen::IngenLV2UI* ui = (ingen::IngenLV2UI*)handle;
- const LV2_Atom* atom = (const LV2_Atom*)buffer;
+ ingen::IngenLV2UI* ui = static_cast<ingen::IngenLV2UI*>(handle);
+ const LV2_Atom* atom = static_cast<const LV2_Atom*>(buffer);
ui->reader->write(atom);
}
diff --git a/src/gui/rgba.hpp b/src/gui/rgba.hpp
index f31e958c..949a80d7 100644
--- a/src/gui/rgba.hpp
+++ b/src/gui/rgba.hpp
@@ -25,22 +25,22 @@ namespace gui {
static inline uint32_t
rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
- return ((((uint32_t)(r)) << 24) |
- (((uint32_t)(g)) << 16) |
- (((uint32_t)(b)) << 8) |
- (((uint32_t)(a))));
+ return ((static_cast<uint32_t>(r) << 24) |
+ (static_cast<uint32_t>(g) << 16) |
+ (static_cast<uint32_t>(b) << 8) |
+ (static_cast<uint32_t>(a)));
}
static inline uint8_t
mono_interpolate(uint8_t v1, uint8_t v2, float f)
{
- return ((int)rint((v2) * (f) + (v1) * (1 - (f))));
+ return static_cast<int>(rint((v2) * (f) + (v1) * (1 - (f))));
}
-#define RGBA_R(x) (((uint32_t)(x)) >> 24)
-#define RGBA_G(x) ((((uint32_t)(x)) >> 16) & 0xFF)
-#define RGBA_B(x) ((((uint32_t)(x)) >> 8) & 0xFF)
-#define RGBA_A(x) (((uint32_t)(x)) & 0xFF)
+#define RGBA_R(x) (static_cast<uint32_t>(x) >> 24)
+#define RGBA_G(x) ((static_cast<uint32_t>(x) >> 16) & 0xFF)
+#define RGBA_B(x) ((static_cast<uint32_t>(x) >> 8) & 0xFF)
+#define RGBA_A(x) (static_cast<uint32_t>(x) & 0xFF)
static inline uint32_t
rgba_interpolate(uint32_t c1, uint32_t c2, float f)
diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp
index fd9a3578..8c072b87 100644
--- a/src/ingen/ingen.cpp
+++ b/src/ingen/ingen.cpp
@@ -201,15 +201,16 @@ main(int argc, char** argv)
*world, *engine_interface, graph, parent, symbol);
} else if (conf.option("server-load").is_valid()) {
const char* path = conf.option("server-load").ptr<char>();
- if (serd_uri_string_has_scheme((const uint8_t*)path)) {
+ if (serd_uri_string_has_scheme(reinterpret_cast<const uint8_t*>(path))) {
std::cout << "Loading " << path << " (server side)" << std::endl;
engine_interface->copy(URI(path), main_uri());
} else {
SerdNode uri = serd_node_new_file_uri(
- (const uint8_t*)path, nullptr, nullptr, true);
- std::cout << "Loading " << (const char*)uri.buf
+ reinterpret_cast<const uint8_t*>(path), nullptr, nullptr, true);
+ std::cout << "Loading " << reinterpret_cast<const char*>(uri.buf)
<< " (server side)" << std::endl;
- engine_interface->copy(URI((const char*)uri.buf), main_uri());
+ engine_interface->copy(URI(reinterpret_cast<const char*>(uri.buf)),
+ main_uri());
serd_node_free(&uri);
}
}
@@ -217,14 +218,15 @@ main(int argc, char** argv)
// Save the currently loaded graph
if (conf.option("save").is_valid()) {
const char* path = conf.option("save").ptr<char>();
- if (serd_uri_string_has_scheme((const uint8_t*)path)) {
+ if (serd_uri_string_has_scheme(reinterpret_cast<const uint8_t*>(path))) {
std::cout << "Saving to " << path << std::endl;
engine_interface->copy(main_uri(), URI(path));
} else {
SerdNode uri = serd_node_new_file_uri(
- (const uint8_t*)path, nullptr, nullptr, true);
- std::cout << "Saving to " << (const char*)uri.buf << std::endl;
- engine_interface->copy(main_uri(), URI((const char*)uri.buf));
+ reinterpret_cast<const uint8_t*>(path), nullptr, nullptr, true);
+ std::cout << "Saving to " << reinterpret_cast<const char*>(uri.buf)
+ << std::endl;
+ engine_interface->copy(main_uri(), URI(reinterpret_cast<const char*>(uri.buf)));
serd_node_free(&uri);
}
}
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 9e1693df..2368109e 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -149,7 +149,7 @@ BlockFactory::load_lv2_plugins()
using Types = std::vector<SPtr<LilvNode>>;
Types types;
for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) {
- const URI& uri(PortType((PortType::ID)t).uri());
+ const URI& uri(PortType(static_cast<PortType::ID>(t)).uri());
types.push_back(
SPtr<LilvNode>(lilv_new_uri(_world.lilv_world(), uri.c_str()),
lilv_node_free));
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index ba0bdc77..06bd13c5 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -57,7 +57,7 @@ BlockImpl::~BlockImpl()
assert(!_activated);
if (is_linked()) {
- ((GraphImpl*)_parent)->remove_block(*this);
+ reinterpret_cast<GraphImpl*>(_parent)->remove_block(*this);
}
}
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 15a4e075..54fcd221 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -179,7 +179,10 @@ public:
uint32_t size);
/** The Graph this Block belongs to. */
- GraphImpl* parent_graph() const override { return (GraphImpl*)_parent; }
+ GraphImpl* parent_graph() const override
+ {
+ return reinterpret_cast<GraphImpl*>(_parent);
+ }
uint32_t num_ports() const override { return _ports ? _ports->size() : 0; }
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index c3430858..509cbc01 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -131,14 +131,14 @@ Buffer::render_sequence(const RunContext& context, const Buffer* src, bool add)
{
const LV2_URID atom_Float = _factory.uris().atom_Float;
const auto* seq = src->get<const LV2_Atom_Sequence>();
- const auto* init = (const LV2_Atom_Float*)src->value();
+ const auto* init = reinterpret_cast<const LV2_Atom_Float*>(src->value());
float value = init ? init->body : 0.0f;
SampleCount offset = context.offset();
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (ev->time.frames >= offset && ev->body.type == atom_Float) {
write_block(value, offset, ev->time.frames, add);
- value = ((const LV2_Atom_Float*)&ev->body)->body;
+ value = reinterpret_cast<const LV2_Atom_Float*>(&ev->body)->body;
offset = ev->time.frames;
}
}
@@ -192,7 +192,7 @@ Buffer::port_data(PortType port_type, SampleCount offset)
if (_type == _factory.uris().atom_Float) {
return &get<LV2_Atom_Float>()->body;
} else if (_type == _factory.uris().atom_Sound) {
- return (Sample*)_buf + offset;
+ return static_cast<Sample*>(_buf) + offset;
}
break;
case PortType::ID::ATOM:
@@ -225,7 +225,7 @@ float
Buffer::peak(const RunContext& context) const
{
#ifdef __SSE__
- const auto* const vbuf = (const __m128*)samples();
+ const auto* const vbuf = reinterpret_cast<const __m128*>(samples());
__m128 vpeak = mm_abs_ps(vbuf[0]);
const SampleCount nblocks = context.nframes() / 4;
@@ -270,7 +270,7 @@ Buffer::prepare_write(RunContext&)
if (_type == _factory.uris().atom_Sequence) {
auto* atom = get<LV2_Atom>();
- atom->type = (LV2_URID)_factory.uris().atom_Sequence;
+ atom->type = static_cast<LV2_URID>(_factory.uris().atom_Sequence);
atom->size = sizeof(LV2_Atom_Sequence_Body);
_latest_event = 0;
}
@@ -282,7 +282,7 @@ Buffer::prepare_output_write(RunContext&)
if (_type == _factory.uris().atom_Sequence) {
auto* atom = get<LV2_Atom>();
- atom->type = (LV2_URID)_factory.uris().atom_Chunk;
+ atom->type = static_cast<LV2_URID>(_factory.uris().atom_Chunk);
atom->size = _capacity - sizeof(LV2_Atom);
_latest_event = 0;
}
@@ -305,9 +305,9 @@ Buffer::append_event(int64_t frames,
return false;
}
- auto* seq = (LV2_Atom_Sequence*)atom;
- auto* ev = (LV2_Atom_Event*)(
- (uint8_t*)seq + lv2_atom_total_size(&seq->atom));
+ auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(atom);
+ auto* ev = reinterpret_cast<LV2_Atom_Event*>(
+ reinterpret_cast<uint8_t*>(seq) + lv2_atom_total_size(&seq->atom));
ev->time.frames = frames;
ev->body.size = size;
@@ -324,20 +324,23 @@ Buffer::append_event(int64_t frames,
bool
Buffer::append_event(int64_t frames, const LV2_Atom* body)
{
- return append_event(frames, body->size, body->type, (const uint8_t*)(body + 1));
+ return append_event(frames,
+ body->size,
+ body->type,
+ reinterpret_cast<const uint8_t*>(body + 1));
}
bool
Buffer::append_event_buffer(const Buffer* buf)
{
- auto* seq = (LV2_Atom_Sequence*)get<LV2_Atom>();
- auto* bseq = (const LV2_Atom_Sequence*)buf->get<LV2_Atom>();
+ auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(get<LV2_Atom>());
+ auto* bseq = reinterpret_cast<const LV2_Atom_Sequence*>(buf->get<LV2_Atom>());
if (seq->atom.type == _factory.uris().atom_Chunk) {
clear(); // Chunk initialized with prepare_output_write(), clear
}
const uint32_t total_size = lv2_atom_total_size(&seq->atom);
- uint8_t* const end = (uint8_t*)seq + total_size;
+ uint8_t* const end = reinterpret_cast<uint8_t*>(seq) + total_size;
const uint32_t n_bytes = bseq->atom.size - sizeof(bseq->body);
if (sizeof(LV2_Atom) + total_size + n_bytes >= _capacity) {
return false; // Not enough space
@@ -444,7 +447,7 @@ void* Buffer::aligned_alloc(size_t size)
{
#ifdef HAVE_POSIX_MEMALIGN
void* buf;
- if (!posix_memalign((void**)&buf, 16, size)) {
+ if (!posix_memalign(static_cast<void**>(&buf), 16, size)) {
memset(buf, 0, size);
return buf;
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 1cbb0f29..c784f661 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -94,9 +94,10 @@ public:
/// Audio or float buffers only
inline const Sample* samples() const {
if (is_control()) {
- return (const Sample*)LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>());
+ return static_cast<const Sample*>(
+ LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>()));
} else if (is_audio()) {
- return (const Sample*)_buf;
+ return static_cast<const Sample*>(_buf);
}
return nullptr;
}
@@ -104,9 +105,9 @@ public:
/// Audio buffers only
inline Sample* samples() {
if (is_control()) {
- return (Sample*)LV2_ATOM_BODY(get<LV2_Atom_Float>());
+ return static_cast<Sample*>(LV2_ATOM_BODY(get<LV2_Atom_Float>()));
} else if (is_audio()) {
- return (Sample*)_buf;
+ return static_cast<Sample*>(_buf);
}
return nullptr;
}
@@ -116,7 +117,7 @@ public:
if (is_audio() || is_control()) {
return samples()[offset];
} else if (_value_buffer) {
- return ((const LV2_Atom_Float*)value())->body;
+ return reinterpret_cast<const LV2_Atom_Float*>(value())->body;
}
return 0.0f;
}
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 23b44884..657484d8 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -170,7 +170,8 @@ BufferFactory::create(LV2_URID type, LV2_URID value_type, uint32_t capacity)
if (capacity == 0) {
capacity = default_size(type);
} else if (type == _uris.atom_Float) {
- capacity = std::max(capacity, (uint32_t)sizeof(LV2_Atom_Float));
+ capacity =
+ std::max(capacity, static_cast<uint32_t>(sizeof(LV2_Atom_Float)));
} else if (type == _uris.atom_Sound) {
capacity = std::max(capacity, default_size(_uris.atom_Sound));
}
diff --git a/src/server/ClientUpdate.cpp b/src/server/ClientUpdate.cpp
index cb3c34dc..0c0f9203 100644
--- a/src/server/ClientUpdate.cpp
+++ b/src/server/ClientUpdate.cpp
@@ -69,7 +69,7 @@ ClientUpdate::put_block(const BlockImpl* block)
const URIs& uris = plugin->uris();
if (uris.ingen_Graph == plugin->type()) {
- put_graph((const GraphImpl*)block);
+ put_graph(static_cast<const GraphImpl*>(block));
} else {
put(block->uri(), block->properties());
for (size_t j = 0; j < block->num_ports(); ++j) {
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 3e123a16..8ab4aef7 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -79,7 +79,7 @@ ControlBindings::binding_key(const Atom& binding) const
Key key;
LV2_Atom* num = nullptr;
if (binding.type() == uris.atom_Object) {
- const auto* obj = (const LV2_Atom_Object_Body*)binding.get_body();
+ const auto* obj = static_cast<const LV2_Atom_Object_Body*>(binding.get_body());
if (obj->otype == uris.midi_Bender) {
key = Key(Type::MIDI_BENDER);
} else if (obj->otype == uris.midi_ChannelPressure) {
@@ -87,7 +87,7 @@ ControlBindings::binding_key(const Atom& binding) const
} else if (obj->otype == uris.midi_Controller) {
lv2_atom_object_body_get(binding.size(),
obj,
- (LV2_URID)uris.midi_controllerNumber,
+ uris.midi_controllerNumber.urid(),
&num,
nullptr);
if (!num) {
@@ -95,12 +95,12 @@ ControlBindings::binding_key(const Atom& binding) const
} else if (num->type != uris.atom_Int) {
_engine.log().rt_error("Controller number not an integer\n");
} else {
- key = Key(Type::MIDI_CC, ((LV2_Atom_Int*)num)->body);
+ key = Key(Type::MIDI_CC, reinterpret_cast<LV2_Atom_Int*>(num)->body);
}
} else if (obj->otype == uris.midi_NoteOn) {
lv2_atom_object_body_get(binding.size(),
obj,
- (LV2_URID)uris.midi_noteNumber,
+ uris.midi_noteNumber.urid(),
&num,
nullptr);
if (!num) {
@@ -108,7 +108,7 @@ ControlBindings::binding_key(const Atom& binding) const
} else if (num->type != uris.atom_Int) {
_engine.log().rt_error("Note number not an integer\n");
} else {
- key = Key(Type::MIDI_NOTE, ((LV2_Atom_Int*)num)->body);
+ key = Key(Type::MIDI_NOTE, reinterpret_cast<LV2_Atom_Int*>(num)->body);
}
}
} else if (binding.type()) {
@@ -199,7 +199,10 @@ ControlBindings::port_value_changed(RunContext& ctx,
break;
}
if (size > 0) {
- _feedback->append_event(ctx.nframes() - 1, size, (LV2_URID)uris.midi_MidiEvent, buf);
+ _feedback->append_event(ctx.nframes() - 1,
+ size,
+ static_cast<LV2_URID>(uris.midi_MidiEvent),
+ buf);
}
}
}
@@ -237,10 +240,10 @@ ControlBindings::control_to_port_value(RunContext& context,
switch (type) {
case Type::MIDI_CC:
case Type::MIDI_CHANNEL_PRESSURE:
- normal = (float)value / 127.0f;
+ normal = static_cast<float>(value) / 127.0f;
break;
case Type::MIDI_BENDER:
- normal = (float)value / 16383.0f;
+ normal = static_cast<float>(value) / 16383.0f;
break;
case Type::MIDI_NOTE:
normal = (value == 0) ? 0.0f : 1.0f;
@@ -250,7 +253,7 @@ ControlBindings::control_to_port_value(RunContext& context,
}
if (port->is_logarithmic()) {
- normal = (expf(normal) - 1.0f) / ((float)M_E - 1.0f);
+ normal = (expf(normal) - 1.0f) / (static_cast<float>(M_E) - 1.0f);
}
float min = 0.0f;
@@ -286,7 +289,7 @@ ControlBindings::port_value_to_control(RunContext& context,
}
if (port->is_logarithmic()) {
- normal = logf(normal * ((float)M_E - 1.0f) + 1.0f);
+ normal = logf(normal * (static_cast<float>(M_E) - 1.0f) + 1.0f);
}
switch (type) {
@@ -367,7 +370,7 @@ ControlBindings::finish_learn(RunContext& context, Key key)
LV2_Atom buf[16];
memset(buf, 0, sizeof(buf));
- lv2_atom_forge_set_buffer(&_forge, (uint8_t*)buf, sizeof(buf));
+ lv2_atom_forge_set_buffer(&_forge, reinterpret_cast<uint8_t*>(buf), sizeof(buf));
forge_binding(uris, &_forge, key.type, key.num);
const LV2_Atom* atom = buf;
context.notify(uris.midi_binding,
@@ -412,7 +415,7 @@ ControlBindings::pre_process(RunContext& ctx, Buffer* buffer)
auto* seq = buffer->get<LV2_Atom_Sequence>();
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (ev->body.type == uris.midi_MidiEvent) {
- const auto* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
+ const auto* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY(&ev->body));
const Key key = midi_event_key(ev->body.size, buf, value);
if (_learn_binding && !!key) {
diff --git a/src/server/FrameTimer.hpp b/src/server/FrameTimer.hpp
index 57acbaa5..344ed201 100644
--- a/src/server/FrameTimer.hpp
+++ b/src/server/FrameTimer.hpp
@@ -37,11 +37,13 @@ public:
static constexpr double us_per_s = 1000000.0;
FrameTimer(uint32_t period_size, uint32_t sample_rate)
- : tper(((double)period_size / (double)sample_rate) * us_per_s)
- , omega(2 * PI * bandwidth / us_per_s * tper)
- , b(sqrt(2) * omega)
- , c(omega * omega)
- , nper(period_size)
+ : tper((static_cast<double>(period_size) /
+ static_cast<double>(sample_rate)) *
+ us_per_s)
+ , omega(2 * PI * bandwidth / us_per_s * tper)
+ , b(sqrt(2) * omega)
+ , c(omega * omega)
+ , nper(period_size)
{
}
@@ -53,7 +55,7 @@ public:
}
// Calculate loop error
- const double e = ((double)usec - t1);
+ const double e = (static_cast<double>(usec) - t1);
// Update loop
t0 = t1;
@@ -71,7 +73,7 @@ public:
return 0;
}
- const double delta = (double)usec - t0;
+ const double delta = static_cast<double>(usec) - t0;
const double period = t1 - t0;
return n0 + std::round(delta / period * nper);
}
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 6d15f3a8..af4dde8f 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -122,7 +122,7 @@ JackDriver::attach(const std::string& server_name,
return false;
}
} else {
- _client = (jack_client_t*)jack_client;
+ _client = static_cast<jack_client_t*>(jack_client);
}
_sample_rate = jack_get_sample_rate(_client);
@@ -223,7 +223,7 @@ JackDriver::add_port(RunContext& context, EnginePort* port)
DuplexPort* graph_port = port->graph_port();
if (graph_port->is_a(PortType::AUDIO) || graph_port->is_a(PortType::CV)) {
const SampleCount nframes = context.nframes();
- jack_port_t* jport = (jack_port_t*)port->handle();
+ jack_port_t* jport = static_cast<jack_port_t*>(port->handle());
void* jbuf = jack_port_get_buffer(jport, nframes);
/* Jack fails to return a buffer if this is too soon after registering
@@ -267,7 +267,7 @@ JackDriver::register_port(EnginePort& port)
void
JackDriver::unregister_port(EnginePort& port)
{
- if (jack_port_unregister(_client, (jack_port_t*)port.handle())) {
+ if (jack_port_unregister(_client, static_cast<jack_port_t*>(port.handle()))) {
_engine.log().error("Failed to unregister Jack port\n");
}
@@ -281,8 +281,9 @@ JackDriver::rename_port(const Raul::Path& old_path,
EnginePort* eport = get_port(old_path);
if (eport) {
#ifdef HAVE_JACK_PORT_RENAME
- jack_port_rename(
- _client, (jack_port_t*)eport->handle(), new_path.substr(1).c_str());
+ jack_port_rename(_client,
+ static_cast<jack_port_t*>(eport->handle()),
+ new_path.substr(1).c_str());
#else
jack_port_set_name((jack_port_t*)eport->handle(),
new_path.substr(1).c_str());
@@ -298,7 +299,9 @@ JackDriver::port_property(const Raul::Path& path,
#ifdef HAVE_JACK_METADATA
EnginePort* eport = get_port(path);
if (eport) {
- const jack_port_t* const jport = (const jack_port_t*)eport->handle();
+ const jack_port_t* const jport =
+ static_cast<const jack_port_t*>(eport->handle());
+
port_property_internal(jport, uri, value);
}
#endif
@@ -352,7 +355,7 @@ JackDriver::pre_process_port(RunContext& context, EnginePort* port)
{
const URIs& uris = context.engine().world().uris();
const SampleCount nframes = context.nframes();
- jack_port_t* jack_port = (jack_port_t*)port->handle();
+ jack_port_t* jack_port = static_cast<jack_port_t*>(port->handle());
DuplexPort* graph_port = port->graph_port();
Buffer* graph_buf = graph_port->buffer(0).get();
void* jack_buf = jack_port_get_buffer(jack_port, nframes);
@@ -387,7 +390,7 @@ JackDriver::post_process_port(RunContext& context, EnginePort* port)
{
const URIs& uris = context.engine().world().uris();
const SampleCount nframes = context.nframes();
- jack_port_t* jack_port = (jack_port_t*)port->handle();
+ jack_port_t* jack_port = static_cast<jack_port_t*>(port->handle());
DuplexPort* graph_port = port->graph_port();
void* jack_buf = port->buffer();
@@ -405,7 +408,9 @@ JackDriver::post_process_port(RunContext& context, EnginePort* port)
jack_midi_clear_buffer(jack_buf);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
+ const uint8_t* buf =
+ static_cast<const uint8_t*>(LV2_ATOM_BODY(&ev->body));
+
if (ev->body.type == _midi_event_type) {
jack_midi_event_write(
jack_buf, ev->time.frames, buf, ev->body.size);
@@ -443,7 +448,10 @@ JackDriver::append_time_events(RunContext& context,
// Build an LV2 position object to append to the buffer
LV2_Atom pos_buf[16];
LV2_Atom_Forge_Frame frame;
- lv2_atom_forge_set_buffer(&_forge, (uint8_t*)pos_buf, sizeof(pos_buf));
+ lv2_atom_forge_set_buffer(&_forge,
+ reinterpret_cast<uint8_t*>(pos_buf),
+ sizeof(pos_buf));
+
lv2_atom_forge_object(&_forge, &frame, 0, uris.time_Position);
lv2_atom_forge_key(&_forge, uris.time_frame);
lv2_atom_forge_long(&_forge, pos->frame);
@@ -464,9 +472,11 @@ JackDriver::append_time_events(RunContext& context,
}
// Append position to buffer at offset 0 (start of this cycle)
- LV2_Atom* lpos = (LV2_Atom*)pos_buf;
- buffer.append_event(
- 0, lpos->size, lpos->type, (const uint8_t*)LV2_ATOM_BODY_CONST(lpos));
+ LV2_Atom* lpos = static_cast<LV2_Atom*>(pos_buf);
+ buffer.append_event(0,
+ lpos->size,
+ lpos->type,
+ static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(lpos)));
}
/**** Jack Callbacks ****/
@@ -564,7 +574,7 @@ JackDriver::_session_cb(jack_session_event_t* event)
URI(std::string("file://") + event->session_dir));
}
- event->command_line = (char*)malloc(cmd.size() + 1);
+ event->command_line = static_cast<char*>(malloc(cmd.size() + 1));
memcpy(event->command_line, cmd.c_str(), cmd.size() + 1);
jack_session_reply(_client, event);
diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp
index 00b1836a..433fd21a 100644
--- a/src/server/JackDriver.hpp
+++ b/src/server/JackDriver.hpp
@@ -108,20 +108,20 @@ private:
// Static JACK callbacks which call the non-static callbacks (methods)
inline static void thread_init_cb(void* const jack_driver) {
- return ((JackDriver*)jack_driver)->_thread_init_cb();
+ return static_cast<JackDriver*>(jack_driver)->_thread_init_cb();
}
inline static void shutdown_cb(void* const jack_driver) {
- return ((JackDriver*)jack_driver)->_shutdown_cb();
+ return static_cast<JackDriver*>(jack_driver)->_shutdown_cb();
}
inline static int process_cb(jack_nframes_t nframes, void* const jack_driver) {
- return ((JackDriver*)jack_driver)->_process_cb(nframes);
+ return static_cast<JackDriver*>(jack_driver)->_process_cb(nframes);
}
inline static int block_length_cb(jack_nframes_t nframes, void* const jack_driver) {
- return ((JackDriver*)jack_driver)->_block_length_cb(nframes);
+ return static_cast<JackDriver*>(jack_driver)->_block_length_cb(nframes);
}
#ifdef INGEN_JACK_SESSION
inline static void session_cb(jack_session_event_t* event, void* jack_driver) {
- ((JackDriver*)jack_driver)->_session_cb(event);
+ static_cast<JackDriver*>(jack_driver)->_session_cb(event);
}
#endif
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index 124390ff..99f846a4 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -94,8 +94,8 @@ LV2Block::make_instance(URIs& uris,
const LV2_Options_Interface* options_iface = nullptr;
if (lilv_plugin_has_extension_data(lplug, uris.opt_interface)) {
- options_iface = (const LV2_Options_Interface*)
- lilv_instance_get_extension_data(inst, LV2_OPTIONS__interface);
+ options_iface = static_cast<const LV2_Options_Interface*>(
+ lilv_instance_get_extension_data(inst, LV2_OPTIONS__interface));
}
for (uint32_t p = 0; p < num_ports(); ++p) {
@@ -137,7 +137,7 @@ LV2Block::make_instance(URIs& uris,
options_iface->get(inst->lv2_handle, options);
if (options[0].value) {
- LV2_URID type = *(const LV2_URID*)options[0].value;
+ LV2_URID type = *static_cast<const LV2_URID*>(options[0].value);
if (type == _uris.lv2_ControlPort) {
port->set_type(PortType::CONTROL, 0);
} else if (type == _uris.lv2_CVPort) {
@@ -460,9 +460,9 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
// FIXME: Polyphony + worker?
if (lilv_plugin_has_feature(plug, uris.work_schedule)) {
- _worker_iface = (const LV2_Worker_Interface*)
+ _worker_iface = static_cast<const LV2_Worker_Interface*>(
lilv_instance_get_extension_data(instance(0),
- LV2_WORKER__interface);
+ LV2_WORKER__interface));
}
return ret;
@@ -558,7 +558,7 @@ LV2Block::work_respond(LV2_Worker_Respond_Handle handle,
uint32_t size,
const void* data)
{
- auto* block = (LV2Block*)handle;
+ auto* block = static_cast<LV2Block*>(handle);
auto* r = new LV2Block::Response(size, data);
block->_responses.push_back(*r);
return LV2_WORKER_SUCCESS;
@@ -673,7 +673,7 @@ get_port_value(const char* port_symbol,
uint32_t* size,
uint32_t* type)
{
- auto* const block = (LV2Block*)user_data;
+ auto* const block = static_cast<LV2Block*>(user_data);
auto* const port = block->port_by_symbol(port_symbol);
if (port && port->is_input() && port->value().is_valid()) {
diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp
index 9b454b07..5ef8c69a 100644
--- a/src/server/LV2Block.hpp
+++ b/src/server/LV2Block.hpp
@@ -107,7 +107,7 @@ protected:
bool preparing);
inline LilvInstance* instance(uint32_t voice) {
- return (LilvInstance*)(*_instances)[voice]->instance;
+ return static_cast<LilvInstance*>((*_instances)[voice]->instance);
}
using Instances = Raul::Array<SPtr<Instance>>;
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
index fbe46eee..852a30a5 100644
--- a/src/server/LV2Options.hpp
+++ b/src/server/LV2Options.hpp
@@ -51,7 +51,7 @@ public:
{ LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, nullptr }
};
- LV2_Feature* f = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ LV2_Feature* f = static_cast<LV2_Feature*>(malloc(sizeof(LV2_Feature)));
f->URI = LV2_OPTIONS__options;
f->data = malloc(sizeof(options));
memcpy(f->data, options, sizeof(options));
diff --git a/src/server/Load.hpp b/src/server/Load.hpp
index 2d806684..f69d0659 100644
--- a/src/server/Load.hpp
+++ b/src/server/Load.hpp
@@ -40,7 +40,9 @@ struct Load
mean = load;
changed = true;
} else {
- const float a = mean + ((float)load - mean) / (float)++n;
+ const float a = mean + (static_cast<float>(load) - mean) /
+ static_cast<float>(++n);
+
if (a != mean) {
changed = floorf(a) != floorf(mean);
mean = a;
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
index 47d4a990..7d13f07f 100644
--- a/src/server/NodeImpl.cpp
+++ b/src/server/NodeImpl.cpp
@@ -54,7 +54,7 @@ NodeImpl::get_property(const URI& key) const
GraphImpl*
NodeImpl::parent_graph() const
{
- return dynamic_cast<GraphImpl*>((BlockImpl*)_parent);
+ return dynamic_cast<GraphImpl*>(reinterpret_cast<BlockImpl*>(_parent));
}
} // namespace server
diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp
index 38b04842..de8c36cb 100644
--- a/src/server/PortAudioDriver.cpp
+++ b/src/server/PortAudioDriver.cpp
@@ -243,9 +243,14 @@ PortAudioDriver::pre_process_port(RunContext& context,
}
if (port->is_input()) {
- port->set_buffer(((float**)inputs)[port->driver_index()]);
+ const float* const* const ins =
+ static_cast<const float* const*>(inputs);
+
+ port->set_buffer(const_cast<float*>(ins[port->driver_index()]));
} else {
- port->set_buffer(((float**)outputs)[port->driver_index()]);
+ float* const* const outs = static_cast<float* const*>(inputs);
+
+ port->set_buffer(outs[port->driver_index()]);
memset(port->buffer(), 0, _block_length * sizeof(float));
}
diff --git a/src/server/PortAudioDriver.hpp b/src/server/PortAudioDriver.hpp
index 679223ad..3b7c6a94 100644
--- a/src/server/PortAudioDriver.hpp
+++ b/src/server/PortAudioDriver.hpp
@@ -88,7 +88,7 @@ private:
const PaStreamCallbackTimeInfo* time,
PaStreamCallbackFlags flags,
void* handle) {
- return ((PortAudioDriver*)handle)->process_cb(
+ return static_cast<PortAudioDriver*>(handle)->process_cb(
inputs, outputs, nframes, time, flags);
}
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index ab5e4ee8..7bbb5185 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -91,7 +91,7 @@ PortImpl::PortImpl(BufferFactory& bufs,
set_type(type, buffer_type);
remove_property(uris.lv2_index, uris.patch_wildcard);
- set_property(uris.lv2_index, bufs.forge().make((int32_t)index));
+ set_property(uris.lv2_index, bufs.forge().make(static_cast<int32_t>(index)));
if (has_value()) {
set_property(uris.ingen_value, value);
@@ -249,7 +249,9 @@ PortImpl::set_voice_value(const RunContext& context,
switch (_type.id()) {
case PortType::CONTROL:
if (buffer(voice)->value()) {
- ((LV2_Atom_Float*)buffer(voice)->value())->body = value;
+ const_cast<LV2_Atom_Float*>(
+ reinterpret_cast<const LV2_Atom_Float*>(buffer(voice)->value()))
+ ->body = value;
}
_voices->at(voice).set_state.set(context, context.start(), value);
break;
@@ -277,7 +279,7 @@ PortImpl::set_voice_value(const RunContext& context,
buffer(voice)->append_event(offset,
sizeof(value),
_bufs.uris().atom_Float,
- (const uint8_t*)&value);
+ reinterpret_cast<const uint8_t*>(&value));
}
_voices->at(voice).set_state.set(context, time, value);
} else {
@@ -319,7 +321,7 @@ PortImpl::update_set_state(const RunContext& context, uint32_t v)
buf->clear();
buf->append_event(
0, sizeof(float), _bufs.uris().atom_Float,
- (const uint8_t*)&state.value);
+ reinterpret_cast<const uint8_t*>(&state.value));
} else {
buf->set_block(state.value, 0, context.nframes());
}
@@ -483,7 +485,7 @@ PortImpl::monitor(RunContext& context, bool send_now)
uninitialized Chunk, so do nothing. */
} else if (_monitored) {
/* Sequence explicitly monitored, send everything. */
- const auto* seq = (const LV2_Atom_Sequence*)atom;
+ const auto* seq = reinterpret_cast<const LV2_Atom_Sequence*>(atom);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
context.notify(uris.ingen_activity,
context.start() + ev->time.frames,
@@ -495,7 +497,7 @@ PortImpl::monitor(RunContext& context, bool send_now)
} else if (value && value->type == _bufs.uris().atom_Float) {
/* Float sequence, monitor as a control. */
key = uris.ingen_value;
- val = ((const LV2_Atom_Float*)buffer(0)->value())->body;
+ val = reinterpret_cast<const LV2_Atom_Float*>(buffer(0)->value())->body;
} else if (atom->size > sizeof(LV2_Atom_Sequence_Body)) {
/* General sequence, send activity for blinkenlights. */
const int32_t one = 1;
@@ -503,7 +505,7 @@ PortImpl::monitor(RunContext& context, bool send_now)
context.start(),
this,
sizeof(int32_t),
- (LV2_URID)uris.atom_Bool,
+ static_cast<LV2_URID>(uris.atom_Bool),
&one);
_force_monitor_update = false;
}
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 5392d9b7..bde5a946 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -99,7 +99,7 @@ public:
GraphType graph_type() const override { return GraphType::PORT; }
/** A port's parent is always a block, so static cast should be safe */
- BlockImpl* parent_block() const { return (BlockImpl*)_parent; }
+ BlockImpl* parent_block() const { return reinterpret_cast<BlockImpl*>(_parent); }
/** Set the the voices (buffers) for this port in the audio thread. */
void set_voices(RunContext& context, MPtr<Voices>&& voices);
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index 61a3598e..33da71d7 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -149,11 +149,11 @@ PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit)
const uint64_t start = engine.cycle_start_time(context);
const uint64_t end = engine.current_time();
fprintf(stderr, "Processed %zu events in %u us\n",
- n_processed, (unsigned)(end - start));
+ n_processed, static_cast<unsigned>(end - start));
}
#endif
- auto* next = (Event*)last->next();
+ auto* next = static_cast<Event*>(last->next());
last->next(nullptr);
dest.append(context, head, last);
@@ -245,7 +245,7 @@ PreProcessor::run()
wait_for_block_state(BlockState::UNBLOCKED);
}
- back = (Event*)ev->next();
+ back = static_cast<Event*>(ev->next());
}
}
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp
index 9190d172..0ba4916b 100644
--- a/src/server/RunContext.hpp
+++ b/src/server/RunContext.hpp
@@ -101,7 +101,7 @@ public:
* less time to avoid a dropout when running in real time).
*/
inline uint64_t duration() const {
- return (uint64_t)_nframes * 1e6 / _rate;
+ return static_cast<uint64_t>(_nframes) * 1e6 / _rate;
}
inline void locate(FrameTime s, SampleCount nframes) {
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index b4b50a14..08a719fd 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -52,7 +52,7 @@ get_link_target(const char* link_path)
}
// Allocate buffer and read link target
- char* target = (char*)calloc(1, link_stat.st_size + 1);
+ char* target = static_cast<char*>(calloc(1, link_stat.st_size + 1));
if (readlink(link_path, target, link_stat.st_size) != -1) {
const std::string result(target);
free(target);
diff --git a/src/server/ThreadManager.hpp b/src/server/ThreadManager.hpp
index 17f2c6ff..5f59208f 100644
--- a/src/server/ThreadManager.hpp
+++ b/src/server/ThreadManager.hpp
@@ -37,13 +37,13 @@ class INGEN_API ThreadManager {
public:
static inline void set_flag(ThreadFlag f) {
#ifndef NDEBUG
- flags = ((unsigned)flags | f);
+ flags = (static_cast<unsigned>(flags) | f);
#endif
}
static inline void unset_flag(ThreadFlag f) {
#ifndef NDEBUG
- flags = ((unsigned)flags & (~f));
+ flags = (static_cast<unsigned>(flags) & (~f));
#endif
}
diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp
index a94617a5..d9e00075 100644
--- a/src/server/UndoStack.cpp
+++ b/src/server/UndoStack.cpp
@@ -29,9 +29,9 @@
#include <iterator>
#include <memory>
-#define NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-#define USTR(s) ((const uint8_t*)(s))
+#define USTR(s) reinterpret_cast<const uint8_t*>(s)
namespace ingen {
namespace server {
@@ -62,22 +62,22 @@ UndoStack::ignore_later_event(const LV2_Atom* first,
return false;
}
- const auto* f = (const LV2_Atom_Object*)first;
- const auto* s = (const LV2_Atom_Object*)second;
+ const auto* f = reinterpret_cast<const LV2_Atom_Object*>(first);
+ const auto* s = reinterpret_cast<const LV2_Atom_Object*>(second);
if (f->body.otype == _uris.patch_Set && f->body.otype == s->body.otype) {
const LV2_Atom* f_subject = nullptr;
const LV2_Atom* f_property = nullptr;
const LV2_Atom* s_subject = nullptr;
const LV2_Atom* s_property = nullptr;
lv2_atom_object_get(f,
- (LV2_URID)_uris.patch_subject, &f_subject,
- (LV2_URID)_uris.patch_property, &f_property,
+ _uris.patch_subject.urid(), &f_subject,
+ _uris.patch_property.urid(), &f_property,
0);
lv2_atom_object_get(s,
- (LV2_URID)_uris.patch_subject, &s_subject,
- (LV2_URID)_uris.patch_property, &s_property,
+ _uris.patch_subject.urid(), &s_subject,
+ _uris.patch_property.urid(), &s_property,
0);
- return (lv2_atom_equals(f_subject, s_subject) &&
+ return (lv2_atom_equals(f_subject, s_subject) &&
lv2_atom_equals(f_property, s_property));
}
@@ -149,7 +149,7 @@ struct ListContext {
const SerdNode node = start_node(writer);
// node rdf:first value
- p = serd_node_from_string(SERD_URI, NS_RDF "first");
+ p = serd_node_from_string(SERD_URI, USTR(NS_RDF "first"));
flags = SERD_LIST_CONT;
serd_writer_write_statement(writer, flags|oflags, nullptr, &node, &p, value, nullptr, nullptr);
@@ -159,12 +159,15 @@ struct ListContext {
void end_node(SerdWriter*, const SerdNode* node) {
// Prepare for next call: node rdf:rest ...
s = *node;
- p = serd_node_from_string(SERD_URI, NS_RDF "rest");
+ p = serd_node_from_string(SERD_URI, USTR(NS_RDF "rest"));
}
void end(SerdWriter* writer) {
- const SerdNode nil = serd_node_from_string(SERD_URI, NS_RDF "nil");
- serd_writer_write_statement(writer, flags, nullptr, &s, &p, &nil, nullptr, nullptr);
+ const SerdNode nil =
+ serd_node_from_string(SERD_URI, USTR(NS_RDF "nil"));
+
+ serd_writer_write_statement(
+ writer, flags, nullptr, &s, &p, &nil, nullptr, nullptr);
}
BlankIDs& ids;
@@ -195,7 +198,10 @@ UndoStack::write_entry(Sratom* sratom,
for (const LV2_Atom* atom : entry.events) {
const SerdNode node = ctx.start_node(writer);
- p = serd_node_from_string(SERD_URI, NS_RDF "first");
+ p = serd_node_from_string(SERD_URI,
+ reinterpret_cast<const uint8_t*>(NS_RDF
+ "first"));
+
ctx.flags = SERD_LIST_CONT;
sratom_write(sratom, &_map.urid_unmap_feature()->urid_unmap, SERD_LIST_CONT,
&node, &p,
@@ -219,23 +225,25 @@ UndoStack::save(FILE* stream, const char* name)
SerdURI base_uri;
serd_uri_parse(base.buf, &base_uri);
- SerdWriter* writer = serd_writer_new(
- SERD_TURTLE,
- (SerdStyle)(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED|SERD_STYLE_CURIED),
- env,
- &base_uri,
- serd_file_sink,
- stream);
+ SerdWriter* writer =
+ serd_writer_new(SERD_TURTLE,
+ static_cast<SerdStyle>(SERD_STYLE_RESOLVED |
+ SERD_STYLE_ABBREVIATED |
+ SERD_STYLE_CURIED),
+ env,
+ &base_uri,
+ serd_file_sink,
+ stream);
// Configure sratom to write directly to the writer (and thus the socket)
Sratom* sratom = sratom_new(&_map.urid_map_feature()->urid_map);
sratom_set_sink(sratom,
- (const char*)base.buf,
- (SerdStatementSink)serd_writer_write_statement,
- (SerdEndSink)serd_writer_end_anon,
+ reinterpret_cast<const char*>(base.buf),
+ reinterpret_cast<SerdStatementSink>(serd_writer_write_statement),
+ reinterpret_cast<SerdEndSink>(serd_writer_end_anon),
writer);
- SerdNode s = serd_node_from_string(SERD_BLANK, (const uint8_t*)name);
+ SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name));
SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries"));
BlankIDs ids('u');
diff --git a/src/server/UndoStack.hpp b/src/server/UndoStack.hpp
index 04021b99..92f32131 100644
--- a/src/server/UndoStack.hpp
+++ b/src/server/UndoStack.hpp
@@ -71,7 +71,7 @@ public:
void push_event(const LV2_Atom* ev) {
const uint32_t size = lv2_atom_total_size(ev);
- LV2_Atom* copy = (LV2_Atom*)malloc(size);
+ LV2_Atom* copy = static_cast<LV2_Atom*>(malloc(size));
memcpy(copy, ev, size);
events.push_front(copy);
}
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 68926278..e0d198d7 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -40,7 +40,7 @@ schedule(LV2_Worker_Schedule_Handle handle,
uint32_t size,
const void* data)
{
- auto* block = (LV2Block*)handle;
+ auto* block = static_cast<LV2Block*>(handle);
Engine& engine = block->parent_graph()->engine();
return engine.worker()->request(block, size, data);
@@ -51,7 +51,7 @@ schedule_sync(LV2_Worker_Schedule_Handle handle,
uint32_t size,
const void* data)
{
- auto* block = (LV2Block*)handle;
+ auto* block = static_cast<LV2Block*>(handle);
Engine& engine = block->parent_graph()->engine();
return engine.sync_worker()->request(block, size, data);
@@ -95,11 +95,12 @@ Worker::Schedule::feature(World&, Node* n)
return SPtr<LV2_Feature>();
}
- auto* data = (LV2_Worker_Schedule*)malloc(sizeof(LV2_Worker_Schedule));
+ auto* data = static_cast<LV2_Worker_Schedule*>(malloc(sizeof(LV2_Worker_Schedule)));
+
data->handle = block;
data->schedule_work = synchronous ? schedule_sync : schedule;
- auto* f = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ auto* f = static_cast<LV2_Feature*>(malloc(sizeof(LV2_Feature)));
f->URI = LV2_WORKER__schedule;
f->data = data;
@@ -112,7 +113,7 @@ Worker::Worker(Log& log, uint32_t buffer_size, bool synchronous)
, _sem(0)
, _requests(buffer_size)
, _responses(buffer_size)
- , _buffer((uint8_t*)malloc(buffer_size))
+ , _buffer(static_cast<uint8_t*>(malloc(buffer_size)))
, _buffer_size(buffer_size)
, _thread(nullptr)
, _exit_flag(false)
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index d0dcbaf3..e6862731 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -172,8 +172,8 @@ CreatePort::pre_process(PreProcessContext&)
_update = _graph_port->properties();
- assert(_graph_port->index() == (uint32_t)index_i->second.get<int32_t>());
- assert(_graph->num_ports_non_rt() == (uint32_t)old_n_ports + 1);
+ assert(_graph_port->index() == static_cast<uint32_t>(index_i->second.get<int32_t>()));
+ assert(_graph->num_ports_non_rt() == static_cast<uint32_t>(old_n_ports) + 1u);
assert(_ports_array->size() == _graph->num_ports_non_rt());
assert(_graph_port->index() < _ports_array->size());
return Event::pre_process_done(Status::SUCCESS);
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 5d605bca..f5f2e272 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -121,9 +121,9 @@ Delete::pre_process(PreProcessContext& ctx)
_port_index_changes.emplace(
port->path(), std::make_pair(port->index(), i));
port->remove_property(uris.lv2_index, uris.patch_wildcard);
- port->set_property(
- uris.lv2_index,
- _engine.buffer_factory()->forge().make((int32_t)i));
+ port->set_property(uris.lv2_index,
+ _engine.buffer_factory()->forge().make(
+ static_cast<int32_t>(i)));
}
}
}
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 0a7b05ea..eb70d046 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -148,7 +148,7 @@ s_add_set_event(const char* port_symbol,
uint32_t size,
uint32_t type)
{
- ((Delta*)user_data)->add_set_event(port_symbol, value, size, type);
+ static_cast<Delta*>(user_data)->add_set_event(port_symbol, value, size, type);
}
static LilvNode*
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index 2eecf9ce..f341737c 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -116,7 +116,7 @@ SetPortValue::apply(RunContext& context)
if (!buf->append_event(_time - context.start(),
_value.size(),
_value.type(),
- (const uint8_t*)_value.get_body())) {
+ reinterpret_cast<const uint8_t*>(_value.get_body()))) {
_status = Status::NO_SPACE;
}
} else if (buf->type() == uris.atom_URID) {
diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp
index 37aa9c7b..8421ed94 100644
--- a/src/server/ingen_jack.cpp
+++ b/src/server/ingen_jack.cpp
@@ -29,20 +29,23 @@ using namespace ingen;
struct IngenJackModule : public ingen::Module {
void load(ingen::World& world) override {
- if (((server::Engine*)world.engine().get())->driver()) {
+ server::Engine* const engine =
+ static_cast<server::Engine*>(world.engine().get());
+
+ if (engine->driver()) {
world.log().warn("Engine already has a driver\n");
return;
}
- server::JackDriver* driver = new server::JackDriver(
- *(server::Engine*)world.engine().get());
- const Atom& s = world.conf().option("jack-server");
- const std::string server_name = s.is_valid() ? s.ptr<char>() : "";
+ server::JackDriver* driver = new server::JackDriver(*engine);
+ const Atom& s = world.conf().option("jack-server");
+ const std::string server_name = s.is_valid() ? s.ptr<char>() : "";
+
driver->attach(server_name,
world.conf().option("jack-name").ptr<char>(),
nullptr);
- ((server::Engine*)world.engine().get())->set_driver(
- SPtr<server::Driver>(driver));
+
+ engine->set_driver(SPtr<server::Driver>(driver));
}
};
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 90bfaef3..e368d8f1 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -103,7 +103,8 @@ void signal_main(RunContext& context, LV2Driver* driver);
inline size_t
ui_ring_size(SampleCount block_length)
{
- return std::max((size_t)8192, (size_t)block_length * 16);
+ return std::max(static_cast<size_t>(8192u),
+ static_cast<size_t>(block_length) * 16u);
}
class LV2Driver : public ingen::server::Driver
@@ -148,11 +149,17 @@ public:
if (graph_port->is_a(PortType::AUDIO) || graph_port->is_a(PortType::CV)) {
graph_port->set_driver_buffer(lv2_buf, nframes * sizeof(float));
} else if (graph_port->buffer_type() == uris.atom_Sequence) {
- graph_port->set_driver_buffer(lv2_buf, lv2_atom_total_size((LV2_Atom*)lv2_buf));
+ graph_port->set_driver_buffer(lv2_buf,
+ lv2_atom_total_size(
+ static_cast<LV2_Atom*>(lv2_buf)));
+
if (graph_port->symbol() == "control") { // TODO: Safe to use index?
- LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)lv2_buf;
- bool enqueued = false;
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_Atom_Sequence* seq =
+ reinterpret_cast<LV2_Atom_Sequence*>(lv2_buf);
+
+ bool enqueued = false;
+ LV2_ATOM_SEQUENCE_FOREACH(seq, ev)
+ {
if (AtomReader::is_message(uris, &ev->body)) {
enqueued = enqueue_message(&ev->body) || enqueued;
}
@@ -186,7 +193,8 @@ public:
_engine.locate(_frame_time, nframes);
// Notify buffer is a Chunk with size set to the available space
- _notify_capacity = ((LV2_Atom_Sequence*)_ports[1]->buffer())->atom.size;
+ _notify_capacity =
+ static_cast<LV2_Atom_Sequence*>(_ports[1]->buffer())->atom.size;
for (auto& p : _ports) {
pre_process_port(_engine.run_context(), p);
@@ -261,15 +269,19 @@ public:
void append_time_events(RunContext& context, Buffer& buffer) override {
const URIs& uris = _engine.world().uris();
- LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[0]->buffer();
+ LV2_Atom_Sequence* seq =
+ static_cast<LV2_Atom_Sequence*>(_ports[0]->buffer());
+
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (ev->body.type == uris.atom_Object) {
- const LV2_Atom_Object* obj = (LV2_Atom_Object*)&ev->body;
+ const LV2_Atom_Object* obj =
+ reinterpret_cast<LV2_Atom_Object*>(&ev->body);
+
if (obj->body.otype == uris.time_Position) {
buffer.append_event(ev->time.frames,
ev->body.size,
ev->body.type,
- (const uint8_t*)(&ev->body + 1));
+ reinterpret_cast<const uint8_t*>(&ev->body + 1));
}
}
}
@@ -317,12 +329,14 @@ public:
buf = realloc(buf, sizeof(LV2_Atom) + atom.size);
memcpy(buf, &atom, sizeof(LV2_Atom));
- if (!_from_ui.read(atom.size, (char*)buf + sizeof(LV2_Atom))) {
- _engine.log().rt_error("Error reading body from from-UI ring\n");
+ if (!_from_ui.read(atom.size,
+ static_cast<char*>(buf) + sizeof(LV2_Atom))) {
+ _engine.log().rt_error(
+ "Error reading body from from-UI ring\n");
break;
}
- _reader.write((LV2_Atom*)buf);
+ _reader.write(static_cast<LV2_Atom*>(buf));
read += sizeof(LV2_Atom) + atom.size;
}
free(buf);
@@ -334,7 +348,9 @@ public:
return;
}
- LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[1]->buffer();
+ LV2_Atom_Sequence* seq =
+ static_cast<LV2_Atom_Sequence*>(_ports[1]->buffer());
+
if (!seq) {
_engine.log().rt_error("Notify output not connected\n");
return;
@@ -358,8 +374,8 @@ public:
break; // Output port buffer full, resume next time
}
- LV2_Atom_Event* ev = (LV2_Atom_Event*)(
- (uint8_t*)seq + lv2_atom_total_size(&seq->atom));
+ LV2_Atom_Event* ev = reinterpret_cast<LV2_Atom_Event*>(
+ reinterpret_cast<uint8_t*>(seq) + lv2_atom_total_size(&seq->atom));
ev->time.frames = 0; // TODO: Time?
ev->body = atom;
@@ -486,13 +502,13 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
const LV2_Options_Option* options = nullptr;
for (int i = 0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID__map)) {
- map = (LV2_URID_Map*)features[i]->data;
+ map = static_cast<LV2_URID_Map*>(features[i]->data);
} else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
- unmap = (LV2_URID_Unmap*)features[i]->data;
+ unmap = static_cast<LV2_URID_Unmap*>(features[i]->data);
} else if (!strcmp(features[i]->URI, LV2_LOG__log)) {
- log = (LV2_Log_Log*)features[i]->data;
+ log = static_cast<LV2_Log_Log*>(features[i]->data);
} else if (!strcmp(features[i]->URI, LV2_OPTIONS__options)) {
- options = (const LV2_Options_Option*)features[i]->data;
+ options = static_cast<const LV2_Options_Option*>(features[i]->data);
}
}
@@ -509,10 +525,14 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
set_bundle_path(bundle_path);
const std::string manifest_path = ingen::bundle_file_path("manifest.ttl");
- SerdNode manifest_node = serd_node_new_file_uri(
- (const uint8_t*)manifest_path.c_str(), nullptr, nullptr, true);
-
- Lib::Graphs graphs = find_graphs(URI((const char*)manifest_node.buf));
+ SerdNode manifest_node =
+ serd_node_new_file_uri(reinterpret_cast<const uint8_t*>(
+ manifest_path.c_str()),
+ nullptr,
+ nullptr,
+ true);
+
+ Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
serd_node_free(&manifest_node);
const LV2Graph* graph = nullptr;
@@ -541,9 +561,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
if (options) {
for (const LV2_Options_Option* o = options; o->key; ++o) {
if (o->key == bufsz_max && o->type == atom_Int) {
- block_length = *(const int32_t*)o->value;
+ block_length = *static_cast<const int32_t*>(o->value);
} else if (o->key == bufsz_seq && o->type == atom_Int) {
- seq_size = *(const int32_t*)o->value;
+ seq_size = *static_cast<const int32_t*>(o->value);
}
}
}
@@ -607,7 +627,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
engine->register_client(client);
driver->set_instantiated(true);
- return (LV2_Handle)plugin;
+ return static_cast<LV2_Handle>(plugin);
}
static void
@@ -615,8 +635,8 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
{
using namespace ingen::server;
- IngenPlugin* me = (IngenPlugin*)instance;
- server::Engine* engine = (server::Engine*)me->world->engine().get();
+ IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ server::Engine* engine = static_cast<server::Engine*>(me->world->engine().get());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
if (port < driver->ports().size()) {
driver->ports().at(port)->set_buffer(data);
@@ -628,7 +648,7 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
static void
ingen_activate(LV2_Handle instance)
{
- IngenPlugin* me = (IngenPlugin*)instance;
+ IngenPlugin* me = static_cast<IngenPlugin*>(instance);
SPtr<server::Engine> engine = static_ptr_cast<server::Engine>(me->world->engine());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
engine->activate();
@@ -638,7 +658,7 @@ ingen_activate(LV2_Handle instance)
static void
ingen_run(LV2_Handle instance, uint32_t sample_count)
{
- IngenPlugin* me = (IngenPlugin*)instance;
+ IngenPlugin* me = static_cast<IngenPlugin*>(instance);
SPtr<server::Engine> engine = static_ptr_cast<server::Engine>(me->world->engine());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
@@ -651,7 +671,7 @@ ingen_run(LV2_Handle instance, uint32_t sample_count)
static void
ingen_deactivate(LV2_Handle instance)
{
- IngenPlugin* me = (IngenPlugin*)instance;
+ IngenPlugin* me = static_cast<IngenPlugin*>(instance);
me->world->engine()->deactivate();
if (me->main) {
me->main->join();
@@ -662,7 +682,7 @@ ingen_deactivate(LV2_Handle instance)
static void
ingen_cleanup(LV2_Handle instance)
{
- IngenPlugin* me = (IngenPlugin*)instance;
+ IngenPlugin* me = static_cast<IngenPlugin*>(instance);
me->world->set_engine(SPtr<ingen::server::Engine>());
me->world->set_interface(SPtr<ingen::Interface>());
if (me->main) {
@@ -681,9 +701,9 @@ get_state_features(const LV2_Feature* const* features,
{
for (int i = 0; features[i]; ++i) {
if (map && !strcmp(features[i]->URI, LV2_STATE__mapPath)) {
- *map = (LV2_State_Map_Path*)features[i]->data;
+ *map = static_cast<LV2_State_Map_Path*>(features[i]->data);
} else if (make && !strcmp(features[i]->URI, LV2_STATE__makePath)) {
- *make = (LV2_State_Make_Path*)features[i]->data;
+ *make = static_cast<LV2_State_Make_Path*>(features[i]->data);
}
}
}
@@ -695,7 +715,7 @@ ingen_save(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- IngenPlugin* plugin = (IngenPlugin*)instance;
+ IngenPlugin* plugin = static_cast<IngenPlugin*>(instance);
LV2_State_Map_Path* map_path = nullptr;
LV2_State_Make_Path* make_path = nullptr;
@@ -742,7 +762,7 @@ ingen_restore(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- IngenPlugin* plugin = (IngenPlugin*)instance;
+ IngenPlugin* plugin = static_cast<IngenPlugin*>(instance);
LV2_State_Map_Path* map_path = nullptr;
get_state_features(features, &map_path, nullptr);
@@ -757,8 +777,8 @@ ingen_restore(LV2_Handle instance,
uint32_t valflags;
// Get abstract path to graph file
- const char* path = (const char*)retrieve(
- handle, ingen_file, &size, &type, &valflags);
+ const char* path = static_cast<const char*>(
+ retrieve(handle, ingen_file, &size, &type, &valflags));
if (!path) {
return LV2_STATE_ERR_NO_PROPERTY;
}
@@ -821,10 +841,14 @@ Lib::Lib(const char* bundle_path)
{
ingen::set_bundle_path(bundle_path);
const std::string manifest_path = ingen::bundle_file_path("manifest.ttl");
- SerdNode manifest_node = serd_node_new_file_uri(
- (const uint8_t*)manifest_path.c_str(), nullptr, nullptr, true);
+ SerdNode manifest_node =
+ serd_node_new_file_uri(reinterpret_cast<const uint8_t*>(
+ manifest_path.c_str()),
+ nullptr,
+ nullptr,
+ true);
- graphs = find_graphs(URI((const char*)manifest_node.buf));
+ graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
serd_node_free(&manifest_node);
}
@@ -832,14 +856,14 @@ Lib::Lib(const char* bundle_path)
static void
lib_cleanup(LV2_Lib_Handle handle)
{
- Lib* lib = (Lib*)handle;
+ Lib* lib = static_cast<Lib*>(handle);
delete lib;
}
static const LV2_Descriptor*
lib_get_plugin(LV2_Lib_Handle handle, uint32_t index)
{
- Lib* lib = (Lib*)handle;
+ Lib* lib = static_cast<Lib*>(handle);
return index < lib->graphs.size() ? &lib->graphs[index]->descriptor : nullptr;
}
@@ -853,7 +877,7 @@ lv2_lib_descriptor(const char* bundle_path,
Lib* lib = new Lib(bundle_path);
// FIXME: memory leak. I think the LV2_Lib_Descriptor API is botched :(
- LV2_Lib_Descriptor* desc = (LV2_Lib_Descriptor*)malloc(desc_size);
+ LV2_Lib_Descriptor* desc = static_cast<LV2_Lib_Descriptor*>(malloc(desc_size));
desc->handle = lib;
desc->size = desc_size;
desc->cleanup = lib_cleanup;
diff --git a/src/server/ingen_portaudio.cpp b/src/server/ingen_portaudio.cpp
index f4e633d0..09229f91 100644
--- a/src/server/ingen_portaudio.cpp
+++ b/src/server/ingen_portaudio.cpp
@@ -28,16 +28,17 @@ using namespace ingen;
struct IngenPortAudioModule : public ingen::Module {
void load(ingen::World& world) override {
- if (((server::Engine*)world.engine().get())->driver()) {
+ server::Engine* const engine =
+ static_cast<server::Engine*>(world.engine().get());
+
+ if (engine->driver()) {
world.log().warn("Engine already has a driver\n");
return;
}
- server::PortAudioDriver* driver = new server::PortAudioDriver(
- *(server::Engine*)world.engine().get());
+ server::PortAudioDriver* driver = new server::PortAudioDriver(*engine);
driver->attach();
- ((server::Engine*)world.engine().get())->set_driver(
- SPtr<server::Driver>(driver));
+ engine->set_driver(SPtr<server::Driver>(driver));
}
};
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index b8738e1e..1a6bb483 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -114,7 +114,7 @@ ControllerNode::run(RunContext& context)
LV2_Atom_Sequence* seq = midi_in->get<LV2_Atom_Sequence>();
const BufferRef midi_out = _midi_out_port->buffer(0);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
+ const uint8_t* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3 &&
lv2_midi_message_type(buf) == LV2_MIDI_MSG_CONTROLLER) {
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index cfc0c157..0d375eac 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -167,8 +167,12 @@ NoteNode::run(RunContext& context)
Buffer* const midi_in = _midi_in_port->buffer(0).get();
LV2_Atom_Sequence* seq = midi_in->get<LV2_Atom_Sequence>();
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY_CONST(&ev->body);
- const FrameTime time = context.start() + (FrameTime)ev->time.frames;
+ const uint8_t* buf =
+ static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
+
+ const FrameTime time =
+ context.start() + static_cast<FrameTime>(ev->time.frames);
+
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
switch (lv2_midi_message_type(buf)) {
@@ -198,8 +202,11 @@ NoteNode::run(RunContext& context)
}
break;
case LV2_MIDI_MSG_BENDER:
- bend(context, time, (((((uint16_t)buf[2] << 7) | buf[1]) - 8192.0f)
- / 8192.0f));
+ bend(context,
+ time,
+ ((((static_cast<uint16_t>(buf[2]) << 7) | buf[1]) -
+ 8192.0f) /
+ 8192.0f));
break;
case LV2_MIDI_MSG_CHANNEL_PRESSURE:
channel_pressure(context, time, buf[1] / 127.0f);
@@ -218,7 +225,7 @@ static inline float
note_to_freq(uint8_t num)
{
static const float A4 = 440.0f;
- return A4 * powf(2.0f, (float)(num - 57.0f) / 12.0f);
+ return A4 * powf(2.0f, static_cast<float>(num - 57.0f) / 12.0f);
}
void
@@ -286,7 +293,7 @@ NoteNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, Frame
assert(_keys[voice->note].voice == voice_num);
_freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num));
- _num_port->set_voice_value(context, voice_num, time, (float)note_num);
+ _num_port->set_voice_value(context, voice_num, time, static_cast<float>(note_num));
_vel_port->set_voice_value(context, voice_num, time, velocity / 127.0f);
_gate_port->set_voice_value(context, voice_num, time, 1.0f);
if (!double_trigger) {
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 4ceae3c8..f9c21438 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -115,7 +115,7 @@ TriggerNode::run(RunContext& context)
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
const int64_t t = ev->time.frames;
- const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
+ const uint8_t* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
bool emit = false;
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
@@ -156,7 +156,7 @@ TriggerNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, Fr
const uint32_t offset = time - context.start();
if (_learning) {
- _note_port->set_control_value(context, time, (float)note_num);
+ _note_port->set_control_value(context, time, static_cast<float>(note_num));
_note_port->force_monitor_update();
_learning = false;
}
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index 5f77eda2..e6f999f4 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -29,7 +29,7 @@ is_end(const Buffer* buf, const LV2_Atom_Event* ev)
{
const LV2_Atom* atom = buf->get<const LV2_Atom>();
return lv2_atom_sequence_is_end(
- (const LV2_Atom_Sequence_Body*)LV2_ATOM_BODY_CONST(atom),
+ static_cast<const LV2_Atom_Sequence_Body*>(LV2_ATOM_BODY_CONST(atom)),
atom->size,
ev);
}
@@ -96,7 +96,7 @@ mix(const RunContext& context,
if (first) {
dst->append_event(
first->time.frames, first->body.size, first->body.type,
- (const uint8_t*)LV2_ATOM_BODY_CONST(&first->body));
+ static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&first->body)));
iters[first_i] = lv2_atom_sequence_next(first);
if (is_end(srcs[first_i], iters[first_i])) {
diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp
index 0a042f94..2741e5d6 100644
--- a/tests/ingen_bench.cpp
+++ b/tests/ingen_bench.cpp
@@ -82,11 +82,13 @@ 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(static_cast<const char*>(load.get_body()));
+
+ const std::string out_file = static_cast<const char*>(out.get_body());
if (start_graph.empty()) {
cerr << "error: initial graph '"
- << ((const char*)load.get_body())
+ << static_cast<const char*>(load.get_body())
<< "' does not exist" << endl;
return EXIT_FAILURE;
}
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp
index 4d9823bc..605b25fc 100644
--- a/tests/ingen_test.cpp
+++ b/tests/ingen_test.cpp
@@ -94,8 +94,8 @@ main(int argc, char** argv)
}
// Get start graph and commands file options
- const FilePath load_path = real_file_path((const char*)load.get_body());
- const FilePath run_path = real_file_path((const char*)execute.get_body());
+ const FilePath load_path = real_file_path(static_cast<const char*>(load.get_body()));
+ const FilePath run_path = real_file_path(static_cast<const char*>(execute.get_body()));
if (load_path.empty()) {
cerr << "error: initial graph '" << load_path << "' does not exist" << endl;
@@ -142,10 +142,13 @@ main(int argc, char** argv)
SerdURI cmds_base;
SerdNode cmds_file_uri = serd_node_new_file_uri(
- (const uint8_t*)run_path.c_str(),
+ reinterpret_cast<const uint8_t*>(run_path.c_str()),
nullptr, &cmds_base, true);
- Sord::Model* cmds = new Sord::Model(*world->rdf_world(),
- (const char*)cmds_file_uri.buf);
+
+ Sord::Model* cmds =
+ new Sord::Model(*world->rdf_world(),
+ reinterpret_cast<const char*>(cmds_file_uri.buf));
+
SerdEnv* env = serd_env_new(&cmds_file_uri);
cmds->load_file(env, SERD_TURTLE, run_path);
Sord::Node nil;
@@ -153,7 +156,7 @@ main(int argc, char** argv)
for (;; ++n_events) {
std::string subject_str = fmt("msg%1%", n_events);
Sord::URI subject(*world->rdf_world(), subject_str,
- (const char*)cmds_file_uri.buf);
+ reinterpret_cast<const char*>(cmds_file_uri.buf));
Sord::Iter iter = cmds->find(subject, nil, nil);
if (iter.end()) {
break;
diff --git a/wscript b/wscript
index f213f86c..76444268 100644
--- a/wscript
+++ b/wscript
@@ -71,7 +71,6 @@ def configure(conf):
'-Wno-implicit-float-conversion',
'-Wno-implicit-int-conversion',
'-Wno-inconsistent-missing-destructor-override',
- '-Wno-old-style-cast',
'-Wno-padded',
'-Wno-range-loop-bind-reference',
'-Wno-reserved-id-macro',
@@ -102,7 +101,6 @@ def configure(conf):
'-Wno-format-nonliteral',
'-Wno-implicit-fallthrough',
'-Wno-multiple-inheritance',
- '-Wno-old-style-cast',
'-Wno-padded',
'-Wno-pedantic',
'-Wno-shadow',