aboutsummaryrefslogtreecommitdiffstats
path: root/include/lv2/atom
diff options
context:
space:
mode:
Diffstat (limited to 'include/lv2/atom')
-rw-r--r--include/lv2/atom/forge.h52
-rw-r--r--include/lv2/atom/util.h35
2 files changed, 46 insertions, 41 deletions
diff --git a/include/lv2/atom/forge.h b/include/lv2/atom/forge.h
index f894a5a..daf603c 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
@@ -287,7 +287,7 @@ lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size)
forge->offset += size;
memcpy(mem, data, size);
}
- for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
+ for (const LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
lv2_atom_forge_deref(forge, f->ref)->size += size;
}
return out;
@@ -492,7 +492,7 @@ 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}};
const LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
@@ -569,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,
@@ -588,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,
diff --git a/include/lv2/atom/util.h b/include/lv2/atom/util.h
index b8bb295..9524210 100644
--- a/include/lv2/atom/util.h
+++ b/include/lv2/atom/util.h
@@ -1,4 +1,4 @@
-// Copyright 2008-2015 David Robillard <d@drobilla.net>
+// Copyright 2008-2024 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#ifndef LV2_ATOM_UTIL_H
@@ -21,7 +21,7 @@
@{
*/
-#include "lv2/atom/atom.h"
+#include <lv2/atom/atom.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -38,9 +38,7 @@ extern "C" {
static inline uint32_t
lv2_atom_pad_size(uint32_t size)
{
- static const uint32_t mask = 7U;
-
- return (size + mask) & ~mask;
+ return (size + 7U) & ~(7U);
}
/** Return the total size of `atom`, including the header. */
@@ -61,8 +59,7 @@ lv2_atom_is_null(const LV2_Atom* atom)
static inline bool
lv2_atom_equals(const LV2_Atom* a, const LV2_Atom* b)
{
- return (a == b) || ((a->type == b->type) && (a->size == b->size) &&
- !memcmp(a + 1, b + 1, a->size));
+ return (a == b) || !memcmp(a, b, sizeof(LV2_Atom) + a->size);
}
/**
@@ -252,7 +249,7 @@ static inline LV2_Atom_Property_Body*
lv2_atom_object_next(const LV2_Atom_Property_Body* i)
{
const LV2_Atom* const value =
- (const LV2_Atom*)((const uint8_t*)i + 2 * sizeof(uint32_t));
+ (const LV2_Atom*)((const uint8_t*)i + (2 * sizeof(uint32_t)));
return (LV2_Atom_Property_Body*)((const uint8_t*)i +
lv2_atom_pad_size(
(uint32_t)sizeof(LV2_Atom_Property_Body) +
@@ -332,12 +329,15 @@ lv2_atom_object_query(const LV2_Atom_Object* object,
int n_queries = 0;
/* Count number of query keys so we can short-circuit when done */
- for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
+ for (const LV2_Atom_Object_Query* q = query; q->key; ++q) {
++n_queries;
}
- LV2_ATOM_OBJECT_FOREACH (object, prop) {
- for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
+ for (const LV2_Atom_Property_Body* prop =
+ lv2_atom_object_begin(&object->body);
+ !lv2_atom_object_is_end(&object->body, object->atom.size, prop);
+ prop = lv2_atom_object_next(prop)) {
+ for (const LV2_Atom_Object_Query* q = query; q->key; ++q) {
if (q->key == prop->key && !*q->value) {
*q->value = &prop->value;
if (++matches == n_queries) {
@@ -370,7 +370,9 @@ lv2_atom_object_body_get(uint32_t size, const LV2_Atom_Object_Body* body, ...)
}
va_end(args);
- LV2_ATOM_OBJECT_BODY_FOREACH (body, size, prop) {
+ for (const LV2_Atom_Property_Body* prop = lv2_atom_object_begin(body);
+ !lv2_atom_object_is_end(body, size, prop);
+ prop = lv2_atom_object_next(prop)) {
va_start(args, body);
for (int i = 0; i < n_queries; ++i) {
const uint32_t qkey = va_arg(args, uint32_t);
@@ -425,7 +427,10 @@ lv2_atom_object_get(const LV2_Atom_Object* object, ...)
}
va_end(args);
- LV2_ATOM_OBJECT_FOREACH (object, prop) {
+ for (const LV2_Atom_Property_Body* prop =
+ lv2_atom_object_begin(&object->body);
+ !lv2_atom_object_is_end(&object->body, object->atom.size, prop);
+ prop = lv2_atom_object_next(prop)) {
va_start(args, object);
for (int i = 0; i < n_queries; ++i) {
const uint32_t qkey = va_arg(args, uint32_t);
@@ -481,7 +486,9 @@ lv2_atom_object_get_typed(const LV2_Atom_Object* object, ...)
}
va_end(args);
- LV2_ATOM_OBJECT_FOREACH (object, prop) {
+ for (const LV2_Atom_Property_Body* prop = lv2_atom_object_begin(&object->body);
+ !lv2_atom_object_is_end(&object->body, object->atom.size, prop);
+ prop = lv2_atom_object_next(prop)) {
va_start(args, object);
for (int i = 0; i < n_queries; ++i) {
const uint32_t qkey = va_arg(args, uint32_t);