aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-27 23:44:21 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-27 23:44:21 -0700
commit8bbcb5006ebf77a7944472eb2e4a0604f7bbc733 (patch)
tree3ba1c79e181a28ecc26e69e8684e55001df98968
parent4f4c446bc4c2c9bf9c9597275f54c2955cfb76d8 (diff)
downloadbun-8bbcb5006ebf77a7944472eb2e4a0604f7bbc733.tar.gz
bun-8bbcb5006ebf77a7944472eb2e4a0604f7bbc733.tar.zst
bun-8bbcb5006ebf77a7944472eb2e4a0604f7bbc733.zip
[Bun.js] Add `DOMException`
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index c62457c32..5550b7de9 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -79,6 +79,7 @@
#include "JSDOMURL.h"
#include "JSURLSearchParams.h"
+#include "JSDOMException.h"
#include "Process.h"
@@ -321,6 +322,17 @@ JSC_DEFINE_CUSTOM_GETTER(JSURLSearchParams_getter,
WebCore::JSURLSearchParams::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
}
+JSC_DECLARE_CUSTOM_GETTER(JSDOMException_getter);
+
+JSC_DEFINE_CUSTOM_GETTER(JSDOMException_getter,
+ (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName))
+{
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
+ return JSC::JSValue::encode(
+ WebCore::JSDOMException::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
+}
+
static JSC_DECLARE_CUSTOM_SETTER(property_lazyProcessSetter);
static JSC_DECLARE_CUSTOM_GETTER(property_lazyProcessGetter);
@@ -725,21 +737,20 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
"reportError", functionReportError),
JSC::PropertyAttribute::DontDelete | 0 });
- JSC::Identifier URLConstructor = JSC::Identifier::fromString(vm, "URL"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { reportErrorIdentifier,
- JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
- "reportError", functionReportError),
- JSC::PropertyAttribute::DontDelete | 0 });
-
this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter),
+ JSC::PropertyAttribute::CustomAccessor | 0);
+
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URL"), JSC::CustomGetterSetter::create(vm, JSDOMURL_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URLSearchParams"), JSC::CustomGetterSetter::create(vm, JSURLSearchParams_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "DOMException"), JSC::CustomGetterSetter::create(vm, JSDOMException_getter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+
extraStaticGlobals.releaseBuffer();
}