From 2c6e5c3fc4a7255eb29f7ae618d2826dd9a7d5e5 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 25 Apr 2022 07:09:18 -0700 Subject: some of buffer --- src/javascript/jsc/bindings/ZigGlobalObject.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/javascript/jsc/bindings/ZigGlobalObject.cpp') diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index a2e4fc42a..8e522ab85 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -88,6 +88,8 @@ #include "JavaScriptCore/RemoteInspectorServer.h" +#include "JSBuffer.h" + using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; using JSValue = JSC::JSValue; @@ -99,6 +101,7 @@ using SourceOrigin = JSC::SourceOrigin; using JSObject = JSC::JSObject; using JSNonFinalObject = JSC::JSNonFinalObject; namespace JSCastingHelpers = JSC::JSCastingHelpers; +using JSBuffer = WebCore::JSBuffer; static bool has_loaded_jsc = false; @@ -325,6 +328,17 @@ void GlobalObject::setConsole(void* console) #pragma mark - Globals +JSC_DECLARE_CUSTOM_GETTER(JSBuffer_getter); + +JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter, + (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, + JSC::PropertyName)) +{ + Zig::GlobalObject* thisObject = JSC::jsCast(lexicalGlobalObject); + return JSC::JSValue::encode( + WebCore::JSBuffer::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject)); +} + JSC_DECLARE_CUSTOM_GETTER(JSDOMURL_getter); JSC_DEFINE_CUSTOM_GETTER(JSDOMURL_getter, @@ -874,6 +888,9 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ErrorEvent"_s), JSC::CustomGetterSetter::create(vm, JSErrorEvent_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr), + JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + extraStaticGlobals.releaseBuffer(); this->setRemoteDebuggingEnabled(true); -- cgit v1.2.3