File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed
Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change 11import _CJavaScriptKit
22
33public protocol JSBridgedType : JSValueCodable , CustomStringConvertible {
4- static var constructor : JSFunction ? { get }
4+ static var classRef : JSFunction { get }
55
66 var objectRef : JSObject { get }
77 init ( objectRef: JSObject )
@@ -21,11 +21,7 @@ public typealias JSValueCodable = JSValueConvertible & JSValueConstructible
2121
2222extension JSBridgedType {
2323 public static func canDecode( from jsValue: JSValue ) -> Bool {
24- if let constructor = Self . constructor {
25- return jsValue. isInstanceOf ( constructor)
26- } else {
27- return jsValue. isObject
28- }
24+ jsValue. isInstanceOf ( Self . classRef)
2925 }
3026
3127 public init ( jsValue: JSValue ) {
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type {
5050}
5151
5252public func dynamicCast< Type: JSBridgedType > ( _ ref: JSBridgedType ) -> Type ? {
53- guard let constructor = Type . constructor , ref. objectRef. isInstanceOf ( constructor ) else {
53+ guard ref. objectRef. isInstanceOf ( Type . classRef ) else {
5454 return nil
5555 }
5656 return staticCast ( ref)
You can’t perform that action at this time.
0 commit comments