11import _CJavaScriptKit
22
3- public class JSFunctionRef : JSObjectRef {
3+ public class JSFunction : JSObject {
44 @discardableResult
5- public func callAsFunction( this: JSObjectRef ? = nil , arguments: [ JSValueConvertible ] ) -> JSValue {
5+ public func callAsFunction( this: JSObject ? = nil , arguments: [ JSValueConvertible ] ) -> JSValue {
66 let result = arguments. withRawJSValues { rawValues in
77 rawValues. withUnsafeBufferPointer { bufferPointer -> RawJSValue in
88 let argv = bufferPointer. baseAddress
@@ -25,19 +25,19 @@ public class JSFunctionRef: JSObjectRef {
2525 }
2626
2727 @discardableResult
28- public func callAsFunction( this: JSObjectRef ? = nil , _ arguments: JSValueConvertible ... ) -> JSValue {
28+ public func callAsFunction( this: JSObject ? = nil , _ arguments: JSValueConvertible ... ) -> JSValue {
2929 self ( this: this, arguments: arguments)
3030 }
3131
32- public func new( _ arguments: JSValueConvertible ... ) -> JSObjectRef {
32+ public func new( _ arguments: JSValueConvertible ... ) -> JSObject {
3333 new ( arguments: arguments)
3434 }
3535
3636 // Guaranteed to return an object because either:
3737 // a) the constructor explicitly returns an object, or
3838 // b) the constructor returns nothing, which causes JS to return the `this` value, or
3939 // c) the constructor returns undefined, null or a non-object, in which case JS also returns `this`.
40- public func new( arguments: [ JSValueConvertible ] ) -> JSObjectRef {
40+ public func new( arguments: [ JSValueConvertible ] ) -> JSObject {
4141 arguments. withRawJSValues { rawValues in
4242 rawValues. withUnsafeBufferPointer { bufferPointer in
4343 let argv = bufferPointer. baseAddress
@@ -47,13 +47,13 @@ public class JSFunctionRef: JSObjectRef {
4747 self . id, argv, Int32 ( argc) ,
4848 & resultObj
4949 )
50- return JSObjectRef ( id: resultObj)
50+ return JSObject ( id: resultObj)
5151 }
5252 }
5353 }
5454
5555 @available ( * , unavailable, message: " Please use JSClosure instead " )
56- public static func from( _: @escaping ( [ JSValue ] ) -> JSValue ) -> JSFunctionRef {
56+ public static func from( _: @escaping ( [ JSValue ] ) -> JSValue ) -> JSFunction {
5757 fatalError ( " unavailable " )
5858 }
5959
@@ -62,7 +62,7 @@ public class JSFunctionRef: JSObjectRef {
6262 }
6363}
6464
65- public class JSClosure : JSFunctionRef {
65+ public class JSClosure : JSFunction {
6666 static var sharedFunctions : [ JavaScriptHostFuncRef : ( [ JSValue ] ) -> JSValue ] = [ : ]
6767
6868 private var hostFuncRef : JavaScriptHostFuncRef = 0
@@ -128,6 +128,6 @@ public func _call_host_function(
128128 $0. jsValue ( )
129129 }
130130 let result = hostFunc ( arguments)
131- let callbackFuncRef = JSFunctionRef ( id: callbackFuncRef)
131+ let callbackFuncRef = JSFunction ( id: callbackFuncRef)
132132 _ = callbackFuncRef ( result)
133133}
0 commit comments