Skip to content

Commit

Permalink
NJS: loader should be registered using njs_vm_set_module_loader()
Browse files Browse the repository at this point in the history
This change was introduced in NJS 0.8.3 here:
<https://hg.nginx.com/njs/rev/ad1a7ad3c715>
  • Loading branch information
andrey-zelenkov committed Feb 19, 2024
1 parent 1dca860 commit 5c00593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
16 changes: 6 additions & 10 deletions src/nxt_js.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ nxt_js_module_loader(njs_vm_t *vm, njs_external_ptr_t external, njs_str_t *name)
}


static njs_vm_ops_t nxt_js_ops = {
NULL,
NULL,
nxt_js_module_loader,
NULL,
};


njs_int_t nxt_js_proto_id;


Expand Down Expand Up @@ -127,6 +119,7 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)
{
u_char *p;
size_t size;
njs_vm_t *vm;
nxt_uint_t i;
njs_vm_opt_t opts;
nxt_js_module_t *module, *mod;
Expand All @@ -146,7 +139,6 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)
goto done;
}

opts.ops = &nxt_js_ops;
opts.external = jcf;

size = 0;
Expand Down Expand Up @@ -203,7 +195,11 @@ nxt_js_vm_create(nxt_js_conf_t *jcf)

done:

return njs_vm_create(&opts);
vm = njs_vm_create(&opts);

njs_vm_set_module_loader(vm, nxt_js_module_loader, jcf);

return vm;
}


Expand Down
10 changes: 0 additions & 10 deletions src/nxt_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ static void nxt_script_buf_completion(nxt_task_t *task, void *obj, void *data);
static nxt_lvlhsh_t nxt_script_info;


static njs_vm_ops_t nxt_js_ops = {
NULL,
NULL,
nxt_js_module_loader,
NULL,
};


nxt_script_t *
nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size,
u_char *error)
Expand All @@ -63,8 +55,6 @@ nxt_script_new(nxt_task_t *task, nxt_str_t *name, u_char *data, size_t size,
opts.file.start = (u_char *) "default";
opts.file.length = 7;

opts.ops = &nxt_js_ops;

vm = njs_vm_create(&opts);
if (nxt_slow_path(vm == NULL)) {
return NULL;
Expand Down

0 comments on commit 5c00593

Please sign in to comment.