aboutsummaryrefslogtreecommitdiffstats
path: root/include/lv2/atom/forge.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lv2/atom/forge.h')
-rw-r--r--include/lv2/atom/forge.h72
1 files changed, 39 insertions, 33 deletions
diff --git a/include/lv2/atom/forge.h b/include/lv2/atom/forge.h
index 5e9bef8..58b7512 100644
--- a/include/lv2/atom/forge.h
+++ b/include/lv2/atom/forge.h
@@ -38,10 +38,10 @@
@{
*/
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/core/attributes.h"
-#include "lv2/urid/urid.h"
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/core/attributes.h>
+#include <lv2/urid/urid.h>
#include <assert.h>
#include <stdbool.h>
@@ -90,24 +90,24 @@ typedef struct {
LV2_Atom_Forge_Frame* stack;
- LV2_URID Blank LV2_DEPRECATED;
- LV2_URID Bool;
- LV2_URID Chunk;
- LV2_URID Double;
- LV2_URID Float;
- LV2_URID Int;
- LV2_URID Long;
- LV2_URID Literal;
- LV2_URID Object;
- LV2_URID Path;
- LV2_URID Property;
+ LV2_URID Blank LV2_DEPRECATED;
+ LV2_URID Bool;
+ LV2_URID Chunk;
+ LV2_URID Double;
+ LV2_URID Float;
+ LV2_URID Int;
+ LV2_URID Long;
+ LV2_URID Literal;
+ LV2_URID Object;
+ LV2_URID Path;
+ LV2_URID Property;
LV2_URID Resource LV2_DEPRECATED;
- LV2_URID Sequence;
- LV2_URID String;
- LV2_URID Tuple;
- LV2_URID URI;
- LV2_URID URID;
- LV2_URID Vector;
+ LV2_URID Sequence;
+ LV2_URID String;
+ LV2_URID Tuple;
+ LV2_URID URI;
+ LV2_URID URID;
+ LV2_URID Vector;
} LV2_Atom_Forge;
static inline void
@@ -147,6 +147,7 @@ lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
static inline LV2_Atom*
lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref)
{
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref);
}
@@ -305,7 +306,7 @@ lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written)
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size)
{
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
+ const LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
if (out) {
lv2_atom_forge_pad(forge, size);
}
@@ -316,11 +317,18 @@ lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size)
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_string_body(LV2_Atom_Forge* forge, const char* str, uint32_t len)
{
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len);
- if (out && (out = lv2_atom_forge_raw(forge, "", 1))) {
- lv2_atom_forge_pad(forge, len + 1);
+ const LV2_Atom_Forge_Ref s = lv2_atom_forge_raw(forge, str, len);
+ if (!s) {
+ return s;
}
- return out;
+
+ const LV2_Atom_Forge_Ref t = lv2_atom_forge_raw(forge, "", 1);
+ if (!t) {
+ return t;
+ }
+
+ lv2_atom_forge_pad(forge, len + 1U);
+ return t;
}
/**
@@ -484,10 +492,10 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge,
const void* elems)
{
const LV2_Atom_Vector a = {
- {(uint32_t)sizeof(LV2_Atom_Vector_Body) + n_elems * child_size,
+ {(uint32_t)sizeof(LV2_Atom_Vector_Body) + (n_elems * child_size),
forge->Vector},
{child_size, child_type}};
- LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
+ const LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
if (out) {
lv2_atom_forge_write(forge, elems, child_size * n_elems);
}
@@ -561,8 +569,7 @@ lv2_atom_forge_object(LV2_Atom_Forge* forge,
This function is deprecated and should not be used in new code.
Use lv2_atom_forge_object() directly instead.
*/
-LV2_DEPRECATED
-static inline LV2_Atom_Forge_Ref
+LV2_DEPRECATED static inline LV2_Atom_Forge_Ref
lv2_atom_forge_resource(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
LV2_URID id,
@@ -580,8 +587,7 @@ lv2_atom_forge_resource(LV2_Atom_Forge* forge,
This function is deprecated and should not be used in new code.
Use lv2_atom_forge_object() directly instead.
*/
-LV2_DEPRECATED
-static inline LV2_Atom_Forge_Ref
+LV2_DEPRECATED static inline LV2_Atom_Forge_Ref
lv2_atom_forge_blank(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
uint32_t id,
@@ -667,4 +673,4 @@ LV2_RESTORE_WARNINGS
@}
*/
-#endif /* LV2_ATOM_FORGE_H */
+#endif // LV2_ATOM_FORGE_H