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 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 JSObjectRef . instanceof ( object, constructor: constructor)
34
- }
35
- return true
31
+ return JSObjectRef . instanceof ( object, constructor: Self . classRef)
36
32
}
37
33
return false
38
34
}
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type {
234
234
}
235
235
236
236
public func dynamicCast< Type: JSBridgedType > ( _ ref: JSBridgedType ) -> Type ? {
237
- guard let constructor = Type . classRef , JSObjectRef . instanceof ( ref. objectRef, constructor: constructor ) else {
237
+ guard JSObjectRef . instanceof ( ref. objectRef, constructor: Type . classRef ) else {
238
238
return nil
239
239
}
240
240
return staticCast ( ref)
You can’t perform that action at this time.
0 commit comments