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 classRef : JSFunctionRef ? { get }
4
+ static var classRef : JSFunctionRef { get }
5
5
6
6
var objectRef : JSObjectRef { get }
7
7
init ( objectRef: JSObjectRef )
8
8
}
9
9
10
10
extension JSBridgedType {
11
- static var classRef : JSFunctionRef ? { nil }
12
11
public var description : String {
13
12
return objectRef. toString!( ) . fromJSValue ( )
14
13
}
@@ -29,10 +28,7 @@ public typealias JSValueCodable = JSValueEncodable & JSValueDecodable
29
28
extension JSBridgedType {
30
29
public static func canDecode( from jsValue: JSValue ) -> Bool {
31
30
if let object = jsValue. object {
32
- if let constructor = Self . classRef {
33
- return object. instanceof ( constructor)
34
- }
35
- return true
31
+ return object. instanceof ( Self . classRef)
36
32
}
37
33
return false
38
34
}
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type {
237
237
}
238
238
239
239
public func dynamicCast< Type: JSBridgedType > ( _ ref: JSBridgedType ) -> Type ? {
240
- guard let constructor = Type . classRef , ref. objectRef. instanceof ( constructor ) else {
240
+ guard ref. objectRef. instanceof ( Type . classRef ) else {
241
241
return nil
242
242
}
243
243
return staticCast ( ref)
You can’t perform that action at this time.
0 commit comments