return NJS_ERROR;
}
- engine->u.qjs.ctx = qjs_new_context(engine->u.qjs.rt, 1);
+ engine->u.qjs.ctx = qjs_new_context(engine->u.qjs.rt, NULL, 1);
if (engine->u.qjs.ctx == NULL) {
njs_stderror("JS_NewContext() failed\n");
return NJS_ERROR;
JSContext *
-qjs_new_context(JSRuntime *rt, _Bool eval)
+qjs_new_context(JSRuntime *rt, qjs_module_t **addons, _Bool eval)
{
JSValue global_obj;
JSContext *ctx;
}
}
+ if (addons != NULL) {
+ for (module = addons; *module != NULL; module++) {
+ if ((*module)->init(ctx, (*module)->name) == NULL) {
+ return NULL;
+ }
+ }
+ }
+
global_obj = JS_GetGlobalObject(ctx);
JS_SetPropertyFunctionList(ctx, global_obj, qjs_global_proto,
} qjs_module_t;
-JSContext *qjs_new_context(JSRuntime *rt, _Bool eval);
+JSContext *qjs_new_context(JSRuntime *rt, qjs_module_t **addons, _Bool eval);
JSValue qjs_buffer_alloc(JSContext *ctx, size_t size);