Skip to content

Commit 2a081de

Browse files
Remove dead code and fix error message
1 parent 58f91c3 commit 2a081de

File tree

2 files changed

+3
-79
lines changed

2 files changed

+3
-79
lines changed

Diff for: Runtime/src/js-value.ts

-76
Original file line numberDiff line numberDiff line change
@@ -92,82 +92,6 @@ export const write = (
9292
memory.writeUint32(kind_ptr, kind);
9393
};
9494

95-
export function decompose(value: any, memory: Memory): {
96-
kind: JavaScriptValueKindAndFlags;
97-
payload1: number;
98-
payload2: number;
99-
} {
100-
if (value === null) {
101-
return {
102-
kind: Kind.Null,
103-
payload1: 0,
104-
payload2: 0,
105-
}
106-
}
107-
const type = typeof value;
108-
switch (type) {
109-
case "boolean": {
110-
return {
111-
kind: Kind.Boolean,
112-
payload1: value ? 1 : 0,
113-
payload2: 0,
114-
}
115-
}
116-
case "number": {
117-
return {
118-
kind: Kind.Number,
119-
payload1: 0,
120-
payload2: value,
121-
}
122-
}
123-
case "string": {
124-
return {
125-
kind: Kind.String,
126-
payload1: memory.retain(value),
127-
payload2: 0,
128-
}
129-
}
130-
case "undefined": {
131-
return {
132-
kind: Kind.Undefined,
133-
payload1: 0,
134-
payload2: 0,
135-
}
136-
}
137-
case "object": {
138-
return {
139-
kind: Kind.Object,
140-
payload1: memory.retain(value),
141-
payload2: 0,
142-
}
143-
}
144-
case "function": {
145-
return {
146-
kind: Kind.Function,
147-
payload1: memory.retain(value),
148-
payload2: 0,
149-
}
150-
}
151-
case "symbol": {
152-
return {
153-
kind: Kind.Symbol,
154-
payload1: memory.retain(value),
155-
payload2: 0,
156-
}
157-
}
158-
case "bigint": {
159-
return {
160-
kind: Kind.BigInt,
161-
payload1: memory.retain(value),
162-
payload2: 0,
163-
}
164-
}
165-
default:
166-
assertNever(type, `Type "${type}" is not supported yet`);
167-
}
168-
throw new Error("unreachable");
169-
}
170-
17195
export const writeAndReturnKindBits = (
17296
value: any,
17397
payload1_ptr: pointer,

Diff for: Sources/JavaScriptEventLoop/JSObject+Transferring.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public struct JSTransferring<T>: @unchecked Sendable {
6969
self.storage.context.withLock { context in
7070
guard context.continuation == nil else {
7171
// This is a programming error, `receive` should be called only once.
72-
fatalError("JSObject.Transferring object is already received", file: file, line: line)
72+
fatalError("JSTransferring object is already received", file: file, line: line)
7373
}
7474
// The continuation will be resumed by `swjs_receive_object`.
7575
context.continuation = continuation
@@ -147,7 +147,7 @@ func _swjs_receive_response(_ object: JavaScriptObjectRef, _ transferring: Unsaf
147147
guard let transferring = transferring else { return }
148148
let context = Unmanaged<_JSTransferringContext>.fromOpaque(transferring).takeRetainedValue()
149149
context.withLock { state in
150-
assert(state.continuation != nil, "JSObject.Transferring object is not yet received!?")
150+
assert(state.continuation != nil, "JSTransferring object is not yet received!?")
151151
state.continuation?.resume(returning: object)
152152
}
153153
#endif
@@ -169,7 +169,7 @@ func _swjs_receive_error(_ error: JavaScriptObjectRef, _ transferring: UnsafeRaw
169169
guard let transferring = transferring else { return }
170170
let context = Unmanaged<_JSTransferringContext>.fromOpaque(transferring).takeRetainedValue()
171171
context.withLock { state in
172-
assert(state.continuation != nil, "JSObject.Transferring object is not yet received!?")
172+
assert(state.continuation != nil, "JSTransferring object is not yet received!?")
173173
state.continuation?.resume(throwing: JSException(JSObject(id: error).jsValue))
174174
}
175175
#endif

0 commit comments

Comments
 (0)