summaryrefslogtreecommitdiffstats
path: root/js/src/shell/ShellModuleObjectWrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/shell/ShellModuleObjectWrapper.cpp')
-rw-r--r--js/src/shell/ShellModuleObjectWrapper.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/js/src/shell/ShellModuleObjectWrapper.cpp b/js/src/shell/ShellModuleObjectWrapper.cpp
index 4e8c234e61..7a047ebaf4 100644
--- a/js/src/shell/ShellModuleObjectWrapper.cpp
+++ b/js/src/shell/ShellModuleObjectWrapper.cpp
@@ -85,6 +85,7 @@ using mozilla::Span;
DEFINE_NATIVE_CLASS_IMPL(CLASS)
DEFINE_CLASS(ModuleRequestObject)
+DEFINE_NATIVE_CLASS(ImportAttribute)
DEFINE_NATIVE_CLASS(ImportEntry)
DEFINE_NATIVE_CLASS(ExportEntry)
DEFINE_NATIVE_CLASS(RequestedModule)
@@ -281,6 +282,17 @@ bool SpanToArrayFilter(JSContext* cx, JS::Handle<JSObject*> owner,
return true;
}
+template <class T>
+bool SpanToNullableArrayFilter(JSContext* cx, JS::Handle<JSObject*> owner,
+ Span<const typename T::Target> from,
+ JS::MutableHandle<JS::Value> to) {
+ if (from.Length() == 0) {
+ to.setNull();
+ return true;
+ }
+ return SpanToArrayFilter<T>(cx, owner, from, to);
+}
+
template <class T, typename RawGetterT, typename FilterT>
bool ShellModuleNativeWrapperGetter(JSContext* cx, const JS::CallArgs& args,
RawGetterT rawGetter, FilterT filter) {
@@ -313,14 +325,22 @@ bool ShellModuleNativeWrapperGetter(JSContext* cx, const JS::CallArgs& args,
cx, args); \
}
+DEFINE_GETTER_FUNCTIONS(ImportAttribute, key, StringOrNullValue, IdentFilter);
+DEFINE_GETTER_FUNCTIONS(ImportAttribute, value, StringOrNullValue, IdentFilter);
+
+static const JSPropertySpec ShellImportAttributeWrapper_accessors[] = {
+ JS_PSG("key", ShellImportAttributeWrapper_keyGetter, 0),
+ JS_PSG("value", ShellImportAttributeWrapper_valueGetter, 0), JS_PS_END};
+
DEFINE_GETTER_FUNCTIONS(ModuleRequestObject, specifier, StringOrNullValue,
IdentFilter)
-DEFINE_GETTER_FUNCTIONS(ModuleRequestObject, attributes, ObjectOrNullValue,
- IdentFilter)
+DEFINE_NATIVE_GETTER_FUNCTIONS(
+ ModuleRequestObject, attributes,
+ SpanToNullableArrayFilter<ShellImportAttributeWrapper>);
static const JSPropertySpec ShellModuleRequestObjectWrapper_accessors[] = {
JS_PSG("specifier", ShellModuleRequestObjectWrapper_specifierGetter, 0),
- JS_PSG("assertions", ShellModuleRequestObjectWrapper_attributesGetter, 0),
+ JS_PSG("attributes", ShellModuleRequestObjectWrapper_attributesGetter, 0),
JS_PS_END};
DEFINE_GETTER_FUNCTIONS(ImportEntry, moduleRequest, ObjectOrNullValue,
@@ -469,6 +489,8 @@ static const JSPropertySpec ShellModuleObjectWrapper_accessors[] = {
DEFINE_CREATE(ModuleRequestObject, ShellModuleRequestObjectWrapper_accessors,
nullptr)
+DEFINE_NATIVE_CREATE(ImportAttribute, ShellImportAttributeWrapper_accessors,
+ nullptr)
DEFINE_NATIVE_CREATE(ImportEntry, ShellImportEntryWrapper_accessors, nullptr)
DEFINE_NATIVE_CREATE(ExportEntry, ShellExportEntryWrapper_accessors, nullptr)
DEFINE_NATIVE_CREATE(RequestedModule, ShellRequestedModuleWrapper_accessors,