From 1c19342487174edbc180114bff52c352e1350848 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Dec 2017 16:25:46 +0100 Subject: [PATCH] pod: add info property flag Add an info property flag that should not be taken into account when intersecting. We use this for docs and labels. Improve builder, make it possible to make struct properties with flags. Add some docs to the property flags and ranges. --- spa/include/spa/pod/builder.h | 39 ++++++++++++++++++----------------- spa/include/spa/pod/pod.h | 22 +++++++++++--------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h index 83bd4402f..9992f5276 100644 --- a/spa/include/spa/pod/builder.h +++ b/spa/include/spa/pod/builder.h @@ -398,6 +398,8 @@ static inline uint32_t spa_pod_flag_from_id(char id) return SPA_POD_PROP_FLAG_READONLY; case 'd': return SPA_POD_PROP_FLAG_DEPRECATED; + case 'i': + return SPA_POD_PROP_FLAG_INFO; default: return 0; } @@ -500,7 +502,9 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, const char *format, va_list args) { while (format) { - switch (*format) { + char t = *format; + next: + switch (t) { case '<': { uint32_t id = va_arg(args, uint32_t); @@ -516,32 +520,28 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, break; case ':': { - const char *spec; - char type; int n_values; uint32_t key, flags; key = va_arg(args, uint32_t); - format = spec = va_arg(args, const char *); - type = *spec; - if (*spec != '\0') - spec++; - flags = spa_pod_range_from_id(*spec); - if (*spec != '\0') - spec++; - for (;*spec;spec++) - flags |= spa_pod_flag_from_id(*spec); + format = va_arg(args, const char *); + t = *format; + if (*format != '\0') + format++; + flags = spa_pod_range_from_id(*format); + if (*format != '\0') + format++; + for (;*format;format++) + flags |= spa_pod_flag_from_id(*format); spa_pod_builder_push_prop(builder, key, flags); - if (type == '{' || type == '[') - continue; - - format = spec; + if (t == '<' || t == '[') + goto next; n_values = -1; while (n_values-- != 0) { - SPA_POD_BUILDER_COLLECT(builder, type, args); + SPA_POD_BUILDER_COLLECT(builder, t, args); if ((flags & SPA_POD_PROP_RANGE_MASK) == 0) break; @@ -565,10 +565,11 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, format = va_arg(args, const char *); continue; default: - SPA_POD_BUILDER_COLLECT(builder,*format,args); + SPA_POD_BUILDER_COLLECT(builder, t, args); break;; } - format++; + if (*format != '\0') + format++; } return spa_pod_builder_deref(builder, builder->frame[builder->state.depth].ref); } diff --git a/spa/include/spa/pod/pod.h b/spa/include/spa/pod/pod.h index b8a3037ca..d1a1af857 100644 --- a/spa/include/spa/pod/pod.h +++ b/spa/include/spa/pod/pod.h @@ -209,16 +209,18 @@ struct spa_pod_fd { struct spa_pod_prop_body { uint32_t key; -#define SPA_POD_PROP_RANGE_NONE 0 -#define SPA_POD_PROP_RANGE_MIN_MAX 1 -#define SPA_POD_PROP_RANGE_STEP 2 -#define SPA_POD_PROP_RANGE_ENUM 3 -#define SPA_POD_PROP_RANGE_FLAGS 4 -#define SPA_POD_PROP_RANGE_MASK 0xf -#define SPA_POD_PROP_FLAG_UNSET (1 << 4) -#define SPA_POD_PROP_FLAG_OPTIONAL (1 << 5) -#define SPA_POD_PROP_FLAG_READONLY (1 << 6) -#define SPA_POD_PROP_FLAG_DEPRECATED (1 << 7) +#define SPA_POD_PROP_RANGE_NONE 0 /**< no range */ +#define SPA_POD_PROP_RANGE_MIN_MAX 1 /**< property has range */ +#define SPA_POD_PROP_RANGE_STEP 2 /**< property has range with step */ +#define SPA_POD_PROP_RANGE_ENUM 3 /**< property has enumeration */ +#define SPA_POD_PROP_RANGE_FLAGS 4 /**< property has flags */ +#define SPA_POD_PROP_RANGE_MASK 0xf /**< mask to select range type */ +#define SPA_POD_PROP_FLAG_UNSET (1 << 4) /**< property value is unset */ +#define SPA_POD_PROP_FLAG_OPTIONAL (1 << 5) /**< property value is optional */ +#define SPA_POD_PROP_FLAG_READONLY (1 << 6) /**< property is readonly */ +#define SPA_POD_PROP_FLAG_DEPRECATED (1 << 7) /**< property is deprecated */ +#define SPA_POD_PROP_FLAG_INFO (1 << 8) /**< property is informational and is not + * used when filtering */ uint32_t flags; struct spa_pod value; /* array with elements of value.size follows,