diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/checkers/checkers.c | 60 | ||||
-rw-r--r-- | src/modules/compose/compose.c | 29 | ||||
-rw-r--r-- | src/modules/mixer/mixer.c | 15 | ||||
-rw-r--r-- | src/modules/montage/montage.c | 16 | ||||
-rw-r--r-- | src/modules/rkt/rkt.c | 16 | ||||
-rw-r--r-- | src/modules/rtv/rtv.c | 11 |
6 files changed, 62 insertions, 85 deletions
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index 9ea89cf..5d76a88 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -448,7 +448,7 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se { const char *size; const char *pattern; - const char *fill_module; + const char *fill_module, *fill_module_name; const til_settings_t *fill_module_settings; til_setting_t *fill_module_setting; const char *dynamics; @@ -572,11 +572,9 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se assert((*res_setting)->value_as_nested_settings); fill_module_settings = (*res_setting)->value_as_nested_settings; - fill_module = til_settings_get_value_by_idx(fill_module_settings, 0, &fill_module_setting); - if (!fill_module) - return -EINVAL; + fill_module_name = til_settings_get_value_by_idx(fill_module_settings, 0, &fill_module_setting); - if (!fill_module_setting->desc) { + if (!fill_module_name || !fill_module_setting->desc) { r = til_setting_desc_new(fill_module_settings, &(til_setting_spec_t){ .name = "Filled cell module name", @@ -587,60 +585,26 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se if (r < 0) return r; - *res_setting = fill_module_setting; + *res_setting = fill_module_name ? fill_module_setting : NULL; return 1; } - if (strcasecmp(fill_module, "none")) { - const til_module_t *mod = til_lookup_module(fill_module); + if (strcasecmp(fill_module_name, "none")) { + const til_module_t *mod = til_lookup_module(fill_module_name); + + if (!mod) { + *res_setting = fill_module_setting; - if (!mod) return -EINVAL; + } if (mod->setup) { r = mod->setup(fill_module_settings, res_setting, res_desc, NULL); if (r) return r; - - /* XXX: note no res_setup was provided, so while yes the fill_module_settings are - * fully populated according to the setup's return value, we don't yet have the baked - * setup. That occurs below while baking the checkers res_setup. - */ } } - /* TODO: here we would do nested setup for fill_module via (*res_setting)->settings until that returned 0. - * It seems like we would just leave res_setup NULL for nested setup at this phase, then in our if (res_setup) - * branch down below the nested setup would have to recur with res_setup supplied but pointing at a nested - * setup pointer hosted within this setup. */ - - /* XXX but this is a little more complicated than simply performing exhaustive setup of the fill_module here. - * it's kind of like how in scripting languages you have two forms of interpolation while initializing variables; - * there's the immediate interpolation at the time of intialization, and there's the delayed interpolation at - * time of variable use. i.e. foo="$a $b" vs. foo:="$a $b", the latter may expand $a and $b once and store the - * result in foo, whereas the former may just store the literal "$a $b" in foo and (re)perform the expansion of - * $a and $b every time $foo is evaluated. - * - * should every module have its own separate setting or snowflake syntax to control exhaustive setup up-front - * vs. just taking what settings have been provided and randomizing what's not provided at context create time? - * in the case of checkers::fill_module it's arguably less relevant (though the current frontends don't have a - * randomize settings feature, so if exhaustive setup of fill_module were forced up-front using the existing frontends - * would mean loss of fill_module randomized setup) But that might be O.K. for something like checkers::fill_module - * - * where it becomes more relevant is something like rtv::channels, where the single rtv instance will repeatedly - * create+destroy channel contexts using the supplied (or omitted) settings. We may want to have the settings - * exhaustively applied once when rtv was intantiated, giving the frontend setup opportunity to explicitly configure - * the channels exhaustively. Or we may want to just partially specify some settings for the channels, and for - * the settings non-specified use the defaults OR for those unsepcified have them be randomized. Then there's the - * question of should the randomizing recur for every channel switch or just occur once at time of rtv instantiation? - * - * it feels like the module settings syntax should probably control this behavior in a general way so the modules don't - * start inventing their own approaches. Perhaps the module name at the start of the settings string could simply have - * an optional leading modifier character from a reserved set module names can't start with. Someting like %modulename - * for randomizing unspecified settings, : for evaluating settings just once up-front then reusing them, @modulename for - * accepting defaults for anything unspecified, and !modulename to fail if any settings aren't specified. Maybe also - * something like * for making the current qualifiers apply recursively. - */ r = til_settings_get_and_describe_value(settings, &(til_setting_spec_t){ @@ -758,8 +722,8 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se return -EINVAL; } - if (strcasecmp(fill_module, "none")) { - setup->fill_module = til_lookup_module(fill_module); + if (strcasecmp(fill_module_name, "none")) { + setup->fill_module = til_lookup_module(fill_module_name); if (!setup->fill_module) { til_setup_free(&setup->til_setup); return -EINVAL; diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index cf1c9b1..5a10113 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -314,13 +314,10 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set */ for (size_t i = 0; til_settings_get_value_by_idx(layers_settings, i, &layer_setting); i++) { til_setting_t *layer_module_setting; - const char *layer = til_settings_get_value_by_idx(layer_setting->value_as_nested_settings, 0, &layer_module_setting); - const til_module_t *layer_module = til_lookup_module(layer); - - if (!layer_module || !layer_module_setting) - return -EINVAL; + const char *layer_module_name = til_settings_get_value_by_idx(layer_setting->value_as_nested_settings, 0, &layer_module_setting); + const til_module_t *layer_module; - if (!layer_module_setting->desc) { + if (!layer_module_name || !layer_module_setting->desc) { r = til_setting_desc_new( layer_setting->value_as_nested_settings, &(til_setting_spec_t){ .name = "Layer module name", @@ -330,11 +327,18 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set if (r < 0) return r; - *res_setting = layer_module_setting; + *res_setting = layer_module_name ? layer_module_setting : NULL; return 1; } + layer_module = til_lookup_module(layer_module_name); + if (!layer_module) { + *res_setting = layer_module_setting; + + return -EINVAL; + } + if (layer_module->setup) { r = layer_module->setup(layer_setting->value_as_nested_settings, res_setting, res_desc, NULL); if (r) @@ -364,10 +368,8 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set assert(res_setting && *res_setting && (*res_setting)->value_as_nested_settings); texture_settings = (*res_setting)->value_as_nested_settings; texture = til_settings_get_value_by_idx(texture_settings, 0, &texture_module_setting); - if (!texture) - return -EINVAL; - if (!texture_module_setting->desc) { + if (!texture || !texture_module_setting->desc) { r = til_setting_desc_new(texture_settings, &(til_setting_spec_t){ /* this is basically just to get the .as_label */ @@ -379,7 +381,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set if (r < 0) return r; - *res_setting = texture_module_setting; + *res_setting = texture ? texture_module_setting : NULL; return 1; } @@ -387,8 +389,11 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set if (strcasecmp(texture, "none")) { const til_module_t *texture_module = til_lookup_module(texture); - if (!texture_module) + if (!texture_module) { + *res_setting = texture_module_setting; + return -EINVAL; + } if (texture_module->setup) { r = texture_module->setup(texture_settings, res_setting, res_desc, NULL); diff --git a/src/modules/mixer/mixer.c b/src/modules/mixer/mixer.c index 07f72a3..793df50 100644 --- a/src/modules/mixer/mixer.c +++ b/src/modules/mixer/mixer.c @@ -340,7 +340,6 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti .name = input_names[i], .key = input_keys[i], .preferred = input_preferred[i], - .annotations = NULL, .as_nested_settings = 1, }, &inputs[i], @@ -354,28 +353,28 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti inputs_settings[i] = (*res_setting)->value_as_nested_settings; inputs[i] = til_settings_get_value_by_idx(inputs_settings[i], 0, &inputs_module_setting[i]); - if (!inputs[i]) - return -EINVAL; - - if (!inputs_module_setting[i]->desc) { + if (!inputs[i] || !inputs_module_setting[i]->desc) { r = til_setting_desc_new(inputs_settings[i], &(til_setting_spec_t){ .name = input_module_name_names[i], - .preferred = "ref", + .preferred = input_preferred[i], .as_label = 1, }, res_desc); if (r < 0) return r; - *res_setting = inputs_module_setting[i]; + *res_setting = inputs[i] ? inputs_module_setting[i] : NULL; return 1; } mod = til_lookup_module(inputs[i]); - if (!mod) + if (!mod) { + *res_setting = inputs_module_setting[i]; + return -EINVAL; + } if (mod->setup) { r = mod->setup(inputs_settings[i], res_setting, res_desc, NULL); diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index c7c2eb0..8efeec1 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -270,12 +270,9 @@ static int montage_setup(const til_settings_t *settings, til_setting_t **res_set for (size_t i = 0; til_settings_get_value_by_idx(tiles_settings, i, &tile_setting); i++) { til_setting_t *tile_module_setting; const char *tile_module_name = til_settings_get_value_by_idx(tile_setting->value_as_nested_settings, 0, &tile_module_setting); - const til_module_t *tile_module = til_lookup_module(tile_module_name); - - if (!tile_module || !tile_module_setting) - return -EINVAL; + const til_module_t *tile_module; - if (!tile_module_setting->desc) { + if (!tile_module_name || !tile_module_setting->desc) { r = til_setting_desc_new( tile_setting->value_as_nested_settings, &(til_setting_spec_t){ .name = "Layer module name", @@ -285,11 +282,18 @@ static int montage_setup(const til_settings_t *settings, til_setting_t **res_set if (r < 0) return r; - *res_setting = tile_module_setting; + *res_setting = tile_module_name ? tile_module_setting : NULL; return 1; } + tile_module = til_lookup_module(tile_module_name); + if (!tile_module) { + *res_setting = tile_module_setting; + + return -EINVAL; + } + if (tile_module->setup) { r = tile_module->setup(tile_setting->value_as_nested_settings, res_setting, res_desc, NULL); if (r) diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index 3c97bc4..6d0a8bf 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -376,12 +376,9 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting for (size_t i = 0; til_settings_get_value_by_idx(scenes_settings, i, &scene_setting); i++) { til_setting_t *scene_module_setting; const char *scene_module_name = til_settings_get_value_by_idx(scene_setting->value_as_nested_settings, 0, &scene_module_setting); - const til_module_t *scene_module = til_lookup_module(scene_module_name); - - if (!scene_module || !scene_module_setting) - return -EINVAL; + const til_module_t *scene_module; - if (!scene_module_setting->desc) { + if (!scene_module_name || !scene_module_setting->desc) { r = til_setting_desc_new( scene_setting->value_as_nested_settings, &(til_setting_spec_t){ .name = "Scene module name", @@ -391,11 +388,18 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting if (r < 0) return r; - *res_setting = scene_module_setting; + *res_setting = scene_module_name ? scene_module_setting : NULL; return 1; } + scene_module = til_lookup_module(scene_module_name); + if (!scene_module) { + *res_setting = scene_module_setting; + + return -EINVAL; + } + if (scene_module->setup) { r = scene_module->setup(scene_setting->value_as_nested_settings, res_setting, res_desc, NULL); if (r) diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 12f5580..18a2a1a 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -463,10 +463,8 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting assert(res_setting && *res_setting && (*res_setting)->value_as_nested_settings); snow_module_settings = (*res_setting)->value_as_nested_settings; snow_module_name = til_settings_get_value_by_idx(snow_module_settings, 0, &snow_module_name_setting); - if (!snow_module_name) - return -EINVAL; - if (!snow_module_name_setting->desc) { + if (!snow_module_name || !snow_module_name_setting->desc) { r = til_setting_desc_new(snow_module_settings, &(til_setting_spec_t){ /* this is basically just to get the .as_label */ @@ -478,7 +476,7 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting if (r < 0) return r; - *res_setting = snow_module_name_setting; + *res_setting = snow_module_name ? snow_module_name_setting : NULL; return 1; } @@ -486,8 +484,11 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting if (strcasecmp(snow_module_name, "none")) { const til_module_t *snow_module = til_lookup_module(snow_module_name); - if (!snow_module) + if (!snow_module) { + *res_setting = snow_module_name_setting; + return -EINVAL; + } if (snow_module->setup) { r = snow_module->setup(snow_module_settings, res_setting, res_desc, NULL); |