diff options
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -2583,3 +2583,26 @@ uc_lib_init(uc_value_t *scope) { uc_add_proto_functions(scope, functions); } + +uc_value_t * +uc_alloc_global(uc_vm *vm) +{ + const char *path[] = { LIB_SEARCH_PATH }; + uc_value_t *global, *arr; + size_t i; + + global = ucv_object_new(vm); + + /* build default require() search path */ + arr = ucv_array_new(vm); + + for (i = 0; i < ARRAY_SIZE(path); i++) + ucv_array_push(arr, ucv_string_new(path[i])); + + ucv_object_add(global, "REQUIRE_SEARCH_PATH", arr); + + /* register global property */ + ucv_object_add(global, "global", ucv_get(global)); + + return global; +} |