Skip to content

Commit f9b76bf

Browse files
Phase 2: Unify JSValue representation - functions now use .object case
Co-authored-by: kateinoigakukun <[email protected]>
1 parent 11d38dd commit f9b76bf

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

Sources/JavaScriptKit/ConvertibleToJSValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ extension RawJSValue: ConvertibleToJSValue {
209209
case .undefined:
210210
return .undefined
211211
case .function:
212-
return .function(JSFunction(id: UInt32(payload1)))
212+
return .object(JSFunction(id: UInt32(payload1)))
213213
case .symbol:
214214
return .symbol(JSSymbol(id: UInt32(payload1)))
215215
case .bigInt:

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public class JSClosure: JSObject, JSClosureProtocol {
166166
}
167167

168168
override public var jsValue: JSValue {
169-
.function(JSFunction(id: self.id))
169+
.object(self)
170170
}
171171

172172
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))

Sources/JavaScriptKit/FundamentalObjects/JSFunction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class JSFunction: JSObject {
105105
}
106106

107107
override public var jsValue: JSValue {
108-
.function(self)
108+
.object(self)
109109
}
110110
}
111111

Sources/JavaScriptKit/JSValue.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public enum JSValue: Equatable {
6565
public var function: JSFunction? {
6666
switch self {
6767
case .function(let function): return function
68+
case .object(let object as JSFunction): return object
6869
default: return nil
6970
}
7071
}

0 commit comments

Comments
 (0)