aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2026-01-08 11:12:58 -0500
committerDavid Robillard <d@drobilla.net>2026-01-08 11:12:58 -0500
commit9a8c52e3fc24fe3b3d659b72b6e7608b6d25e62b (patch)
tree99c648c1a014562e793af65ba822afb1df032366
parente8ffc0c759f6db73fbc820eef433b68153f53daa (diff)
downloadlv2-9a8c52e3fc24fe3b3d659b72b6e7608b6d25e62b.tar.xz
Avoid using LV2_ATOM_OBJECT_FOREACH in atom utilities
Using these on const atoms violates const-correctness, but unfortunately changing the macros would technically break the API. Ultimately, this code should be moved outside the (effective) spec so that it can be improved in general, but for now, just inline the macro bodies and add the necessary const qualifiers.
-rw-r--r--include/lv2/atom/util.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/lv2/atom/util.h b/include/lv2/atom/util.h
index 3cf2164..9524210 100644
--- a/include/lv2/atom/util.h
+++ b/include/lv2/atom/util.h
@@ -333,7 +333,10 @@ lv2_atom_object_query(const LV2_Atom_Object* object,
++n_queries;
}
- 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)) {
for (const LV2_Atom_Object_Query* q = query; q->key; ++q) {
if (q->key == prop->key && !*q->value) {
*q->value = &prop->value;
@@ -367,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);
@@ -422,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);
@@ -478,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);