Skip to content

Commit

Permalink
Add JSAbstractBridgedType
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Aug 4, 2020
1 parent 307f6d4 commit da7002f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/JavaScriptKit/JSValueConvertible.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import _CJavaScriptKit

public protocol JSBridgedType: JSValueCodable, CustomStringConvertible {
static var classRef: JSFunctionRef { get }

// Use this protocol when your type has no single JavaScript class.
// For example, a union type of multiple classes.
public protocol JSAbstractBridgedType: JSValueCodable, CustomStringConvertible {
var objectRef: JSObjectRef { get }
init(objectRef: JSObjectRef)
}

extension JSBridgedType {
extension JSAbstractBridgedType {
public var description: String {
return objectRef.toString!().fromJSValue()
}
}

public protocol JSBridgedType: JSAbstractBridgedType {
static var classRef: JSFunctionRef { get }
}

public protocol JSValueEncodable {
subscript(jsValue _: ()) -> JSValue { get }
}
Expand Down

0 comments on commit da7002f

Please sign in to comment.