From 1a89d30e76d2bdb8268c17073d8a780b5adf3049 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 26 May 2023 18:11:58 -0700 Subject: til_settings: add til_setting_spec_t.as_label Currently settings instances get labels from three sources: 1. explicitly labeled by a root-level til_settings_new() call, like main.c::til_settings_new(NULL, "video", args->video); 2. implicitly labeled in a spec.as_nested_settings w/spec.key 3. positionally labeled in a spec.as_nested_settings w/o spec.key But when constructing setting/desc paths, using strictly these settings instance labels as the "directory name path component" equivalent, leaves something to be desired. Take this hypothetical module setting path for example: /module/layers/[0]/viscosity Strictly using settings instance labels as-is, the above is what you'd get for the drizzle::viscosity setting in something like: --module=compose,layers=drizzle Which is really awkward. What's really desired is more like: /module/compose/layers/[0]/drizzle/viscosity Now one way to achieve that is to just create more settings instances to hold these module names as labels and things would Just Work more or less. But that would be rather annoying and heavyweight, when what's _really_ wanted is a way to turn the first entry's value of a given setting instance into a sort of synthetic directory component in the path. So that's what this commit does. When a spec has .as_label specified, it's saying that path construction should treat this setting's value as if it were a label on a settings instance. But it's special cased to only apply to descs hanging off the first entry of a settings instance, as that's the only scenario we're making use of, and it avoids having to do crazy things like search all the entries for specs w/.as_label set. It feels a bit janky but it does achieve what's needed with little pain/churn. --- src/modules/compose/compose.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/modules/compose') diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 3e9ab2c..19f5867 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -375,6 +375,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set &(til_setting_spec_t){ .name = "Layer module name", .preferred = "none", + .as_label = 1, }, res_desc); if (r < 0) return r; @@ -402,6 +403,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set .annotations = NULL, .values = texture_values, .as_nested_settings = 1, + .as_label = 1, }, &texture, res_setting, @@ -421,6 +423,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set /* this is basically just to get the .as_label */ .name = "Texture module name", .preferred = "none", + .as_label = 1, }, res_desc); if (r < 0) -- cgit v1.2.3