diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-07-05 10:52:05 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-05 10:58:12 -0700 |
commit | 02cb290db43a2c6761083328d408dca63ed3d3b6 (patch) | |
tree | a420eede4e2ef5a2666a3d9e26af2800db6b0bbb /src/modules | |
parent | 5191d68bb76129cb2a95c62ea18d2ef9ae6605f2 (diff) |
modules/rkt: resolve module_name->til_module_t in setup
With the "ref" builtin module established and seeming to work
well enough, it looks unlikely we'll need access to unresolvable
module names in the contexts.
The thinking originally was that these names might have special
syntax making them more generic. E.g something like
"@/module/rkt/scenes/[1]/drizzle" for a module_name would have
been supported, which would get resolved either at context create
or even later (as in the ref builtin) at render time.
But the ref builtin is using a path setting, so module names just
stay module names.
Maybe in the future a special syntax will be added for brevity
reasons, but it does make the code more complicated vs. module
names just being names and resolving them entirely at setup time.
Anyhow, this commit does away with the module_name in the
context's scenes. You can still access it via
til_module_context_t.module.name anyways... it's basically just a
resolution-of-name-to-context time constraint that's being
codified now.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/rkt/rkt.c | 27 | ||||
-rw-r--r-- | src/modules/rkt/rkt.h | 5 |
2 files changed, 8 insertions, 24 deletions
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index 6d0a8bf..ee7ac0e 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -225,13 +225,9 @@ static til_module_context_t * rkt_create_context(const til_module_t *module, til til_stream_set_hooks(stream, &rkt_stream_hooks, ctxt); for (size_t i = 0; i < ctxt->n_scenes; i++) { - int r; + int r; - ctxt->scenes[i].module = til_lookup_module(s->scenes[i].module_name); - if (!ctxt->scenes[i].module) /* this isn't really expected since setup already does this */ - return til_module_context_free(&ctxt->til_module_context); - - r = til_module_create_context(ctxt->scenes[i].module, stream, rand_r(&seed), ticks, 0, s->scenes[i].setup, &ctxt->scenes[i].module_ctxt); + r = til_module_create_context(s->scenes[i].module, stream, rand_r(&seed), ticks, 0, s->scenes[i].setup, &ctxt->scenes[i].module_ctxt); if (r < 0) return til_module_context_free(&ctxt->til_module_context); } @@ -308,10 +304,9 @@ static void rkt_setup_free(til_setup_t *setup) rkt_setup_t *s = (rkt_setup_t *)setup; if (s) { - for (size_t i = 0; i < s->n_scenes; i++) { - free(s->scenes[i].module_name); + for (size_t i = 0; i < s->n_scenes; i++) til_setup_free(s->scenes[i].setup); - } + free((void *)s->base); free((void *)s->host); free(setup); @@ -514,24 +509,14 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting return -EINVAL; } - /* XXX If it's appropriate stow the resolved til_module_t* or the name is still unclear, since - * the module names will soon be able to address existing contexts in the stream at their path. - * So for now I'm just going to continue stowing the name, even though the lookup above prevents - * any sort of context address being used... - */ - setup->scenes[i].module_name = strdup(scene_module_name); - if (!setup->scenes[i].module_name) { - til_setup_free(&setup->til_setup); - - return -ENOMEM; - } - r = til_module_setup_finalize(scene_module, scene_setting->value_as_nested_settings, &setup->scenes[i].setup); if (r < 0) { til_setup_free(&setup->til_setup); return r; } + + setup->scenes[i].module = scene_module; } setup->base = strdup(base); diff --git a/src/modules/rkt/rkt.h b/src/modules/rkt/rkt.h index 861aa6b..2c41631 100644 --- a/src/modules/rkt/rkt.h +++ b/src/modules/rkt/rkt.h @@ -5,7 +5,6 @@ #include "til_module_context.h" typedef struct rkt_scene_t { - const til_module_t *module; til_module_context_t *module_ctxt; } rkt_scene_t; @@ -23,8 +22,8 @@ typedef struct rkt_context_t { } rkt_context_t; typedef struct rkt_setup_scene_t { - char *module_name; - til_setup_t *setup; + const til_module_t *module; + til_setup_t *setup; /* Baked setup as-configured via setup. */ } rkt_setup_scene_t; typedef struct rkt_setup_t { |