diff options
author | 2022-06-22 23:21:48 -0700 | |
---|---|---|
committer | 2022-06-22 23:21:48 -0700 | |
commit | 729d445b6885f69dd2c6355f38707bd42851c791 (patch) | |
tree | f87a7c408929ea3f57bbb7ace380cf869da83c0e /src/bun.js/bindings/BunStream.h | |
parent | 25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff) | |
download | bun-729d445b6885f69dd2c6355f38707bd42851c791.tar.gz bun-729d445b6885f69dd2c6355f38707bd42851c791.tar.zst bun-729d445b6885f69dd2c6355f38707bd42851c791.zip |
change the directory structurejarred/rename
Diffstat (limited to 'src/bun.js/bindings/BunStream.h')
-rw-r--r-- | src/bun.js/bindings/BunStream.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/bun.js/bindings/BunStream.h b/src/bun.js/bindings/BunStream.h new file mode 100644 index 000000000..64837c219 --- /dev/null +++ b/src/bun.js/bindings/BunStream.h @@ -0,0 +1,89 @@ +#pragma once + +#include "BunBuiltinNames.h" +#include "BunClientData.h" +#include "root.h" + +namespace WebCore { + +using namespace JSC; + +class Readable : public JSC::JSNonFinalObject { + using Base = JSC::JSNonFinalObject; + +public: + Bun__Readable* state; + Readable(JSC::VM& vm, Bun__Readable* readable, JSC::Structure* structure) + : Base(vm, structure) + { + state = readable; + } + + ~Readable(); + + DECLARE_INFO; + + static constexpr unsigned StructureFlags = Base::StructureFlags; + + template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(VM& vm) + { + return &vm.plainObjectSpace(); + } + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, + JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, + JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + static Readable* create(JSC::VM& vm, Bun__Readable* state, JSC::Structure* structure) + { + Readable* accessor = new (NotNull, JSC::allocateCell<WebCore::Readable>(vm)) Readable(vm, state, structure); + accessor->finishCreation(vm); + return accessor; + } + + void finishCreation(JSC::VM& vm); +}; + +class Writable : public JSC::JSNonFinalObject { + using Base = JSC::JSNonFinalObject; + +public: + Bun__Writable* state; + Writable(JSC::VM& vm, Bun__Writable* writable, JSC::Structure* structure) + : Base(vm, structure) + { + state = writable; + } + + DECLARE_INFO; + + static constexpr unsigned StructureFlags = Base::StructureFlags; + + template<typename CellType, SubspaceAccess> static GCClient::IsoSubspace* subspaceFor(VM& vm) + { + return &vm.plainObjectSpace(); + } + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, + JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, + JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + + static Writable* create(JSC::VM& vm, Bun__Writable* state, JSC::Structure* structure) + { + + Writable* accessor = new (NotNull, JSC::allocateCell<Writable>(vm)) Writable(vm, state, structure); + accessor->finishCreation(vm); + return accessor; + } + ~Writable(); + + void finishCreation(JSC::VM& vm); +}; + +} // namespace WebCore
\ No newline at end of file |