File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import _CJavaScriptKit
22
33@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 {
145
156 @discardableResult
167 public func dynamicallyCall( withArguments arguments: [ JSValueConvertible ] ) -> JSValue {
@@ -72,6 +63,10 @@ public class JSFunctionRef: Equatable {
7263
7364 return JSFunctionRef ( id: funcRef)
7465 }
66+
67+ public override func jsValue( ) -> JSValue {
68+ . function( self )
69+ }
7570}
7671
7772
Original file line number Diff line number Diff line change @@ -49,4 +49,8 @@ public class JSObjectRef: Equatable {
4949 public static func == ( lhs: JSObjectRef , rhs: JSObjectRef ) -> Bool {
5050 return lhs. id == rhs. id
5151 }
52+
53+ public func jsValue( ) -> JSValue {
54+ . object( self )
55+ }
5256}
Original file line number Diff line number Diff line change @@ -21,11 +21,8 @@ extension String: JSValueConvertible {
2121}
2222
2323extension 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`
2926}
3027
3128private let Object = JSObjectRef . global. Object. function!
You can’t perform that action at this time.
0 commit comments