aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-params.lv2/state_map.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-26 19:21:17 +0100
committerDavid Robillard <d@drobilla.net>2020-12-26 19:21:17 +0100
commit882b9446cbf7316345de391188e68c2a7333da5b (patch)
tree5baf31e0a28313b380cc7e8694b09a2a517d14f3 /plugins/eg-params.lv2/state_map.h
parent8d2251749da9e0ae4254502edfc8917236a9b8c0 (diff)
downloadlv2-882b9446cbf7316345de391188e68c2a7333da5b.tar.xz
Format all code with clang-format
Diffstat (limited to 'plugins/eg-params.lv2/state_map.h')
-rw-r--r--plugins/eg-params.lv2/state_map.h80
1 files changed, 39 insertions, 41 deletions
diff --git a/plugins/eg-params.lv2/state_map.h b/plugins/eg-params.lv2/state_map.h
index 85358f8..f534f60 100644
--- a/plugins/eg-params.lv2/state_map.h
+++ b/plugins/eg-params.lv2/state_map.h
@@ -24,33 +24,31 @@
/** Entry in an array that serves as a dictionary of properties. */
typedef struct {
- const char* uri;
- LV2_URID urid;
- LV2_Atom* value;
+ const char* uri;
+ LV2_URID urid;
+ LV2_Atom* value;
} StateMapItem;
/** Comparator for StateMapItems sorted by URID. */
static int
state_map_cmp(const void* a, const void* b)
{
- const StateMapItem* ka = (const StateMapItem*)a;
- const StateMapItem* kb = (const StateMapItem*)b;
- if (ka->urid < kb->urid) {
- return -1;
- }
+ const StateMapItem* ka = (const StateMapItem*)a;
+ const StateMapItem* kb = (const StateMapItem*)b;
+ if (ka->urid < kb->urid) {
+ return -1;
+ }
- if (kb->urid < ka->urid) {
- return 1;
- }
+ if (kb->urid < ka->urid) {
+ return 1;
+ }
- return 0;
+ return 0;
}
/** Helper macro for terse state map initialisation. */
#define STATE_MAP_INIT(type, ptr) \
- (LV2_ATOM__ ## type), \
- (sizeof(*ptr) - sizeof(LV2_Atom)), \
- (ptr)
+ (LV2_ATOM__##type), (sizeof(*ptr) - sizeof(LV2_Atom)), (ptr)
/**
Initialise a state map.
@@ -76,29 +74,30 @@ state_map_cmp(const void* a, const void* b)
NULL);
*/
static void
-state_map_init(StateMapItem dict[],
- LV2_URID_Map* map,
- LV2_URID_Map_Handle handle,
- /* const char* uri, const char* type, uint32_t size, LV2_Atom* value */ ...)
+state_map_init(
+ StateMapItem dict[],
+ LV2_URID_Map* map,
+ LV2_URID_Map_Handle handle,
+ /* const char* uri, const char* type, uint32_t size, LV2_Atom* value */...)
{
- // Set dict entries from parameters
- unsigned i = 0;
- va_list args;
- va_start(args, handle);
- for (const char* uri = NULL; (uri = va_arg(args, const char*)); ++i) {
- const char* type = va_arg(args, const char*);
- const uint32_t size = va_arg(args, uint32_t);
- LV2_Atom* const value = va_arg(args, LV2_Atom*);
- dict[i].uri = uri;
- dict[i].urid = map->map(map->handle, uri);
- dict[i].value = value;
- dict[i].value->size = size;
- dict[i].value->type = map->map(map->handle, type);
- }
- va_end(args);
-
- // Sort for fast lookup by URID by state_map_find()
- qsort(dict, i, sizeof(StateMapItem), state_map_cmp);
+ // Set dict entries from parameters
+ unsigned i = 0;
+ va_list args;
+ va_start(args, handle);
+ for (const char* uri = NULL; (uri = va_arg(args, const char*)); ++i) {
+ const char* type = va_arg(args, const char*);
+ const uint32_t size = va_arg(args, uint32_t);
+ LV2_Atom* const value = va_arg(args, LV2_Atom*);
+ dict[i].uri = uri;
+ dict[i].urid = map->map(map->handle, uri);
+ dict[i].value = value;
+ dict[i].value->size = size;
+ dict[i].value->type = map->map(map->handle, type);
+ }
+ va_end(args);
+
+ // Sort for fast lookup by URID by state_map_find()
+ qsort(dict, i, sizeof(StateMapItem), state_map_cmp);
}
/**
@@ -111,8 +110,7 @@ state_map_init(StateMapItem dict[],
static StateMapItem*
state_map_find(StateMapItem dict[], uint32_t n_entries, LV2_URID urid)
{
- const StateMapItem key = { NULL, urid, NULL };
- return (StateMapItem*)bsearch(
- &key, dict, n_entries, sizeof(StateMapItem), state_map_cmp);
+ const StateMapItem key = {NULL, urid, NULL};
+ return (StateMapItem*)bsearch(
+ &key, dict, n_entries, sizeof(StateMapItem), state_map_cmp);
}
-