summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-09 14:57:10 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-11 15:19:25 -0700
commita4d52bcd363ee185ff20c74b3c97de96e314d381 (patch)
tree0c34191ca0b31f885f733a8629ca7ab7b98a4106
parent974c464d4b2b12682d1a33a2e8ffe105bd78b519 (diff)
til_settings: make use of til_setting_desc_t.container
This commit pivots everything over to using desc->container as the target settings instance when adding settings, as well as actually assigning the settings container @ desc create. Given nothing is actually triggering settings heirarchies yet (no specs set as_nested_settings) this shouldn't actually result in any realized functional difference, yet. The settings pointer being placed in desc->container should be identical to what was getting used before.
-rw-r--r--src/setup.c6
-rw-r--r--src/til.c6
-rw-r--r--src/til_settings.c2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/setup.c b/src/setup.c
index 8f9c5c1..5d99178 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -100,7 +100,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
if (*buf == '\n') {
/* accept preferred */
- til_settings_add_value(settings, desc->spec.key, desc->spec.preferred, NULL);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred, NULL);
} else {
buf[strlen(buf) - 1] = '\0';
@@ -116,7 +116,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
for (found = i = 0; desc->spec.values[i]; i++) {
if (i == j) {
- til_settings_add_value(settings, desc->spec.key, desc->spec.values[i], NULL);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[i], NULL);
found = 1;
break;
}
@@ -131,7 +131,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
} else {
/* use typed input as setting, TODO: apply regex */
- til_settings_add_value(settings, desc->spec.key, buf, NULL);
+ til_settings_add_value(desc->container, desc->spec.key, buf, NULL);
}
}
_next:
diff --git a/src/til.c b/src/til.c
index e1b4907..f5c2e8f 100644
--- a/src/til.c
+++ b/src/til.c
@@ -337,7 +337,7 @@ int til_module_randomize_setup(const til_module_t *module, unsigned seed, til_se
char *value;
value = desc->spec.random(rand_r(&seed));
- til_settings_add_value(settings, desc->spec.key, value, desc);
+ til_settings_add_value(desc->container, desc->spec.key, value, desc);
free(value);
} else if (desc->spec.values) {
int n;
@@ -346,9 +346,9 @@ int til_module_randomize_setup(const til_module_t *module, unsigned seed, til_se
n = rand_r(&seed) % n;
- til_settings_add_value(settings, desc->spec.key, desc->spec.values[n], desc);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[n], desc);
} else {
- til_settings_add_value(settings, desc->spec.key, desc->spec.preferred, desc);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred, desc);
}
}
diff --git a/src/til_settings.c b/src/til_settings.c
index 4749372..4631849 100644
--- a/src/til_settings.c
+++ b/src/til_settings.c
@@ -363,6 +363,8 @@ int til_setting_desc_new(const til_settings_t *settings, const til_setting_spec_
if (!d)
return -ENOMEM;
+ /* XXX: intentionally casting away the const here, since the purpose of desc->container is to point where to actually put the setting for the front-end setup code */
+ d->container = (til_settings_t *)settings;
if (spec->name)
d->spec.name = strdup(spec->name);
© All Rights Reserved