Skip to content

Commit c6cc6a9

Browse files
author
Fabrice Bellard
committed
export JS_GetModuleNamespace (github issue bellard#34)
1 parent cd666a8 commit c6cc6a9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

quickjs.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27792,13 +27792,11 @@ static int exported_names_cmp(const void *p1, const void *p2, void *opaque)
2779227792
return ret;
2779327793
}
2779427794

27795-
static JSValue js_get_module_ns(JSContext *ctx, JSModuleDef *m);
27796-
2779727795
static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom atom,
2779827796
void *opaque)
2779927797
{
2780027798
JSModuleDef *m = opaque;
27801-
return js_get_module_ns(ctx, m);
27799+
return JS_GetModuleNamespace(ctx, m);
2780227800
}
2780327801

2780427802
static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m)
@@ -27904,7 +27902,7 @@ static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m)
2790427902
return JS_EXCEPTION;
2790527903
}
2790627904

27907-
static JSValue js_get_module_ns(JSContext *ctx, JSModuleDef *m)
27905+
JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m)
2790827906
{
2790927907
if (JS_IsUndefined(m->module_ns)) {
2791027908
JSValue val;
@@ -28165,7 +28163,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m,
2816528163
if (mi->import_name == JS_ATOM__star_) {
2816628164
JSValue val;
2816728165
/* name space import */
28168-
val = js_get_module_ns(ctx, m1);
28166+
val = JS_GetModuleNamespace(ctx, m1);
2816928167
if (JS_IsException(val))
2817028168
goto fail;
2817128169
set_value(ctx, &var_refs[mi->var_idx]->value, val);
@@ -28189,7 +28187,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m,
2818928187
JSModuleDef *m2;
2819028188
/* name space import from */
2819128189
m2 = res_m->req_module_entries[res_me->u.req_module_idx].module;
28192-
val = js_get_module_ns(ctx, m2);
28190+
val = JS_GetModuleNamespace(ctx, m2);
2819328191
if (JS_IsException(val))
2819428192
goto fail;
2819528193
var_ref = js_create_module_var(ctx, TRUE);
@@ -28397,7 +28395,7 @@ static JSValue js_load_module_fulfilled(JSContext *ctx, JSValueConst this_val,
2839728395
JSValue ret, ns;
2839828396

2839928397
/* return the module namespace */
28400-
ns = js_get_module_ns(ctx, m);
28398+
ns = JS_GetModuleNamespace(ctx, m);
2840128399
if (JS_IsException(ns)) {
2840228400
JSValue err = JS_GetException(ctx);
2840328401
js_load_module_rejected(ctx, JS_UNDEFINED, 1, (JSValueConst *)&err, 0, func_data);

quickjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ void JS_SetModuleLoaderFunc(JSRuntime *rt,
876876
/* return the import.meta object of a module */
877877
JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m);
878878
JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
879+
JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m);
879880

880881
/* JS Job support */
881882

0 commit comments

Comments
 (0)