Skip to content

Commit b3e8ed0

Browse files
committed
chore(engine): formatting and lint fixes
Signed-off-by: Dario Valdespino <[email protected]>
1 parent 18e42d0 commit b3e8ed0

File tree

10 files changed

+123
-14
lines changed

10 files changed

+123
-14
lines changed

packages/engine/src/main/kotlin/elide/runtime/plugins/AbstractLanguagePlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Elide Technologies, Inc.
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
33
*
44
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
55
* with the License. You may obtain a copy of the License at

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/ArrayBufferViews.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js
214

315
import org.graalvm.polyglot.Context

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableByteStream.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import org.graalvm.polyglot.Value
@@ -304,15 +316,15 @@ internal class ReadableByteStream(
304316

305317
/** Called whenever the [queueSize] decreases, e.g. allowing the stream to consider whether pulling is needed. */
306318
private fun handleDrain() {
307-
if (queueSize.get() == 0L && sourceState.get() == SOURCE_CLOSING) finalize()
319+
if (queueSize.get() == 0L && sourceState.get() == SOURCE_CLOSING) cleanup()
308320
else maybePull()
309321
}
310322

311323
/**
312324
* Finalize this stream, setting its state to "closed", and releasing the locked [reader]. Pending descriptors in
313325
* the [pullQueue] will be discarded, and pending reads in the [readQueue] will be completed with a `null` value.
314326
*/
315-
private fun finalize() {
327+
private fun cleanup() {
316328
queueLock.withLock {
317329
while (pullQueue.isNotEmpty()) {
318330
val head = pullQueue.poll()
@@ -363,6 +375,7 @@ internal class ReadableByteStream(
363375
* This method is meant to be used by the [RequestDelegate] implementation to notify the stream about a response
364376
* from the source.
365377
*/
378+
@Suppress("ThrowsCount")
366379
private fun respondWithView(view: Value) {
367380
queueLock.withLock {
368381
val head = checkNotNull(pullQueue.peek())
@@ -471,6 +484,7 @@ internal class ReadableByteStream(
471484
* Read at least [min] bytes into the given [view], drawing from buffered chunks in the stream's queue, or enqueueing
472485
* the read internally if not enough data is available.
473486
*/
487+
@Suppress("ReturnCount")
474488
internal fun readOrEnqueue(view: Value, min: Long): JsPromise<ReadResult> {
475489
val state = streamState.get()
476490

@@ -662,7 +676,7 @@ internal class ReadableByteStream(
662676
throw TypeError.create("Failed to close: stream is not readable")
663677

664678
// only fully close if there are no undelivered chunks
665-
if (queueSize.get() == 0L) finalize()
679+
if (queueSize.get() == 0L) cleanup()
666680
}
667681

668682
override fun release() {

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableDefaultStream.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import com.google.common.util.concurrent.AtomicDouble
@@ -65,7 +77,7 @@ internal class ReadableDefaultStream(
6577
}
6678

6779
/** Finalize this stream, setting its state to "closed", and releasing the locked [reader]. */
68-
private fun finalize() {
80+
private fun cleanup() {
6981
streamState.set(STREAM_CLOSED)
7082
lockedReader.getAndSet(null)?.close()
7183
}
@@ -87,7 +99,7 @@ internal class ReadableDefaultStream(
8799
// resolve directly using a cached chunk, this may finish closing the stream, so other pending
88100
// reads will be aborted, and new reads will fail
89101
if (chunkQueue.isEmpty() && sourceState.compareAndSet(SOURCE_CLOSING, SOURCE_CLOSED)) {
90-
finalize()
102+
cleanup()
91103
}
92104

93105
queueSize.addAndGet(-cached.size)
@@ -147,7 +159,7 @@ internal class ReadableDefaultStream(
147159
throw TypeError.create("Failed to close: stream is not readable")
148160

149161
// only fully close if there are no undelivered chunks
150-
if (chunkQueue.isEmpty()) finalize()
162+
if (chunkQueue.isEmpty()) cleanup()
151163
}
152164

153165
override fun release() {

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamBase.kt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import org.graalvm.polyglot.Value
@@ -57,13 +69,12 @@ internal abstract class ReadableStreamBase : ReadableStream {
5769
* should always call this method exactly once immediately after construction.
5870
*/
5971
protected fun setupSource(source: ReadableStreamSource, controller: ReadableStreamController) {
60-
try {
61-
source.start(controller)
62-
sourceState.compareAndSet(SOURCE_UNINITIALIZED, SOURCE_READY)
63-
maybePull()
64-
} catch (reason: Throwable) {
65-
error(reason)
66-
}
72+
runCatching { source.start(controller) }
73+
.onFailure(::error)
74+
.onSuccess {
75+
sourceState.compareAndSet(SOURCE_UNINITIALIZED, SOURCE_READY)
76+
maybePull()
77+
}
6778
}
6879

6980
/** Whether the stream should pull from the underlying source, given its current state and the size of the queue. */

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamByobReaderToken.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import org.graalvm.polyglot.Value

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamByteControllerToken.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import org.graalvm.polyglot.Value

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamDefaultControllerToken.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import org.graalvm.polyglot.Value

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamDefaultReaderToken.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
import elide.runtime.intrinsics.js.JsPromise

packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/js/webstreams/ReadableStreamReaderTokenBase.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2024-2025 Elide Technologies, Inc.
3+
*
4+
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
*
7+
* https://opensource.org/license/mit/
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
* License for the specific language governing permissions and limitations under the License.
12+
*/
113
package elide.runtime.gvm.internals.intrinsics.js.webstreams
214

315
/**

0 commit comments

Comments
 (0)