Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Aug 3, 2020
1 parent 1f1a7e4 commit 98d1026
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Sources/JavaScriptKit/JSObject.swift
Expand Up @@ -9,18 +9,13 @@ public class JSObjectRef: Equatable {
}

@_disfavoredOverload
public subscript(dynamicMember name: String) -> ((JSValueEncodable...) -> JSValue)? {
public subscript(_ name: String) -> ((JSValueEncodable...) -> JSValue)? {
guard let function = self[name].function else { return nil }
return { (arguments: JSValueEncodable...) in
function(this: self, args: arguments)
}
}

public subscript(dynamicMember name: String) -> JSValue {
get { self[name] }
set { self[name] = newValue }
}

public subscript(_ name: String) -> JSValue {
get { getJSValue(this: self, name: name) }
set { setJSValue(this: self, name: name, value: newValue) }
Expand All @@ -31,6 +26,19 @@ public class JSObjectRef: Equatable {
set { setJSValue(this: self, index: Int32(index), value: newValue) }
}

@_disfavoredOverload
public subscript(dynamicMember name: String) -> ((JSValueEncodable...) -> JSValue)? {
guard let function = self[name].function else { return nil }
return { (arguments: JSValueEncodable...) in
function(this: self, args: arguments)
}
}

public subscript(dynamicMember name: String) -> JSValue {
get { self[name] }
set { self[name] = newValue }
}

public static func instanceof(_ instance: JSObjectRef, constructor: JSFunctionRef) -> Bool {
_instanceof(instance.id, constructor.id)
}
Expand Down

0 comments on commit 98d1026

Please sign in to comment.