File tree 2 files changed +3
-7
lines changed
2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change 1
1
import _CJavaScriptKit
2
2
3
3
public protocol JSBridgedType : JSValueCodable , CustomStringConvertible {
4
- static var constructor : JSFunctionRef ? { get }
4
+ static var classRef : JSFunctionRef { get }
5
5
6
6
var objectRef : JSObjectRef { get }
7
7
init ( objectRef: JSObjectRef )
@@ -21,11 +21,7 @@ public typealias JSValueCodable = JSValueConvertible & JSValueConstructible
21
21
22
22
extension JSBridgedType {
23
23
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)
29
25
}
30
26
31
27
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 {
50
50
}
51
51
52
52
public 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 {
54
54
return nil
55
55
}
56
56
return staticCast ( ref)
You can’t perform that action at this time.
0 commit comments