about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2024-01-27 13:27:32 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 18:12:23 +0100
commitc7d33e636e716b62c2342d1ead88880b5a5586ae (patch)
treefbb37c94e4ceb8b4a46cbf23dc34b445a71ede32
parenta8ca2d984e81e5d4d887d11565c4c1ff10962494 (diff)
downloadchawan-c7d33e636e716b62c2342d1ead88880b5a5586ae.tar.gz
export JS_GetModuleNamespace (github issue #34)
-rw-r--r--lib/quickjs/quickjs.c12
-rw-r--r--lib/quickjs/quickjs.h1
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 947bb2b5..d3c1ca37 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -27900,13 +27900,11 @@ static int exported_names_cmp(const void *p1, const void *p2, void *opaque)
     return ret;
 }
 
-static JSValue js_get_module_ns(JSContext *ctx, JSModuleDef *m);
-
 static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom atom,
                                      void *opaque)
 {
     JSModuleDef *m = opaque;
-    return js_get_module_ns(ctx, m);
+    return JS_GetModuleNamespace(ctx, m);
 }
 
 static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m)
@@ -28012,7 +28010,7 @@ static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m)
     return JS_EXCEPTION;
 }
 
-static JSValue js_get_module_ns(JSContext *ctx, JSModuleDef *m)
+JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m)
 {
     if (JS_IsUndefined(m->module_ns)) {
         JSValue val;
@@ -28273,7 +28271,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m,
             if (mi->import_name == JS_ATOM__star_) {
                 JSValue val;
                 /* name space import */
-                val = js_get_module_ns(ctx, m1);
+                val = JS_GetModuleNamespace(ctx, m1);
                 if (JS_IsException(val))
                     goto fail;
                 set_value(ctx, &var_refs[mi->var_idx]->value, val);
@@ -28297,7 +28295,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m,
                     JSModuleDef *m2;
                     /* name space import from */
                     m2 = res_m->req_module_entries[res_me->u.req_module_idx].module;
-                    val = js_get_module_ns(ctx, m2);
+                    val = JS_GetModuleNamespace(ctx, m2);
                     if (JS_IsException(val))
                         goto fail;
                     var_ref = js_create_module_var(ctx, TRUE);
@@ -28505,7 +28503,7 @@ static JSValue js_load_module_fulfilled(JSContext *ctx, JSValueConst this_val,
     JSValue ret, ns;
     
     /* return the module namespace */
-    ns = js_get_module_ns(ctx, m);
+    ns = JS_GetModuleNamespace(ctx, m);
     if (JS_IsException(ns)) {
         JSValue err = JS_GetException(ctx);
         js_load_module_rejected(ctx, JS_UNDEFINED, 1, (JSValueConst *)&err, 0, func_data);
diff --git a/lib/quickjs/quickjs.h b/lib/quickjs/quickjs.h
index 073f45b9..64df355f 100644
--- a/lib/quickjs/quickjs.h
+++ b/lib/quickjs/quickjs.h
@@ -884,6 +884,7 @@ void JS_SetModuleLoaderFunc(JSRuntime *rt,
 /* return the import.meta object of a module */
 JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m);
 JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
+JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m);
 
 /* JS Job support */