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 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 )
@@ -27,11 +27,7 @@ public typealias JSValueCodable = JSValueEncodable & JSValueDecodable
27
27
28
28
extension JSBridgedType {
29
29
public static func canDecode( from jsValue: JSValue ) -> Bool {
30
- if let constructor = Self . constructor {
31
- return jsValue. isInstanceOf ( constructor)
32
- } else {
33
- return jsValue. isObject
34
- }
30
+ jsValue. isInstanceOf ( Self . classRef)
35
31
}
36
32
37
33
public init ( jsValue: JSValue ) {
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type {
222
222
}
223
223
224
224
public func dynamicCast< Type: JSBridgedType > ( _ ref: JSBridgedType ) -> Type ? {
225
- guard let constructor = Type . constructor , ref. objectRef. isInstanceOf ( constructor ) else {
225
+ guard ref. objectRef. isInstanceOf ( Type . classRef ) else {
226
226
return nil
227
227
}
228
228
return staticCast ( ref)
You can’t perform that action at this time.
0 commit comments