Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Aug 4, 2020
1 parent fca7080 commit 000fe5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Sources/JavaScriptKit/JSValueConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ public protocol JSValueDecodable {

public typealias JSValueCodable = JSValueEncodable & JSValueDecodable

extension JSBridgedType {
public static func canDecode(from jsValue: JSValue) -> Bool {
jsValue.isInstanceOf(Self.classRef)
}

extension JSAbstractBridgedType {
public init(jsValue: JSValue) {
self.init(objectRef: jsValue.object!)
}

public func jsValue() -> JSValue {
return JSValue.object(objectRef)
.object(objectRef)
}
}

extension JSBridgedType {
public static func canDecode(from jsValue: JSValue) -> Bool {
jsValue.isInstanceOf(Self.classRef)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/JavaScriptKit/Support.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public struct AnyJSValueCodable: JSValueCodable, ExpressibleByNilLiteral {
}
}

public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type {
public func staticCast<Type: JSAbstractBridgedType>(_ ref: JSAbstractBridgedType) -> Type {
return Type(objectRef: ref.objectRef)
}

Expand Down

0 comments on commit 000fe5b

Please sign in to comment.