Skip to content

Commit 36e1b16

Browse files
Jake ChampionJakeChampion
authored andcommitted
refactor TransformStreamDefaultController to extend from BuiltinImpl class
1 parent db04d45 commit 36e1b16

File tree

5 files changed

+188
-141
lines changed

5 files changed

+188
-141
lines changed

c-dependencies/js-compute-runtime/builtins/compression-stream.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ bool deflate_chunk(JSContext *cx, JS::HandleObject self, JS::HandleValue chunk,
103103
zstream->next_in = nullptr;
104104
}
105105

106-
JS::RootedObject controller(cx, TransformStream::controller(transform(self)));
106+
JS::RootedObject controller(cx, builtins::TransformStream::controller(transform(self)));
107107

108108
// Steps 3-5 of transform are identical to steps 2-4 of flush, so numbers
109109
// below refer to the former for those. Also, the compression happens in
@@ -195,13 +195,13 @@ bool flushAlgorithm(JSContext *cx, unsigned argc, JS::Value *vp) {
195195

196196
bool readable_get(JSContext *cx, unsigned argc, JS::Value *vp) {
197197
METHOD_HEADER_WITH_NAME(0, "get readable")
198-
args.rval().setObject(*TransformStream::readable(transform(self)));
198+
args.rval().setObject(*builtins::TransformStream::readable(transform(self)));
199199
return true;
200200
}
201201

202202
bool writable_get(JSContext *cx, unsigned argc, JS::Value *vp) {
203203
METHOD_HEADER_WITH_NAME(0, "get writable")
204-
args.rval().setObject(*TransformStream::writable(transform(self)));
204+
args.rval().setObject(*builtins::TransformStream::writable(transform(self)));
205205
return true;
206206
}
207207

@@ -238,13 +238,14 @@ JSObject *create(JSContext *cx, JS::HandleObject stream, Format format) {
238238
// 6. [Set up](https://streams.spec.whatwg.org/#transformstream-set-up)
239239
// this's transform with _transformAlgorithm_ set to _transformAlgorithm_ and
240240
// _flushAlgorithm_ set to _flushAlgorithm_.
241-
JS::RootedObject transform(cx, TransformStream::create(cx, 1, nullptr, 0, nullptr, stream_val,
242-
nullptr, transformAlgo, flushAlgo));
241+
JS::RootedObject transform(cx, builtins::TransformStream::create(cx, 1, nullptr, 0, nullptr,
242+
stream_val, nullptr,
243+
transformAlgo, flushAlgo));
243244
if (!transform) {
244245
return nullptr;
245246
}
246247

247-
TransformStream::set_used_as_mixin(transform);
248+
builtins::TransformStream::set_used_as_mixin(transform);
248249
JS::SetReservedSlot(stream, Slots::Transform, JS::ObjectValue(*transform));
249250

250251
// The remainder of the function deals with setting up the deflate state used

c-dependencies/js-compute-runtime/builtins/decompression-stream.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool inflate_chunk(JSContext *cx, JS::HandleObject self, JS::HandleValue chunk,
105105
zstream->next_in = nullptr;
106106
}
107107

108-
JS::RootedObject controller(cx, TransformStream::controller(transform(self)));
108+
JS::RootedObject controller(cx, builtins::TransformStream::controller(transform(self)));
109109

110110
// Steps 3-5 of transform are identical to steps 3-5 of flush, so numbers
111111
// below refer to the former for those. Also, the compression happens in
@@ -198,13 +198,13 @@ bool flushAlgorithm(JSContext *cx, unsigned argc, JS::Value *vp) {
198198

199199
bool readable_get(JSContext *cx, unsigned argc, JS::Value *vp) {
200200
METHOD_HEADER_WITH_NAME(0, "get readable")
201-
args.rval().setObject(*TransformStream::readable(transform(self)));
201+
args.rval().setObject(*builtins::TransformStream::readable(transform(self)));
202202
return true;
203203
}
204204

205205
bool writable_get(JSContext *cx, unsigned argc, JS::Value *vp) {
206206
METHOD_HEADER_WITH_NAME(0, "get writable")
207-
args.rval().setObject(*TransformStream::writable(transform(self)));
207+
args.rval().setObject(*builtins::TransformStream::writable(transform(self)));
208208
return true;
209209
}
210210

@@ -241,13 +241,14 @@ JSObject *create(JSContext *cx, JS::HandleObject stream, Format format) {
241241
// 6. [Set up](https://streams.spec.whatwg.org/#transformstream-set-up)
242242
// this's transform with _transformAlgorithm_ set to _transformAlgorithm_ and
243243
// _flushAlgorithm_ set to _flushAlgorithm_.
244-
JS::RootedObject transform(cx, TransformStream::create(cx, 1, nullptr, 0, nullptr, stream_val,
245-
nullptr, transformAlgo, flushAlgo));
244+
JS::RootedObject transform(cx, builtins::TransformStream::create(cx, 1, nullptr, 0, nullptr,
245+
stream_val, nullptr,
246+
transformAlgo, flushAlgo));
246247
if (!transform) {
247248
return nullptr;
248249
}
249250

250-
TransformStream::set_used_as_mixin(transform);
251+
builtins::TransformStream::set_used_as_mixin(transform);
251252
JS::SetReservedSlot(stream, Slots::Transform, JS::ObjectValue(*transform));
252253

253254
// The remainder of the function deals with setting up the inflate state used

0 commit comments

Comments
 (0)