File tree 3 files changed +11
-15
lines changed
3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 1
1
import _CJavaScriptKit
2
2
3
3
@dynamicCallable
4
- public class JSFunctionRef : Equatable {
5
- let id : UInt32
6
-
7
- init ( id: UInt32 ) {
8
- self . id = id
9
- }
10
-
11
- public static func == ( lhs: JSFunctionRef , rhs: JSFunctionRef ) -> Bool {
12
- return lhs. id == rhs. id
13
- }
4
+ public class JSFunctionRef : JSObjectRef {
14
5
15
6
@discardableResult
16
7
public func dynamicallyCall( withArguments arguments: [ JSValueConvertible ] ) -> JSValue {
@@ -72,6 +63,10 @@ public class JSFunctionRef: Equatable {
72
63
73
64
return JSFunctionRef ( id: funcRef)
74
65
}
66
+
67
+ public override func jsValue( ) -> JSValue {
68
+ . function( self )
69
+ }
75
70
}
76
71
77
72
Original file line number Diff line number Diff line change @@ -49,4 +49,8 @@ public class JSObjectRef: Equatable {
49
49
public static func == ( lhs: JSObjectRef , rhs: JSObjectRef ) -> Bool {
50
50
return lhs. id == rhs. id
51
51
}
52
+
53
+ public func jsValue( ) -> JSValue {
54
+ . object( self )
55
+ }
52
56
}
Original file line number Diff line number Diff line change @@ -21,11 +21,8 @@ extension String: JSValueConvertible {
21
21
}
22
22
23
23
extension JSObjectRef : JSValueConvertible {
24
- public func jsValue( ) -> JSValue { . object( self ) }
25
- }
26
-
27
- extension JSFunctionRef : JSValueConvertible {
28
- public func jsValue( ) -> JSValue { . function( self ) }
24
+ // `JSObjectRef.jsValue` is defined in JSObjectRef.swift to be able to overridden
25
+ // from `JSFunctionRef`
29
26
}
30
27
31
28
private let Object = JSObjectRef . global. Object. function!
You can’t perform that action at this time.
0 commit comments