diff options
| author | 2022-09-06 15:57:16 +0800 | |
|---|---|---|
| committer | 2022-09-06 00:57:16 -0700 | |
| commit | b9fad14f87899816cf021b0a7eea8c0de84a5190 (patch) | |
| tree | 793c793d6e7432bbdbf9f7e1af6583af8d9ad1e4 /src/bun.js/bindings/ZigGlobalObject.cpp | |
| parent | 5a715210218715f71cba2053083ba9993ea82c7e (diff) | |
| download | bun-b9fad14f87899816cf021b0a7eea8c0de84a5190.tar.gz bun-b9fad14f87899816cf021b0a7eea8c0de84a5190.tar.zst bun-b9fad14f87899816cf021b0a7eea8c0de84a5190.zip | |
Add native ReadableState (#1210)
* use functionSpace for JSStringDecoderConstructor and fix console.log on prototype
* Add native ReadableState
* move kPaused to class property
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
| -rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 2753707e8..34c12161e 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -88,6 +88,7 @@ #include "JSCloseEvent.h" #include "JSFetchHeaders.h" #include "JSStringDecoder.h" +#include "JSReadableState.h" #include "Process.h" @@ -1070,9 +1071,8 @@ JSC: if (string == bunStreamString) { auto* obj = constructEmptyObject(globalObject); - auto* bufferList = JSC::JSFunction::create( - vm, globalObject, 0, "BufferList"_s, WebCore::constructJSBufferList, ImplementationVisibility::Public, NoIntrinsic, WebCore::constructJSBufferList); - obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "BufferList"_s)), bufferList, 0); + obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "BufferList"_s)), reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSBufferList(), 0); + obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "ReadableState"_s)), reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSReadableState(), 0); return JSValue::encode(obj); } @@ -1995,6 +1995,18 @@ void GlobalObject::finishCreation(VM& vm) init.setConstructor(constructor); }); + m_JSBufferListClassStructure.initLater( + [](LazyClassStructure::Initializer& init) { + auto* prototype = JSBufferListPrototype::create( + init.vm, init.global, JSBufferListPrototype::createStructure(init.vm, init.global, init.global->objectPrototype())); + auto* structure = JSBufferList::createStructure(init.vm, init.global, prototype); + auto* constructor = JSBufferListConstructor::create( + init.vm, init.global, JSBufferListConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), prototype); + init.setPrototype(prototype); + init.setStructure(structure); + init.setConstructor(constructor); + }); + m_JSStringDecoderClassStructure.initLater( [](LazyClassStructure::Initializer& init) { auto* prototype = JSStringDecoderPrototype::create( @@ -2007,6 +2019,18 @@ void GlobalObject::finishCreation(VM& vm) init.setConstructor(constructor); }); + m_JSReadableStateClassStructure.initLater( + [](LazyClassStructure::Initializer& init) { + auto* prototype = JSReadableStatePrototype::create( + init.vm, init.global, JSReadableStatePrototype::createStructure(init.vm, init.global, init.global->objectPrototype())); + auto* structure = JSReadableState::createStructure(init.vm, init.global, prototype); + auto* constructor = JSReadableStateConstructor::create( + init.vm, init.global, JSReadableStateConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), prototype); + init.setPrototype(prototype); + init.setStructure(structure); + init.setConstructor(constructor); + }); + m_JSFFIFunctionStructure.initLater( [](LazyClassStructure::Initializer& init) { init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->functionPrototype())); |
