summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ingen/AtomForge.hpp74
-rw-r--r--include/ingen/ClashAvoider.hpp6
-rw-r--r--include/ingen/Library.hpp4
-rw-r--r--include/ingen/Log.hpp6
-rw-r--r--include/ingen/Module.hpp4
-rw-r--r--include/ingen/Resource.hpp4
-rw-r--r--include/ingen/Serialiser.hpp4
-rw-r--r--include/ingen/URI.hpp4
-rw-r--r--include/ingen/client/GraphModel.hpp1
-rw-r--r--include/ingen/client/PortModel.hpp4
-rw-r--r--include/ingen/client/SigClientInterface.hpp2
11 files changed, 33 insertions, 80 deletions
diff --git a/include/ingen/AtomForge.hpp b/include/ingen/AtomForge.hpp
index cf5a759d..b1e5a5df 100644
--- a/include/ingen/AtomForge.hpp
+++ b/include/ingen/AtomForge.hpp
@@ -17,55 +17,41 @@
#ifndef INGEN_ATOMFORGE_HPP
#define INGEN_ATOMFORGE_HPP
+#include "ingen/ingen.h"
#include "ingen/memory.hpp"
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
-#include "lv2/atom/util.h"
#include "lv2/urid/urid.h"
#include "sord/sord.h"
-#include "sord/sordmm.hpp"
#include "sratom/sratom.h"
-#include <cassert>
#include <cstdint>
#include <cstdlib>
-#include <cstring>
#include <memory>
+namespace Sord {
+class World;
+} // namespace Sord
+
namespace ingen {
/// An atom forge that writes to an automatically-resized memory buffer
-class AtomForge : public LV2_Atom_Forge
+class INGEN_API AtomForge : public LV2_Atom_Forge
{
public:
- explicit AtomForge(LV2_URID_Map& map)
- : LV2_Atom_Forge{}
- , _sratom{sratom_new(&map)}
- , _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);
- }
+ explicit AtomForge(LV2_URID_Map& map);
/// Forge an atom from `node` in `model`
- void read(Sord::World& world, SordModel* model, const SordNode* node)
- {
- sratom_read(_sratom.get(), this, world.c_obj(), model, node);
- }
+ void read(Sord::World& world, SordModel* model, const SordNode* node);
/// Return the top-level atom that has been forged
- const LV2_Atom* atom() const { return _buf.get(); }
+ const LV2_Atom* atom() const;
/// Clear the atom buffer and reset the forge
- void clear()
- {
- lv2_atom_forge_set_sink(this, c_append, c_deref, this);
- _size = 0;
- *_buf = {0U, 0U};
- }
+ void clear();
/// Return the internal atom serialiser
- Sratom& sratom() { return *_sratom; }
+ Sratom& sratom();
private:
struct SratomDeleter { void operator()(Sratom* s) { sratom_free(s); } };
@@ -74,46 +60,16 @@ private:
using SratomPtr = std::unique_ptr<Sratom, SratomDeleter>;
/// Append some data and return a reference to its start
- intptr_t append(const void* data, uint32_t len) {
- // Record offset of the start of this write (+1 to avoid null)
- const auto ref = static_cast<intptr_t>(_size + 1U);
-
- // Update size and reallocate if necessary
- if (lv2_atom_pad_size(_size + len) > _capacity) {
- _capacity = lv2_atom_pad_size(_size + len);
-
- _buf = AtomPtr{static_cast<LV2_Atom*>(
- realloc(_buf.release(), _capacity)),
- FreeDeleter<LV2_Atom>{}};
- }
-
- // Append new data
- memcpy(reinterpret_cast<uint8_t*>(_buf.get()) + _size, data, len);
- _size += len;
- return ref;
- }
+ intptr_t append(const void* data, uint32_t len);
/// Dereference a reference previously returned by append()
- LV2_Atom* deref(intptr_t ref) {
- /* Make some assumptions and do unnecessary math to appease
- -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 static_cast<LV2_Atom*>(_buf.get() + (ref - 1) / sizeof(LV2_Atom));
-
- // Alternatively:
- // return (LV2_Atom*)((uint8_t*)_buf + ref - 1);
- }
+ LV2_Atom* deref(intptr_t ref);
static LV2_Atom_Forge_Ref
- c_append(void* self, const void* data, uint32_t len) {
- return static_cast<AtomForge*>(self)->append(data, len);
- }
+ c_append(void* self, const void* data, uint32_t len);
static LV2_Atom*
- c_deref(void* self, LV2_Atom_Forge_Ref ref) {
- return static_cast<AtomForge*>(self)->deref(ref);
- }
+ c_deref(void* self, LV2_Atom_Forge_Ref ref);
size_t _size{0}; ///< Current atom size
size_t _capacity{8 * sizeof(LV2_Atom)}; ///< Allocated size of buffer
diff --git a/include/ingen/ClashAvoider.hpp b/include/ingen/ClashAvoider.hpp
index c1d62754..c0091fbc 100644
--- a/include/ingen/ClashAvoider.hpp
+++ b/include/ingen/ClashAvoider.hpp
@@ -48,9 +48,9 @@ public:
* @param new_path The new path that `old_path` was mapped to
* @param name The old name.
*/
- static std::string adjust_name(const raul::Path& old_path,
- const raul::Path& new_path,
- std::string name);
+ static std::string adjust_name(const raul::Path& old_path,
+ const raul::Path& new_path,
+ const std::string& name);
private:
using Offsets = std::map<raul::Path, unsigned>;
diff --git a/include/ingen/Library.hpp b/include/ingen/Library.hpp
index 4cee985f..ac494e4c 100644
--- a/include/ingen/Library.hpp
+++ b/include/ingen/Library.hpp
@@ -26,7 +26,7 @@ namespace ingen {
class INGEN_API Library
{
public:
- Library(const FilePath& path);
+ explicit Library(const FilePath& path);
~Library();
Library(const Library&) = delete;
@@ -40,7 +40,7 @@ public:
static const char* get_last_error();
- operator bool() const { return _lib; }
+ explicit operator bool() const { return _lib; }
private:
void* _lib;
diff --git a/include/ingen/Log.hpp b/include/ingen/Log.hpp
index 8d1b420c..acbb4b6d 100644
--- a/include/ingen/Log.hpp
+++ b/include/ingen/Log.hpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -25,7 +25,6 @@
#include "lv2/urid/urid.h"
#include <cstdarg>
-#include <cstdio>
#include <functional>
#include <memory>
#include <string>
@@ -89,14 +88,13 @@ public:
}
int vtprintf(LV2_URID type, const char* fmt, va_list args);
+ int tprintf(LV2_URID type, const char* fmt, ...);
void set_flush(bool f) { _flush = f; }
void set_trace(bool f) { _trace = f; }
void set_sink(Sink s) { _sink = std::move(s); }
private:
- void print(FILE* stream, const std::string& msg) const;
-
LV2_Log_Log* _log;
URIs& _uris;
Sink _sink;
diff --git a/include/ingen/Module.hpp b/include/ingen/Module.hpp
index 90f2f930..c9929c0a 100644
--- a/include/ingen/Module.hpp
+++ b/include/ingen/Module.hpp
@@ -46,8 +46,8 @@ public:
/** Library implementing this module.
*
- * This is managed by the World and not this class, since closing the library
- * in this destructor could possibly reference code from the library
+ * This is managed by the World and not this class, since closing the
+ * library in this destructor could possibly reference code from the library
* afterwards and cause a segfault on exit.
*/
std::unique_ptr<Library> library;
diff --git a/include/ingen/Resource.hpp b/include/ingen/Resource.hpp
index 8b96a27b..3ba65dda 100644
--- a/include/ingen/Resource.hpp
+++ b/include/ingen/Resource.hpp
@@ -175,8 +175,8 @@ public:
/** Get the ingen type from a set of Properties.
*
- * If some coherent ingen type is found, true is returned and the appropriate
- * output parameter set to true. Otherwise false is returned.
+ * If some coherent ingen type is found, true is returned and the
+ * appropriate output parameter set to true. Otherwise false is returned.
*/
static bool type(const URIs& uris,
const Properties& properties,
diff --git a/include/ingen/Serialiser.hpp b/include/ingen/Serialiser.hpp
index f7f04317..5b70c78b 100644
--- a/include/ingen/Serialiser.hpp
+++ b/include/ingen/Serialiser.hpp
@@ -56,8 +56,8 @@ public:
*
* This must be called before any serializing methods.
*
- * The results of the serialization will be returned by the finish() method after
- * the desired objects have been serialised.
+ * The results of the serialization will be returned by the finish() method
+ * after the desired objects have been serialised.
*
* All serialized paths will have the root path chopped from their prefix
* (therefore all serialized paths must be descendants of the root)
diff --git a/include/ingen/URI.hpp b/include/ingen/URI.hpp
index a45fb268..959f2290 100644
--- a/include/ingen/URI.hpp
+++ b/include/ingen/URI.hpp
@@ -40,7 +40,7 @@ public:
explicit URI(const char* str);
URI(const std::string& str, const URI& base);
URI(const Sord::Node& node);
- URI(SerdNode node);
+ URI(const SerdNode& node);
explicit URI(const FilePath& path);
URI(const URI& uri);
@@ -98,7 +98,7 @@ public:
}
private:
- URI(SerdNode node, SerdURI uri);
+ URI(const SerdNode& node, const SerdURI& uri);
static Chunk make_chunk(const SerdChunk& chunk) {
return {reinterpret_cast<const char*>(chunk.buf), chunk.len};
diff --git a/include/ingen/client/GraphModel.hpp b/include/ingen/client/GraphModel.hpp
index 1bc445ac..1b762566 100644
--- a/include/ingen/client/GraphModel.hpp
+++ b/include/ingen/client/GraphModel.hpp
@@ -54,7 +54,6 @@ public:
get_arc(const ingen::Node* tail, const ingen::Node* head);
bool enabled() const;
- bool polyphonic() const;
uint32_t internal_poly() const;
// Signals
diff --git a/include/ingen/client/PortModel.hpp b/include/ingen/client/PortModel.hpp
index 903a435d..eb85eb6c 100644
--- a/include/ingen/client/PortModel.hpp
+++ b/include/ingen/client/PortModel.hpp
@@ -86,8 +86,8 @@ private:
, _direction(dir)
{}
- void add_child(const std::shared_ptr<ObjectModel>& c) override { throw; }
- bool remove_child(const std::shared_ptr<ObjectModel>& c) override { throw; }
+ void add_child(const std::shared_ptr<ObjectModel>& c) override;
+ bool remove_child(const std::shared_ptr<ObjectModel>& c) override;
void set(const std::shared_ptr<ObjectModel>& model) override;
diff --git a/include/ingen/client/SigClientInterface.hpp b/include/ingen/client/SigClientInterface.hpp
index 6bff2e33..955c6dcd 100644
--- a/include/ingen/client/SigClientInterface.hpp
+++ b/include/ingen/client/SigClientInterface.hpp
@@ -45,7 +45,7 @@ public:
INGEN_SIGNAL(message, void, Message)
- /** Fire pending signals. Only does anything on derived classes (that may queue) */
+ /** Fire pending signals (for derived classes that may queue). */
virtual bool emit_signals() { return false; }
protected: