diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-21 10:49:23 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-07-30 00:41:56 +0200 |
commit | 3c168b5184ebd217ea276bf374d28bbf937681fd (patch) | |
tree | 00da23f6c0500518c4bebc73e9b85566ef75f052 /include | |
parent | d85bc716df9b97ac6093afa0bdf77c1b6b0cf6aa (diff) |
vm, cli: move search path into global configuration structure
The upcoming compile-time module support will require the configured
extension search path in the compiler as well, so move it to the
already shared uc_parse_config_t structure and add the appropriate
utility functions to initialize, append and free the search path
vector.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/types.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index b810744..c32829f 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -217,13 +217,33 @@ typedef struct uc_program { /* Parser definitions */ +uc_declare_vector(uc_search_path_t, char *); + typedef struct { bool lstrip_blocks; bool trim_blocks; bool strict_declarations; bool raw_mode; + uc_search_path_t module_search_path; } uc_parse_config_t; +extern uc_parse_config_t uc_default_parse_config; + +void uc_search_path_init(uc_search_path_t *search_path); + +static inline void +uc_search_path_add(uc_search_path_t *search_path, char *path) { + uc_vector_push(search_path, xstrdup(path)); +} + +static inline void +uc_search_path_free(uc_search_path_t *search_path) { + while (search_path->count > 0) + free(search_path->entries[--search_path->count]); + + uc_vector_clear(search_path); +} + /* VM definitions */ |