diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-02 22:22:45 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-02 22:28:56 +0200 |
commit | 26f152e73eb02c6afdb98e6f7228d0a30ee973f3 (patch) | |
tree | e4737757d02f16d02355ab1b5b690bc737c2b17a /eval.c | |
parent | 2bce10151bace89d6ed38475da816f469b73418d (diff) |
eval, lib: add loadable module infrastructure
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -1333,6 +1333,29 @@ ut_execute_op_sequence(struct ut_state *state, struct ut_opcode *op) return v; } +static void +ut_globals_init(struct ut_state *state, struct json_object *scope) +{ + struct json_object *arr = json_object_new_array(); + const char *p, *last; + + if (!arr) + return; + + for (p = last = LIB_SEARCH_PATH;; p++) { + if (*p == ':' || *p == '\0') { + json_object_array_add(arr, json_object_new_string_len(last, p - last)); + + if (!*p) + break; + + last = p + 1; + } + } + + json_object_object_add(scope, "REQUIRE_SEARCH_PATH", arr); +} + enum ut_error_type ut_run(struct ut_state *state) { @@ -1351,6 +1374,7 @@ ut_run(struct ut_state *state) state->ctx = scope; + ut_globals_init(state, scope); ut_lib_init(state, scope); args = json_object_new_array(); |