diff --git a/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift b/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift deleted file mode 100644 index e6bb84c1..00000000 --- a/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift +++ /dev/null @@ -1,58 +0,0 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoop") -fileprivate func bjs_benchmarkHelperNoop() -> Void -#else -fileprivate func bjs_benchmarkHelperNoop() -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -func benchmarkHelperNoop() throws(JSException) -> Void { - bjs_benchmarkHelperNoop() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoopWithNumber") -fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void -#else -fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -func benchmarkHelperNoopWithNumber(_ n: Double) throws(JSException) -> Void { - let nValue = n.bridgeJSLowerParameter() - bjs_benchmarkHelperNoopWithNumber(nValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkRunner") -fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void -#else -fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -func benchmarkRunner(_ name: String, _ body: JSObject) throws(JSException) -> Void { - let nameValue = name.bridgeJSLowerParameter() - let bodyValue = body.bridgeJSLowerParameter() - bjs_benchmarkRunner(nameValue, bodyValue) - if let error = _swift_js_take_exception() { - throw error - } -} \ No newline at end of file diff --git a/Benchmarks/Sources/Generated/BridgeJS.Macros.swift b/Benchmarks/Sources/Generated/BridgeJS.Macros.swift new file mode 100644 index 00000000..bc2ceb32 --- /dev/null +++ b/Benchmarks/Sources/Generated/BridgeJS.Macros.swift @@ -0,0 +1,13 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func benchmarkHelperNoop() throws (JSException) -> Void + +@JSFunction func benchmarkHelperNoopWithNumber(_ n: Double) throws (JSException) -> Void + +@JSFunction func benchmarkRunner(_ name: String, _ body: JSObject) throws (JSException) -> Void diff --git a/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift b/Benchmarks/Sources/Generated/BridgeJS.swift similarity index 96% rename from Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift rename to Benchmarks/Sources/Generated/BridgeJS.swift index 2c9d9b6b..85d81f4a 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1,3 +1,4 @@ +// bridge-js: skip // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, // DO NOT EDIT. // @@ -1172,4 +1173,55 @@ fileprivate func _bjs_ClassRoundtrip_wrap(_ pointer: UnsafeMutableRawPointer) -> fileprivate func _bjs_ClassRoundtrip_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } -#endif \ No newline at end of file +#endif + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoop") +fileprivate func bjs_benchmarkHelperNoop() -> Void +#else +fileprivate func bjs_benchmarkHelperNoop() -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$benchmarkHelperNoop() throws(JSException) -> Void { + bjs_benchmarkHelperNoop() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoopWithNumber") +fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void +#else +fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$benchmarkHelperNoopWithNumber(_ n: Double) throws(JSException) -> Void { + let nValue = n.bridgeJSLowerParameter() + bjs_benchmarkHelperNoopWithNumber(nValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkRunner") +fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void +#else +fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$benchmarkRunner(_ name: String, _ body: JSObject) throws(JSException) -> Void { + let nameValue = name.bridgeJSLowerParameter() + let bodyValue = body.bridgeJSLowerParameter() + bjs_benchmarkRunner(nameValue, bodyValue) + if let error = _swift_js_take_exception() { + throw error + } +} \ No newline at end of file diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ExportSwift.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ExportSwift.json deleted file mode 100644 index e3532d33..00000000 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ExportSwift.json +++ /dev/null @@ -1,1584 +0,0 @@ -{ - "classes" : [ - { - "constructor" : { - "abiName" : "bjs_EnumRoundtrip_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_EnumRoundtrip_take", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "take", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makeSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeSuccess", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makeFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFailure", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makeFlag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFlag", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makeRate", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeRate", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makePrecise", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makePrecise", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_makeInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_EnumRoundtrip_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtrip", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "name" : "EnumRoundtrip", - "properties" : [ - - ], - "swiftCallName" : "EnumRoundtrip" - }, - { - "constructor" : { - "abiName" : "bjs_ComplexResultRoundtrip_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_ComplexResultRoundtrip_take", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "take", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeSuccess", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeError", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeError", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeLocation", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeLocation", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeStatus", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeCoordinates", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeCoordinates", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeComprehensive", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComprehensive", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_makeInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_ComplexResultRoundtrip_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtrip", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - ], - "name" : "ComplexResultRoundtrip", - "properties" : [ - - ], - "swiftCallName" : "ComplexResultRoundtrip" - }, - { - "constructor" : { - "abiName" : "bjs_StringRoundtrip_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_StringRoundtrip_take", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "take", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_StringRoundtrip_make", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "make", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "StringRoundtrip", - "properties" : [ - - ], - "swiftCallName" : "StringRoundtrip" - }, - { - "constructor" : { - "abiName" : "bjs_StructRoundtrip_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_StructRoundtrip_takeSimple", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeSimple", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "SimpleStruct" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_makeSimple", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeSimple", - "parameters" : [ - - ], - "returnType" : { - "swiftStruct" : { - "_0" : "SimpleStruct" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_roundtripSimple", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripSimple", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "SimpleStruct" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "SimpleStruct" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_takeAddress", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeAddress", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_makeAddress", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAddress", - "parameters" : [ - - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Address" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_roundtripAddress", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAddress", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Address" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_takePerson", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takePerson", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "Person" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_makePerson", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makePerson", - "parameters" : [ - - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Person" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_roundtripPerson", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripPerson", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "Person" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Person" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_takeComplex", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeComplex", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ComplexStruct" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_makeComplex", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplex", - "parameters" : [ - - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ComplexStruct" - } - } - }, - { - "abiName" : "bjs_StructRoundtrip_roundtripComplex", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripComplex", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ComplexStruct" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ComplexStruct" - } - } - } - ], - "name" : "StructRoundtrip", - "properties" : [ - - ], - "swiftCallName" : "StructRoundtrip" - }, - { - "constructor" : { - "abiName" : "bjs_SimpleClass_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "label" : "count", - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "label" : "flag", - "name" : "flag", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "rate", - "name" : "rate", - "type" : { - "float" : { - - } - } - }, - { - "label" : "precise", - "name" : "precise", - "type" : { - "double" : { - - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "SimpleClass", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "flag", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "rate", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "precise", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "SimpleClass" - }, - { - "constructor" : { - "abiName" : "bjs_AddressClass_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "street", - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "label" : "city", - "name" : "city", - "type" : { - "string" : { - - } - } - }, - { - "label" : "zipCode", - "name" : "zipCode", - "type" : { - "int" : { - - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "AddressClass", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "city", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "zipCode", - "type" : { - "int" : { - - } - } - } - ], - "swiftCallName" : "AddressClass" - }, - { - "constructor" : { - "abiName" : "bjs_ClassRoundtrip_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_ClassRoundtrip_takeSimpleClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeSimpleClass", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "SimpleClass" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_ClassRoundtrip_makeSimpleClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeSimpleClass", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "SimpleClass" - } - } - }, - { - "abiName" : "bjs_ClassRoundtrip_roundtripSimpleClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripSimpleClass", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "SimpleClass" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "SimpleClass" - } - } - }, - { - "abiName" : "bjs_ClassRoundtrip_takeAddressClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeAddressClass", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "AddressClass" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_ClassRoundtrip_makeAddressClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAddressClass", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "AddressClass" - } - } - }, - { - "abiName" : "bjs_ClassRoundtrip_roundtripAddressClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAddressClass", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "AddressClass" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "AddressClass" - } - } - } - ], - "name" : "ClassRoundtrip", - "properties" : [ - - ], - "swiftCallName" : "ClassRoundtrip" - } - ], - "enums" : [ - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - } - ], - "name" : "flag" - }, - { - "associatedValues" : [ - { - "type" : { - "float" : { - - } - } - } - ], - "name" : "rate" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "precise" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "APIResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "APIResult", - "tsFullPath" : "APIResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "error" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "location" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "status" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "coordinates" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "comprehensive" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "ComplexResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "ComplexResult", - "tsFullPath" : "ComplexResult" - } - ], - "exposeToGlobal" : false, - "functions" : [ - { - "abiName" : "bjs_run", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "run", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ], - "moduleName" : "Benchmarks", - "protocols" : [ - - ], - "structs" : [ - { - "methods" : [ - - ], - "name" : "SimpleStruct", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "flag", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "rate", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "precise", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "SimpleStruct" - }, - { - "methods" : [ - - ], - "name" : "Address", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "city", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "zipCode", - "type" : { - "int" : { - - } - } - } - ], - "swiftCallName" : "Address" - }, - { - "methods" : [ - - ], - "name" : "Person", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "age", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "address", - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "email", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "swiftCallName" : "Person" - }, - { - "methods" : [ - - ], - "name" : "ComplexStruct", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "title", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "active", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "score", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "tags", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "metadata", - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "ComplexStruct" - } - ] -} \ No newline at end of file diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ImportTS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ImportTS.json deleted file mode 100644 index 366342bb..00000000 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.ImportTS.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "children" : [ - { - "functions" : [ - { - "name" : "benchmarkHelperNoop", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "name" : "benchmarkHelperNoopWithNumber", - "parameters" : [ - { - "name" : "n", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "name" : "benchmarkRunner", - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "body", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "types" : [ - - ] - } - ], - "moduleName" : "Benchmarks" -} \ No newline at end of file diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json new file mode 100644 index 00000000..27a245f5 --- /dev/null +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,1660 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_EnumRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_EnumRoundtrip_take", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "take", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makeSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSuccess", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makeFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFailure", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makeFlag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFlag", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makeRate", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeRate", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makePrecise", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makePrecise", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_makeInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_EnumRoundtrip_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtrip", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "name" : "EnumRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "EnumRoundtrip" + }, + { + "constructor" : { + "abiName" : "bjs_ComplexResultRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_ComplexResultRoundtrip_take", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "take", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSuccess", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeError", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeLocation", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeLocation", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeStatus", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeCoordinates", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeCoordinates", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeComprehensive", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComprehensive", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_makeInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_ComplexResultRoundtrip_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtrip", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + ], + "name" : "ComplexResultRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "ComplexResultRoundtrip" + }, + { + "constructor" : { + "abiName" : "bjs_StringRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_StringRoundtrip_take", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "take", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_StringRoundtrip_make", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "make", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "StringRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "StringRoundtrip" + }, + { + "constructor" : { + "abiName" : "bjs_StructRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_StructRoundtrip_takeSimple", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeSimple", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "SimpleStruct" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_makeSimple", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSimple", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "SimpleStruct" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_roundtripSimple", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripSimple", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "SimpleStruct" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "SimpleStruct" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_takeAddress", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeAddress", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_makeAddress", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAddress", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Address" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_roundtripAddress", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAddress", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Address" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_takePerson", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takePerson", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "Person" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_makePerson", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makePerson", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Person" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_roundtripPerson", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripPerson", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "Person" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Person" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_takeComplex", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeComplex", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ComplexStruct" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_makeComplex", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplex", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ComplexStruct" + } + } + }, + { + "abiName" : "bjs_StructRoundtrip_roundtripComplex", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripComplex", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ComplexStruct" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ComplexStruct" + } + } + } + ], + "name" : "StructRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "StructRoundtrip" + }, + { + "constructor" : { + "abiName" : "bjs_SimpleClass_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "label" : "count", + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "label" : "flag", + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "rate", + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "label" : "precise", + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "SimpleClass", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "SimpleClass" + }, + { + "constructor" : { + "abiName" : "bjs_AddressClass_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "street", + "name" : "street", + "type" : { + "string" : { + + } + } + }, + { + "label" : "city", + "name" : "city", + "type" : { + "string" : { + + } + } + }, + { + "label" : "zipCode", + "name" : "zipCode", + "type" : { + "int" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "AddressClass", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "street", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "city", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "zipCode", + "type" : { + "int" : { + + } + } + } + ], + "swiftCallName" : "AddressClass" + }, + { + "constructor" : { + "abiName" : "bjs_ClassRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_ClassRoundtrip_takeSimpleClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeSimpleClass", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_ClassRoundtrip_makeSimpleClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSimpleClass", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + }, + { + "abiName" : "bjs_ClassRoundtrip_roundtripSimpleClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripSimpleClass", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + }, + { + "abiName" : "bjs_ClassRoundtrip_takeAddressClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeAddressClass", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "AddressClass" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_ClassRoundtrip_makeAddressClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAddressClass", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "AddressClass" + } + } + }, + { + "abiName" : "bjs_ClassRoundtrip_roundtripAddressClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAddressClass", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "AddressClass" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "AddressClass" + } + } + } + ], + "name" : "ClassRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "ClassRoundtrip" + } + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + } + ], + "name" : "flag" + }, + { + "associatedValues" : [ + { + "type" : { + "float" : { + + } + } + } + ], + "name" : "rate" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "precise" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "APIResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIResult", + "tsFullPath" : "APIResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "error" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "location" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "status" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "coordinates" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "comprehensive" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "ComplexResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ComplexResult", + "tsFullPath" : "ComplexResult" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_run", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "run", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ], + "protocols" : [ + + ], + "structs" : [ + { + "methods" : [ + + ], + "name" : "SimpleStruct", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "SimpleStruct" + }, + { + "methods" : [ + + ], + "name" : "Address", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "street", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "city", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "zipCode", + "type" : { + "int" : { + + } + } + } + ], + "swiftCallName" : "Address" + }, + { + "methods" : [ + + ], + "name" : "Person", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "age", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "address", + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "email", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "swiftCallName" : "Person" + }, + { + "methods" : [ + + ], + "name" : "ComplexStruct", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "title", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "active", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "score", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "tags", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "metadata", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "ComplexStruct" + } + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + + ] + }, + { + "functions" : [ + { + "name" : "benchmarkHelperNoop", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "name" : "benchmarkHelperNoopWithNumber", + "parameters" : [ + { + "name" : "n", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "name" : "benchmarkRunner", + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "body", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "types" : [ + + ] + } + ] + }, + "moduleName" : "Benchmarks" +} \ No newline at end of file diff --git a/Benchmarks/Sources/bridge-js.d.ts b/Benchmarks/Sources/bridge-js.d.ts index a9eb5d0b..9f5137e1 100644 --- a/Benchmarks/Sources/bridge-js.d.ts +++ b/Benchmarks/Sources/bridge-js.d.ts @@ -1,3 +1,3 @@ -declare function benchmarkHelperNoop(): void; -declare function benchmarkHelperNoopWithNumber(n: number): void; -declare function benchmarkRunner(name: string, body: (n: number) => void): void; +export function benchmarkHelperNoop(): void; +export function benchmarkHelperNoopWithNumber(n: number): void; +export function benchmarkRunner(name: string, body: (n: number) => void): void; diff --git a/Examples/PlayBridgeJS/Sources/JavaScript/app.js b/Examples/PlayBridgeJS/Sources/JavaScript/app.js index 2f5267d3..7da78e03 100644 --- a/Examples/PlayBridgeJS/Sources/JavaScript/app.js +++ b/Examples/PlayBridgeJS/Sources/JavaScript/app.js @@ -102,11 +102,11 @@ export class BridgeJSPlayground { // Import the BridgeJS module this.setProgress('Loading BridgeJS…', 50); const { init } = await import("../../Bundle/index.js"); - const virtualHost = await this.createTS2SkeletonFactory(); + const virtualHost = await this.createTS2SwiftFactory(); this.setProgress('Preparing TypeScript host…', 60); const { exports } = await init({ getImports: () => ({ - createTS2Skeleton: () => this.createTS2Skeleton(virtualHost) + createTS2Swift: () => this.createTS2Swift(virtualHost) }) }); this.setProgress('Creating runtime…', 65); @@ -193,7 +193,7 @@ export class BridgeJSPlayground { }); } - async createTS2SkeletonFactory() { + async createTS2SwiftFactory() { const createVirtualHost = async () => { const fsMap = await createDefaultMapFromCDN( { target: ts.ScriptTarget.ES2015 }, @@ -217,7 +217,7 @@ export class BridgeJSPlayground { /** * @param {ReturnType} virtualHost */ - createTS2Skeleton(virtualHost) { + createTS2Swift(virtualHost) { return { /** * @param {string} dtsCode @@ -250,9 +250,9 @@ export class BridgeJSPlayground { // Process the TypeScript definitions to generate skeleton const processor = new TypeProcessor(tsProgram.getTypeChecker(), diagnosticEngine); - const skeleton = processor.processTypeDeclarations(tsProgram, virtualFilePath); + const { content } = processor.processTypeDeclarations(tsProgram, virtualFilePath); - return JSON.stringify(skeleton); + return content; } } } @@ -340,4 +340,4 @@ export class BridgeJSPlayground { this.progressBar.classList.add('hidden'); } } -} \ No newline at end of file +} diff --git a/Examples/PlayBridgeJS/Sources/JavaScript/editor.js b/Examples/PlayBridgeJS/Sources/JavaScript/editor.js index dabe7dc5..dc3d362e 100644 --- a/Examples/PlayBridgeJS/Sources/JavaScript/editor.js +++ b/Examples/PlayBridgeJS/Sources/JavaScript/editor.js @@ -38,20 +38,20 @@ export class EditorSystem { modelUri: 'Playground.d.ts' }, { - key: 'import-glue', - id: 'importGlueOutput', + key: 'swift-import-macros', + id: 'swiftImportMacrosOutput', language: 'swift', - placeholder: '// Import Swift Glue will appear here...', + placeholder: '// Import Swift Macros will appear here...', readOnly: true, - modelUri: 'ImportTS.swift' + modelUri: 'BridgeJS.Macros.swift' }, { - key: 'export-glue', - id: 'exportGlueOutput', + key: 'swift-glue', + id: 'swiftGlueOutput', language: 'swift', - placeholder: '// Export Swift Glue will appear here...', + placeholder: '// Swift Glue will appear here...', readOnly: true, - modelUri: 'ExportTS.swift' + modelUri: 'BridgeJS.swift' }, { key: 'js-generated', @@ -206,8 +206,8 @@ export class EditorSystem { updateOutputs(result) { const outputMap = { - 'import-glue': () => result.importSwiftGlue(), - 'export-glue': () => result.exportSwiftGlue(), + 'swift-glue': () => result.swiftGlue(), + 'swift-import-macros': () => result.importSwiftMacroDecls(), 'js-generated': () => result.outputJs(), 'dts-generated': () => result.outputDts() }; @@ -238,4 +238,4 @@ export class EditorSystem { getActiveTabs() { return this.activeTabs; } -} \ No newline at end of file +} diff --git a/Examples/PlayBridgeJS/Sources/JavaScript/processor.js b/Examples/PlayBridgeJS/Sources/JavaScript/processor.js index 61c83392..646254cd 120000 --- a/Examples/PlayBridgeJS/Sources/JavaScript/processor.js +++ b/Examples/PlayBridgeJS/Sources/JavaScript/processor.js @@ -1 +1 @@ -../../../../Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/processor.js \ No newline at end of file +../../../../Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift deleted file mode 100644 index cd1ef981..00000000 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift +++ /dev/null @@ -1,52 +0,0 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "PlayBridgeJS", name: "bjs_createTS2Skeleton") -fileprivate func bjs_createTS2Skeleton() -> Int32 -#else -fileprivate func bjs_createTS2Skeleton() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func createTS2Skeleton() throws(JSException) -> TS2Skeleton { - let ret = bjs_createTS2Skeleton() - if let error = _swift_js_take_exception() { - throw error - } - return TS2Skeleton.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "PlayBridgeJS", name: "bjs_TS2Skeleton_convert") -fileprivate func bjs_TS2Skeleton_convert(_ self: Int32, _ ts: Int32) -> Int32 -#else -fileprivate func bjs_TS2Skeleton_convert(_ self: Int32, _ ts: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -struct TS2Skeleton: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - func convert(_ ts: String) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let tsValue = ts.bridgeJSLowerParameter() - let ret = bjs_TS2Skeleton_convert(selfValue, tsValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } - -} \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.Macros.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.Macros.swift new file mode 100644 index 00000000..053db447 --- /dev/null +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.Macros.swift @@ -0,0 +1,13 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func createTS2Swift() throws (JSException) -> TS2Swift + +@JSClass struct TS2Swift: _JSBridgedClass { + @JSFunction func convert(_ ts: String) throws (JSException) -> String +} diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.swift similarity index 73% rename from Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift rename to Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.swift index 3391b2fd..f97c181d 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.swift @@ -1,3 +1,4 @@ +// bridge-js: skip // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, // DO NOT EDIT. // @@ -89,22 +90,22 @@ public func _bjs_PlayBridgeJSOutput_outputDts(_ _self: UnsafeMutableRawPointer) #endif } -@_expose(wasm, "bjs_PlayBridgeJSOutput_importSwiftGlue") -@_cdecl("bjs_PlayBridgeJSOutput_importSwiftGlue") -public func _bjs_PlayBridgeJSOutput_importSwiftGlue(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_PlayBridgeJSOutput_importSwiftMacroDecls") +@_cdecl("bjs_PlayBridgeJSOutput_importSwiftMacroDecls") +public func _bjs_PlayBridgeJSOutput_importSwiftMacroDecls(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = PlayBridgeJSOutput.bridgeJSLiftParameter(_self).importSwiftGlue() + let ret = PlayBridgeJSOutput.bridgeJSLiftParameter(_self).importSwiftMacroDecls() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PlayBridgeJSOutput_exportSwiftGlue") -@_cdecl("bjs_PlayBridgeJSOutput_exportSwiftGlue") -public func _bjs_PlayBridgeJSOutput_exportSwiftGlue(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_PlayBridgeJSOutput_swiftGlue") +@_cdecl("bjs_PlayBridgeJSOutput_swiftGlue") +public func _bjs_PlayBridgeJSOutput_swiftGlue(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = PlayBridgeJSOutput.bridgeJSLiftParameter(_self).exportSwiftGlue() + let ret = PlayBridgeJSOutput.bridgeJSLiftParameter(_self).swiftGlue() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -134,4 +135,40 @@ fileprivate func _bjs_PlayBridgeJSOutput_wrap(_ pointer: UnsafeMutableRawPointer fileprivate func _bjs_PlayBridgeJSOutput_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } -#endif \ No newline at end of file +#endif + +#if arch(wasm32) +@_extern(wasm, module: "PlayBridgeJS", name: "bjs_createTS2Swift") +fileprivate func bjs_createTS2Swift() -> Int32 +#else +fileprivate func bjs_createTS2Swift() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$createTS2Swift() throws(JSException) -> TS2Swift { + let ret = bjs_createTS2Swift() + if let error = _swift_js_take_exception() { + throw error + } + return TS2Swift.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "PlayBridgeJS", name: "bjs_TS2Swift_convert") +fileprivate func bjs_TS2Swift_convert(_ self: Int32, _ ts: Int32) -> Int32 +#else +fileprivate func bjs_TS2Swift_convert(_ self: Int32, _ ts: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$TS2Swift_convert(_ self: JSObject, _ ts: String) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let tsValue = ts.bridgeJSLowerParameter() + let ret = bjs_TS2Swift_convert(selfValue, tsValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json deleted file mode 100644 index a536a23f..00000000 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "classes" : [ - { - "constructor" : { - "abiName" : "bjs_PlayBridgeJS_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_PlayBridgeJS_update", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "update", - "parameters" : [ - { - "label" : "swiftSource", - "name" : "swiftSource", - "type" : { - "string" : { - - } - } - }, - { - "label" : "dtsSource", - "name" : "dtsSource", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "PlayBridgeJSOutput" - } - } - } - ], - "name" : "PlayBridgeJS", - "properties" : [ - - ], - "swiftCallName" : "PlayBridgeJS" - }, - { - "methods" : [ - { - "abiName" : "bjs_PlayBridgeJSOutput_outputJs", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "outputJs", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_PlayBridgeJSOutput_outputDts", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "outputDts", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_PlayBridgeJSOutput_importSwiftGlue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "importSwiftGlue", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_PlayBridgeJSOutput_exportSwiftGlue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "exportSwiftGlue", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "PlayBridgeJSOutput", - "properties" : [ - - ], - "swiftCallName" : "PlayBridgeJSOutput" - } - ], - "enums" : [ - - ], - "exposeToGlobal" : false, - "functions" : [ - - ], - "moduleName" : "PlayBridgeJS", - "protocols" : [ - - ], - "structs" : [ - - ] -} \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ImportTS.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ImportTS.json deleted file mode 100644 index f1a567cd..00000000 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ImportTS.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "children" : [ - { - "functions" : [ - { - "name" : "createTS2Skeleton", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - "_0" : "TS2Skeleton" - } - } - } - ], - "types" : [ - { - "methods" : [ - { - "name" : "convert", - "parameters" : [ - { - "name" : "ts", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "TS2Skeleton", - "properties" : [ - - ] - } - ] - } - ], - "moduleName" : "PlayBridgeJS" -} \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json new file mode 100644 index 00000000..1cf8e64c --- /dev/null +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,209 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_PlayBridgeJS_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_PlayBridgeJS_update", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "update", + "parameters" : [ + { + "label" : "swiftSource", + "name" : "swiftSource", + "type" : { + "string" : { + + } + } + }, + { + "label" : "dtsSource", + "name" : "dtsSource", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "PlayBridgeJSOutput" + } + } + } + ], + "name" : "PlayBridgeJS", + "properties" : [ + + ], + "swiftCallName" : "PlayBridgeJS" + }, + { + "methods" : [ + { + "abiName" : "bjs_PlayBridgeJSOutput_outputJs", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "outputJs", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_PlayBridgeJSOutput_outputDts", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "outputDts", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_PlayBridgeJSOutput_importSwiftMacroDecls", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "importSwiftMacroDecls", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_PlayBridgeJSOutput_swiftGlue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "swiftGlue", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "PlayBridgeJSOutput", + "properties" : [ + + ], + "swiftCallName" : "PlayBridgeJSOutput" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + { + "name" : "createTS2Swift", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + "_0" : "TS2Swift" + } + } + } + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + { + "name" : "convert", + "parameters" : [ + { + "name" : "ts", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "TS2Swift", + "setters" : [ + + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + + ] + } + ] + }, + "moduleName" : "PlayBridgeJS" +} \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/bridge-js.d.ts b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/bridge-js.d.ts index 44e79a5c..7173fab8 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/bridge-js.d.ts +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/bridge-js.d.ts @@ -1,5 +1,5 @@ -export interface TS2Skeleton { +export interface TS2Swift { convert(ts: string): string; } -export function createTS2Skeleton(): TS2Skeleton; \ No newline at end of file +export function createTS2Swift(): TS2Swift; \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift index 52cb0cc2..e7f70311 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/main.swift @@ -17,38 +17,31 @@ import class Foundation.JSONDecoder } func _update(swiftSource: String, dtsSource: String) throws -> PlayBridgeJSOutput { - let exportSwift = ExportSwift(progress: .silent, moduleName: "Playground", exposeToGlobal: false) + let moduleName = "Playground" + let exportSwift = ExportSwift(progress: .silent, moduleName: moduleName, exposeToGlobal: false) let sourceFile = Parser.parse(source: swiftSource) try exportSwift.addSourceFile(sourceFile, "Playground.swift") let exportResult = try exportSwift.finalize() - var importTS = ImportTS(progress: .silent, moduleName: "Playground") - let ts2skeleton = try createTS2Skeleton() - let skeletonJSONString = try ts2skeleton.convert(dtsSource) - let decoder = JSONDecoder() - let importSkeleton = try decoder.decode( - ImportedFileSkeleton.self, - from: skeletonJSONString.data(using: .utf8)! - ) - importTS.addSkeleton(importSkeleton) - let importSwiftGlue = try importTS.finalize() - - let linker = BridgeJSLink( - exportedSkeletons: exportResult.map { [$0.outputSkeleton] } ?? [], - importedSkeletons: [ - ImportedModuleSkeleton( - moduleName: "Playground", - children: [importSkeleton] - ) - ], - sharedMemory: false + let ts2swift = try createTS2Swift() + let importSwiftMacroDecls = try ts2swift.convert(dtsSource) + let importSwift = ImportSwiftMacros(progress: .silent, moduleName: moduleName) + let importSourceFile = Parser.parse(source: importSwiftMacroDecls) + importSwift.addSourceFile(importSourceFile, "Playground.Macros.swift") + importSwift.addSourceFile(sourceFile, "Playground.swift") + let importResult = try importSwift.finalize() + let skeleton = BridgeJSSkeleton( + moduleName: moduleName, + exported: exportResult.map { $0.outputSkeleton }, + imported: importResult.outputSkeleton ) + let linker = BridgeJSLink(skeletons: [skeleton], sharedMemory: false) let linked = try linker.link() return PlayBridgeJSOutput( outputJs: linked.outputJs, outputDts: linked.outputDts, - importSwiftGlue: importSwiftGlue ?? "", - exportSwiftGlue: exportResult?.outputSwift ?? "" + importSwiftMacroDecls: importSwiftMacroDecls, + swiftGlue: (importResult.outputSwift ?? "") + "\n\n" + (exportResult?.outputSwift ?? "") ) } } @@ -56,18 +49,18 @@ import class Foundation.JSONDecoder @JS class PlayBridgeJSOutput { let _outputJs: String let _outputDts: String - let _importSwiftGlue: String - let _exportSwiftGlue: String + let _importSwiftMacroDecls: String + let _swiftGlue: String - init(outputJs: String, outputDts: String, importSwiftGlue: String, exportSwiftGlue: String) { + init(outputJs: String, outputDts: String, importSwiftMacroDecls: String, swiftGlue: String) { self._outputJs = outputJs self._outputDts = outputDts - self._importSwiftGlue = importSwiftGlue - self._exportSwiftGlue = exportSwiftGlue + self._importSwiftMacroDecls = importSwiftMacroDecls + self._swiftGlue = swiftGlue } @JS func outputJs() -> String { self._outputJs } @JS func outputDts() -> String { self._outputDts } - @JS func importSwiftGlue() -> String { self._importSwiftGlue } - @JS func exportSwiftGlue() -> String { self._exportSwiftGlue } + @JS func importSwiftMacroDecls() -> String { self._importSwiftMacroDecls } + @JS func swiftGlue() -> String { self._swiftGlue } } diff --git a/Examples/PlayBridgeJS/index.html b/Examples/PlayBridgeJS/index.html index 799c36a1..1dd07fe2 100644 --- a/Examples/PlayBridgeJS/index.html +++ b/Examples/PlayBridgeJS/index.html @@ -84,15 +84,15 @@

Output

+ - - +
-
-
+
+
-
-
+
+
diff --git a/Package.swift b/Package.swift index 670b4350..62b10a7d 100644 --- a/Package.swift +++ b/Package.swift @@ -42,7 +42,7 @@ let package = Package( targets: [ .target( name: "JavaScriptKit", - dependencies: ["_CJavaScriptKit"], + dependencies: ["_CJavaScriptKit", "BridgeJSMacros"], exclude: useLegacyResourceBundling ? [] : ["Runtime"], resources: useLegacyResourceBundling ? [.copy("Runtime")] : [], cSettings: shouldBuildForEmbedded @@ -59,6 +59,14 @@ let package = Package( ] : []) ), .target(name: "_CJavaScriptKit"), + .macro( + name: "BridgeJSMacros", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ] + ), + .testTarget( name: "JavaScriptKitTests", dependencies: ["JavaScriptKit"], @@ -165,7 +173,7 @@ let package = Package( .product(name: "SwiftBasicFormat", package: "swift-syntax"), .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), ], - exclude: ["TS2Skeleton/JavaScript", "README.md"] + exclude: ["TS2Swift/JavaScript", "README.md"] ), .testTarget( name: "BridgeJSRuntimeTests", diff --git a/Plugins/BridgeJS/Package.swift b/Plugins/BridgeJS/Package.swift index 36b92052..63c74c53 100644 --- a/Plugins/BridgeJS/Package.swift +++ b/Plugins/BridgeJS/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version: 6.0 +import CompilerPluginSupport import PackageDescription let package = Package( @@ -14,11 +15,11 @@ let package = Package( name: "BridgeJSTool", dependencies: [ "BridgeJSCore", - "TS2Skeleton", + "TS2Swift", ] ), .target( - name: "TS2Skeleton", + name: "TS2Swift", dependencies: [ "BridgeJSCore", "BridgeJSSkeleton", @@ -52,9 +53,23 @@ let package = Package( dependencies: [ "BridgeJSCore", "BridgeJSLink", - "TS2Skeleton", + "TS2Swift", ], exclude: ["__Snapshots__", "Inputs", "MultifileInputs"] ), + .macro( + name: "BridgeJSMacros", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ] + ), + .testTarget( + name: "BridgeJSMacrosTests", + dependencies: [ + "BridgeJSMacros", + .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), + ] + ), ] ) diff --git a/Plugins/BridgeJS/README.md b/Plugins/BridgeJS/README.md index f762c294..0cc4ceba 100644 --- a/Plugins/BridgeJS/README.md +++ b/Plugins/BridgeJS/README.md @@ -13,34 +13,39 @@ BridgeJS provides easy interoperability between Swift and JavaScript/TypeScript. 1. **Importing TypeScript APIs into Swift**: Use TypeScript/JavaScript APIs directly from Swift code 2. **Exporting Swift APIs to JavaScript**: Make your Swift APIs available to JavaScript code +The workflow is: +1. `ts2swift` converts TypeScript definitions (`bridge-js.d.ts`) to macro-annotated Swift declarations (`BridgeJS.Macros.swift`) +2. `bridge-js generate` processes both Swift source files (for export) and macro-annotated Swift files (for import) to generate: + - `BridgeJS.swift` (Swift glue code) + - `JavaScript/BridgeJS.json` (a unified skeleton for linking) +3. `bridge-js link` combines module skeletons (`JavaScript/BridgeJS.json`) to produce JavaScript glue code (`bridge-js.js` and `bridge-js.d.ts`) + ## Architecture Diagram ```mermaid graph LR - E1 --> G3[ExportSwift.json] subgraph ModuleA - A.swift --> E1[[bridge-js export]] - B.swift --> E1 - E1 --> G1[ExportSwift.swift] - B1[bridge-js.d.ts]-->I1[[bridge-js import]] - I1 --> G2[ImportTS.swift] + A.swift --> G1[bridge-js generate] + B.swift --> G1 + B1[bridge-js.d.ts] --> T1[[ts2swift]] + T1 --> M1[BridgeJS.Macros.swift] + M1 --> G1 + G1 --> G3[BridgeJS.json] + G1 --> G2[BridgeJS.swift] end - I1 --> G4[ImportTS.json] - E2 --> G7[ExportSwift.json] subgraph ModuleB - C.swift --> E2[[bridge-js export]] - D.swift --> E2 - E2 --> G5[ExportSwift.swift] - B2[bridge-js.d.ts]-->I2[[bridge-js import]] - I2 --> G6[ImportTS.swift] + C.swift --> G4[bridge-js generate] + D.swift --> G4 + B2[bridge-js.d.ts] --> T2[[ts2swift]] + T2 --> M2[BridgeJS.Macros.swift] + M2 --> G4 + G4 --> G5[BridgeJS.swift] + G4 --> G6[BridgeJS.json] end - I2 --> G8[ImportTS.json] G3 --> L1[[bridge-js link]] - G4 --> L1 - G7 --> L1 - G8 --> L1 + G6 --> L1 L1 --> F1[bridge-js.js] L1 --> F2[bridge-js.d.ts] @@ -135,4 +140,4 @@ TBD declare var Foo: FooConstructor; ``` - [ ] Use `externref` once it's widely available -- [ ] Test SwiftObject roundtrip \ No newline at end of file +- [ ] Test SwiftObject roundtrip diff --git a/Plugins/BridgeJS/Sources/BridgeJSBuildPlugin/BridgeJSBuildPlugin.swift b/Plugins/BridgeJS/Sources/BridgeJSBuildPlugin/BridgeJSBuildPlugin.swift index 47487bfc..aec9f3bc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSBuildPlugin/BridgeJSBuildPlugin.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSBuildPlugin/BridgeJSBuildPlugin.swift @@ -11,95 +11,58 @@ struct BridgeJSBuildPlugin: BuildToolPlugin { guard let swiftSourceModuleTarget = target as? SwiftSourceModuleTarget else { return [] } - var commands: [Command] = [] - commands.append(try createExportSwiftCommand(context: context, target: swiftSourceModuleTarget)) - if let importCommand = try createImportTSCommand(context: context, target: swiftSourceModuleTarget) { - commands.append(importCommand) - } - return commands + return [try createGenerateCommand(context: context, target: swiftSourceModuleTarget)] } private func pathToConfigFile(target: SwiftSourceModuleTarget) -> URL { return target.directoryURL.appending(path: "bridge-js.config.json") } - private func createExportSwiftCommand(context: PluginContext, target: SwiftSourceModuleTarget) throws -> Command { - let outputSwiftPath = context.pluginWorkDirectoryURL.appending(path: "BridgeJS.ExportSwift.swift") - let outputSkeletonPath = context.pluginWorkDirectoryURL.appending(path: "BridgeJS.ExportSwift.json") + private func createGenerateCommand(context: PluginContext, target: SwiftSourceModuleTarget) throws -> Command { + let outputSwiftPath = context.pluginWorkDirectoryURL.appending(path: "BridgeJS.swift") + let inputSwiftFiles = target.sourceFiles.filter { !$0.url.path.hasPrefix(context.pluginWorkDirectoryURL.path + "/") } .map(\.url) + let configFile = pathToConfigFile(target: target) - let inputFiles: [URL] + var inputFiles: [URL] = inputSwiftFiles if FileManager.default.fileExists(atPath: configFile.path) { - inputFiles = inputSwiftFiles + [configFile] - } else { - inputFiles = inputSwiftFiles + inputFiles.append(configFile) } - return .buildCommand( - displayName: "Export Swift API", - executable: try context.tool(named: "BridgeJSTool").url, - arguments: [ - "export", - "--module-name", - target.name, - "--target-dir", - target.directoryURL.path, - "--output-skeleton", - outputSkeletonPath.path, - "--output-swift", - outputSwiftPath.path, - // Generate the output files even if nothing is exported not to surprise - // the build system. - "--always-write", "true", - ] + inputSwiftFiles.map(\.path), - inputFiles: inputFiles, - outputFiles: [ - outputSwiftPath - ] - ) - } - private func createImportTSCommand(context: PluginContext, target: SwiftSourceModuleTarget) throws -> Command? { - let outputSwiftPath = context.pluginWorkDirectoryURL.appending(path: "BridgeJS.ImportTS.swift") - let outputSkeletonPath = context.pluginWorkDirectoryURL.appending(path: "BridgeJS.ImportTS.json") let inputTSFile = target.directoryURL.appending(path: "bridge-js.d.ts") - guard FileManager.default.fileExists(atPath: inputTSFile.path) else { - return nil - } + let tsconfigPath = context.package.directoryURL.appending(path: "tsconfig.json") - let configFile = pathToConfigFile(target: target) - let inputFiles: [URL] - if FileManager.default.fileExists(atPath: configFile.path) { - inputFiles = [inputTSFile, configFile] - } else { - inputFiles = [inputTSFile] + var arguments: [String] = [ + "generate", + "--module-name", + target.name, + "--target-dir", + target.directoryURL.path, + "--output-dir", + context.pluginWorkDirectoryURL.path, + "--always-write", "true", + ] + + if FileManager.default.fileExists(atPath: inputTSFile.path) { + // Add .d.ts file and tsconfig.json as inputs + inputFiles.append(contentsOf: [inputTSFile, tsconfigPath]) + arguments.append(contentsOf: [ + "--project", + tsconfigPath.path, + ]) } + + arguments.append(contentsOf: inputSwiftFiles.map(\.path)) + return .buildCommand( - displayName: "Import TypeScript API", + displayName: "Generate BridgeJS code", executable: try context.tool(named: "BridgeJSTool").url, - arguments: [ - "import", - "--target-dir", - target.directoryURL.path, - "--output-skeleton", - outputSkeletonPath.path, - "--output-swift", - outputSwiftPath.path, - "--module-name", - target.name, - // Generate the output files even if nothing is imported not to surprise - // the build system. - "--always-write", "true", - "--project", - context.package.directoryURL.appending(path: "tsconfig.json").path, - inputTSFile.path, - ], + arguments: arguments, inputFiles: inputFiles, - outputFiles: [ - outputSwiftPath - ] + outputFiles: [outputSwiftPath] ) } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCommandPlugin/BridgeJSCommandPlugin.swift b/Plugins/BridgeJS/Sources/BridgeJSCommandPlugin/BridgeJSCommandPlugin.swift index 26a0d0ef..3dce6257 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCommandPlugin/BridgeJSCommandPlugin.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCommandPlugin/BridgeJSCommandPlugin.swift @@ -97,54 +97,41 @@ extension BridgeJSCommandPlugin.Context { ) throws { printStderr("Generating bridge code for \(target.name)...") - printVerbose("Exporting Swift API for \(target.name)...") - let generatedDirectory = target.directoryURL.appending(path: "Generated") let generatedJavaScriptDirectory = generatedDirectory.appending(path: "JavaScript") - try runBridgeJSTool( - arguments: [ - "export", - "--module-name", - target.name, - "--target-dir", - target.directoryURL.path, - "--output-skeleton", - generatedJavaScriptDirectory.appending(path: "BridgeJS.ExportSwift.json").path, - "--output-swift", - generatedDirectory.appending(path: "BridgeJS.ExportSwift.swift").path, - "--verbose", - options.verbose ? "true" : "false", - ] - + target.sourceFiles.filter { - !$0.url.path.hasPrefix(generatedDirectory.path + "/") - }.map(\.url.path) + remainingArguments - ) - - printVerbose("Importing TypeScript API for \(target.name)...") - let bridgeDtsPath = target.directoryURL.appending(path: "bridge-js.d.ts") - // Execute import only if bridge-js.d.ts exists + let tsconfigPath = context.package.directoryURL.appending(path: "tsconfig.json") + + // Unified generate command + var generateArguments: [String] = [ + "generate", + "--module-name", + target.name, + "--target-dir", + target.directoryURL.path, + "--output-dir", + generatedDirectory.path, + "--verbose", + options.verbose ? "true" : "false", + ] + if FileManager.default.fileExists(atPath: bridgeDtsPath.path) { - try runBridgeJSTool( - arguments: [ - "import", - "--target-dir", - target.directoryURL.path, - "--output-skeleton", - generatedJavaScriptDirectory.appending(path: "BridgeJS.ImportTS.json").path, - "--output-swift", - generatedDirectory.appending(path: "BridgeJS.ImportTS.swift").path, - "--verbose", - options.verbose ? "true" : "false", - "--module-name", - target.name, - "--project", - context.package.directoryURL.appending(path: "tsconfig.json").path, - bridgeDtsPath.path, - ] + remainingArguments - ) + generateArguments.append(contentsOf: [ + "--project", + tsconfigPath.path, + bridgeDtsPath.path, + ]) } + + generateArguments.append( + contentsOf: target.sourceFiles.filter { + !$0.url.path.hasPrefix(generatedDirectory.path + "/") + }.map(\.url.path) + ) + generateArguments.append(contentsOf: remainingArguments) + + try runBridgeJSTool(arguments: generateArguments) } private func runBridgeJSTool(arguments: [String]) throws { diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index e20bb6ab..b9b9e063 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -81,7 +81,6 @@ public class ExportSwift { return ( outputSwift: outputSwift, outputSkeleton: ExportedSkeleton( - moduleName: moduleName, functions: exportedFunctions, classes: exportedClasses, enums: exportedEnums, @@ -1659,16 +1658,6 @@ public class ExportSwift { return .swiftHeapObject(swiftCallName) } - static let prelude: DeclSyntax = """ - // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, - // DO NOT EDIT. - // - // To update this file, just rebuild your project or run - // `swift package bridge-js`. - - @_spi(BridgeJS) import JavaScriptKit - """ - func renderSwiftGlue() throws -> String? { var decls: [DeclSyntax] = [] guard @@ -1677,7 +1666,6 @@ public class ExportSwift { else { return nil } - decls.append(Self.prelude) let closureCodegen = ClosureCodegen() var closureSignatures: Set = [] diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportSwiftMacros.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportSwiftMacros.swift new file mode 100644 index 00000000..b4c5820d --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportSwiftMacros.swift @@ -0,0 +1,711 @@ +import SwiftSyntax +#if canImport(BridgeJSSkeleton) +import BridgeJSSkeleton +#endif +#if canImport(BridgeJSUtilities) +import BridgeJSUtilities +#endif + +/// Collects macro-annotated Swift declarations and produces ImportedModuleSkeleton. +public final class ImportSwiftMacros { + let progress: ProgressReporting + let moduleName: String + private var sourceFiles: [(sourceFile: SourceFileSyntax, inputFilePath: String)] = [] + + public init(progress: ProgressReporting, moduleName: String) { + self.progress = progress + self.moduleName = moduleName + } + + /// Processes a Swift source file to find declarations marked with @JSFunction/@JSGetter/@JSSetter/@JSClass + /// + /// - Parameters: + /// - sourceFile: The parsed Swift source file to process + /// - inputFilePath: The file path for error reporting + public func addSourceFile(_ sourceFile: SourceFileSyntax, _ inputFilePath: String) { + sourceFiles.append((sourceFile, inputFilePath)) + } + + /// Finalizes the import process and generates the bridge code plus skeleton. + public func finalize() throws -> (outputSwift: String?, outputSkeleton: ImportedModuleSkeleton) { + var perSourceErrors: [(inputFilePath: String, errors: [DiagnosticError])] = [] + var importedFiles: [ImportedFileSkeleton] = [] + + for (sourceFile, inputFilePath) in sourceFiles { + progress.print("Processing \(inputFilePath)") + let collector = APICollector( + inputFilePath: inputFilePath, + knownJSClassNames: Self.collectJSClassNames(from: sourceFile) + ) + collector.walk(sourceFile) + if !collector.errors.isEmpty { + perSourceErrors.append((inputFilePath: inputFilePath, errors: collector.errors)) + } + importedFiles.append( + ImportedFileSkeleton( + functions: collector.importedFunctions, + types: collector.importedTypes + ) + ) + } + + if !perSourceErrors.isEmpty { + let allErrors = perSourceErrors.flatMap { inputFilePath, errors in + errors.map { $0.formattedDescription(fileName: inputFilePath) } + } + throw BridgeJSCoreError(allErrors.joined(separator: "\n")) + } + + let moduleSkeleton = ImportedModuleSkeleton(children: importedFiles) + + var importer = ImportTS(progress: progress, moduleName: moduleName) + for skeleton in importedFiles { + importer.addSkeleton(skeleton) + } + let outputSwift = try importer.finalize() + return (outputSwift: outputSwift, outputSkeleton: moduleSkeleton) + } + + private static func collectJSClassNames(from sourceFile: SourceFileSyntax) -> Set { + let collector = JSImportTypeNameCollector(viewMode: .sourceAccurate) + collector.walk(sourceFile) + return collector.typeNames + } + + private final class JSImportTypeNameCollector: SyntaxAnyVisitor { + var typeNames: Set = [] + + private func visitTypeDecl(_ attributes: AttributeListSyntax?, _ name: String) -> SyntaxVisitorContinueKind { + if APICollector.AttributeChecker.hasJSClassAttribute(attributes) { + typeNames.insert(name) + } + return .visitChildren + } + + override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind { + visitTypeDecl(node.attributes, node.name.text) + } + + override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind { + visitTypeDecl(node.attributes, node.name.text) + } + } + + fileprivate final class APICollector: SyntaxAnyVisitor { + var importedFunctions: [ImportedFunctionSkeleton] = [] + var importedTypes: [ImportedTypeSkeleton] = [] + var errors: [DiagnosticError] = [] + + private let inputFilePath: String + private var jsClassNames: Set + + // MARK: - State Management + + enum State { + case topLevel + case jsClassBody(name: String) + } + + private var stateStack: [State] = [.topLevel] + var state: State { + return stateStack.last! + } + + // Current type being collected (when in jsClassBody state) + private struct CurrentType { + let name: String + var constructor: ImportedConstructorSkeleton? + var methods: [ImportedFunctionSkeleton] + var getters: [ImportedGetterSkeleton] + var setters: [ImportedSetterSkeleton] + } + private var currentType: CurrentType? + + // MARK: - Attribute Checking + + /// Helper struct for checking and extracting attributes + fileprivate struct AttributeChecker { + static func hasJSFunctionAttribute(_ attributes: AttributeListSyntax?) -> Bool { + hasAttribute(attributes, name: "JSFunction") + } + + static func hasJSGetterAttribute(_ attributes: AttributeListSyntax?) -> Bool { + hasAttribute(attributes, name: "JSGetter") + } + + static func hasJSSetterAttribute(_ attributes: AttributeListSyntax?) -> Bool { + hasAttribute(attributes, name: "JSSetter") + } + + static func firstJSSetterAttribute(_ attributes: AttributeListSyntax?) -> AttributeSyntax? { + attributes?.first { attribute in + attribute.as(AttributeSyntax.self)?.attributeName.trimmedDescription == "JSSetter" + }?.as(AttributeSyntax.self) + } + + static func hasJSClassAttribute(_ attributes: AttributeListSyntax?) -> Bool { + hasAttribute(attributes, name: "JSClass") + } + + static func hasAttribute(_ attributes: AttributeListSyntax?, name: String) -> Bool { + guard let attributes else { return false } + return attributes.contains { attribute in + guard let syntax = attribute.as(AttributeSyntax.self) else { return false } + return syntax.attributeName.trimmedDescription == name + } + } + + /// Extracts the jsName argument value from a @JSSetter attribute, if present. + static func extractJSName(from attribute: AttributeSyntax) -> String? { + guard let arguments = attribute.arguments?.as(LabeledExprListSyntax.self) else { + return nil + } + for argument in arguments { + if argument.label?.text == "jsName", + let stringLiteral = argument.expression.as(StringLiteralExprSyntax.self), + let segment = stringLiteral.segments.first?.as(StringSegmentSyntax.self) + { + return segment.content.text + } + } + return nil + } + } + + // MARK: - Validation Helpers + + /// Common validation result for setter functions + private struct SetterValidationResult { + let effects: Effects + let jsName: String? + let firstParam: FunctionParameterSyntax + let valueType: BridgeType + } + + /// Validates effects (throws required, async not supported) + private func validateEffects( + _ effects: FunctionEffectSpecifiersSyntax?, + node: some SyntaxProtocol, + attributeName: String + ) -> Effects? { + guard let effects = parseEffects(effects) else { + errors.append( + DiagnosticError( + node: node, + message: "@\(attributeName) declarations must be throws.", + hint: "Declare the function as 'throws (JSException)'." + ) + ) + return nil + } + if effects.isAsync { + errors.append( + DiagnosticError( + node: node, + message: "@\(attributeName) declarations do not support async yet." + ) + ) + return nil + } + return effects + } + + /// Validates a setter function and extracts common information + private func validateSetter( + _ node: FunctionDeclSyntax, + jsSetter: AttributeSyntax, + enclosingTypeName: String? + ) -> SetterValidationResult? { + guard let effects = validateEffects(node.signature.effectSpecifiers, node: node, attributeName: "JSSetter") + else { + return nil + } + + let jsName = AttributeChecker.extractJSName(from: jsSetter) + let parameters = node.signature.parameterClause.parameters + + guard let firstParam = parameters.first else { + errors.append( + DiagnosticError( + node: node, + message: "@JSSetter function must have at least one parameter." + ) + ) + return nil + } + + if firstParam.type.is(MissingTypeSyntax.self) { + errors.append( + DiagnosticError( + node: firstParam, + message: "All @JSSetter parameters must have explicit types." + ) + ) + return nil + } + + return SetterValidationResult( + effects: effects, + jsName: jsName, + firstParam: firstParam, + valueType: parseType(firstParam.type, enclosingTypeName: enclosingTypeName) + ) + } + + // MARK: - Property Name Resolution + + /// Helper for resolving property names from setter function names and jsName attributes + private struct PropertyNameResolver { + /// Resolves property name and function base name from a setter function and optional jsName + /// - Returns: (propertyName, functionBaseName) where propertyName preserves case for getter matching, + /// and functionBaseName has lowercase first char for ABI generation + static func resolve( + functionName: String, + jsName: String?, + normalizeIdentifier: (String) -> String + ) -> (propertyName: String, functionBaseName: String)? { + if let jsName = jsName { + let propertyName = normalizeIdentifier(jsName) + let functionBaseName = propertyName.prefix(1).lowercased() + propertyName.dropFirst() + return (propertyName: propertyName, functionBaseName: functionBaseName) + } + + let rawFunctionName = + functionName.hasPrefix("`") && functionName.hasSuffix("`") && functionName.count > 2 + ? String(functionName.dropFirst().dropLast()) + : functionName + + guard rawFunctionName.hasPrefix("set"), rawFunctionName.count > 3 else { + return nil + } + + let derivedPropertyName = String(rawFunctionName.dropFirst(3)) + let normalized = normalizeIdentifier(derivedPropertyName) + let propertyName = normalized.prefix(1).lowercased() + normalized.dropFirst() + return (propertyName: propertyName, functionBaseName: propertyName) + } + } + + init(inputFilePath: String, knownJSClassNames: Set) { + self.inputFilePath = inputFilePath + self.jsClassNames = knownJSClassNames + super.init(viewMode: .sourceAccurate) + } + + private func enterJSClass(_ typeName: String) { + stateStack.append(.jsClassBody(name: typeName)) + currentType = CurrentType(name: typeName, constructor: nil, methods: [], getters: [], setters: []) + } + + private func exitJSClass() { + if case .jsClassBody(let typeName) = state, let type = currentType, type.name == typeName { + importedTypes.append( + ImportedTypeSkeleton( + name: type.name, + constructor: type.constructor, + methods: type.methods, + getters: type.getters, + setters: type.setters, + documentation: nil + ) + ) + currentType = nil + } + stateStack.removeLast() + } + + override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind { + if AttributeChecker.hasJSClassAttribute(node.attributes) { + enterJSClass(node.name.text) + } + return .visitChildren + } + + override func visitPost(_ node: StructDeclSyntax) { + if AttributeChecker.hasJSClassAttribute(node.attributes) { + exitJSClass() + } + } + + override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind { + if AttributeChecker.hasJSClassAttribute(node.attributes) { + enterJSClass(node.name.text) + } + return .visitChildren + } + + override func visitPost(_ node: ClassDeclSyntax) { + if AttributeChecker.hasJSClassAttribute(node.attributes) { + exitJSClass() + } + } + + // MARK: - Visitor Methods + + override func visit(_ node: ExtensionDeclSyntax) -> SyntaxVisitorContinueKind { + let typeName = node.extendedType.trimmedDescription + collectStaticMembers(in: node.memberBlock.members, typeName: typeName) + return .skipChildren + } + + override func visit(_ node: FunctionDeclSyntax) -> SyntaxVisitorContinueKind { + switch state { + case .topLevel: + return handleTopLevelFunction(node) + + case .jsClassBody(let typeName): + guard var type = currentType, type.name == typeName else { + return .skipChildren + } + let isStaticMember = isStatic(node.modifiers) + let handled = handleClassFunction(node, typeName: typeName, isStaticMember: isStaticMember, type: &type) + if handled { + currentType = type + } + return .skipChildren + } + } + + private func handleTopLevelFunction(_ node: FunctionDeclSyntax) -> SyntaxVisitorContinueKind { + if AttributeChecker.hasJSFunctionAttribute(node.attributes), + let function = parseFunction(node, enclosingTypeName: nil, isStaticMember: true) + { + importedFunctions.append(function) + return .skipChildren + } + // Top-level setters are not supported + if AttributeChecker.hasJSSetterAttribute(node.attributes) { + errors.append( + DiagnosticError( + node: node, + message: "@JSSetter is not supported at top-level. Use it only in @JSClass types." + ) + ) + return .skipChildren + } + return .visitChildren + } + + private func handleClassFunction( + _ node: FunctionDeclSyntax, + typeName: String, + isStaticMember: Bool, + type: inout CurrentType + ) -> Bool { + if AttributeChecker.hasJSFunctionAttribute(node.attributes) { + if isStaticMember { + parseFunction(node, enclosingTypeName: typeName, isStaticMember: true).map { + importedFunctions.append($0) + } + } else { + parseFunction(node, enclosingTypeName: typeName, isStaticMember: false).map { + type.methods.append($0) + } + } + return true + } + + if AttributeChecker.hasJSSetterAttribute(node.attributes) { + if isStaticMember { + errors.append( + DiagnosticError( + node: node, + message: + "@JSSetter is not supported for static members. Use it only for instance members in @JSClass types." + ) + ) + } else if let jsSetter = AttributeChecker.firstJSSetterAttribute(node.attributes), + let setter = parseSetterSkeleton(jsSetter, node, enclosingTypeName: typeName) + { + type.setters.append(setter) + } + return true + } + + return false + } + + override func visit(_ node: VariableDeclSyntax) -> SyntaxVisitorContinueKind { + guard AttributeChecker.hasJSGetterAttribute(node.attributes) else { + return .visitChildren + } + + switch state { + case .topLevel: + errors.append( + DiagnosticError( + node: node, + message: "@JSGetter is not supported at top-level. Use it only in @JSClass types." + ) + ) + return .skipChildren + + case .jsClassBody(let typeName): + guard var type = currentType, type.name == typeName else { + return .skipChildren + } + if isStatic(node.modifiers) { + errors.append( + DiagnosticError( + node: node, + message: + "@JSGetter is not supported for static members. Use it only for instance members in @JSClass types." + ) + ) + } else if let getter = parseGetterSkeleton(node, enclosingTypeName: typeName) { + type.getters.append(getter) + currentType = type + } + return .skipChildren + } + } + + override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind { + guard AttributeChecker.hasJSFunctionAttribute(node.attributes) else { + return .visitChildren + } + + switch state { + case .topLevel: + return .visitChildren + + case .jsClassBody(let typeName): + guard var type = currentType, type.name == typeName else { + return .skipChildren + } + if type.constructor != nil { + errors.append( + DiagnosticError( + node: node, + message: "Only one @JSFunction initializer is supported in @JSClass types." + ) + ) + return .skipChildren + } + if let parsed = parseConstructor(node, typeName: typeName) { + type.constructor = parsed + currentType = type + } + return .skipChildren + } + } + + // MARK: - Member Collection + + private func collectStaticMembers(in members: MemberBlockItemListSyntax, typeName: String) { + for member in members { + if let function = member.decl.as(FunctionDeclSyntax.self) { + if AttributeChecker.hasJSFunctionAttribute(function.attributes), + let parsed = parseFunction(function, enclosingTypeName: typeName, isStaticMember: true) + { + importedFunctions.append(parsed) + } else if AttributeChecker.hasJSSetterAttribute(function.attributes) { + errors.append( + DiagnosticError( + node: function, + message: + "@JSSetter is not supported for static members. Use it only for instance members in @JSClass types." + ) + ) + } + } else if let variable = member.decl.as(VariableDeclSyntax.self), + AttributeChecker.hasJSGetterAttribute(variable.attributes) + { + errors.append( + DiagnosticError( + node: variable, + message: + "@JSGetter is not supported for static members. Use it only for instance members in @JSClass types." + ) + ) + } + } + } + + // MARK: - Parsing Methods + + private func parseConstructor( + _ initializer: InitializerDeclSyntax, + typeName: String + ) -> ImportedConstructorSkeleton? { + guard + validateEffects(initializer.signature.effectSpecifiers, node: initializer, attributeName: "JSFunction") + != nil + else { + return nil + } + return ImportedConstructorSkeleton( + parameters: parseParameters( + from: initializer.signature.parameterClause, + enclosingTypeName: typeName + ) + ) + } + + private func parseFunction( + _ node: FunctionDeclSyntax, + enclosingTypeName: String?, + isStaticMember: Bool + ) -> ImportedFunctionSkeleton? { + guard validateEffects(node.signature.effectSpecifiers, node: node, attributeName: "JSFunction") != nil + else { + return nil + } + + let baseName = normalizeIdentifier(node.name.text) + let name: String + if isStaticMember, let enclosingTypeName { + name = "\(enclosingTypeName)_\(baseName)" + } else { + name = baseName + } + + let parameters = parseParameters( + from: node.signature.parameterClause, + enclosingTypeName: enclosingTypeName + ) + let returnType: BridgeType + if let returnTypeSyntax = node.signature.returnClause?.type { + returnType = parseType(returnTypeSyntax, enclosingTypeName: enclosingTypeName) + } else { + returnType = .void + } + return ImportedFunctionSkeleton( + name: name, + parameters: parameters, + returnType: returnType, + documentation: nil + ) + } + + /// Extracts property info from a VariableDeclSyntax (binding, identifier, type) + private func extractPropertyInfo( + _ node: VariableDeclSyntax, + errorMessage: String = "@JSGetter must declare a single stored property with an explicit type." + ) -> (identifier: IdentifierPatternSyntax, type: TypeSyntax)? { + guard let binding = node.bindings.first, + let identifier = binding.pattern.as(IdentifierPatternSyntax.self), + let typeAnnotation = binding.typeAnnotation + else { + errors.append(DiagnosticError(node: node, message: errorMessage)) + return nil + } + return (identifier, typeAnnotation.type) + } + + private func parseGetterSkeleton( + _ node: VariableDeclSyntax, + enclosingTypeName: String? + ) -> ImportedGetterSkeleton? { + guard let (identifier, type) = extractPropertyInfo(node) else { + return nil + } + let propertyType = parseType(type, enclosingTypeName: enclosingTypeName) + let propertyName = normalizeIdentifier(identifier.identifier.text) + return ImportedGetterSkeleton( + name: propertyName, + type: propertyType, + documentation: nil, + functionName: nil + ) + } + + /// Parses a setter as part of a type's property system (for instance setters) + private func parseSetterSkeleton( + _ jsSetter: AttributeSyntax, + _ node: FunctionDeclSyntax, + enclosingTypeName: String? + ) -> ImportedSetterSkeleton? { + guard let validation = validateSetter(node, jsSetter: jsSetter, enclosingTypeName: enclosingTypeName) else { + return nil + } + + let functionName = node.name.text + guard + let (propertyName, functionBaseName) = PropertyNameResolver.resolve( + functionName: functionName, + jsName: validation.jsName, + normalizeIdentifier: normalizeIdentifier + ) + else { + return nil + } + + return ImportedSetterSkeleton( + name: propertyName, + type: validation.valueType, + documentation: nil, + functionName: "\(functionBaseName)_set" + ) + } + + // MARK: - Type and Parameter Parsing + + private func parseParameters( + from clause: FunctionParameterClauseSyntax, + enclosingTypeName: String? + ) -> [Parameter] { + clause.parameters.compactMap { param in + let type = param.type + if type.is(MissingTypeSyntax.self) { + errors.append( + DiagnosticError( + node: param, + message: "All @JSFunction parameters must have explicit types." + ) + ) + return nil + } + let nameToken = param.secondName ?? param.firstName + let name = normalizeIdentifier(nameToken.text) + let labelToken = param.secondName == nil ? nil : param.firstName + let label = labelToken?.text == "_" ? nil : labelToken?.text + let bridgeType = parseType(type, enclosingTypeName: enclosingTypeName) + return Parameter(label: label, name: name, type: bridgeType) + } + } + + private func parseType(_ type: TypeSyntax, enclosingTypeName: String?) -> BridgeType { + guard let identifier = type.as(IdentifierTypeSyntax.self) else { + errors.append( + DiagnosticError( + node: type, + message: "Unsupported @JS type '\(type.trimmedDescription)'." + ) + ) + return .void + } + + let name = normalizeIdentifier(identifier.name.text) + if name == "Self", let enclosingTypeName { + return .jsObject(enclosingTypeName) + } + return BridgeType(swiftType: name) ?? .jsObject(name) + } + + // MARK: - Helper Methods + + private func parseEffects(_ effects: FunctionEffectSpecifiersSyntax?) -> Effects? { + let isThrows = effects?.throwsClause != nil + let isAsync = effects?.asyncSpecifier != nil + guard isThrows else { + return nil + } + return Effects(isAsync: isAsync, isThrows: isThrows) + } + + private func isStatic(_ modifiers: DeclModifierListSyntax?) -> Bool { + guard let modifiers else { return false } + return modifiers.contains { modifier in + modifier.name.tokenKind == .keyword(.static) || modifier.name.tokenKind == .keyword(.class) + } + } + + private func normalizeIdentifier(_ name: String) -> String { + guard name.hasPrefix("`"), name.hasSuffix("`"), name.count >= 2 else { + return name + } + return String(name.dropFirst().dropLast()) + } + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index e4f6c89b..402e6e67 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -19,13 +19,12 @@ import BridgeJSUtilities public struct ImportTS { public let progress: ProgressReporting public private(set) var skeleton: ImportedModuleSkeleton - private var moduleName: String { - skeleton.moduleName - } + private let moduleName: String public init(progress: ProgressReporting, moduleName: String) { self.progress = progress - self.skeleton = ImportedModuleSkeleton(moduleName: moduleName, children: []) + self.moduleName = moduleName + self.skeleton = ImportedModuleSkeleton(children: []) } /// Adds a skeleton to the importer's state @@ -52,8 +51,7 @@ public struct ImportTS { } let format = BasicFormat() - let allDecls: [DeclSyntax] = [Self.prelude] + decls - return allDecls.map { $0.formatted(using: format).description }.joined(separator: "\n\n") + return decls.map { $0.formatted(using: format).description }.joined(separator: "\n\n") } class CallJSEmission { @@ -302,15 +300,27 @@ public struct ImportTS { } } - static let prelude: DeclSyntax = """ - // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, - // DO NOT EDIT. - // - // To update this file, just rebuild your project or run - // `swift package bridge-js`. + private static func thunkName(function: ImportedFunctionSkeleton) -> String { + "_$\(function.name)" + } + + private static func thunkName(type: ImportedTypeSkeleton, method: ImportedFunctionSkeleton) -> String { + "_$\(type.name)_\(method.name)" + } - @_spi(BridgeJS) import JavaScriptKit - """ + private static func thunkName(type: ImportedTypeSkeleton) -> String { + "_$\(type.name)_init" + } + + private static func thunkName( + type: ImportedTypeSkeleton, + propertyName: String, + operation: String + ) + -> String + { + "_$\(type.name)_\(propertyName)_\(operation)" + } func renderSwiftThunk( _ function: ImportedFunctionSkeleton, @@ -325,7 +335,7 @@ public struct ImportTS { topLevelDecls.append(builder.renderImportDecl()) return [ builder.renderThunkDecl( - name: function.name, + name: Self.thunkName(function: function), parameters: function.parameters, returnType: function.returnType ) @@ -334,11 +344,12 @@ public struct ImportTS { } func renderSwiftType(_ type: ImportedTypeSkeleton, topLevelDecls: inout [DeclSyntax]) throws -> [DeclSyntax] { - let name = type.name + let selfParameter = Parameter(label: nil, name: "self", type: .jsObject(nil)) + var decls: [DeclSyntax] = [] func renderMethod(method: ImportedFunctionSkeleton) throws -> [DeclSyntax] { let builder = CallJSEmission(moduleName: moduleName, abiName: method.abiName(context: type)) - try builder.lowerParameter(param: Parameter(label: nil, name: "self", type: .jsObject(name))) + try builder.lowerParameter(param: selfParameter) for param in method.parameters { try builder.lowerParameter(param: param) } @@ -347,11 +358,10 @@ public struct ImportTS { topLevelDecls.append(builder.renderImportDecl()) return [ builder.renderThunkDecl( - name: method.name, - parameters: method.parameters, + name: Self.thunkName(type: type, method: method), + parameters: [selfParameter] + method.parameters, returnType: method.returnType ) - .with(\.leadingTrivia, Self.renderDocumentation(documentation: method.documentation)) ] } @@ -360,119 +370,78 @@ public struct ImportTS { for param in constructor.parameters { try builder.lowerParameter(param: param) } - try builder.call(returnType: .jsObject(name)) - builder.assignThis(returnType: .jsObject(name)) + try builder.call(returnType: .jsObject(nil)) + try builder.liftReturnValue(returnType: .jsObject(nil)) topLevelDecls.append(builder.renderImportDecl()) return [ - builder.renderConstructorDecl(parameters: constructor.parameters) + builder.renderThunkDecl( + name: Self.thunkName(type: type), + parameters: constructor.parameters, + returnType: .jsObject(nil) + ) ] } - func renderGetterDecl(property: ImportedPropertySkeleton) throws -> AccessorDeclSyntax { + func renderGetterDecl(getter: ImportedGetterSkeleton) throws -> DeclSyntax { let builder = CallJSEmission( moduleName: moduleName, - abiName: property.getterAbiName(context: type) + abiName: getter.abiName(context: type) ) - try builder.lowerParameter(param: Parameter(label: nil, name: "self", type: .jsObject(name))) - try builder.call(returnType: property.type) - try builder.liftReturnValue(returnType: property.type) + try builder.lowerParameter(param: selfParameter) + try builder.call(returnType: getter.type) + try builder.liftReturnValue(returnType: getter.type) topLevelDecls.append(builder.renderImportDecl()) - return AccessorDeclSyntax( - accessorSpecifier: .keyword(.get), - effectSpecifiers: Self.buildAccessorEffect(throws: true, async: false), - body: CodeBlockSyntax { - builder.body - } + return DeclSyntax( + builder.renderThunkDecl( + name: Self.thunkName(type: type, propertyName: getter.name, operation: "get"), + parameters: [selfParameter], + returnType: getter.type + ) ) } - func renderSetterDecl(property: ImportedPropertySkeleton) throws -> DeclSyntax { + func renderSetterDecl(setter: ImportedSetterSkeleton) throws -> DeclSyntax { let builder = CallJSEmission( moduleName: moduleName, - abiName: property.setterAbiName(context: type) + abiName: setter.abiName(context: type) ) - let newValue = Parameter(label: nil, name: "newValue", type: property.type) - try builder.lowerParameter(param: Parameter(label: nil, name: "self", type: .jsObject(name))) + let newValue = Parameter(label: nil, name: "newValue", type: setter.type) + try builder.lowerParameter(param: selfParameter) try builder.lowerParameter(param: newValue) try builder.call(returnType: .void) topLevelDecls.append(builder.renderImportDecl()) + // Use functionName if available (has lowercase first char), otherwise derive from name + let propertyNameForThunk: String + if let functionName = setter.functionName, functionName.hasSuffix("_set") { + // Extract base name from functionName (e.g., "any_set" -> "any") + propertyNameForThunk = String(functionName.dropLast(4)) + } else { + // Lowercase first character of property name for thunk + propertyNameForThunk = setter.name.prefix(1).lowercased() + setter.name.dropFirst() + } return builder.renderThunkDecl( - name: "set\(property.name.capitalizedFirstLetter)", - parameters: [newValue], + name: Self.thunkName(type: type, propertyName: propertyNameForThunk, operation: "set"), + parameters: [selfParameter, newValue], returnType: .void ) } - - func renderPropertyDecl(property: ImportedPropertySkeleton) throws -> [DeclSyntax] { - let accessorDecls: [AccessorDeclSyntax] = [try renderGetterDecl(property: property)] - var decls: [DeclSyntax] = [ - DeclSyntax( - VariableDeclSyntax( - leadingTrivia: Self.renderDocumentation(documentation: property.documentation), - bindingSpecifier: .keyword(.var), - bindingsBuilder: { - PatternBindingListSyntax { - PatternBindingSyntax( - pattern: IdentifierPatternSyntax( - identifier: .identifier(property.name.backtickIfNeeded()) - ), - typeAnnotation: TypeAnnotationSyntax( - type: IdentifierTypeSyntax(name: .identifier(property.type.swiftType)) - ), - accessorBlock: AccessorBlockSyntax( - accessors: .accessors( - AccessorDeclListSyntax(accessorDecls) - ) - ) - ) - } - } - ) - ) - ] - if !property.isReadonly { - decls.append(try renderSetterDecl(property: property)) - } - return decls + if let constructor = type.constructor { + decls.append(contentsOf: try renderConstructorDecl(constructor: constructor)) } - let classDecl = try StructDeclSyntax( - leadingTrivia: Self.renderDocumentation(documentation: type.documentation), - name: .identifier(name), - inheritanceClause: InheritanceClauseSyntax( - inheritedTypesBuilder: { - InheritedTypeSyntax(type: TypeSyntax("_JSBridgedClass")) - } - ), - memberBlockBuilder: { - DeclSyntax( - """ - let jsObject: JSObject - """ - ).with(\.trailingTrivia, .newlines(2)) - - DeclSyntax( - """ - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - """ - ).with(\.trailingTrivia, .newlines(2)) - if let constructor = type.constructor { - try renderConstructorDecl(constructor: constructor).map { $0.with(\.trailingTrivia, .newlines(2)) } - } + for getter in type.getters { + decls.append(try renderGetterDecl(getter: getter)) + } - for property in type.properties { - try renderPropertyDecl(property: property).map { $0.with(\.trailingTrivia, .newlines(2)) } - } + for setter in type.setters { + decls.append(try renderSetterDecl(setter: setter)) + } - for method in type.methods { - try renderMethod(method: method).map { $0.with(\.trailingTrivia, .newlines(2)) } - } - } - ) + for method in type.methods { + decls.append(contentsOf: try renderMethod(method: method)) + } - return [DeclSyntax(classDecl)] + return decls } static func renderDocumentation(documentation: String?) -> Trivia { diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 41b32342..d6103f7d 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -8,30 +8,35 @@ import BridgeJSUtilities #endif struct BridgeJSLink { - /// The exported skeletons - var exportedSkeletons: [ExportedSkeleton] = [] - var importedSkeletons: [ImportedModuleSkeleton] = [] + var skeletons: [BridgeJSSkeleton] = [] let sharedMemory: Bool private let namespaceBuilder = NamespaceBuilder() init( - exportedSkeletons: [ExportedSkeleton] = [], - importedSkeletons: [ImportedModuleSkeleton] = [], + skeletons: [BridgeJSSkeleton] = [], sharedMemory: Bool ) { - self.exportedSkeletons = exportedSkeletons - self.importedSkeletons = importedSkeletons + self.skeletons = skeletons self.sharedMemory = sharedMemory } - mutating func addExportedSkeletonFile(data: Data) throws { - let skeleton = try JSONDecoder().decode(ExportedSkeleton.self, from: data) - exportedSkeletons.append(skeleton) - } - - mutating func addImportedSkeletonFile(data: Data) throws { - let skeletons = try JSONDecoder().decode(ImportedModuleSkeleton.self, from: data) - importedSkeletons.append(skeletons) + mutating func addSkeletonFile(data: Data) throws { + do { + let unified = try JSONDecoder().decode(BridgeJSSkeleton.self, from: data) + skeletons.append(unified) + } catch { + struct SkeletonDecodingError: Error, CustomStringConvertible { + let description: String + } + throw SkeletonDecodingError( + description: """ + Failed to decode skeleton file: \(error) + + This file appears to be in an old format. Please regenerate skeleton files using: + bridge-js generate --module-name --target-dir --output-skeleton ... + """ + ) + } } let swiftHeapObjectClassDts = """ @@ -81,7 +86,7 @@ struct BridgeJSLink { var data = LinkData() // Swift heap object class definitions - if exportedSkeletons.contains(where: { $0.classes.count > 0 }) { + if skeletons.contains(where: { $0.exported?.classes.isEmpty == false }) { data.classLines.append( contentsOf: swiftHeapObjectClassJs.split(separator: "\n", omittingEmptySubsequences: false).map { String($0) @@ -95,7 +100,8 @@ struct BridgeJSLink { } // Process exported skeletons - for skeleton in exportedSkeletons { + for unified in skeletons { + guard let skeleton = unified.exported else { continue } // Process classes for klass in skeleton.classes { let (jsType, dtsType, dtsExportEntry) = try renderExportedClass(klass) @@ -162,9 +168,10 @@ struct BridgeJSLink { } // Process imported skeletons - for skeletonSet in importedSkeletons { - let importObjectBuilder = ImportObjectBuilder(moduleName: skeletonSet.moduleName) - for fileSkeleton in skeletonSet.children { + for unified in skeletons { + guard let imported = unified.imported else { continue } + let importObjectBuilder = ImportObjectBuilder(moduleName: unified.moduleName) + for fileSkeleton in imported.children { for function in fileSkeleton.functions { try renderImportedFunction(importObjectBuilder: importObjectBuilder, function: function) } @@ -175,14 +182,16 @@ struct BridgeJSLink { data.importObjectBuilders.append(importObjectBuilder) } - for skeleton in exportedSkeletons { + for unified in skeletons { + guard let skeleton = unified.exported else { continue } + let moduleName = unified.moduleName if !skeleton.protocols.isEmpty { let importObjectBuilder: ImportObjectBuilder - if let existingBuilder = data.importObjectBuilders.first(where: { $0.moduleName == skeleton.moduleName } + if let existingBuilder = data.importObjectBuilders.first(where: { $0.moduleName == moduleName } ) { importObjectBuilder = existingBuilder } else { - importObjectBuilder = ImportObjectBuilder(moduleName: skeleton.moduleName) + importObjectBuilder = ImportObjectBuilder(moduleName: moduleName) data.importObjectBuilders.append(importObjectBuilder) } @@ -297,7 +306,7 @@ struct BridgeJSLink { "bjs = {};", "importObject[\"bjs\"] = bjs;", ]) - if self.importedSkeletons.count > 0 { + if skeletons.contains(where: { $0.imported != nil }) { printer.write(lines: [ "const imports = options.getImports(importsContext);" ]) @@ -576,14 +585,16 @@ struct BridgeJSLink { } printer.write("}") - for skeleton in exportedSkeletons { + for unified in skeletons { + guard let skeleton = unified.exported else { continue } + let moduleName = unified.moduleName var closureSignatures: Set = [] collectClosureSignatures(from: skeleton, into: &closureSignatures) guard !closureSignatures.isEmpty else { continue } for signature in closureSignatures.sorted(by: { $0.mangleName < $1.mangleName }) { - let invokeFuncName = "invoke_js_callback_\(skeleton.moduleName)_\(signature.mangleName)" + let invokeFuncName = "invoke_js_callback_\(moduleName)_\(signature.mangleName)" printer.write( lines: generateInvokeFunction( signature: signature, @@ -591,7 +602,7 @@ struct BridgeJSLink { ) ) - let lowerFuncName = "lower_closure_\(skeleton.moduleName)_\(signature.mangleName)" + let lowerFuncName = "lower_closure_\(moduleName)_\(signature.mangleName)" printer.write( lines: generateLowerClosureFunction( signature: signature, @@ -779,6 +790,8 @@ struct BridgeJSLink { let printer = CodeFragmentPrinter(header: header) printer.nextLine() + let exportedSkeletons = skeletons.compactMap(\.exported) + for skeleton in exportedSkeletons { for proto in skeleton.protocols { printer.write("export interface \(proto.name) {") @@ -922,6 +935,7 @@ struct BridgeJSLink { printer.write(lines: data.topLevelTypeLines) + let exportedSkeletons = skeletons.compactMap(\.exported) let topLevelNamespaceCode = namespaceBuilder.buildTopLevelNamespaceInitialization( exportedSkeletons: exportedSkeletons ) @@ -1028,7 +1042,7 @@ struct BridgeJSLink { private func enumHelperAssignments() -> CodeFragmentPrinter { let printer = CodeFragmentPrinter() - for skeleton in exportedSkeletons { + for skeleton in skeletons.compactMap(\.exported) { for enumDef in skeleton.enums where enumDef.enumType == .associatedValue { printer.write( "const \(enumDef.name)Helpers = __bjs_create\(enumDef.valuesName)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift));" @@ -1044,7 +1058,7 @@ struct BridgeJSLink { private func structHelperAssignments() -> CodeFragmentPrinter { let printer = CodeFragmentPrinter() - for skeleton in exportedSkeletons { + for skeleton in skeletons.compactMap(\.exported) { for structDef in skeleton.structs { printer.write( "const \(structDef.name)Helpers = __bjs_create\(structDef.name)Helpers()(\(JSGlueVariableScope.reservedTmpParamInts), \(JSGlueVariableScope.reservedTmpParamF32s), \(JSGlueVariableScope.reservedTmpParamF64s), \(JSGlueVariableScope.reservedTmpParamPointers), \(JSGlueVariableScope.reservedTmpRetPointers), \(JSGlueVariableScope.reservedTextEncoder), \(JSGlueVariableScope.reservedSwift), \(JSGlueVariableScope.reservedEnumHelpers));" @@ -1064,13 +1078,15 @@ struct BridgeJSLink { var modulesByName: [String: [ExportedClass]] = [:] // Group classes by their module name - for skeleton in exportedSkeletons { + for unified in skeletons { + guard let skeleton = unified.exported else { continue } if skeleton.classes.isEmpty { continue } + let moduleName = unified.moduleName - if modulesByName[skeleton.moduleName] == nil { - modulesByName[skeleton.moduleName] = [] + if modulesByName[moduleName] == nil { + modulesByName[moduleName] = [] } - modulesByName[skeleton.moduleName]?.append(contentsOf: skeleton.classes) + modulesByName[moduleName]?.append(contentsOf: skeleton.classes) } // Generate wrapper functions for each module @@ -1132,7 +1148,8 @@ struct BridgeJSLink { private func generateImportedTypeDefinitions() -> [String] { let printer = CodeFragmentPrinter() - for skeletonSet in importedSkeletons { + for unified in skeletons { + guard let skeletonSet = unified.imported else { continue } for fileSkeleton in skeletonSet.children { for type in fileSkeleton.types { printer.write("export interface \(type.name) {") @@ -1145,14 +1162,21 @@ struct BridgeJSLink { printer.write(methodSignature) } - // Add properties - for property in type.properties { + // Add properties from getters + var propertyNames = Set() + for getter in type.getters { + propertyNames.insert(getter.name) + let hasSetter = type.setters.contains { $0.name == getter.name } let propertySignature = - property.isReadonly - ? "readonly \(property.name): \(resolveTypeScriptType(property.type));" - : "\(property.name): \(resolveTypeScriptType(property.type));" + hasSetter + ? "\(getter.name): \(resolveTypeScriptType(getter.type));" + : "readonly \(getter.name): \(resolveTypeScriptType(getter.type));" printer.write(propertySignature) } + // Add setters that don't have corresponding getters + for setter in type.setters where !propertyNames.contains(setter.name) { + printer.write("\(setter.name): \(resolveTypeScriptType(setter.type));") + } printer.unindent() printer.write("}") @@ -1279,7 +1303,7 @@ struct BridgeJSLink { /// If the type is an enum, looks up the ExportedEnum and uses its tsFullPath /// Otherwise, uses the default tsType property private func resolveTypeScriptType(_ type: BridgeType) -> String { - return Self.resolveTypeScriptType(type, exportedSkeletons: exportedSkeletons) + return Self.resolveTypeScriptType(type, exportedSkeletons: skeletons.compactMap(\.exported)) } /// Static helper for resolving TypeScript types with full enum paths @@ -2868,34 +2892,34 @@ extension BridgeJSLink { constructor: constructor ) } - for property in type.properties { - let getterAbiName = property.getterAbiName(context: type) - let (js, dts) = try renderImportedProperty( - property: property, + for getter in type.getters { + let getterAbiName = getter.abiName(context: type) + let (js, dts) = try renderImportedGetter( + getter: getter, abiName: getterAbiName, emitCall: { thunkBuilder in - return try thunkBuilder.callPropertyGetter(name: property.name, returnType: property.type) + return try thunkBuilder.callPropertyGetter(name: getter.name, returnType: getter.type) } ) importObjectBuilder.assignToImportObject(name: getterAbiName, function: js) importObjectBuilder.appendDts(dts) + } - if !property.isReadonly { - let setterAbiName = property.setterAbiName(context: type) - let (js, dts) = try renderImportedProperty( - property: property, - abiName: setterAbiName, - emitCall: { thunkBuilder in - try thunkBuilder.liftParameter( - param: Parameter(label: nil, name: "newValue", type: property.type) - ) - thunkBuilder.callPropertySetter(name: property.name, returnType: property.type) - return nil - } - ) - importObjectBuilder.assignToImportObject(name: setterAbiName, function: js) - importObjectBuilder.appendDts(dts) - } + for setter in type.setters { + let setterAbiName = setter.abiName(context: type) + let (js, dts) = try renderImportedSetter( + setter: setter, + abiName: setterAbiName, + emitCall: { thunkBuilder in + try thunkBuilder.liftParameter( + param: Parameter(label: nil, name: "newValue", type: setter.type) + ) + thunkBuilder.callPropertySetter(name: setter.name, returnType: setter.type) + return nil + } + ) + importObjectBuilder.assignToImportObject(name: setterAbiName, function: js) + importObjectBuilder.appendDts(dts) } for method in type.methods { let (js, dts) = try renderImportedMethod(context: type, method: method) @@ -2935,8 +2959,8 @@ extension BridgeJSLink { importObjectBuilder.appendDts(dtsPrinter.lines) } - func renderImportedProperty( - property: ImportedPropertySkeleton, + func renderImportedGetter( + getter: ImportedGetterSkeleton, abiName: String, emitCall: (ImportedThunkBuilder) throws -> String? ) throws -> (js: [String], dts: [String]) { @@ -2946,7 +2970,23 @@ extension BridgeJSLink { let funcLines = thunkBuilder.renderFunction( name: abiName, returnExpr: returnExpr, - returnType: property.type + returnType: getter.type + ) + return (funcLines, []) + } + + func renderImportedSetter( + setter: ImportedSetterSkeleton, + abiName: String, + emitCall: (ImportedThunkBuilder) throws -> String? + ) throws -> (js: [String], dts: [String]) { + let thunkBuilder = ImportedThunkBuilder() + thunkBuilder.liftSelf() + let returnExpr = try emitCall(thunkBuilder) + let funcLines = thunkBuilder.renderFunction( + name: abiName, + returnExpr: returnExpr, + returnType: .void ) return (funcLines, []) } diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift new file mode 100644 index 00000000..9a45fa0f --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/BridgeJSMacrosPlugin.swift @@ -0,0 +1,12 @@ +import SwiftCompilerPlugin +import SwiftSyntaxMacros + +@main +struct BridgeJSMacrosPlugin: CompilerPlugin { + var providingMacros: [Macro.Type] = [ + JSFunctionMacro.self, + JSGetterMacro.self, + JSSetterMacro.self, + JSClassMacro.self, + ] +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift new file mode 100644 index 00000000..fc7af6cd --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift @@ -0,0 +1,51 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +public enum JSClassMacro {} + +extension JSClassMacro: MemberMacro { + public static func expansion( + of node: AttributeSyntax, + providingMembersOf declaration: some DeclGroupSyntax, + in context: some MacroExpansionContext + ) throws -> [DeclSyntax] { + var members: [DeclSyntax] = [] + + let existingMembers = declaration.memberBlock.members + let hasJSObjectProperty = existingMembers.contains { member in + guard let variable = member.decl.as(VariableDeclSyntax.self) else { return false } + return variable.bindings.contains { binding in + binding.pattern.as(IdentifierPatternSyntax.self)?.identifier.text == "jsObject" + } + } + + if !hasJSObjectProperty { + members.append(DeclSyntax("let jsObject: JSObject")) + } + + let hasUnsafelyWrappingInit = existingMembers.contains { member in + guard let initializer = member.decl.as(InitializerDeclSyntax.self) else { return false } + let parameters = initializer.signature.parameterClause.parameters + guard let firstParam = parameters.first else { return false } + let externalName = firstParam.firstName.text + let internalName = firstParam.secondName?.text + return externalName == "unsafelyWrapping" && internalName == "jsObject" + } + + if !hasUnsafelyWrappingInit { + members.append( + DeclSyntax( + """ + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + """ + ) + ) + } + + return members + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift new file mode 100644 index 00000000..7dfd635f --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSFunctionMacro.swift @@ -0,0 +1,72 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +public enum JSFunctionMacro {} + +extension JSFunctionMacro: BodyMacro { + public static func expansion( + of node: AttributeSyntax, + providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax, + in context: some MacroExpansionContext + ) throws -> [CodeBlockItemSyntax] { + if let functionDecl = declaration.as(FunctionDeclSyntax.self) { + let enclosingTypeName = JSMacroHelper.enclosingTypeName(from: context) + let isStatic = JSMacroHelper.isStatic(functionDecl.modifiers) + let isInstanceMember = enclosingTypeName != nil && !isStatic + + // Strip backticks from function name (e.g., "`prefix`" -> "prefix") + // Backticks are only needed for Swift identifiers, not function names + let name = JSMacroHelper.stripBackticks(functionDecl.name.text) + let glueName = JSMacroHelper.glueName(baseName: name, enclosingTypeName: enclosingTypeName) + + var arguments: [String] = [] + if isInstanceMember { + arguments.append("self.jsObject") + } + arguments.append( + contentsOf: JSMacroHelper.parameterNames(functionDecl.signature.parameterClause.parameters) + ) + + let argsJoined = arguments.joined(separator: ", ") + let call = "\(glueName)(\(argsJoined))" + + let effects = functionDecl.signature.effectSpecifiers + let isAsync = effects?.asyncSpecifier != nil + let isThrows = effects?.throwsClause != nil + let prefix = JSMacroHelper.tryAwaitPrefix(isAsync: isAsync, isThrows: isThrows) + + let isVoid = JSMacroHelper.isVoidReturn(functionDecl.signature.returnClause?.type) + let line = isVoid ? "\(prefix)\(call)" : "return \(prefix)\(call)" + return [CodeBlockItemSyntax(stringLiteral: line)] + } + + if let initializerDecl = declaration.as(InitializerDeclSyntax.self) { + guard let enclosingTypeName = JSMacroHelper.enclosingTypeName(from: context) else { + context.diagnose( + Diagnostic(node: Syntax(declaration), message: JSMacroMessage.unsupportedDeclaration) + ) + return [] + } + + let glueName = JSMacroHelper.glueName(baseName: "init", enclosingTypeName: enclosingTypeName) + let parameters = initializerDecl.signature.parameterClause.parameters + let arguments = JSMacroHelper.parameterNames(parameters) + let call = "\(glueName)(\(arguments.joined(separator: ", ")))" + + let effects = initializerDecl.signature.effectSpecifiers + let isAsync = effects?.asyncSpecifier != nil + let isThrows = effects?.throwsClause != nil + let prefix = JSMacroHelper.tryAwaitPrefix(isAsync: isAsync, isThrows: isThrows) + + return [ + CodeBlockItemSyntax(stringLiteral: "let jsObject = \(prefix)\(call)"), + CodeBlockItemSyntax(stringLiteral: "self.init(unsafelyWrapping: jsObject)"), + ] + } + + context.diagnose(Diagnostic(node: Syntax(declaration), message: JSMacroMessage.unsupportedDeclaration)) + return [] + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift new file mode 100644 index 00000000..b996facf --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSGetterMacro.swift @@ -0,0 +1,62 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +public enum JSGetterMacro {} + +extension JSGetterMacro: AccessorMacro { + public static func expansion( + of node: AttributeSyntax, + providingAccessorsOf declaration: some DeclSyntaxProtocol, + in context: some MacroExpansionContext + ) throws -> [AccessorDeclSyntax] { + guard let variableDecl = declaration.as(VariableDeclSyntax.self), + let binding = variableDecl.bindings.first, + let identifier = binding.pattern.as(IdentifierPatternSyntax.self) + else { + context.diagnose(Diagnostic(node: Syntax(declaration), message: JSMacroMessage.unsupportedVariable)) + return [] + } + + let enclosingTypeName = JSMacroHelper.enclosingTypeName(from: context) + let isStatic = JSMacroHelper.isStatic(variableDecl.modifiers) + let isInstanceMember = enclosingTypeName != nil && !isStatic + + // Strip backticks from property name (e.g., "`prefix`" -> "prefix") + // Backticks are only needed for Swift identifiers, not function names + let propertyName = JSMacroHelper.stripBackticks(identifier.identifier.text) + let getterName = JSMacroHelper.glueName( + baseName: propertyName, + enclosingTypeName: enclosingTypeName, + operation: "get" + ) + + var getterArgs: [String] = [] + if isInstanceMember { + getterArgs.append("self.jsObject") + } + let getterCall: CodeBlockItemSyntax = + "return try \(raw: getterName)(\(raw: getterArgs.joined(separator: ", ")))" + + let throwsClause = ThrowsClauseSyntax( + throwsSpecifier: .keyword(.throws), + leftParen: .leftParenToken(), + type: IdentifierTypeSyntax(name: .identifier("JSException")), + rightParen: .rightParenToken() + ) + + return [ + AccessorDeclSyntax( + accessorSpecifier: .keyword(.get), + effectSpecifiers: AccessorEffectSpecifiersSyntax( + asyncSpecifier: nil, + throwsClause: throwsClause + ), + body: CodeBlockSyntax { + getterCall + } + ) + ] + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift new file mode 100644 index 00000000..b10871f6 --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift @@ -0,0 +1,100 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +enum JSMacroMessage: String, DiagnosticMessage { + case unsupportedDeclaration = "@JSFunction can only be applied to functions or initializers." + case unsupportedVariable = "@JSGetter can only be applied to single-variable declarations." + case unsupportedSetterDeclaration = "@JSSetter can only be applied to functions." + case invalidSetterName = + "@JSSetter function name must start with 'set' followed by a property name (e.g., 'setFoo')." + case setterRequiresParameter = "@JSSetter function must have at least one parameter." + + var message: String { rawValue } + var diagnosticID: MessageID { MessageID(domain: "JavaScriptKitMacros", id: rawValue) } + var severity: DiagnosticSeverity { .error } +} + +enum JSMacroHelper { + static func enclosingTypeName(from context: some MacroExpansionContext) -> String? { + for syntax in context.lexicalContext { + if let decl = syntax.as(ClassDeclSyntax.self) { + return decl.name.text + } + if let decl = syntax.as(StructDeclSyntax.self) { + return decl.name.text + } + if let decl = syntax.as(EnumDeclSyntax.self) { + return decl.name.text + } + if let decl = syntax.as(ActorDeclSyntax.self) { + return decl.name.text + } + } + return nil + } + + static func isStatic(_ modifiers: DeclModifierListSyntax?) -> Bool { + guard let modifiers else { return false } + return modifiers.contains { modifier in + modifier.name.tokenKind == .keyword(.static) || modifier.name.tokenKind == .keyword(.class) + } + } + + static func isVoidReturn(_ returnType: TypeSyntax?) -> Bool { + guard let returnType else { return true } + if let identifier = returnType.as(IdentifierTypeSyntax.self), identifier.name.text == "Void" { + return true + } + if let tuple = returnType.as(TupleTypeSyntax.self), tuple.elements.isEmpty { + return true + } + return false + } + + static func glueName(baseName: String, enclosingTypeName: String?) -> String { + if let enclosingTypeName { + return "_$\(enclosingTypeName)_\(baseName)" + } + return "_$\(baseName)" + } + + static func glueName(baseName: String, enclosingTypeName: String?, operation: String) -> String { + if let enclosingTypeName { + return "_$\(enclosingTypeName)_\(baseName)_\(operation)" + } + return "_$\(baseName)_\(operation)" + } + + static func parameterNames(_ parameters: FunctionParameterListSyntax) -> [String] { + parameters.compactMap { param in + let nameToken = param.secondName ?? param.firstName + let nameText = nameToken.text + return nameText == "_" ? nil : nameText + } + } + + static func tryAwaitPrefix(isAsync: Bool, isThrows: Bool) -> String { + switch (isAsync, isThrows) { + case (true, true): + return "try await " + case (true, false): + return "await " + case (false, true): + return "try " + case (false, false): + return "" + } + } + + /// Strips backticks from an identifier name. + /// Swift identifiers with keywords are escaped with backticks (e.g., `` `prefix` ``), + /// but function names should not include backticks. + static func stripBackticks(_ name: String) -> String { + if name.hasPrefix("`") && name.hasSuffix("`") && name.count > 2 { + return String(name.dropFirst().dropLast()) + } + return name + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift new file mode 100644 index 00000000..bb9fd1f2 --- /dev/null +++ b/Plugins/BridgeJS/Sources/BridgeJSMacros/JSSetterMacro.swift @@ -0,0 +1,71 @@ +import SwiftSyntax +import SwiftSyntaxBuilder +import SwiftSyntaxMacros +import SwiftDiagnostics + +public enum JSSetterMacro {} + +extension JSSetterMacro: BodyMacro { + public static func expansion( + of node: AttributeSyntax, + providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax, + in context: some MacroExpansionContext + ) throws -> [CodeBlockItemSyntax] { + guard let functionDecl = declaration.as(FunctionDeclSyntax.self) else { + context.diagnose( + Diagnostic(node: Syntax(declaration), message: JSMacroMessage.unsupportedSetterDeclaration) + ) + return [] + } + + let functionName = functionDecl.name.text + + // Extract property name from setter function name (e.g., "setFoo" -> "foo") + // Strip backticks if present (e.g., "set`prefix`" -> "prefix") + let rawFunctionName = JSMacroHelper.stripBackticks(functionName) + guard rawFunctionName.hasPrefix("set"), rawFunctionName.count > 3 else { + context.diagnose(Diagnostic(node: Syntax(declaration), message: JSMacroMessage.invalidSetterName)) + return [] + } + + let propertyName = String(rawFunctionName.dropFirst(3)) + guard !propertyName.isEmpty else { + context.diagnose(Diagnostic(node: Syntax(declaration), message: JSMacroMessage.invalidSetterName)) + return [] + } + + // Convert first character to lowercase (e.g., "Foo" -> "foo") + let baseName = propertyName.prefix(1).lowercased() + propertyName.dropFirst() + + let enclosingTypeName = JSMacroHelper.enclosingTypeName(from: context) + let isStatic = JSMacroHelper.isStatic(functionDecl.modifiers) + let isInstanceMember = enclosingTypeName != nil && !isStatic + + let glueName = JSMacroHelper.glueName( + baseName: baseName, + enclosingTypeName: enclosingTypeName, + operation: "set" + ) + + var arguments: [String] = [] + if isInstanceMember { + arguments.append("self.jsObject") + } + + // Get the parameter name(s) - setters typically have one parameter + let parameters = functionDecl.signature.parameterClause.parameters + guard let firstParam = parameters.first else { + context.diagnose(Diagnostic(node: Syntax(declaration), message: JSMacroMessage.setterRequiresParameter)) + return [] + } + + let paramName = firstParam.secondName ?? firstParam.firstName + arguments.append(paramName.text) + + let argsJoined = arguments.joined(separator: ", ") + let call = "\(glueName)(\(argsJoined))" + + // Setters should throw JSException, so always use try + return [CodeBlockItemSyntax(stringLiteral: "try \(call)")] + } +} diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index b2dae86c..e1815fbe 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -548,7 +548,6 @@ public struct ExportedProperty: Codable, Equatable, Sendable { } public struct ExportedSkeleton: Codable { - public let moduleName: String public let functions: [ExportedFunction] public let classes: [ExportedClass] public let enums: [ExportedEnum] @@ -562,7 +561,6 @@ public struct ExportedSkeleton: Codable { public var exposeToGlobal: Bool public init( - moduleName: String, functions: [ExportedFunction], classes: [ExportedClass], enums: [ExportedEnum], @@ -570,7 +568,6 @@ public struct ExportedSkeleton: Codable { protocols: [ExportedProtocol] = [], exposeToGlobal: Bool ) { - self.moduleName = moduleName self.functions = functions self.classes = classes self.enums = enums @@ -588,6 +585,13 @@ public struct ImportedFunctionSkeleton: Codable { public let returnType: BridgeType public let documentation: String? + public init(name: String, parameters: [Parameter], returnType: BridgeType, documentation: String? = nil) { + self.name = name + self.parameters = parameters + self.returnType = returnType + self.documentation = documentation + } + public func abiName(context: ImportedTypeSkeleton?) -> String { return ABINameGenerator.generateImportedABIName( baseName: name, @@ -599,6 +603,10 @@ public struct ImportedFunctionSkeleton: Codable { public struct ImportedConstructorSkeleton: Codable { public let parameters: [Parameter] + public init(parameters: [Parameter]) { + self.parameters = parameters + } + public func abiName(context: ImportedTypeSkeleton) -> String { return ABINameGenerator.generateImportedABIName( baseName: "init", @@ -607,21 +615,68 @@ public struct ImportedConstructorSkeleton: Codable { } } -public struct ImportedPropertySkeleton: Codable { +public struct ImportedGetterSkeleton: Codable { public let name: String - public let isReadonly: Bool public let type: BridgeType public let documentation: String? + /// Name of the getter function if it's a separate function (from @JSGetter) + public let functionName: String? - public func getterAbiName(context: ImportedTypeSkeleton) -> String { + public init( + name: String, + type: BridgeType, + documentation: String? = nil, + functionName: String? = nil + ) { + self.name = name + self.type = type + self.documentation = documentation + self.functionName = functionName + } + + public func abiName(context: ImportedTypeSkeleton) -> String { + if let functionName = functionName { + return ABINameGenerator.generateImportedABIName( + baseName: functionName, + context: context, + operation: nil + ) + } return ABINameGenerator.generateImportedABIName( baseName: name, context: context, operation: "get" ) } +} - public func setterAbiName(context: ImportedTypeSkeleton) -> String { +public struct ImportedSetterSkeleton: Codable { + public let name: String + public let type: BridgeType + public let documentation: String? + /// Name of the setter function if it's a separate function (from @JSSetter) + public let functionName: String? + + public init( + name: String, + type: BridgeType, + documentation: String? = nil, + functionName: String? = nil + ) { + self.name = name + self.type = type + self.documentation = documentation + self.functionName = functionName + } + + public func abiName(context: ImportedTypeSkeleton) -> String { + if let functionName = functionName { + return ABINameGenerator.generateImportedABIName( + baseName: functionName, + context: context, + operation: nil + ) + } return ABINameGenerator.generateImportedABIName( baseName: name, context: context, @@ -634,25 +689,60 @@ public struct ImportedTypeSkeleton: Codable { public let name: String public let constructor: ImportedConstructorSkeleton? public let methods: [ImportedFunctionSkeleton] - public let properties: [ImportedPropertySkeleton] + public let getters: [ImportedGetterSkeleton] + public let setters: [ImportedSetterSkeleton] public let documentation: String? + + public init( + name: String, + constructor: ImportedConstructorSkeleton? = nil, + methods: [ImportedFunctionSkeleton], + getters: [ImportedGetterSkeleton] = [], + setters: [ImportedSetterSkeleton] = [], + documentation: String? = nil + ) { + self.name = name + self.constructor = constructor + self.methods = methods + self.getters = getters + self.setters = setters + self.documentation = documentation + } } public struct ImportedFileSkeleton: Codable { public let functions: [ImportedFunctionSkeleton] public let types: [ImportedTypeSkeleton] + + public init(functions: [ImportedFunctionSkeleton], types: [ImportedTypeSkeleton]) { + self.functions = functions + self.types = types + } } public struct ImportedModuleSkeleton: Codable { - public let moduleName: String public var children: [ImportedFileSkeleton] - public init(moduleName: String, children: [ImportedFileSkeleton]) { - self.moduleName = moduleName + public init(children: [ImportedFileSkeleton]) { self.children = children } } +// MARK: - Unified Skeleton + +/// Unified skeleton containing both exported and imported API definitions +public struct BridgeJSSkeleton: Codable { + public let moduleName: String + public let exported: ExportedSkeleton? + public let imported: ImportedModuleSkeleton? + + public init(moduleName: String, exported: ExportedSkeleton? = nil, imported: ImportedModuleSkeleton? = nil) { + self.moduleName = moduleName + self.exported = exported + self.imported = imported + } +} + // MARK: - BridgeType extension extension BridgeType { diff --git a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift index d5a58aba..eb692785 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift @@ -9,6 +9,7 @@ @preconcurrency import class Foundation.JSONDecoder @preconcurrency import class Foundation.ProcessInfo import SwiftParser +import SwiftSyntax #if canImport(BridgeJSCore) import BridgeJSCore @@ -16,8 +17,11 @@ import BridgeJSCore #if canImport(BridgeJSSkeleton) import BridgeJSSkeleton #endif -#if canImport(TS2Skeleton) -import TS2Skeleton +#if canImport(TS2Swift) +import TS2Swift +#endif +#if canImport(BridgeJSUtilities) +import BridgeJSUtilities #endif /// BridgeJS Tool @@ -29,10 +33,7 @@ import TS2Skeleton /// 2. Export: Generate JavaScript bindings for Swift declarations /// /// Usage: -/// For importing TypeScript: -/// $ bridge-js import --module-name --output-swift --output-skeleton --project -/// For exporting Swift: -/// $ bridge-js export --output-swift --output-skeleton +/// $ bridge-js generate --module-name --target-dir --output-swift --output-skeleton [--output-import-swift ] [--output-import-skeleton ] [--project ] ... [...] /// /// This tool is intended to be used through the Swift Package Manager plugin system /// and is not typically called directly by end users. @@ -40,11 +41,10 @@ import TS2Skeleton static func help() -> String { return """ - Usage: \(CommandLine.arguments.first ?? "bridge-js-tool") [options] + Usage: \(CommandLine.arguments.first ?? "bridge-js-tool") generate [options] ... - Subcommands: - import Generate binding code to import TypeScript APIs into Swift - export Generate binding code to export Swift APIs to JavaScript + Generate bridge code for both exporting Swift APIs and importing TypeScript APIs. + Input files can be Swift source files (for export) or macro-annotated Swift files (for import). """ } @@ -69,16 +69,16 @@ import TS2Skeleton ) } switch subcommand { - case "import": + case "generate": let parser = ArgumentParser( singleDashOptions: [:], doubleDashOptions: [ "module-name": OptionRule( - help: "The name of the module to import the TypeScript API into", + help: "The name of the module", required: true ), "always-write": OptionRule( - help: "Always write the output files even if no APIs are imported", + help: "Always write the output files even if no APIs are found", required: false ), "verbose": OptionRule( @@ -89,14 +89,13 @@ import TS2Skeleton help: "The SwiftPM package target directory", required: true ), - "output-swift": OptionRule(help: "The output file path for the Swift source code", required: true), - "output-skeleton": OptionRule( - help: "The output file path for the skeleton of the imported TypeScript APIs", + "output-dir": OptionRule( + help: "The output directory for generated code", required: true ), "project": OptionRule( - help: "The path to the TypeScript project configuration file", - required: true + help: "The path to the TypeScript project configuration file (required for .d.ts files)", + required: false ), ] ) @@ -104,140 +103,90 @@ import TS2Skeleton arguments: Array(arguments.dropFirst()) ) let progress = ProgressReporting(verbose: doubleDashOptions["verbose"] == "true") - var importer = ImportTS(progress: progress, moduleName: doubleDashOptions["module-name"]!) + let moduleName = doubleDashOptions["module-name"]! let targetDirectory = URL(fileURLWithPath: doubleDashOptions["target-dir"]!) + let outputDirectory = URL(fileURLWithPath: doubleDashOptions["output-dir"]!) let config = try BridgeJSConfig.load(targetDirectory: targetDirectory) let nodePath: URL = try config.findTool("node", targetDirectory: targetDirectory) - for inputFile in positionalArguments { - if inputFile.hasSuffix(".json") { - let sourceURL = URL(fileURLWithPath: inputFile) - let skeleton = try JSONDecoder().decode( - ImportedFileSkeleton.self, - from: Data(contentsOf: sourceURL) - ) - importer.addSkeleton(skeleton) - } else if inputFile.hasSuffix(".d.ts") { - let tsconfigPath = URL(fileURLWithPath: doubleDashOptions["project"]!) - try importer.addSourceFile(inputFile, tsconfigPath: tsconfigPath.path, nodePath: nodePath) - } - } - let outputSwift = try importer.finalize() - let shouldWrite = doubleDashOptions["always-write"] == "true" || outputSwift != nil - guard shouldWrite else { - progress.print("No imported TypeScript APIs found") - return + let bridgeJsDtsPath = targetDirectory.appending(path: "bridge-js.d.ts") + if FileManager.default.fileExists(atPath: bridgeJsDtsPath.path) { + guard let tsconfigPath = doubleDashOptions["project"] else { + throw BridgeJSToolError("--project option is required when processing .d.ts files") + } + let bridgeJSMacrosPath = outputDirectory.appending(path: "BridgeJS.Macros.swift") + _ = try invokeTS2Swift( + dtsFile: bridgeJsDtsPath.path, + tsconfigPath: tsconfigPath, + nodePath: nodePath, + progress: progress, + outputPath: bridgeJSMacrosPath.path + ) } - let outputSwiftURL = URL(fileURLWithPath: doubleDashOptions["output-swift"]!) - try FileManager.default.createDirectory( - at: outputSwiftURL.deletingLastPathComponent(), - withIntermediateDirectories: true, - attributes: nil - ) - try (outputSwift ?? "").write(to: outputSwiftURL, atomically: true, encoding: .utf8) - - let outputSkeletonsURL = URL(fileURLWithPath: doubleDashOptions["output-skeleton"]!) - try FileManager.default.createDirectory( - at: outputSkeletonsURL.deletingLastPathComponent(), - withIntermediateDirectories: true, - attributes: nil - ) - let encoder = JSONEncoder() - encoder.outputFormatting = [.prettyPrinted, .sortedKeys] - try encoder.encode(importer.skeleton).write(to: outputSkeletonsURL) - - progress.print( - """ - Imported TypeScript APIs: - - \(outputSwiftURL.path) - - \(outputSkeletonsURL.path) - """ - ) - case "export": - let parser = ArgumentParser( - singleDashOptions: [:], - doubleDashOptions: [ - "module-name": OptionRule( - help: "The name of the module for external function references", - required: true - ), - "target-dir": OptionRule( - help: "The SwiftPM package target directory", - required: true - ), - "output-skeleton": OptionRule( - help: "The output file path for the skeleton of the exported Swift APIs", - required: true - ), - "output-swift": OptionRule(help: "The output file path for the Swift source code", required: true), - "always-write": OptionRule( - help: "Always write the output files even if no APIs are exported", - required: false - ), - "verbose": OptionRule( - help: "Print verbose output", - required: false - ), - ] - ) - let (positionalArguments, _, doubleDashOptions) = try parser.parse( - arguments: Array(arguments.dropFirst()) - ) - let progress = ProgressReporting(verbose: doubleDashOptions["verbose"] == "true") - let targetDirectory = URL(fileURLWithPath: doubleDashOptions["target-dir"]!) - let config = try BridgeJSConfig.load(targetDirectory: targetDirectory) + let inputFiles = inputSwiftFiles(targetDirectory: targetDirectory, positionalArguments: positionalArguments) let exporter = ExportSwift( progress: progress, - moduleName: doubleDashOptions["module-name"]!, + moduleName: moduleName, exposeToGlobal: config.exposeToGlobal ) - for inputFile in positionalArguments.sorted() { - let sourceURL = URL(fileURLWithPath: inputFile) - guard sourceURL.pathExtension == "swift" else { continue } - let sourceContent = try String(contentsOf: sourceURL, encoding: .utf8) - let sourceFile = Parser.parse(source: sourceContent) - try exporter.addSourceFile(sourceFile, sourceURL.path) - } + let importSwift = ImportSwiftMacros(progress: progress, moduleName: moduleName) + + for inputFile in inputFiles.sorted() { + let content = try String(contentsOf: URL(fileURLWithPath: inputFile), encoding: .utf8) + if hasBridgeJSSkipComment(content) { + continue + } - // Finalize the export - let output = try exporter.finalize() - let outputSwiftURL = URL(fileURLWithPath: doubleDashOptions["output-swift"]!) - let outputSkeletonURL = URL(fileURLWithPath: doubleDashOptions["output-skeleton"]!) + let sourceFile = Parser.parse(source: content) + try exporter.addSourceFile(sourceFile, inputFile) + importSwift.addSourceFile(sourceFile, inputFile) + } - let shouldWrite = doubleDashOptions["always-write"] == "true" || output != nil - guard shouldWrite else { - progress.print("No exported Swift APIs found") - return + let importResult = try importSwift.finalize() + let exportResult = try exporter.finalize() + let importSkeleton = importResult.outputSkeleton + + // Combine and write unified Swift output + let outputSwiftURL = outputDirectory.appending(path: "BridgeJS.swift") + let combinedSwift = [exportResult?.outputSwift, importResult.outputSwift].compactMap { $0 } + let outputSwift = combineGeneratedSwift(combinedSwift) + let shouldWrite = doubleDashOptions["always-write"] == "true" || !outputSwift.isEmpty + if shouldWrite { + try FileManager.default.createDirectory( + at: outputSwiftURL.deletingLastPathComponent(), + withIntermediateDirectories: true, + attributes: nil + ) + try outputSwift.write(to: outputSwiftURL, atomically: true, encoding: .utf8) } - // Create the output directory if it doesn't exist - try FileManager.default.createDirectory( - at: outputSwiftURL.deletingLastPathComponent(), - withIntermediateDirectories: true, - attributes: nil + // Write unified skeleton + let outputSkeletonURL = outputDirectory.appending(path: "JavaScript/BridgeJS.json") + let unifiedSkeleton = BridgeJSSkeleton( + moduleName: moduleName, + exported: exportResult?.outputSkeleton, + imported: importSkeleton ) try FileManager.default.createDirectory( at: outputSkeletonURL.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil ) + let encoder = JSONEncoder() + encoder.outputFormatting = [.prettyPrinted, .sortedKeys] + let skeletonData = try encoder.encode(unifiedSkeleton) + try skeletonData.write(to: outputSkeletonURL) - // Write the output Swift file - try (output?.outputSwift ?? "").write(to: outputSwiftURL, atomically: true, encoding: .utf8) - - if let outputSkeleton = output?.outputSkeleton { - // Write the output skeleton file - let encoder = JSONEncoder() - encoder.outputFormatting = [.prettyPrinted, .sortedKeys] - let outputSkeletonData = try encoder.encode(outputSkeleton) - try outputSkeletonData.write(to: outputSkeletonURL) + if exportResult != nil || importResult.outputSwift != nil { + progress.print("Generated BridgeJS code") } - progress.print( + case "export", "import": + throw BridgeJSToolError( """ - Exported Swift APIs: - - \(outputSwiftURL.path) - - \(outputSkeletonURL.path) + Error: Subcommands 'export' and 'import' have been unified into 'generate'. + + \(BridgeJSTool.help()) """ ) default: @@ -264,6 +213,53 @@ private func printStderr(_ message: String) { fputs(message + "\n", stderr) } +private func hasBridgeJSSkipComment(_ content: String) -> Bool { + BridgeJSGeneratedFile.hasSkipComment(content) +} + +private func combineGeneratedSwift(_ pieces: [String]) -> String { + let trimmedPieces = + pieces + .map { $0.trimmingCharacters(in: .newlines) } + .filter { !$0.isEmpty } + guard !trimmedPieces.isEmpty else { return "" } + + return ([BridgeJSGeneratedFile.swiftPreamble] + trimmedPieces).joined(separator: "\n\n") +} + +private func recursivelyCollectSwiftFiles(from directory: URL) -> [URL] { + var swiftFiles: [URL] = [] + let fileManager = FileManager.default + + guard + let enumerator = fileManager.enumerator( + at: directory, + includingPropertiesForKeys: [.isRegularFileKey, .isDirectoryKey], + options: [.skipsHiddenFiles] + ) + else { + return [] + } + + for case let fileURL as URL in enumerator { + if fileURL.pathExtension == "swift" { + let resourceValues = try? fileURL.resourceValues(forKeys: [.isRegularFileKey]) + if resourceValues?.isRegularFile == true { + swiftFiles.append(fileURL) + } + } + } + + return swiftFiles.sorted { $0.path < $1.path } +} + +private func inputSwiftFiles(targetDirectory: URL, positionalArguments: [String]) -> [String] { + if positionalArguments.isEmpty { + return recursivelyCollectSwiftFiles(from: targetDirectory).map(\.path) + } + return positionalArguments +} + // MARK: - Minimal Argument Parsing struct OptionRule { diff --git a/Plugins/BridgeJS/Sources/BridgeJSUtilities/Utilities.swift b/Plugins/BridgeJS/Sources/BridgeJSUtilities/Utilities.swift index f091e4a3..2791aa5b 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSUtilities/Utilities.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSUtilities/Utilities.swift @@ -4,3 +4,26 @@ extension String { return prefix(1).uppercased() + dropFirst() } } + +public enum BridgeJSGeneratedFile { + /// The magic comment to skip processing by BridgeJS. + public static let skipLine = "// bridge-js: skip" + + public static func hasSkipComment(_ content: String) -> Bool { + content.starts(with: skipLine + "\n") + } + + public static var swiftPreamble: String { + // The generated Swift file itself should not be processed by BridgeJS again. + """ + \(skipLine) + // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, + // DO NOT EDIT. + // + // To update this file, just rebuild your project or run + // `swift package bridge-js`. + + @_spi(BridgeJS) import JavaScriptKit + """ + } +} diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/README.md b/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/README.md deleted file mode 100644 index de680635..00000000 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# ts2skeleton - -This script analyzes the TypeScript type definitions and produces a structured JSON output with skeleton information that can be used to generate Swift bindings. diff --git a/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/README.md b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/README.md new file mode 100644 index 00000000..b2dbe6a6 --- /dev/null +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/README.md @@ -0,0 +1,3 @@ +# ts2swift + +This script analyzes the TypeScript type definitions and produces macro-annotated Swift declarations that can be fed into BridgeJS for glue generation. diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/bin/ts2skeleton.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/bin/ts2swift.js old mode 100755 new mode 100644 similarity index 53% rename from Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/bin/ts2skeleton.js rename to Plugins/BridgeJS/Sources/TS2Swift/JavaScript/bin/ts2swift.js index ba926a88..cc94fce3 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/bin/ts2skeleton.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/bin/ts2swift.js @@ -2,11 +2,10 @@ // @ts-check /** - * Main entry point for the ts2skeleton tool + * Main entry point for the ts2swift tool * - * This script analyzes the TypeScript type definitions and produces a structured - * JSON output with skeleton information that can be used to generate Swift - * bindings. + * This script analyzes the TypeScript type definitions and produces macro-annotated + * Swift declarations that can be used to generate Swift bindings. */ import { main } from "../src/cli.js" diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/package.json b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/package.json similarity index 69% rename from Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/package.json rename to Plugins/BridgeJS/Sources/TS2Swift/JavaScript/package.json index 48fb77cf..d6b34558 100644 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/package.json +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/package.json @@ -4,6 +4,6 @@ "typescript": "5.8.2" }, "bin": { - "ts2skeleton": "./bin/ts2skeleton.js" + "ts2swift": "./bin/ts2swift.js" } } diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/cli.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js similarity index 90% rename from Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/cli.js rename to Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js index 41f6e419..28f37e0e 100644 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/cli.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/cli.js @@ -73,7 +73,7 @@ class DiagnosticEngine { } function printUsage() { - console.error('Usage: ts2skeleton -p [-o output.json]'); + console.error('Usage: ts2swift -p [-o output.swift]'); } /** @@ -139,13 +139,14 @@ export function main(args) { } const processor = new TypeProcessor(program.getTypeChecker(), diagnosticEngine); - const results = processor.processTypeDeclarations(program, filePath); + const { content: swiftOutput, hasAny } = processor.processTypeDeclarations(program, filePath); - // Write results to file or stdout - const jsonOutput = JSON.stringify(results, null, 2); if (options.values.output) { - fs.writeFileSync(options.values.output, jsonOutput); + if (hasAny) { + fs.mkdirSync(path.dirname(options.values.output), { recursive: true }); + fs.writeFileSync(options.values.output, swiftOutput); + } } else { - process.stdout.write(jsonOutput, "utf-8"); + process.stdout.write(swiftOutput, "utf-8"); } } diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/index.d.ts b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/index.d.ts similarity index 100% rename from Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/index.d.ts rename to Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/index.d.ts diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/processor.js b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js similarity index 52% rename from Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/processor.js rename to Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js index cdcff719..830c0d0a 100644 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/JavaScript/src/processor.js +++ b/Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js @@ -6,13 +6,8 @@ // @ts-check import ts from 'typescript'; -/** @typedef {import('./index').ImportSkeleton} ImportSkeleton */ -/** @typedef {import('./index').ImportFunctionSkeleton} ImportFunctionSkeleton */ -/** @typedef {import('./index').ImportTypeSkeleton} ImportTypeSkeleton */ -/** @typedef {import('./index').ImportPropertySkeleton} ImportPropertySkeleton */ -/** @typedef {import('./index').ImportConstructorSkeleton} ImportConstructorSkeleton */ -/** @typedef {import('./index').Parameter} Parameter */ -/** @typedef {import('./index').BridgeType} BridgeType */ +/** @typedef {import('./index.d.ts').Parameter} Parameter */ +/** @typedef {import('./index.d.ts').BridgeType} BridgeType */ /** * @typedef {{ @@ -57,23 +52,33 @@ export class TypeProcessor { this.processedTypes = new Map(); /** @type {Map} Seen position by type */ this.seenTypes = new Map(); - /** @type {ImportFunctionSkeleton[]} */ - this.functions = []; - /** @type {ImportTypeSkeleton[]} */ - this.types = []; + /** @type {string[]} Collected Swift code lines */ + this.swiftLines = []; } /** - * Process type declarations from a TypeScript program + * Process type declarations from a TypeScript program and render Swift code * @param {ts.Program} program - TypeScript program * @param {string} inputFilePath - Path to the input file - * @returns {ImportSkeleton} Processed type declarations + * @returns {{ content: string, hasAny: boolean }} Rendered Swift code */ processTypeDeclarations(program, inputFilePath) { const sourceFiles = program.getSourceFiles().filter( sf => !sf.isDeclarationFile || sf.fileName === inputFilePath ); + // Add prelude + this.swiftLines.push( + "// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit,", + "// DO NOT EDIT.", + "//", + "// To update this file, just rebuild your project or run", + "// `swift package bridge-js`.", + "", + "@_spi(Experimental) import JavaScriptKit", + "" + ); + for (const sourceFile of sourceFiles) { if (sourceFile.fileName.includes('node_modules/typescript/lib')) continue; @@ -88,10 +93,7 @@ export class TypeProcessor { const typeString = this.checker.typeToString(type); const members = type.getProperties(); if (members) { - const type = this.visitStructuredType(typeString, members); - this.types.push(type); - } else { - this.types.push(this.createUnknownType(typeString)); + this.visitStructuredType(typeString, members); } } }); @@ -100,23 +102,11 @@ export class TypeProcessor { } } - return { functions: this.functions, types: this.types }; + const content = this.swiftLines.join("\n").trimEnd() + "\n"; + const hasAny = this.swiftLines.length > 9; // More than just the prelude + return { content, hasAny }; } - /** - * Create an unknown type - * @param {string} typeString - Type string - * @returns {ImportTypeSkeleton} Unknown type - */ - createUnknownType(typeString) { - return { - name: typeString, - documentation: undefined, - properties: [], - methods: [], - constructor: undefined, - }; - } /** * Visit a node and process it @@ -124,50 +114,34 @@ export class TypeProcessor { */ visitNode(node) { if (ts.isFunctionDeclaration(node)) { - const func = this.visitFunctionLikeDecl(node); - if (func && node.name) { - this.functions.push({ ...func, name: node.name.getText() }); - } + this.visitFunctionDeclaration(node); } else if (ts.isClassDeclaration(node)) { - const cls = this.visitClassDecl(node); - if (cls) this.types.push(cls); + this.visitClassDecl(node); } } /** - * Process a function declaration into ImportFunctionSkeleton format - * @param {ts.SignatureDeclaration} node - The function node - * @returns {ImportFunctionSkeleton | null} Processed function + * Visit a function declaration and render Swift code + * @param {ts.FunctionDeclaration} node - The function node * @private */ - visitFunctionLikeDecl(node) { - if (!node.name) return null; + visitFunctionDeclaration(node) { + if (!node.name) return; const name = node.name.getText(); if (!isValidSwiftDeclName(name)) { - return null; + return; } const signature = this.checker.getSignatureFromDeclaration(node); - if (!signature) return null; - - /** @type {Parameter[]} */ - const parameters = []; - for (const p of signature.getParameters()) { - const bridgeType = this.visitSignatureParameter(p, node); - parameters.push(bridgeType); - } + if (!signature) return; - const returnType = signature.getReturnType(); - const bridgeReturnType = this.visitType(returnType, node); - const documentation = this.getFullJSDocText(node); + const params = this.renderParameters(signature.getParameters(), node); + const returnType = this.renderBridgeType(this.visitType(signature.getReturnType(), node), node); + const effects = this.renderEffects({ isAsync: false }); + const swiftName = this.renderIdentifier(name); - return { - name, - parameters, - returnType: bridgeReturnType, - documentation, - effects: { isAsync: false }, - }; + this.swiftLines.push(`@JSFunction func ${swiftName}(${params}) ${effects} -> ${returnType}`); + this.swiftLines.push(""); } /** @@ -188,25 +162,21 @@ export class TypeProcessor { } /** + * Render constructor parameters * @param {ts.ConstructorDeclaration} node - * @returns {ImportConstructorSkeleton | null} + * @returns {string} Rendered parameters + * @private */ - visitConstructorDecl(node) { + renderConstructorParameters(node) { const signature = this.checker.getSignatureFromDeclaration(node); - if (!signature) return null; - - const parameters = []; - for (const p of signature.getParameters()) { - const bridgeType = this.visitSignatureParameter(p, node); - parameters.push(bridgeType); - } + if (!signature) return ""; - return { parameters }; + return this.renderParameters(signature.getParameters(), node); } /** * @param {ts.PropertyDeclaration | ts.PropertySignature} node - * @returns {ImportPropertySkeleton | null} + * @returns {{ name: string, type: BridgeType, isReadonly: boolean, documentation: string | undefined } | null} */ visitPropertyDecl(node) { if (!node.name) return null; @@ -235,39 +205,29 @@ export class TypeProcessor { } /** + * Visit a class declaration and render Swift code * @param {ts.ClassDeclaration} node - * @returns {ImportTypeSkeleton | null} + * @private */ visitClassDecl(node) { - if (!node.name) return null; + if (!node.name) return; - const name = node.name.text; - const properties = []; - const methods = []; - /** @type {ImportConstructorSkeleton | undefined} */ - let constructor = undefined; + const className = this.renderIdentifier(node.name.text); + this.swiftLines.push(`@JSClass struct ${className}: _JSBridgedClass {`); + // Process members in declaration order for (const member of node.members) { if (ts.isPropertyDeclaration(member)) { - const property = this.visitPropertyDecl(member); - if (property) properties.push(property); + this.renderProperty(member); } else if (ts.isMethodDeclaration(member)) { - const decl = this.visitFunctionLikeDecl(member); - if (decl) methods.push(decl); + this.renderMethod(member); } else if (ts.isConstructorDeclaration(member)) { - const decl = this.visitConstructorDecl(member); - if (decl) constructor = decl; + this.renderConstructor(member); } } - const documentation = this.getFullJSDocText(node); - return { - name, - constructor, - properties, - methods, - documentation, - }; + this.swiftLines.push("}"); + this.swiftLines.push(""); } /** @@ -301,47 +261,51 @@ export class TypeProcessor { } /** + * Visit a structured type (interface) and render Swift code * @param {string} name * @param {ts.Symbol[]} members - * @returns {ImportTypeSkeleton} + * @private */ visitStructuredType(name, members) { - /** @type {ImportPropertySkeleton[]} */ - const properties = []; - /** @type {ImportFunctionSkeleton[]} */ - const methods = []; - /** @type {ImportConstructorSkeleton | undefined} */ - let constructor = undefined; + const typeName = this.renderIdentifier(name); + this.swiftLines.push(`@JSClass struct ${typeName}: _JSBridgedClass {`); + + // Collect all declarations with their positions to preserve order + /** @type {Array<{ decl: ts.Node, symbol: ts.Symbol, position: number }>} */ + const allDecls = []; + for (const symbol of members) { + for (const decl of symbol.getDeclarations() ?? []) { + const sourceFile = decl.getSourceFile(); + const pos = sourceFile ? decl.getStart() : 0; + allDecls.push({ decl, symbol, position: pos }); + } + } + + // Sort by position to preserve declaration order + allDecls.sort((a, b) => a.position - b.position); + + // Process declarations in order + for (const { decl, symbol } of allDecls) { if (symbol.flags & ts.SymbolFlags.Property) { - for (const decl of symbol.getDeclarations() ?? []) { - if (ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl)) { - const property = this.visitPropertyDecl(decl); - if (property) properties.push(property); - } else if (ts.isMethodSignature(decl)) { - const method = this.visitFunctionLikeDecl(decl); - if (method) methods.push(method); - } + if (ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl)) { + this.renderProperty(decl); + } else if (ts.isMethodSignature(decl)) { + this.renderMethodSignature(decl); } } else if (symbol.flags & ts.SymbolFlags.Method) { - for (const decl of symbol.getDeclarations() ?? []) { - if (!ts.isMethodSignature(decl)) { - continue; - } - const method = this.visitFunctionLikeDecl(decl); - if (method) methods.push(method); + if (ts.isMethodSignature(decl)) { + this.renderMethodSignature(decl); } } else if (symbol.flags & ts.SymbolFlags.Constructor) { - for (const decl of symbol.getDeclarations() ?? []) { - if (!ts.isConstructorDeclaration(decl)) { - continue; - } - const ctor = this.visitConstructorDecl(decl); - if (ctor) constructor = ctor; + if (ts.isConstructorDeclaration(decl)) { + this.renderConstructor(decl); } } } - return { name, properties, methods, constructor, documentation: undefined }; + + this.swiftLines.push("}"); + this.swiftLines.push(""); } /** @@ -431,6 +395,160 @@ export class TypeProcessor { } return undefined; } + + /** + * Render a property declaration + * @param {ts.PropertyDeclaration | ts.PropertySignature} node + * @private + */ + renderProperty(node) { + const property = this.visitPropertyDecl(node); + if (!property) return; + + const type = this.renderBridgeType(property.type, node); + const name = this.renderIdentifier(property.name); + + // Always render getter + this.swiftLines.push(` @JSGetter var ${name}: ${type}`); + + // Render setter if not readonly + if (!property.isReadonly) { + const capitalizedName = property.name.charAt(0).toUpperCase() + property.name.slice(1); + const needsJSNameField = property.name.charAt(0) != capitalizedName.charAt(0).toLowerCase(); + const setterName = `set${capitalizedName}`; + const annotation = needsJSNameField ? `@JSSetter(jsName: "${property.name}")` : "@JSSetter"; + this.swiftLines.push(` ${annotation} func ${this.renderIdentifier(setterName)}(_ value: ${type}) ${this.renderEffects({ isAsync: false })}`); + } + } + + /** + * Render a method declaration + * @param {ts.MethodDeclaration | ts.MethodSignature} node + * @private + */ + renderMethod(node) { + if (!node.name) return; + const name = node.name.getText(); + if (!isValidSwiftDeclName(name)) return; + + const signature = this.checker.getSignatureFromDeclaration(node); + if (!signature) return; + + const params = this.renderParameters(signature.getParameters(), node); + const returnType = this.renderBridgeType(this.visitType(signature.getReturnType(), node), node); + const effects = this.renderEffects({ isAsync: false }); + const swiftName = this.renderIdentifier(name); + + this.swiftLines.push(` @JSFunction func ${swiftName}(${params}) ${effects} -> ${returnType}`); + } + + /** + * Render a method signature (from interface) + * @param {ts.MethodSignature} node + * @private + */ + renderMethodSignature(node) { + this.renderMethod(node); + } + + /** + * Render a constructor declaration + * @param {ts.ConstructorDeclaration} node + * @private + */ + renderConstructor(node) { + const params = this.renderConstructorParameters(node); + const effects = this.renderEffects({ isAsync: false }); + this.swiftLines.push(` @JSFunction init(${params}) ${effects}`); + } + + /** + * Render function parameters + * @param {ts.Symbol[]} parameters + * @param {ts.Node} node + * @returns {string} + * @private + */ + renderParameters(parameters, node) { + const params = []; + for (const p of parameters) { + const bridgeType = this.visitSignatureParameter(p, node); + const paramName = this.renderIdentifier(p.name); + const type = this.renderBridgeType(bridgeType.type, node); + params.push(`_ ${paramName}: ${type}`); + } + return params.join(", "); + } + + /** + * Render bridge type to Swift type + * @param {BridgeType} bridgeType + * @param {ts.Node} node + * @returns {string} + * @private + */ + renderBridgeType(bridgeType, node) { + if ("int" in bridgeType) return "Int"; + if ("float" in bridgeType) return "Float"; + if ("double" in bridgeType) return "Double"; + if ("string" in bridgeType) return "String"; + if ("bool" in bridgeType) return "Bool"; + if ("void" in bridgeType) return "Void"; + if ("jsObject" in bridgeType) { + const name = "_0" in bridgeType.jsObject ? bridgeType.jsObject._0 : undefined; + return name ? this.renderIdentifier(name) : "JSObject"; + } + return "JSObject"; + } + + /** + * Render effects (async/throws) + * @param {{ isAsync: boolean }} effects + * @returns {string} + * @private + */ + renderEffects(effects) { + const parts = []; + if (effects?.isAsync) { + parts.push("async"); + } + parts.push("throws (JSException)"); + return parts.join(" "); + } + + /** + * Render identifier with backticks if needed + * @param {string} name + * @returns {string} + * @private + */ + renderIdentifier(name) { + if (!name) return name; + if (!isValidSwiftDeclName(name) || isSwiftKeyword(name)) { + return `\`${name}\``; + } + return name; + } +} + + +const SWIFT_KEYWORDS = new Set([ + "associatedtype", "class", "deinit", "enum", "extension", "fileprivate", + "func", "import", "init", "inout", "internal", "let", "open", "operator", + "private", "protocol", "public", "static", "struct", "subscript", "typealias", + "var", "break", "case", "continue", "default", "defer", "do", "else", + "fallthrough", "for", "guard", "if", "in", "repeat", "return", "switch", + "where", "while", "as", "Any", "catch", "false", "is", "nil", "rethrows", + "super", "self", "Self", "throw", "throws", "true", "try", + "prefix", "postfix", "infix" // Contextual keywords for operator declarations +]); + +/** + * @param {string} name + * @returns {boolean} + */ +function isSwiftKeyword(name) { + return SWIFT_KEYWORDS.has(name); } /** diff --git a/Plugins/BridgeJS/Sources/TS2Skeleton/TS2Skeleton.swift b/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift similarity index 65% rename from Plugins/BridgeJS/Sources/TS2Skeleton/TS2Skeleton.swift rename to Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift index c7725faf..0a69eb70 100644 --- a/Plugins/BridgeJS/Sources/TS2Skeleton/TS2Skeleton.swift +++ b/Plugins/BridgeJS/Sources/TS2Swift/TS2Swift.swift @@ -1,4 +1,3 @@ -@preconcurrency import class Foundation.JSONDecoder @preconcurrency import class Foundation.Process @preconcurrency import class Foundation.Pipe @preconcurrency import class Foundation.ProcessInfo @@ -11,6 +10,8 @@ @preconcurrency import var Foundation.SIGTERM import protocol Dispatch.DispatchSourceSignal import class Dispatch.DispatchSource +import SwiftParser +import SwiftSyntax #if canImport(BridgeJSCore) import BridgeJSCore @@ -76,48 +77,57 @@ extension BridgeJSConfig { } } -extension ImportTS { - /// Processes a TypeScript definition file and extracts its API information - public mutating func addSourceFile( - _ sourceFile: String, - tsconfigPath: String, - nodePath: URL - ) throws { - let ts2skeletonPath = URL(fileURLWithPath: #filePath) - .deletingLastPathComponent() - .appendingPathComponent("JavaScript") - .appendingPathComponent("bin") - .appendingPathComponent("ts2skeleton.js") - let arguments = [ts2skeletonPath.path, sourceFile, "--project", tsconfigPath] +/// Invokes ts2swift to convert TypeScript definitions to macro-annotated Swift +/// - Parameters: +/// - dtsFile: Path to the TypeScript definition file +/// - tsconfigPath: Path to the TypeScript project configuration file +/// - nodePath: Path to the node executable +/// - progress: Progress reporting instance +/// - outputPath: Optional path to write the output file. If nil, output is collected from stdout (for testing) +/// - Returns: The generated Swift source code (always collected from stdout for return value) +public func invokeTS2Swift( + dtsFile: String, + tsconfigPath: String, + nodePath: URL, + progress: ProgressReporting, + outputPath: String? = nil +) throws -> String { + let ts2swiftPath = URL(fileURLWithPath: #filePath) + .deletingLastPathComponent() + .appendingPathComponent("JavaScript") + .appendingPathComponent("bin") + .appendingPathComponent("ts2swift.js") + var arguments = [ts2swiftPath.path, dtsFile, "--project", tsconfigPath] + if let outputPath = outputPath { + arguments.append(contentsOf: ["--output", outputPath]) + } - progress.print("Running ts2skeleton...") - progress.print(" \(([nodePath.path] + arguments).joined(separator: " "))") + progress.print("Running ts2swift...") + progress.print(" \(([nodePath.path] + arguments).joined(separator: " "))") - let process = Process() - let stdoutPipe = Pipe() - nonisolated(unsafe) var stdoutData = Data() + let process = Process() + let stdoutPipe = Pipe() + nonisolated(unsafe) var stdoutData = Data() - process.executableURL = nodePath - process.arguments = arguments - process.standardOutput = stdoutPipe + process.executableURL = nodePath + process.arguments = arguments + process.standardOutput = stdoutPipe - stdoutPipe.fileHandleForReading.readabilityHandler = { handle in - let data = handle.availableData - if data.count > 0 { - stdoutData.append(data) - } - } - try process.forwardTerminationSignals { - try process.run() - process.waitUntilExit() + stdoutPipe.fileHandleForReading.readabilityHandler = { handle in + let data = handle.availableData + if data.count > 0 { + stdoutData.append(data) } + } + try process.forwardTerminationSignals { + try process.run() + process.waitUntilExit() + } - if process.terminationStatus != 0 { - throw BridgeJSCoreError("ts2skeleton returned \(process.terminationStatus)") - } - let skeleton = try JSONDecoder().decode(ImportedFileSkeleton.self, from: stdoutData) - self.addSkeleton(skeleton) + if process.terminationStatus != 0 { + throw BridgeJSCoreError("ts2swift returned \(process.terminationStatus)") } + return String(decoding: stdoutData, as: UTF8.self) } extension Foundation.Process { diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift new file mode 100644 index 00000000..5997d305 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift @@ -0,0 +1,289 @@ +import SwiftDiagnostics +import SwiftSyntax +import SwiftSyntaxMacros +import SwiftSyntaxMacrosTestSupport +import Testing +import BridgeJSMacros + +@Suite struct JSClassMacroTests { + private let indentationWidth: Trivia = .spaces(4) + + @Test func emptyStruct() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithExistingJSObject() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + let jsObject: JSObject + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithExistingInit() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithBothExisting() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithMembers() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + var name: String + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + var name: String + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func _class() { + assertMacroExpansion( + """ + @JSClass + class MyClass { + } + """, + expandedSource: """ + class MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func _enum() { + assertMacroExpansion( + """ + @JSClass + enum MyEnum { + } + """, + expandedSource: """ + enum MyEnum { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func _actor() { + assertMacroExpansion( + """ + @JSClass + actor MyActor { + } + """, + expandedSource: """ + actor MyActor { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithDifferentJSObjectName() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + var otherProperty: String + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + var otherProperty: String + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithDifferentInit() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + init(name: String) { + } + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + init(name: String) { + } + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithMultipleMembers() { + assertMacroExpansion( + """ + @JSClass + struct MyClass { + var name: String + var age: Int + } + """, + expandedSource: """ + struct MyClass { + let jsObject: JSObject + + var name: String + var age: Int + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func structWithComment() { + assertMacroExpansion( + """ + /// Documentation comment + @JSClass + struct MyClass { + } + """, + expandedSource: """ + /// Documentation comment + struct MyClass { + let jsObject: JSObject + + init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + } + """, + macros: ["JSClass": JSClassMacro.self], + indentationWidth: indentationWidth + ) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift new file mode 100644 index 00000000..8cfdd66e --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSFunctionMacroTests.swift @@ -0,0 +1,377 @@ +import SwiftDiagnostics +import SwiftSyntax +import SwiftSyntaxMacros +import SwiftSyntaxMacrosTestSupport +import Testing +import BridgeJSMacros + +@Suite struct JSFunctionMacroTests { + private let indentationWidth: Trivia = .spaces(4) + + @Test func topLevelFunction() { + assertMacroExpansion( + """ + @JSFunction + func greet(name: String) -> String + """, + expandedSource: """ + func greet(name: String) -> String { + return _$greet(name) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionVoidReturn() { + assertMacroExpansion( + """ + @JSFunction + func log(message: String) + """, + expandedSource: """ + func log(message: String) { + _$log(message) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionWithExplicitVoidReturn() { + assertMacroExpansion( + """ + @JSFunction + func log(message: String) -> Void + """, + expandedSource: """ + func log(message: String) -> Void { + _$log(message) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionWithEmptyTupleReturn() { + assertMacroExpansion( + """ + @JSFunction + func log(message: String) -> () + """, + expandedSource: """ + func log(message: String) -> () { + _$log(message) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionThrows() { + assertMacroExpansion( + """ + @JSFunction + func parse(json: String) throws -> [String: Any] + """, + expandedSource: """ + func parse(json: String) throws -> [String: Any] { + return try _$parse(json) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionAsync() { + assertMacroExpansion( + """ + @JSFunction + func fetch(url: String) async -> String + """, + expandedSource: """ + func fetch(url: String) async -> String { + return await _$fetch(url) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionAsyncThrows() { + assertMacroExpansion( + """ + @JSFunction + func fetch(url: String) async throws -> String + """, + expandedSource: """ + func fetch(url: String) async throws -> String { + return try await _$fetch(url) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionWithUnderscoreParameter() { + assertMacroExpansion( + """ + @JSFunction + func process(_ value: Int) -> Int + """, + expandedSource: """ + func process(_ value: Int) -> Int { + return _$process(value) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelFunctionWithMultipleParameters() { + assertMacroExpansion( + """ + @JSFunction + func add(a: Int, b: Int) -> Int + """, + expandedSource: """ + func add(a: Int, b: Int) -> Int { + return _$add(a, b) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func instanceMethod() { + assertMacroExpansion( + """ + struct MyClass { + @JSFunction + func getName() -> String + } + """, + expandedSource: """ + struct MyClass { + func getName() -> String { + return _$MyClass_getName(self.jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func staticMethod() { + assertMacroExpansion( + """ + struct MyClass { + @JSFunction + static func create() -> MyClass + } + """, + expandedSource: """ + struct MyClass { + static func create() -> MyClass { + return _$create() + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func classMethod() { + assertMacroExpansion( + """ + class MyClass { + @JSFunction + class func create() -> MyClass + } + """, + expandedSource: """ + class MyClass { + class func create() -> MyClass { + return _$create() + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func initializer() { + assertMacroExpansion( + """ + struct MyClass { + @JSFunction + init(name: String) + } + """, + expandedSource: """ + struct MyClass { + init(name: String) { + let jsObject = _$MyClass_init(name) + self.init(unsafelyWrapping: jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func initializerThrows() { + assertMacroExpansion( + """ + struct MyClass { + @JSFunction + init(name: String) throws + } + """, + expandedSource: """ + struct MyClass { + init(name: String) throws { + let jsObject = try _$MyClass_init(name) + self.init(unsafelyWrapping: jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func initializerAsyncThrows() { + assertMacroExpansion( + """ + struct MyClass { + @JSFunction + init(name: String) async throws + } + """, + expandedSource: """ + struct MyClass { + init(name: String) async throws { + let jsObject = try await _$MyClass_init(name) + self.init(unsafelyWrapping: jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func initializerWithoutEnclosingType() { + assertMacroExpansion( + """ + @JSFunction + init() + """, + expandedSource: """ + init() + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSFunction can only be applied to functions or initializers.", + line: 1, + column: 1 + ) + ], + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func unsupportedDeclaration() { + assertMacroExpansion( + """ + @JSFunction + var property: String + """, + expandedSource: """ + var property: String + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSFunction can only be applied to functions or initializers.", + line: 1, + column: 1 + ) + ], + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func enumInstanceMethod() { + assertMacroExpansion( + """ + enum MyEnum { + @JSFunction + func getValue() -> Int + } + """, + expandedSource: """ + enum MyEnum { + func getValue() -> Int { + return _$MyEnum_getValue(self.jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func actorInstanceMethod() { + assertMacroExpansion( + """ + actor MyActor { + @JSFunction + func getValue() -> Int + } + """, + expandedSource: """ + actor MyActor { + func getValue() -> Int { + return _$MyActor_getValue(self.jsObject) + } + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func functionWithExistingBody() { + assertMacroExpansion( + """ + @JSFunction + func greet(name: String) -> String { + return "Hello, \\(name)" + } + """, + expandedSource: """ + func greet(name: String) -> String { + return _$greet(name) + } + """, + macros: ["JSFunction": JSFunctionMacro.self], + indentationWidth: indentationWidth + ) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift new file mode 100644 index 00000000..8c7f3c11 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSGetterMacroTests.swift @@ -0,0 +1,299 @@ +import SwiftDiagnostics +import SwiftSyntax +import SwiftSyntaxMacros +import SwiftSyntaxMacrosTestSupport +import Testing +import BridgeJSMacros + +@Suite struct JSGetterMacroTests { + private let indentationWidth: Trivia = .spaces(4) + + @Test func topLevelVariable() { + assertMacroExpansion( + """ + @JSGetter + var count: Int + """, + expandedSource: """ + var count: Int { + get throws(JSException) { + return try _$count_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelLet() { + assertMacroExpansion( + """ + @JSGetter + let constant: String + """, + expandedSource: """ + let constant: String { + get throws(JSException) { + return try _$constant_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func instanceProperty() { + assertMacroExpansion( + """ + struct MyClass { + @JSGetter + var name: String + } + """, + expandedSource: """ + struct MyClass { + var name: String { + get throws(JSException) { + return try _$MyClass_name_get(self.jsObject) + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func instanceLetProperty() { + assertMacroExpansion( + """ + struct MyClass { + @JSGetter + let id: Int + } + """, + expandedSource: """ + struct MyClass { + let id: Int { + get throws(JSException) { + return try _$MyClass_id_get(self.jsObject) + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func staticProperty() { + assertMacroExpansion( + """ + struct MyClass { + @JSGetter + static var version: String + } + """, + expandedSource: """ + struct MyClass { + static var version: String { + get throws(JSException) { + return try _$version_get() + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func classProperty() { + assertMacroExpansion( + """ + class MyClass { + @JSGetter + class var version: String + } + """, + expandedSource: """ + class MyClass { + class var version: String { + get throws(JSException) { + return try _$version_get() + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func enumProperty() { + assertMacroExpansion( + """ + enum MyEnum { + @JSGetter + var value: Int + } + """, + expandedSource: """ + enum MyEnum { + var value: Int { + get throws(JSException) { + return try _$MyEnum_value_get(self.jsObject) + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func actorProperty() { + assertMacroExpansion( + """ + actor MyActor { + @JSGetter + var state: String + } + """, + expandedSource: """ + actor MyActor { + var state: String { + get throws(JSException) { + return try _$MyActor_state_get(self.jsObject) + } + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func variableWithExistingAccessor() { + assertMacroExpansion( + """ + @JSGetter + var count: Int { + return 0 + } + """, + expandedSource: """ + var count: Int { + get { + return 0 + } + get throws(JSException) { + return try _$count_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func variableWithInitializer() { + assertMacroExpansion( + """ + @JSGetter + var count: Int = 0 + """, + expandedSource: """ + var count: Int { + get throws(JSException) { + return try _$count_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func multipleBindings() { + assertMacroExpansion( + """ + @JSGetter + var x: Int, y: Int + """, + expandedSource: """ + var x: Int, y: Int + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSGetter can only be applied to single-variable declarations.", + line: 1, + column: 1, + severity: .error + ) + ], + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func unsupportedDeclaration() { + assertMacroExpansion( + """ + @JSGetter + func test() {} + """, + expandedSource: """ + func test() {} + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSGetter can only be applied to single-variable declarations.", + line: 1, + column: 1, + severity: .error + ) + ], + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func variableWithTrailingComment() { + assertMacroExpansion( + """ + @JSGetter + var count: Int // comment + """, + expandedSource: """ + var count: Int { // comment + get throws(JSException) { + return try _$count_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func variableWithUnderscoreName() { + assertMacroExpansion( + """ + @JSGetter + var _internal: String + """, + expandedSource: """ + var _internal: String { + get throws(JSException) { + return try _$internal_get() + } + } + """, + macros: ["JSGetter": JSGetterMacro.self], + indentationWidth: indentationWidth + ) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift new file mode 100644 index 00000000..83289e09 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSSetterMacroTests.swift @@ -0,0 +1,278 @@ +import SwiftDiagnostics +import SwiftSyntax +import SwiftSyntaxMacros +import SwiftSyntaxMacrosTestSupport +import Testing +import BridgeJSMacros + +@Suite struct JSSetterMacroTests { + private let indentationWidth: Trivia = .spaces(4) + + @Test func topLevelSetter() { + assertMacroExpansion( + """ + @JSSetter + func setFoo(_ value: Foo) throws(JSException) + """, + expandedSource: """ + func setFoo(_ value: Foo) throws(JSException) { + try _$foo_set(value) + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func topLevelSetterWithNamedParameter() { + assertMacroExpansion( + """ + @JSSetter + func setCount(count: Int) throws(JSException) + """, + expandedSource: """ + func setCount(count: Int) throws(JSException) { + try _$count_set(count) + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func instanceSetter() { + assertMacroExpansion( + """ + struct MyClass { + @JSSetter + func setName(_ name: String) throws(JSException) + } + """, + expandedSource: """ + struct MyClass { + func setName(_ name: String) throws(JSException) { + try _$MyClass_name_set(self.jsObject, name) + } + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func staticSetter() { + assertMacroExpansion( + """ + struct MyClass { + @JSSetter + static func setVersion(_ version: String) throws(JSException) + } + """, + expandedSource: """ + struct MyClass { + static func setVersion(_ version: String) throws(JSException) { + try _$version_set(version) + } + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func classSetter() { + assertMacroExpansion( + """ + class MyClass { + @JSSetter + class func setConfig(_ config: Config) throws(JSException) + } + """, + expandedSource: """ + class MyClass { + class func setConfig(_ config: Config) throws(JSException) { + try _$config_set(config) + } + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func enumSetter() { + assertMacroExpansion( + """ + enum MyEnum { + @JSSetter + func setValue(_ value: Int) throws(JSException) + } + """, + expandedSource: """ + enum MyEnum { + func setValue(_ value: Int) throws(JSException) { + try _$MyEnum_value_set(self.jsObject, value) + } + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func actorSetter() { + assertMacroExpansion( + """ + actor MyActor { + @JSSetter + func setState(_ state: String) throws(JSException) + } + """, + expandedSource: """ + actor MyActor { + func setState(_ state: String) throws(JSException) { + try _$MyActor_state_set(self.jsObject, state) + } + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func setterWithExistingBody() { + assertMacroExpansion( + """ + @JSSetter + func setFoo(_ value: Foo) throws(JSException) { + print("Setting foo") + } + """, + expandedSource: """ + func setFoo(_ value: Foo) throws(JSException) { + try _$foo_set(value) + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func invalidSetterName() { + assertMacroExpansion( + """ + @JSSetter + func updateFoo(_ value: Foo) throws(JSException) + """, + expandedSource: """ + func updateFoo(_ value: Foo) throws(JSException) + """, + diagnostics: [ + DiagnosticSpec( + message: + "@JSSetter function name must start with 'set' followed by a property name (e.g., 'setFoo').", + line: 1, + column: 1 + ) + ], + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func setterNameTooShort() { + assertMacroExpansion( + """ + @JSSetter + func set(_ value: Foo) throws(JSException) + """, + expandedSource: """ + func set(_ value: Foo) throws(JSException) + """, + diagnostics: [ + DiagnosticSpec( + message: + "@JSSetter function name must start with 'set' followed by a property name (e.g., 'setFoo').", + line: 1, + column: 1 + ) + ], + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func setterWithoutParameter() { + assertMacroExpansion( + """ + @JSSetter + func setFoo() throws(JSException) + """, + expandedSource: """ + func setFoo() throws(JSException) + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSSetter function must have at least one parameter.", + line: 1, + column: 1 + ) + ], + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func unsupportedDeclaration() { + assertMacroExpansion( + """ + @JSSetter + var property: String + """, + expandedSource: """ + var property: String + """, + diagnostics: [ + DiagnosticSpec( + message: "@JSSetter can only be applied to functions.", + line: 1, + column: 1 + ) + ], + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func setterWithMultipleWords() { + assertMacroExpansion( + """ + @JSSetter + func setConnectionTimeout(_ timeout: Int) throws(JSException) + """, + expandedSource: """ + func setConnectionTimeout(_ timeout: Int) throws(JSException) { + try _$connectionTimeout_set(timeout) + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } + + @Test func setterWithSingleLetterProperty() { + assertMacroExpansion( + """ + @JSSetter + func setX(_ x: Int) throws(JSException) + """, + expandedSource: """ + func setX(_ x: Int) throws(JSException) { + try _$x_set(x) + } + """, + macros: ["JSSetter": JSSetterMacro.self], + indentationWidth: indentationWidth + ) + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index c81a224f..0485adfc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -4,7 +4,8 @@ import SwiftParser import Testing @testable import BridgeJSLink @testable import BridgeJSCore -@testable import TS2Skeleton +@testable import TS2Swift +@testable import BridgeJSSkeleton @Suite struct BridgeJSLinkTests { private func snapshot( @@ -52,26 +53,51 @@ import Testing let name = url.deletingPathExtension().lastPathComponent let (_, outputSkeleton) = try #require(try swiftAPI.finalize()) - let bridgeJSLink: BridgeJSLink = BridgeJSLink(exportedSkeletons: [outputSkeleton], sharedMemory: false) + let bridgeJSLink: BridgeJSLink = BridgeJSLink( + skeletons: [ + BridgeJSSkeleton(moduleName: "TestModule", exported: outputSkeleton) + ], + sharedMemory: false + ) try snapshot(bridgeJSLink: bridgeJSLink, name: name + ".Export") } @Test(arguments: collectInputs(extension: ".d.ts")) func snapshotImport(input: String) throws { let url = Self.inputsDirectory.appendingPathComponent(input) + let name = url.deletingPathExtension().deletingPathExtension().lastPathComponent let tsconfigPath = url.deletingLastPathComponent().appendingPathComponent("tsconfig.json") - var importTS = ImportTS(progress: .silent, moduleName: "TestModule") let nodePath = try #require(which("node")) - try importTS.addSourceFile(url.path, tsconfigPath: tsconfigPath.path, nodePath: nodePath) - let name = url.deletingPathExtension().deletingPathExtension().lastPathComponent + let swiftSource = try invokeTS2Swift( + dtsFile: url.path, + tsconfigPath: tsconfigPath.path, + nodePath: nodePath, + progress: .silent + ) - let encoder = JSONEncoder() - encoder.outputFormatting = [.prettyPrinted, .sortedKeys] - let outputSkeletonData = try encoder.encode(importTS.skeleton) + let sourceFile = Parser.parse(source: swiftSource) + let importSwift = ImportSwiftMacros(progress: .silent, moduleName: "TestModule") + importSwift.addSourceFile(sourceFile, "\(name).Macros.swift") + let importResult = try importSwift.finalize() + + var importTS = ImportTS(progress: .silent, moduleName: "TestModule") + for child in importResult.outputSkeleton.children { + importTS.addSkeleton(child) + } + let importSkeleton = importTS.skeleton var bridgeJSLink = BridgeJSLink(sharedMemory: false) - try bridgeJSLink.addImportedSkeletonFile(data: outputSkeletonData) + // Create unified skeleton for test + let unifiedSkeleton = BridgeJSSkeleton( + moduleName: "TestModule", + exported: nil, + imported: importSkeleton + ) + let encoder = JSONEncoder() + encoder.outputFormatting = [.prettyPrinted, .sortedKeys] + let unifiedData = try encoder.encode(unifiedSkeleton) + try bridgeJSLink.addSkeletonFile(data: unifiedData) try snapshot(bridgeJSLink: bridgeJSLink, name: name + ".Import") } @@ -88,7 +114,12 @@ import Testing try swiftAPI.addSourceFile(sourceFile, inputFile) let name = url.deletingPathExtension().lastPathComponent let (_, outputSkeleton) = try #require(try swiftAPI.finalize()) - let bridgeJSLink: BridgeJSLink = BridgeJSLink(exportedSkeletons: [outputSkeleton], sharedMemory: false) + let bridgeJSLink: BridgeJSLink = BridgeJSLink( + skeletons: [ + BridgeJSSkeleton(moduleName: "TestModule", exported: outputSkeleton) + ], + sharedMemory: false + ) try snapshot(bridgeJSLink: bridgeJSLink, name: name + ".Global.Export") } @@ -107,7 +138,10 @@ import Testing let (_, privateSkeleton) = try #require(try privateAPI.finalize()) let bridgeJSLink = BridgeJSLink( - exportedSkeletons: [globalSkeleton, privateSkeleton], + skeletons: [ + BridgeJSSkeleton(moduleName: "GlobalModule", exported: globalSkeleton), + BridgeJSSkeleton(moduleName: "PrivateModule", exported: privateSkeleton), + ], sharedMemory: false ) try snapshot(bridgeJSLink: bridgeJSLink, name: "MixedModules.Export") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ImportTSTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ImportTSTests.swift index ef642ed3..0a3101f1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ImportTSTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ImportTSTests.swift @@ -1,7 +1,8 @@ import Testing import Foundation +import SwiftParser @testable import BridgeJSCore -@testable import TS2Skeleton +@testable import TS2Swift @Suite struct ImportTSTests { static let inputsDirectory = URL(fileURLWithPath: #filePath).deletingLastPathComponent().appendingPathComponent( @@ -16,13 +17,31 @@ import Foundation @Test(arguments: collectInputs()) func snapshot(input: String) throws { - var api = ImportTS(progress: .silent, moduleName: "Check") let url = Self.inputsDirectory.appendingPathComponent(input) + let name = url.deletingPathExtension().deletingPathExtension().deletingPathExtension().lastPathComponent let nodePath = try #require(which("node")) let tsconfigPath = url.deletingLastPathComponent().appendingPathComponent("tsconfig.json") - try api.addSourceFile(url.path, tsconfigPath: tsconfigPath.path, nodePath: nodePath) - let outputSwift = try #require(try api.finalize()) - let name = url.deletingPathExtension().deletingPathExtension().deletingPathExtension().lastPathComponent + + let swiftSource = try invokeTS2Swift( + dtsFile: url.path, + tsconfigPath: tsconfigPath.path, + nodePath: nodePath, + progress: .silent + ) + try assertSnapshot( + name: name + ".Macros", + filePath: #filePath, + function: #function, + input: swiftSource.data(using: .utf8)!, + fileExtension: "swift" + ) + + let sourceFile = Parser.parse(source: swiftSource) + let importSwift = ImportSwiftMacros(progress: .silent, moduleName: "Check") + importSwift.addSourceFile(sourceFile, "\(name).Macros.swift") + let importResult = try importSwift.finalize() + + let outputSwift = try #require(importResult.outputSwift) try assertSnapshot( name: name, filePath: #filePath, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/WhichTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/WhichTests.swift index 958d4d64..f82b3dfe 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/WhichTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/WhichTests.swift @@ -1,6 +1,6 @@ import Testing import Foundation -@testable import TS2Skeleton +@testable import TS2Swift @testable import BridgeJSCore @Suite struct WhichTests { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js index a71c8dd7..60435e56 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js @@ -237,43 +237,43 @@ export async function createInstantiator(options, swift) { setException(error); } } - TestModule["bjs_WeirdNaming_normalProperty_set"] = function bjs_WeirdNaming_normalProperty_set(self, newValue) { + TestModule["bjs_WeirdNaming_for_get"] = function bjs_WeirdNaming_for_get(self) { try { - const newValueObject = swift.memory.getObject(newValue); - swift.memory.release(newValue); - swift.memory.getObject(self).normalProperty = newValueObject; + let ret = swift.memory.getObject(self).for; + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; } catch (error) { setException(error); } } - TestModule["bjs_WeirdNaming_for_get"] = function bjs_WeirdNaming_for_get(self) { + TestModule["bjs_WeirdNaming_Any_get"] = function bjs_WeirdNaming_Any_get(self) { try { - let ret = swift.memory.getObject(self).for; + let ret = swift.memory.getObject(self).Any; tmpRetBytes = textEncoder.encode(ret); return tmpRetBytes.length; } catch (error) { setException(error); } } - TestModule["bjs_WeirdNaming_for_set"] = function bjs_WeirdNaming_for_set(self, newValue) { + TestModule["bjs_WeirdNaming_normalProperty_set"] = function bjs_WeirdNaming_normalProperty_set(self, newValue) { try { const newValueObject = swift.memory.getObject(newValue); swift.memory.release(newValue); - swift.memory.getObject(self).for = newValueObject; + swift.memory.getObject(self).normalProperty = newValueObject; } catch (error) { setException(error); } } - TestModule["bjs_WeirdNaming_Any_get"] = function bjs_WeirdNaming_Any_get(self) { + TestModule["bjs_WeirdNaming_for_set"] = function bjs_WeirdNaming_for_set(self, newValue) { try { - let ret = swift.memory.getObject(self).Any; - tmpRetBytes = textEncoder.encode(ret); - return tmpRetBytes.length; + const newValueObject = swift.memory.getObject(newValue); + swift.memory.release(newValue); + swift.memory.getObject(self).for = newValueObject; } catch (error) { setException(error); } } - TestModule["bjs_WeirdNaming_Any_set"] = function bjs_WeirdNaming_Any_set(self, newValue) { + TestModule["bjs_WeirdNaming_any_set"] = function bjs_WeirdNaming_any_set(self, newValue) { try { const newValueObject = swift.memory.getObject(newValue); swift.memory.release(newValue); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MultipleImportedTypes.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MultipleImportedTypes.Import.js index 86edf39a..40a3f4e3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MultipleImportedTypes.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MultipleImportedTypes.Import.js @@ -244,7 +244,6 @@ export async function createInstantiator(options, swift) { swift.memory.getObject(self).connectionTimeout = newValue; } catch (error) { setException(error); - return 0 } } TestModule["bjs_DatabaseConnection_connect"] = function bjs_DatabaseConnection_connect(self, url) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js index 0e204182..6c44fd00 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js @@ -211,22 +211,22 @@ export async function createInstantiator(options, swift) { setException(error); } } - TestModule["bjs_Greeter_name_set"] = function bjs_Greeter_name_set(self, newValue) { + TestModule["bjs_Greeter_age_get"] = function bjs_Greeter_age_get(self) { try { - const newValueObject = swift.memory.getObject(newValue); - swift.memory.release(newValue); - swift.memory.getObject(self).name = newValueObject; + let ret = swift.memory.getObject(self).age; + return ret; } catch (error) { setException(error); + return 0 } } - TestModule["bjs_Greeter_age_get"] = function bjs_Greeter_age_get(self) { + TestModule["bjs_Greeter_name_set"] = function bjs_Greeter_name_set(self, newValue) { try { - let ret = swift.memory.getObject(self).age; - return ret; + const newValueObject = swift.memory.getObject(newValue); + swift.memory.release(newValue); + swift.memory.getObject(self).name = newValueObject; } catch (error) { setException(error); - return 0 } } TestModule["bjs_Greeter_greet"] = function bjs_Greeter_greet(self) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.json index 4bb84558..77c5b367 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.json @@ -175,7 +175,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.swift index 08e38435..4c97553d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Async.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_asyncReturnVoid") @_cdecl("bjs_asyncReturnVoid") public func _bjs_asyncReturnVoid() -> Int32 { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.json index faff4484..97def206 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.json @@ -140,7 +140,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.swift index eef86b6d..05437f54 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.ReverseOrder.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_standaloneFunction") @_cdecl("bjs_standaloneFunction") public func _bjs_standaloneFunction(_ b: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.json index a0caf3bc..acfa4c9e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.json @@ -140,7 +140,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.swift index 72952036..fa8e80cd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileFunctionTypes.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_standaloneFunction") @_cdecl("bjs_standaloneFunction") public func _bjs_standaloneFunction(_ b: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.json index aa4242cd..de5fb19b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.json @@ -52,7 +52,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.swift index 7504b289..8d697f8b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.ReverseOrder.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_ClassA_linkedB_get") @_cdecl("bjs_ClassA_linkedB_get") public func _bjs_ClassA_linkedB_get(_ _self: UnsafeMutableRawPointer) -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.json index e6acc7f3..53a5f858 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.json @@ -52,7 +52,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.swift index 04130f74..0a039607 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/CrossFileTypeResolution.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_ClassB_init") @_cdecl("bjs_ClassB_init") public func _bjs_ClassB_init() -> UnsafeMutableRawPointer { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.json index 7e614a32..1a013eed 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.json @@ -730,7 +730,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.swift index f624dc33..d5e5bdc4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/DefaultParameters.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Status: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.json index f7e57aab..ab7fbfd9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.json @@ -835,7 +835,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.swift index 1a1bc9ba..13239108 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumAssociatedValue.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension APIResult: _BridgedSwiftAssociatedValueEnum { private static func _bridgeJSLiftFromCaseId(_ caseId: Int32) -> APIResult { switch caseId { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.json index 1f4d5504..ca6fabce 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.json @@ -311,7 +311,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.swift index a513a22a..06c3e1cd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumCase.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Direction: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.json index 98ded1fe..42a084c4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.json @@ -406,7 +406,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.swift index 66f8e22a..9683b530 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.Global.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Networking.API.Method: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.json index 24afb4eb..23bb0642 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.json @@ -406,7 +406,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.swift index 66f8e22a..9683b530 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumNamespace.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Networking.API.Method: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.json index b7ea9cd1..078772ff 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.json @@ -1489,7 +1489,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.swift index 5d88fce4..12fdeba0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/EnumRawType.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Theme: _BridgedSwiftEnumNoPayload { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.json index 995c3efc..5409a400 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.json @@ -67,7 +67,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.swift index 3e38fee4..981e01be 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedGlobal.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_GlobalAPI_globalFunction") @_cdecl("bjs_GlobalAPI_globalFunction") public func _bjs_GlobalAPI_globalFunction() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.json index c986a903..bc58d985 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.json @@ -67,7 +67,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.swift index 76a1a6c2..1e9eae2b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/MixedPrivate.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_PrivateAPI_privateFunction") @_cdecl("bjs_PrivateAPI_privateFunction") public func _bjs_PrivateAPI_privateFunction() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.json index a0b1efea..eb11e983 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.json @@ -173,7 +173,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.swift index 19fe8ea9..cb19c685 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.Global.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_plainFunction") @_cdecl("bjs_plainFunction") public func _bjs_plainFunction() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.json index 2420d592..914b7b89 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.json @@ -173,7 +173,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.swift index 19fe8ea9..cb19c685 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Namespaces.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_plainFunction") @_cdecl("bjs_plainFunction") public func _bjs_plainFunction() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.json index 64aaa295..b3a4fc2c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.json @@ -690,7 +690,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.swift index f2f19f9a..88195f37 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Optionals.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_roundTripOptionalClass") @_cdecl("bjs_roundTripOptionalClass") public func _bjs_roundTripOptionalClass(_ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.json index d9edf11c..ab2539ab 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.json @@ -60,7 +60,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift index 4f906704..bb3ea0fd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_check") @_cdecl("bjs_check") public func _bjs_check(_ a: Int32, _ b: Float32, _ c: Float64, _ d: Int32) -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.json index 79ce75da..e63b4a24 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.json @@ -76,7 +76,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift index 63e5f03c..62b5826d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_checkInt") @_cdecl("bjs_checkInt") public func _bjs_checkInt() -> Int32 { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.json index aa5fcc86..43d05d9f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.json @@ -351,7 +351,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.swift index 96bde51e..b5b3c8d9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PropertyTypes.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_createPropertyHolder") @_cdecl("bjs_createPropertyHolder") public func _bjs_createPropertyHolder(_ intValue: Int32, _ floatValue: Float32, _ doubleValue: Float64, _ boolValue: Int32, _ stringValueBytes: Int32, _ stringValueLength: Int32, _ jsObject: Int32) -> UnsafeMutableRawPointer { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.json index c3107394..b79a59d1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.json @@ -396,7 +396,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.swift index 318b908b..735c225f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Protocol.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - struct AnyMyViewControllerDelegate: MyViewControllerDelegate, _BridgedSwiftProtocolWrapper { let jsObject: JSObject diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.json index 4e8d80d5..3b6937c3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.json @@ -327,7 +327,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.swift index 8ea228dc..8a5b5606 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.Global.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Calculator: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.json index ab399f10..652465df 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.json @@ -327,7 +327,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.swift index 8ea228dc..8a5b5606 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticFunctions.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension Calculator: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.json index 472406ba..4ec19f83 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.json @@ -330,7 +330,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.swift index 91577ebf..6510fd89 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.Global.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension PropertyEnum: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.json index 6ef93798..0e8b2de2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.json @@ -330,7 +330,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.swift index 91577ebf..6510fd89 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StaticProperties.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension PropertyEnum: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.json index b7015123..9116fd48 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.json @@ -58,7 +58,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift index 6e32c00d..d980f5bc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_checkString") @_cdecl("bjs_checkString") public func _bjs_checkString(_ aBytes: Int32, _ aLength: Int32) -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.json index 39ec8b7a..01f9ca4b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.json @@ -25,7 +25,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift index 0475def5..1c260ec5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_checkString") @_cdecl("bjs_checkString") public func _bjs_checkString() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.json index df4975e1..b8f908c2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.json @@ -133,7 +133,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift index 65279210..216dfc68 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_takeGreeter") @_cdecl("bjs_takeGreeter") public func _bjs_takeGreeter(_ greeter: UnsafeMutableRawPointer) -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.json index 20015ba2..27627407 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.json @@ -1066,7 +1066,6 @@ "functions" : [ ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.swift index 2e57a8a5..7d0ae15d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClosure.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule10HttpStatusO_Si") fileprivate func invoke_js_callback_TestModule_10TestModule10HttpStatusO_Si(_ callback: Int32, _ param0: Int32) -> Int32 diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.json index 498231bf..c6e430ed 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.json @@ -86,7 +86,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.swift index f35fc3b0..a09d312d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftStruct.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - extension DataPoint: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter() -> DataPoint { let optFlag = Optional.bridgeJSLiftParameter(_swift_js_pop_param_int32(), _swift_js_pop_param_int32()) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.json index ef42dc6c..ad47cbf0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.json @@ -25,7 +25,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift index 8b865b7d..37f6d9c9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_throwsSomething") @_cdecl("bjs_throwsSomething") public func _bjs_throwsSomething() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.json index c80650af..b6b9c7bc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.json @@ -25,7 +25,6 @@ } } ], - "moduleName" : "TestModule", "protocols" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift index 15e91a0b..d5bc03b1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - @_expose(wasm, "bjs_check") @_cdecl("bjs_check") public func _bjs_check() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.Macros.swift new file mode 100644 index 00000000..cf1118df --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.Macros.swift @@ -0,0 +1,13 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func checkArray(_ a: JSObject) throws (JSException) -> Void + +@JSFunction func checkArrayWithLength(_ a: JSObject, _ b: Double) throws (JSException) -> Void + +@JSFunction func checkArray(_ a: JSObject) throws (JSException) -> Void diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift index 56425b20..4e2cec8d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_checkArray") fileprivate func bjs_checkArray(_ a: Int32) -> Void @@ -15,7 +7,7 @@ fileprivate func bjs_checkArray(_ a: Int32) -> Void { } #endif -func checkArray(_ a: JSObject) throws(JSException) -> Void { +func _$checkArray(_ a: JSObject) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() bjs_checkArray(aValue) if let error = _swift_js_take_exception() { @@ -32,7 +24,7 @@ fileprivate func bjs_checkArrayWithLength(_ a: Int32, _ b: Float64) -> Void { } #endif -func checkArrayWithLength(_ a: JSObject, _ b: Double) throws(JSException) -> Void { +func _$checkArrayWithLength(_ a: JSObject, _ b: Double) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() let bValue = b.bridgeJSLowerParameter() bjs_checkArrayWithLength(aValue, bValue) @@ -50,7 +42,7 @@ fileprivate func bjs_checkArray(_ a: Int32) -> Void { } #endif -func checkArray(_ a: JSObject) throws(JSException) -> Void { +func _$checkArray(_ a: JSObject) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() bjs_checkArray(aValue) if let error = _swift_js_take_exception() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.Macros.swift new file mode 100644 index 00000000..dd037737 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.Macros.swift @@ -0,0 +1,21 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func asyncReturnVoid() throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripInt(_ v: Double) throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripString(_ v: String) throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripBool(_ v: Bool) throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripFloat(_ v: Double) throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripDouble(_ v: Double) throws (JSException) -> JSPromise + +@JSFunction func asyncRoundTripJSObject(_ v: JSObject) throws (JSException) -> JSPromise diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.swift index 41a89ad2..1cc954b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Async.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_asyncReturnVoid") fileprivate func bjs_asyncReturnVoid() -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_asyncReturnVoid() -> Int32 { } #endif -func asyncReturnVoid() throws(JSException) -> JSPromise { +func _$asyncReturnVoid() throws(JSException) -> JSPromise { let ret = bjs_asyncReturnVoid() if let error = _swift_js_take_exception() { throw error @@ -32,7 +24,7 @@ fileprivate func bjs_asyncRoundTripInt(_ v: Float64) -> Int32 { } #endif -func asyncRoundTripInt(_ v: Double) throws(JSException) -> JSPromise { +func _$asyncRoundTripInt(_ v: Double) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripInt(vValue) if let error = _swift_js_take_exception() { @@ -50,7 +42,7 @@ fileprivate func bjs_asyncRoundTripString(_ v: Int32) -> Int32 { } #endif -func asyncRoundTripString(_ v: String) throws(JSException) -> JSPromise { +func _$asyncRoundTripString(_ v: String) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripString(vValue) if let error = _swift_js_take_exception() { @@ -68,7 +60,7 @@ fileprivate func bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { } #endif -func asyncRoundTripBool(_ v: Bool) throws(JSException) -> JSPromise { +func _$asyncRoundTripBool(_ v: Bool) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripBool(vValue) if let error = _swift_js_take_exception() { @@ -86,7 +78,7 @@ fileprivate func bjs_asyncRoundTripFloat(_ v: Float64) -> Int32 { } #endif -func asyncRoundTripFloat(_ v: Double) throws(JSException) -> JSPromise { +func _$asyncRoundTripFloat(_ v: Double) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripFloat(vValue) if let error = _swift_js_take_exception() { @@ -104,7 +96,7 @@ fileprivate func bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { } #endif -func asyncRoundTripDouble(_ v: Double) throws(JSException) -> JSPromise { +func _$asyncRoundTripDouble(_ v: Double) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripDouble(vValue) if let error = _swift_js_take_exception() { @@ -122,7 +114,7 @@ fileprivate func bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { } #endif -func asyncRoundTripJSObject(_ v: JSObject) throws(JSException) -> JSPromise { +func _$asyncRoundTripJSObject(_ v: JSObject) throws(JSException) -> JSPromise { let vValue = v.bridgeJSLowerParameter() let ret = bjs_asyncRoundTripJSObject(vValue) if let error = _swift_js_take_exception() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.Macros.swift new file mode 100644 index 00000000..1017ded7 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.Macros.swift @@ -0,0 +1,14 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func returnAnimatable() throws (JSException) -> Animatable + +@JSClass struct Animatable: _JSBridgedClass { + @JSFunction func animate(_ keyframes: JSObject, _ options: JSObject) throws (JSException) -> JSObject + @JSFunction func getAnimations(_ options: JSObject) throws (JSException) -> JSObject +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift index 12277171..fd16bd0d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_returnAnimatable") fileprivate func bjs_returnAnimatable() -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_returnAnimatable() -> Int32 { } #endif -func returnAnimatable() throws(JSException) -> Animatable { +func _$returnAnimatable() throws(JSException) -> Animatable { let ret = bjs_returnAnimatable() if let error = _swift_js_take_exception() { throw error @@ -41,32 +33,23 @@ fileprivate func bjs_Animatable_getAnimations(_ self: Int32, _ options: Int32) - } #endif -struct Animatable: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - func animate(_ keyframes: JSObject, _ options: JSObject) throws(JSException) -> JSObject { - let selfValue = self.bridgeJSLowerParameter() - let keyframesValue = keyframes.bridgeJSLowerParameter() - let optionsValue = options.bridgeJSLowerParameter() - let ret = bjs_Animatable_animate(selfValue, keyframesValue, optionsValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) +func _$Animatable_animate(_ self: JSObject, _ keyframes: JSObject, _ options: JSObject) throws(JSException) -> JSObject { + let selfValue = self.bridgeJSLowerParameter() + let keyframesValue = keyframes.bridgeJSLowerParameter() + let optionsValue = options.bridgeJSLowerParameter() + let ret = bjs_Animatable_animate(selfValue, keyframesValue, optionsValue) + if let error = _swift_js_take_exception() { + throw error } + return JSObject.bridgeJSLiftReturn(ret) +} - func getAnimations(_ options: JSObject) throws(JSException) -> JSObject { - let selfValue = self.bridgeJSLowerParameter() - let optionsValue = options.bridgeJSLowerParameter() - let ret = bjs_Animatable_getAnimations(selfValue, optionsValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) +func _$Animatable_getAnimations(_ self: JSObject, _ options: JSObject) throws(JSException) -> JSObject { + let selfValue = self.bridgeJSLowerParameter() + let optionsValue = options.bridgeJSLowerParameter() + let ret = bjs_Animatable_getAnimations(selfValue, optionsValue) + if let error = _swift_js_take_exception() { + throw error } - + return JSObject.bridgeJSLiftReturn(ret) } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.Macros.swift new file mode 100644 index 00000000..ee636020 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.Macros.swift @@ -0,0 +1,26 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func createArrayBuffer() throws (JSException) -> ArrayBufferLike + +@JSClass struct ArrayBufferLike: _JSBridgedClass { + @JSGetter var byteLength: Double + @JSFunction func slice(_ begin: Double, _ end: Double) throws (JSException) -> ArrayBufferLike +} + +@JSFunction func createWeirdObject() throws (JSException) -> WeirdNaming + +@JSClass struct WeirdNaming: _JSBridgedClass { + @JSGetter var normalProperty: String + @JSSetter func setNormalProperty(_ value: String) throws (JSException) + @JSGetter var `for`: String + @JSSetter func setFor(_ value: String) throws (JSException) + @JSGetter var `Any`: String + @JSSetter(jsName: "Any") func setAny(_ value: String) throws (JSException) + @JSFunction func `as`() throws (JSException) -> Void +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.swift index c7868299..ba9e925e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_createArrayBuffer") fileprivate func bjs_createArrayBuffer() -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_createArrayBuffer() -> Int32 { } #endif -func createArrayBuffer() throws(JSException) -> ArrayBufferLike { +func _$createArrayBuffer() throws(JSException) -> ArrayBufferLike { let ret = bjs_createArrayBuffer() if let error = _swift_js_take_exception() { throw error @@ -32,7 +24,7 @@ fileprivate func bjs_createWeirdObject() -> Int32 { } #endif -func createWeirdObject() throws(JSException) -> WeirdNaming { +func _$createWeirdObject() throws(JSException) -> WeirdNaming { let ret = bjs_createWeirdObject() if let error = _swift_js_take_exception() { throw error @@ -58,35 +50,24 @@ fileprivate func bjs_ArrayBufferLike_slice(_ self: Int32, _ begin: Float64, _ en } #endif -struct ArrayBufferLike: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var byteLength: Double { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_ArrayBufferLike_byteLength_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) - } +func _$ArrayBufferLike_byteLength_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ArrayBufferLike_byteLength_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return Double.bridgeJSLiftReturn(ret) +} - func slice(_ begin: Double, _ end: Double) throws(JSException) -> ArrayBufferLike { - let selfValue = self.bridgeJSLowerParameter() - let beginValue = begin.bridgeJSLowerParameter() - let endValue = end.bridgeJSLowerParameter() - let ret = bjs_ArrayBufferLike_slice(selfValue, beginValue, endValue) - if let error = _swift_js_take_exception() { - throw error - } - return ArrayBufferLike.bridgeJSLiftReturn(ret) +func _$ArrayBufferLike_slice(_ self: JSObject, _ begin: Double, _ end: Double) throws(JSException) -> ArrayBufferLike { + let selfValue = self.bridgeJSLowerParameter() + let beginValue = begin.bridgeJSLowerParameter() + let endValue = end.bridgeJSLowerParameter() + let ret = bjs_ArrayBufferLike_slice(selfValue, beginValue, endValue) + if let error = _swift_js_take_exception() { + throw error } - + return ArrayBufferLike.bridgeJSLiftReturn(ret) } #if arch(wasm32) @@ -99,46 +80,46 @@ fileprivate func bjs_WeirdNaming_normalProperty_get(_ self: Int32) -> Int32 { #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_normalProperty_set") -fileprivate func bjs_WeirdNaming_normalProperty_set(_ self: Int32, _ newValue: Int32) -> Void +@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_for_get") +fileprivate func bjs_WeirdNaming_for_get(_ self: Int32) -> Int32 #else -fileprivate func bjs_WeirdNaming_normalProperty_set(_ self: Int32, _ newValue: Int32) -> Void { +fileprivate func bjs_WeirdNaming_for_get(_ self: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_for_get") -fileprivate func bjs_WeirdNaming_for_get(_ self: Int32) -> Int32 +@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_Any_get") +fileprivate func bjs_WeirdNaming_Any_get(_ self: Int32) -> Int32 #else -fileprivate func bjs_WeirdNaming_for_get(_ self: Int32) -> Int32 { +fileprivate func bjs_WeirdNaming_Any_get(_ self: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_for_set") -fileprivate func bjs_WeirdNaming_for_set(_ self: Int32, _ newValue: Int32) -> Void +@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_normalProperty_set") +fileprivate func bjs_WeirdNaming_normalProperty_set(_ self: Int32, _ newValue: Int32) -> Void #else -fileprivate func bjs_WeirdNaming_for_set(_ self: Int32, _ newValue: Int32) -> Void { +fileprivate func bjs_WeirdNaming_normalProperty_set(_ self: Int32, _ newValue: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_Any_get") -fileprivate func bjs_WeirdNaming_Any_get(_ self: Int32) -> Int32 +@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_for_set") +fileprivate func bjs_WeirdNaming_for_set(_ self: Int32, _ newValue: Int32) -> Void #else -fileprivate func bjs_WeirdNaming_Any_get(_ self: Int32) -> Int32 { +fileprivate func bjs_WeirdNaming_for_set(_ self: Int32, _ newValue: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_Any_set") -fileprivate func bjs_WeirdNaming_Any_set(_ self: Int32, _ newValue: Int32) -> Void +@_extern(wasm, module: "Check", name: "bjs_WeirdNaming_any_set") +fileprivate func bjs_WeirdNaming_any_set(_ self: Int32, _ newValue: Int32) -> Void #else -fileprivate func bjs_WeirdNaming_Any_set(_ self: Int32, _ newValue: Int32) -> Void { +fileprivate func bjs_WeirdNaming_any_set(_ self: Int32, _ newValue: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif @@ -152,79 +133,64 @@ fileprivate func bjs_WeirdNaming_as(_ self: Int32) -> Void { } #endif -struct WeirdNaming: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var normalProperty: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeirdNaming_normalProperty_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$WeirdNaming_normalProperty_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeirdNaming_normalProperty_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func setNormalProperty(_ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_WeirdNaming_normalProperty_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$WeirdNaming_for_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeirdNaming_for_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - var `for`: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeirdNaming_for_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$WeirdNaming_Any_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeirdNaming_Any_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func setFor(_ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_WeirdNaming_for_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$WeirdNaming_normalProperty_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_WeirdNaming_normalProperty_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error } +} - var `Any`: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeirdNaming_Any_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$WeirdNaming_for_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_WeirdNaming_for_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error } +} - func setAny(_ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_WeirdNaming_Any_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$WeirdNaming_any_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_WeirdNaming_any_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error } +} - func `as`() throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - bjs_WeirdNaming_as(selfValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$WeirdNaming_as(_ self: JSObject) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + bjs_WeirdNaming_as(selfValue) + if let error = _swift_js_take_exception() { + throw error } - } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.Macros.swift new file mode 100644 index 00000000..64317b79 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.Macros.swift @@ -0,0 +1,33 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func createDatabaseConnection(_ config: JSObject) throws (JSException) -> DatabaseConnection + +@JSClass struct DatabaseConnection: _JSBridgedClass { + @JSFunction func connect(_ url: String) throws (JSException) -> Void + @JSFunction func execute(_ query: String) throws (JSException) -> JSObject + @JSGetter var isConnected: Bool + @JSGetter var connectionTimeout: Double + @JSSetter func setConnectionTimeout(_ value: Double) throws (JSException) +} + +@JSFunction func createLogger(_ level: String) throws (JSException) -> Logger + +@JSClass struct Logger: _JSBridgedClass { + @JSFunction func log(_ message: String) throws (JSException) -> Void + @JSFunction func error(_ message: String, _ error: JSObject) throws (JSException) -> Void + @JSGetter var level: String +} + +@JSFunction func getConfigManager() throws (JSException) -> ConfigManager + +@JSClass struct ConfigManager: _JSBridgedClass { + @JSFunction func get(_ key: String) throws (JSException) -> JSObject + @JSFunction func set(_ key: String, _ value: JSObject) throws (JSException) -> Void + @JSGetter var configPath: String +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.swift index 1f8a1480..1c1418af 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/MultipleImportedTypes.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_createDatabaseConnection") fileprivate func bjs_createDatabaseConnection(_ config: Int32) -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_createDatabaseConnection(_ config: Int32) -> Int32 { } #endif -func createDatabaseConnection(_ config: JSObject) throws(JSException) -> DatabaseConnection { +func _$createDatabaseConnection(_ config: JSObject) throws(JSException) -> DatabaseConnection { let configValue = config.bridgeJSLowerParameter() let ret = bjs_createDatabaseConnection(configValue) if let error = _swift_js_take_exception() { @@ -33,7 +25,7 @@ fileprivate func bjs_createLogger(_ level: Int32) -> Int32 { } #endif -func createLogger(_ level: String) throws(JSException) -> Logger { +func _$createLogger(_ level: String) throws(JSException) -> Logger { let levelValue = level.bridgeJSLowerParameter() let ret = bjs_createLogger(levelValue) if let error = _swift_js_take_exception() { @@ -51,7 +43,7 @@ fileprivate func bjs_getConfigManager() -> Int32 { } #endif -func getConfigManager() throws(JSException) -> ConfigManager { +func _$getConfigManager() throws(JSException) -> ConfigManager { let ret = bjs_getConfigManager() if let error = _swift_js_take_exception() { throw error @@ -104,63 +96,50 @@ fileprivate func bjs_DatabaseConnection_execute(_ self: Int32, _ query: Int32) - } #endif -struct DatabaseConnection: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var isConnected: Bool { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_DatabaseConnection_isConnected_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) - } +func _$DatabaseConnection_isConnected_get(_ self: JSObject) throws(JSException) -> Bool { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_DatabaseConnection_isConnected_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return Bool.bridgeJSLiftReturn(ret) +} - var connectionTimeout: Double { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_DatabaseConnection_connectionTimeout_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) - } +func _$DatabaseConnection_connectionTimeout_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_DatabaseConnection_connectionTimeout_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return Double.bridgeJSLiftReturn(ret) +} - func setConnectionTimeout(_ newValue: Double) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_DatabaseConnection_connectionTimeout_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$DatabaseConnection_connectionTimeout_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_DatabaseConnection_connectionTimeout_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error } +} - func connect(_ url: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let urlValue = url.bridgeJSLowerParameter() - bjs_DatabaseConnection_connect(selfValue, urlValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$DatabaseConnection_connect(_ self: JSObject, _ url: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let urlValue = url.bridgeJSLowerParameter() + bjs_DatabaseConnection_connect(selfValue, urlValue) + if let error = _swift_js_take_exception() { + throw error } +} - func execute(_ query: String) throws(JSException) -> JSObject { - let selfValue = self.bridgeJSLowerParameter() - let queryValue = query.bridgeJSLowerParameter() - let ret = bjs_DatabaseConnection_execute(selfValue, queryValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) +func _$DatabaseConnection_execute(_ self: JSObject, _ query: String) throws(JSException) -> JSObject { + let selfValue = self.bridgeJSLowerParameter() + let queryValue = query.bridgeJSLowerParameter() + let ret = bjs_DatabaseConnection_execute(selfValue, queryValue) + if let error = _swift_js_take_exception() { + throw error } - + return JSObject.bridgeJSLiftReturn(ret) } #if arch(wasm32) @@ -190,43 +169,32 @@ fileprivate func bjs_Logger_error(_ self: Int32, _ message: Int32, _ error: Int3 } #endif -struct Logger: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var level: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Logger_level_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$Logger_level_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Logger_level_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func log(_ message: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let messageValue = message.bridgeJSLowerParameter() - bjs_Logger_log(selfValue, messageValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$Logger_log(_ self: JSObject, _ message: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let messageValue = message.bridgeJSLowerParameter() + bjs_Logger_log(selfValue, messageValue) + if let error = _swift_js_take_exception() { + throw error } +} - func error(_ message: String, _ error: JSObject) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let messageValue = message.bridgeJSLowerParameter() - let errorValue = error.bridgeJSLowerParameter() - bjs_Logger_error(selfValue, messageValue, errorValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$Logger_error(_ self: JSObject, _ message: String, _ error: JSObject) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let messageValue = message.bridgeJSLowerParameter() + let errorValue = error.bridgeJSLowerParameter() + bjs_Logger_error(selfValue, messageValue, errorValue) + if let error = _swift_js_take_exception() { + throw error } - } #if arch(wasm32) @@ -256,42 +224,31 @@ fileprivate func bjs_ConfigManager_set(_ self: Int32, _ key: Int32, _ value: Int } #endif -struct ConfigManager: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var configPath: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_ConfigManager_configPath_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$ConfigManager_configPath_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ConfigManager_configPath_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func get(_ key: String) throws(JSException) -> JSObject { - let selfValue = self.bridgeJSLowerParameter() - let keyValue = key.bridgeJSLowerParameter() - let ret = bjs_ConfigManager_get(selfValue, keyValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) +func _$ConfigManager_get(_ self: JSObject, _ key: String) throws(JSException) -> JSObject { + let selfValue = self.bridgeJSLowerParameter() + let keyValue = key.bridgeJSLowerParameter() + let ret = bjs_ConfigManager_get(selfValue, keyValue) + if let error = _swift_js_take_exception() { + throw error } + return JSObject.bridgeJSLiftReturn(ret) +} - func set(_ key: String, _ value: JSObject) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let keyValue = key.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - bjs_ConfigManager_set(selfValue, keyValue, valueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$ConfigManager_set(_ self: JSObject, _ key: String, _ value: JSObject) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let keyValue = key.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + bjs_ConfigManager_set(selfValue, keyValue, valueValue) + if let error = _swift_js_take_exception() { + throw error } - } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.Macros.swift new file mode 100644 index 00000000..eea42f30 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.Macros.swift @@ -0,0 +1,9 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func check(_ a: Double, _ b: Bool) throws (JSException) -> Void diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift index 90088799..6d59ca52 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_check") fileprivate func bjs_check(_ a: Float64, _ b: Int32) -> Void @@ -15,7 +7,7 @@ fileprivate func bjs_check(_ a: Float64, _ b: Int32) -> Void { } #endif -func check(_ a: Double, _ b: Bool) throws(JSException) -> Void { +func _$check(_ a: Double, _ b: Bool) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() let bValue = b.bridgeJSLowerParameter() bjs_check(aValue, bValue) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.Macros.swift new file mode 100644 index 00000000..15867131 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.Macros.swift @@ -0,0 +1,11 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func checkNumber() throws (JSException) -> Double + +@JSFunction func checkBoolean() throws (JSException) -> Bool diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift index 6424329b..17f536ba 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_checkNumber") fileprivate func bjs_checkNumber() -> Float64 @@ -15,7 +7,7 @@ fileprivate func bjs_checkNumber() -> Float64 { } #endif -func checkNumber() throws(JSException) -> Double { +func _$checkNumber() throws(JSException) -> Double { let ret = bjs_checkNumber() if let error = _swift_js_take_exception() { throw error @@ -32,7 +24,7 @@ fileprivate func bjs_checkBoolean() -> Int32 { } #endif -func checkBoolean() throws(JSException) -> Bool { +func _$checkBoolean() throws(JSException) -> Bool { let ret = bjs_checkBoolean() if let error = _swift_js_take_exception() { throw error diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.Macros.swift new file mode 100644 index 00000000..38fe0dd2 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.Macros.swift @@ -0,0 +1,11 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func checkString(_ a: String) throws (JSException) -> Void + +@JSFunction func checkStringWithLength(_ a: String, _ b: Double) throws (JSException) -> Void diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift index 35502a7c..694c44e0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_checkString") fileprivate func bjs_checkString(_ a: Int32) -> Void @@ -15,7 +7,7 @@ fileprivate func bjs_checkString(_ a: Int32) -> Void { } #endif -func checkString(_ a: String) throws(JSException) -> Void { +func _$checkString(_ a: String) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() bjs_checkString(aValue) if let error = _swift_js_take_exception() { @@ -32,7 +24,7 @@ fileprivate func bjs_checkStringWithLength(_ a: Int32, _ b: Float64) -> Void { } #endif -func checkStringWithLength(_ a: String, _ b: Double) throws(JSException) -> Void { +func _$checkStringWithLength(_ a: String, _ b: Double) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() let bValue = b.bridgeJSLowerParameter() bjs_checkStringWithLength(aValue, bValue) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.Macros.swift new file mode 100644 index 00000000..60aae03c --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.Macros.swift @@ -0,0 +1,9 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func checkString() throws (JSException) -> String diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift index 638eedb0..bde90ea7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_checkString") fileprivate func bjs_checkString() -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_checkString() -> Int32 { } #endif -func checkString() throws(JSException) -> String { +func _$checkString() throws(JSException) -> String { let ret = bjs_checkString() if let error = _swift_js_take_exception() { throw error diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.Macros.swift new file mode 100644 index 00000000..39998492 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.Macros.swift @@ -0,0 +1,22 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func createTS2Skeleton() throws (JSException) -> TypeScriptProcessor + +@JSClass struct TypeScriptProcessor: _JSBridgedClass { + @JSFunction func convert(_ ts: String) throws (JSException) -> String + @JSFunction func validate(_ ts: String) throws (JSException) -> Bool + @JSGetter var version: String +} + +@JSFunction func createCodeGenerator(_ format: String) throws (JSException) -> CodeGenerator + +@JSClass struct CodeGenerator: _JSBridgedClass { + @JSFunction func generate(_ input: JSObject) throws (JSException) -> String + @JSGetter var outputFormat: String +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.swift index 26d37a90..54d3b915 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TS2SkeletonLike.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_createTS2Skeleton") fileprivate func bjs_createTS2Skeleton() -> Int32 @@ -15,7 +7,7 @@ fileprivate func bjs_createTS2Skeleton() -> Int32 { } #endif -func createTS2Skeleton() throws(JSException) -> TypeScriptProcessor { +func _$createTS2Skeleton() throws(JSException) -> TypeScriptProcessor { let ret = bjs_createTS2Skeleton() if let error = _swift_js_take_exception() { throw error @@ -32,7 +24,7 @@ fileprivate func bjs_createCodeGenerator(_ format: Int32) -> Int32 { } #endif -func createCodeGenerator(_ format: String) throws(JSException) -> CodeGenerator { +func _$createCodeGenerator(_ format: String) throws(JSException) -> CodeGenerator { let formatValue = format.bridgeJSLowerParameter() let ret = bjs_createCodeGenerator(formatValue) if let error = _swift_js_take_exception() { @@ -68,44 +60,33 @@ fileprivate func bjs_TypeScriptProcessor_validate(_ self: Int32, _ ts: Int32) -> } #endif -struct TypeScriptProcessor: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var version: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_TypeScriptProcessor_version_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$TypeScriptProcessor_version_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_TypeScriptProcessor_version_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func convert(_ ts: String) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let tsValue = ts.bridgeJSLowerParameter() - let ret = bjs_TypeScriptProcessor_convert(selfValue, tsValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) +func _$TypeScriptProcessor_convert(_ self: JSObject, _ ts: String) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let tsValue = ts.bridgeJSLowerParameter() + let ret = bjs_TypeScriptProcessor_convert(selfValue, tsValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func validate(_ ts: String) throws(JSException) -> Bool { - let selfValue = self.bridgeJSLowerParameter() - let tsValue = ts.bridgeJSLowerParameter() - let ret = bjs_TypeScriptProcessor_validate(selfValue, tsValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) +func _$TypeScriptProcessor_validate(_ self: JSObject, _ ts: String) throws(JSException) -> Bool { + let selfValue = self.bridgeJSLowerParameter() + let tsValue = ts.bridgeJSLowerParameter() + let ret = bjs_TypeScriptProcessor_validate(selfValue, tsValue) + if let error = _swift_js_take_exception() { + throw error } - + return Bool.bridgeJSLiftReturn(ret) } #if arch(wasm32) @@ -126,32 +107,21 @@ fileprivate func bjs_CodeGenerator_generate(_ self: Int32, _ input: Int32) -> In } #endif -struct CodeGenerator: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - var outputFormat: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_CodeGenerator_outputFormat_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$CodeGenerator_outputFormat_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_CodeGenerator_outputFormat_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func generate(_ input: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let inputValue = input.bridgeJSLowerParameter() - let ret = bjs_CodeGenerator_generate(selfValue, inputValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) +func _$CodeGenerator_generate(_ self: JSObject, _ input: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let inputValue = input.bridgeJSLowerParameter() + let ret = bjs_CodeGenerator_generate(selfValue, inputValue) + if let error = _swift_js_take_exception() { + throw error } - + return String.bridgeJSLiftReturn(ret) } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.Macros.swift new file mode 100644 index 00000000..62b2b466 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.Macros.swift @@ -0,0 +1,9 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func checkSimple(_ a: Double) throws (JSException) -> Void diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift index afd99723..0b5d0c40 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_checkSimple") fileprivate func bjs_checkSimple(_ a: Float64) -> Void @@ -15,7 +7,7 @@ fileprivate func bjs_checkSimple(_ a: Float64) -> Void { } #endif -func checkSimple(_ a: Double) throws(JSException) -> Void { +func _$checkSimple(_ a: Double) throws(JSException) -> Void { let aValue = a.bridgeJSLowerParameter() bjs_checkSimple(aValue) if let error = _swift_js_take_exception() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.Macros.swift new file mode 100644 index 00000000..4026e007 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.Macros.swift @@ -0,0 +1,16 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSClass struct Greeter: _JSBridgedClass { + @JSGetter var name: String + @JSSetter func setName(_ value: String) throws (JSException) + @JSGetter var age: Double + @JSFunction init(_ name: String) throws (JSException) + @JSFunction func greet() throws (JSException) -> String + @JSFunction func changeName(_ name: String) throws (JSException) -> Void +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift index 6d1bdca3..67c77897 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_Greeter_init") fileprivate func bjs_Greeter_init(_ name: Int32) -> Int32 @@ -25,19 +17,19 @@ fileprivate func bjs_Greeter_name_get(_ self: Int32) -> Int32 { #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_Greeter_name_set") -fileprivate func bjs_Greeter_name_set(_ self: Int32, _ newValue: Int32) -> Void +@_extern(wasm, module: "Check", name: "bjs_Greeter_age_get") +fileprivate func bjs_Greeter_age_get(_ self: Int32) -> Float64 #else -fileprivate func bjs_Greeter_name_set(_ self: Int32, _ newValue: Int32) -> Void { +fileprivate func bjs_Greeter_age_get(_ self: Int32) -> Float64 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "Check", name: "bjs_Greeter_age_get") -fileprivate func bjs_Greeter_age_get(_ self: Int32) -> Float64 +@_extern(wasm, module: "Check", name: "bjs_Greeter_name_set") +fileprivate func bjs_Greeter_name_set(_ self: Int32, _ newValue: Int32) -> Void #else -fileprivate func bjs_Greeter_age_get(_ self: Int32) -> Float64 { +fileprivate func bjs_Greeter_name_set(_ self: Int32, _ newValue: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif @@ -60,69 +52,56 @@ fileprivate func bjs_Greeter_changeName(_ self: Int32, _ name: Int32) -> Void { } #endif -struct Greeter: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - init(_ name: String) throws(JSException) { - let nameValue = name.bridgeJSLowerParameter() - let ret = bjs_Greeter_init(nameValue) - if let error = _swift_js_take_exception() { - throw error - } - self.jsObject = JSObject(id: UInt32(bitPattern: ret)) +func _$Greeter_init(_ name: String) throws(JSException) -> JSObject { + let nameValue = name.bridgeJSLowerParameter() + let ret = bjs_Greeter_init(nameValue) + if let error = _swift_js_take_exception() { + throw error } + return JSObject.bridgeJSLiftReturn(ret) +} - var name: String { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Greeter_name_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } +func _$Greeter_name_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Greeter_name_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func setName(_ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_Greeter_name_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$Greeter_age_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Greeter_age_get(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return Double.bridgeJSLiftReturn(ret) +} - var age: Double { - get throws(JSException) { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Greeter_age_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) - } +func _$Greeter_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_Greeter_name_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error } +} - func greet() throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Greeter_greet(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) +func _$Greeter_greet(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Greeter_greet(selfValue) + if let error = _swift_js_take_exception() { + throw error } + return String.bridgeJSLiftReturn(ret) +} - func changeName(_ name: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let nameValue = name.bridgeJSLowerParameter() - bjs_Greeter_changeName(selfValue, nameValue) - if let error = _swift_js_take_exception() { - throw error - } +func _$Greeter_changeName(_ self: JSObject, _ name: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let nameValue = name.bridgeJSLowerParameter() + bjs_Greeter_changeName(selfValue, nameValue) + if let error = _swift_js_take_exception() { + throw error } - } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.Macros.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.Macros.swift new file mode 100644 index 00000000..b3a7fc6f --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.Macros.swift @@ -0,0 +1,9 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func check() throws (JSException) -> Void diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift index 51167847..2a2622ce 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift @@ -1,11 +1,3 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - #if arch(wasm32) @_extern(wasm, module: "Check", name: "bjs_check") fileprivate func bjs_check() -> Void @@ -15,7 +7,7 @@ fileprivate func bjs_check() -> Void { } #endif -func check() throws(JSException) -> Void { +func _$check() throws(JSException) -> Void { bjs_check() if let error = _swift_js_take_exception() { throw error diff --git a/Plugins/PackageToJS/Sources/PackageToJS.swift b/Plugins/PackageToJS/Sources/PackageToJS.swift index ec984043..268f3f20 100644 --- a/Plugins/PackageToJS/Sources/PackageToJS.swift +++ b/Plugins/PackageToJS/Sources/PackageToJS.swift @@ -394,10 +394,8 @@ struct PackagingPlanner { let selfPackageDir: BuildPath /// The path of this file itself, used to capture changes of planner code let selfPath: BuildPath - /// The exported API skeletons source files - let exportedSkeletons: [BuildPath] - /// The imported API skeletons source files - let importedSkeletons: [BuildPath] + /// The BridgeJS API skeletons source files + let skeletons: [BuildPath] /// The directory for the final output let outputDir: BuildPath /// The directory for intermediate files @@ -418,8 +416,7 @@ struct PackagingPlanner { packageId: String, intermediatesDir: BuildPath, selfPackageDir: BuildPath, - exportedSkeletons: [BuildPath], - importedSkeletons: [BuildPath], + skeletons: [BuildPath], outputDir: BuildPath, wasmProductArtifact: BuildPath, wasmFilename: String, @@ -431,8 +428,7 @@ struct PackagingPlanner { self.options = options self.packageId = packageId self.selfPackageDir = selfPackageDir - self.exportedSkeletons = exportedSkeletons - self.importedSkeletons = importedSkeletons + self.skeletons = skeletons self.outputDir = outputDir self.intermediatesDir = intermediatesDir self.wasmFilename = wasmFilename @@ -592,7 +588,7 @@ struct PackagingPlanner { ) packageInputs.append(packageJsonTask) - if exportedSkeletons.count > 0 || importedSkeletons.count > 0 { + if skeletons.count > 0 { if ProcessInfo.processInfo.environment["JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS"] == nil { fatalError( "BridgeJS is still an experimental feature. Set the environment variable JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 to enable." @@ -601,20 +597,17 @@ struct PackagingPlanner { let bridgeJs = outputDir.appending(path: "bridge-js.js") let bridgeDts = outputDir.appending(path: "bridge-js.d.ts") packageInputs.append( - make.addTask(inputFiles: exportedSkeletons + importedSkeletons, output: bridgeJs) { _, scope in - let link = try BridgeJSLink( - exportedSkeletons: exportedSkeletons.map { - let decoder = JSONDecoder() - let data = try Data(contentsOf: URL(fileURLWithPath: scope.resolve(path: $0).path)) - return try decoder.decode(ExportedSkeleton.self, from: data) - }, - importedSkeletons: importedSkeletons.map { - let decoder = JSONDecoder() - let data = try Data(contentsOf: URL(fileURLWithPath: scope.resolve(path: $0).path)) - return try decoder.decode(ImportedModuleSkeleton.self, from: data) - }, + make.addTask(inputFiles: skeletons, output: bridgeJs) { _, scope in + var link = BridgeJSLink( sharedMemory: Self.isSharedMemoryEnabled(triple: triple) ) + + // Decode skeleton format + for skeletonPath in skeletons { + let data = try Data(contentsOf: URL(fileURLWithPath: scope.resolve(path: skeletonPath).path)) + try link.addSkeletonFile(data: data) + } + let (outputJs, outputDts) = try link.link() try system.writeFile(atPath: scope.resolve(path: bridgeJs).path, content: Data(outputJs.utf8)) try system.writeFile(atPath: scope.resolve(path: bridgeDts).path, content: Data(outputDts.utf8)) @@ -732,8 +725,8 @@ struct PackagingPlanner { "USE_SHARED_MEMORY": Self.isSharedMemoryEnabled(triple: triple), "IS_WASI": triple.hasPrefix("wasm32-unknown-wasi"), "USE_WASI_CDN": options.useCDN, - "HAS_BRIDGE": exportedSkeletons.count > 0 || importedSkeletons.count > 0, - "HAS_IMPORTS": importedSkeletons.count > 0, + "HAS_BRIDGE": skeletons.count > 0, + "HAS_IMPORTS": skeletons.count > 0, "TARGET_DEFAULT_PLATFORM_NODE": options.defaultPlatform == .node, "TARGET_DEFAULT_PLATFORM_BROWSER": options.defaultPlatform == .browser, ] diff --git a/Plugins/PackageToJS/Sources/PackageToJSPlugin.swift b/Plugins/PackageToJS/Sources/PackageToJSPlugin.swift index 709dc8f3..3cbd2901 100644 --- a/Plugins/PackageToJS/Sources/PackageToJSPlugin.swift +++ b/Plugins/PackageToJS/Sources/PackageToJSPlugin.swift @@ -166,7 +166,7 @@ struct PackageToJSPlugin: CommandPlugin { } } - static let JAVASCRIPTKIT_PRODUCT_ID: Product.ID = "JavaScriptKit" + static let JAVASCRIPTEVENTLOOP_PRODUCT_ID: Product.ID = "JavaScriptEventLoop" func performBuildCommand(context: PluginContext, arguments: [String]) throws { if arguments.contains(where: { ["-h", "--help"].contains($0) }) { @@ -199,7 +199,7 @@ struct PackageToJSPlugin: CommandPlugin { exit(1) } let skeletonCollector = SkeletonCollector(context: context) - let (exportedSkeletons, importedSkeletons) = skeletonCollector.collectFromProduct(name: productName) + let skeletons = skeletonCollector.collectFromProduct(name: productName) let productArtifact = try build.findWasmArtifact(for: productName) let outputDir = if let outputPath = buildOptions.packageOptions.outputPath { @@ -215,8 +215,7 @@ struct PackageToJSPlugin: CommandPlugin { options: buildOptions.packageOptions, context: context, selfPackage: selfPackage, - exportedSkeletons: exportedSkeletons, - importedSkeletons: importedSkeletons, + skeletons: skeletons, outputDir: outputDir, wasmProductArtifact: productArtifact, wasmFilename: productArtifact.lastPathComponent @@ -263,7 +262,7 @@ struct PackageToJSPlugin: CommandPlugin { } let skeletonCollector = SkeletonCollector(context: context) - let (exportedSkeletons, importedSkeletons) = skeletonCollector.collectFromTests() + let skeletons = skeletonCollector.collectFromTests() // NOTE: Find the product artifact from the default build directory // because PackageManager.BuildResult doesn't include the @@ -300,8 +299,7 @@ struct PackageToJSPlugin: CommandPlugin { options: testOptions.packageOptions, context: context, selfPackage: selfPackage, - exportedSkeletons: exportedSkeletons, - importedSkeletons: importedSkeletons, + skeletons: skeletons, outputDir: outputDir, wasmProductArtifact: productArtifact, // If the product artifact doesn't have a .wasm extension, add it @@ -396,7 +394,11 @@ struct PackageToJSPlugin: CommandPlugin { guard let selfPackage = findPackageInDependencies( package: package, - including: Self.JAVASCRIPTKIT_PRODUCT_ID + // NOTE: We use JavaScriptEventLoop product to find the JavaScriptKit package + // instead of JavaScriptKit product because SwiftPM in 6.0 does not returns + // product information for JavaScriptKit product for some reason (very likely + // a bug in SwiftPM). + including: Self.JAVASCRIPTEVENTLOOP_PRODUCT_ID ) else { throw PackageToJSError("Failed to find JavaScriptKit in dependencies!?") @@ -702,25 +704,23 @@ class SkeletonCollector { private var visitedProducts: Set = [] private var visitedTargets: Set = [] - var exportedSkeletons: [URL] = [] - var importedSkeletons: [URL] = [] - let exportedSkeletonFile = "BridgeJS.ExportSwift.json" - let importedSkeletonFile = "BridgeJS.ImportTS.json" + var skeletons: [URL] = [] + let skeletonFile = "BridgeJS.json" let context: PluginContext init(context: PluginContext) { self.context = context } - func collectFromProduct(name: String) -> (exportedSkeletons: [URL], importedSkeletons: [URL]) { + func collectFromProduct(name: String) -> [URL] { guard let product = context.package.products.first(where: { $0.name == name }) else { - return ([], []) + return [] } visit(product: product, package: context.package) - return (exportedSkeletons, importedSkeletons) + return skeletons } - func collectFromTests() -> (exportedSkeletons: [URL], importedSkeletons: [URL]) { + func collectFromTests() -> [URL] { let tests = context.package.targets.filter { guard let target = $0 as? SwiftSourceModuleTarget else { return false } return target.kind == .test @@ -728,7 +728,7 @@ class SkeletonCollector { for test in tests { visit(target: test, package: context.package) } - return (exportedSkeletons, importedSkeletons) + return skeletons } private func visit(product: Product, package: Package) { @@ -742,6 +742,11 @@ class SkeletonCollector { private func visit(target: Target, package: Package) { if visitedTargets.contains(target.id) { return } visitedTargets.insert(target.id) + if let sourceModuleTarget = target as? SourceModuleTarget { + if sourceModuleTarget.kind == .macro { + return + } + } if let target = target as? SwiftSourceModuleTarget { let directories = [ target.directoryURL.appending(path: "Generated/JavaScript"), @@ -751,13 +756,9 @@ class SkeletonCollector { .appending(path: "outputs/\(package.id)/\(target.name)/destination/BridgeJS"), ] for directory in directories { - let exportedSkeletonURL = directory.appending(path: exportedSkeletonFile) - let importedSkeletonURL = directory.appending(path: importedSkeletonFile) - if FileManager.default.fileExists(atPath: exportedSkeletonURL.path) { - exportedSkeletons.append(exportedSkeletonURL) - } - if FileManager.default.fileExists(atPath: importedSkeletonURL.path) { - importedSkeletons.append(importedSkeletonURL) + let skeletonURL = directory.appending(path: skeletonFile) + if FileManager.default.fileExists(atPath: skeletonURL.path) { + skeletons.append(skeletonURL) } } } @@ -787,8 +788,7 @@ extension PackagingPlanner { options: PackageToJS.PackageOptions, context: PluginContext, selfPackage: Package, - exportedSkeletons: [URL], - importedSkeletons: [URL], + skeletons: [URL], outputDir: URL, wasmProductArtifact: URL, wasmFilename: String @@ -803,8 +803,7 @@ extension PackagingPlanner { absolute: context.pluginWorkDirectoryURL.appending(path: outputBaseName + ".tmp").path ), selfPackageDir: BuildPath(absolute: selfPackage.directoryURL.path), - exportedSkeletons: exportedSkeletons.map { BuildPath(absolute: $0.path) }, - importedSkeletons: importedSkeletons.map { BuildPath(absolute: $0.path) }, + skeletons: skeletons.map { BuildPath(absolute: $0.path) }, outputDir: BuildPath(absolute: outputDir.path), wasmProductArtifact: BuildPath(absolute: wasmProductArtifact.path), wasmFilename: wasmFilename, diff --git a/Plugins/PackageToJS/Tests/PackagingPlannerTests.swift b/Plugins/PackageToJS/Tests/PackagingPlannerTests.swift index 03fc4c9c..3e0d67a3 100644 --- a/Plugins/PackageToJS/Tests/PackagingPlannerTests.swift +++ b/Plugins/PackageToJS/Tests/PackagingPlannerTests.swift @@ -65,8 +65,7 @@ import Testing packageId: "test", intermediatesDir: BuildPath(prefix: "INTERMEDIATES"), selfPackageDir: BuildPath(prefix: "SELF_PACKAGE"), - exportedSkeletons: [], - importedSkeletons: [], + skeletons: [], outputDir: BuildPath(prefix: "OUTPUT"), wasmProductArtifact: BuildPath(prefix: "WASM_PRODUCT_ARTIFACT"), wasmFilename: "main.wasm", @@ -96,8 +95,7 @@ import Testing packageId: "test", intermediatesDir: BuildPath(prefix: "INTERMEDIATES"), selfPackageDir: BuildPath(prefix: "SELF_PACKAGE"), - exportedSkeletons: [], - importedSkeletons: [], + skeletons: [], outputDir: BuildPath(prefix: "OUTPUT"), wasmProductArtifact: BuildPath(prefix: "WASM_PRODUCT_ARTIFACT"), wasmFilename: "main.wasm", diff --git a/Sources/BridgeJSMacros b/Sources/BridgeJSMacros new file mode 120000 index 00000000..2d3d8a4a --- /dev/null +++ b/Sources/BridgeJSMacros @@ -0,0 +1 @@ +../Plugins/BridgeJS/Sources/BridgeJSMacros \ No newline at end of file diff --git a/Sources/BridgeJSTool/TS2Skeleton b/Sources/BridgeJSTool/TS2Skeleton deleted file mode 120000 index c41c1280..00000000 --- a/Sources/BridgeJSTool/TS2Skeleton +++ /dev/null @@ -1 +0,0 @@ -../../Plugins/BridgeJS/Sources/TS2Skeleton \ No newline at end of file diff --git a/Sources/BridgeJSTool/TS2Swift b/Sources/BridgeJSTool/TS2Swift new file mode 120000 index 00000000..6d9b4332 --- /dev/null +++ b/Sources/BridgeJSTool/TS2Swift @@ -0,0 +1 @@ +../../Plugins/BridgeJS/Sources/TS2Swift \ No newline at end of file diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Ahead-of-Time-Code-Generation.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Ahead-of-Time-Code-Generation.md index e3f52885..ee6ac304 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Ahead-of-Time-Code-Generation.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Ahead-of-Time-Code-Generation.md @@ -111,9 +111,8 @@ This command will: For example, with a target named "MyApp", it will create: ``` -Sources/MyApp/Generated/ExportSwift.swift # Generated code for Swift exports -Sources/MyApp/Generated/ImportTS.swift # Generated code for TypeScript imports -Sources/MyApp/Generated/JavaScript/ # Generated JSON skeletons +Sources/MyApp/Generated/BridgeJS.swift # Generated code for both exports and imports +Sources/MyApp/Generated/JavaScript/BridgeJS.json # Unified skeleton JSON ``` ### Step 6: Add Generated Files to Version Control diff --git a/Sources/JavaScriptKit/Macros.swift b/Sources/JavaScriptKit/Macros.swift index b8a44a08..9e11db3b 100644 --- a/Sources/JavaScriptKit/Macros.swift +++ b/Sources/JavaScriptKit/Macros.swift @@ -107,3 +107,81 @@ public enum JSEnumStyle: String { /// - Important: This feature is still experimental. No API stability is guaranteed, and the API may change in future releases. @attached(peer) public macro JS(namespace: String? = nil, enumStyle: JSEnumStyle = .const) = Builtin.ExternalMacro + +/// A macro that generates a Swift getter that reads a value from JavaScript. +/// +/// This macro is used by BridgeJS-generated Swift declarations. +/// +/// Example: +/// +/// ```swift +/// @_spi(Experimental) import JavaScriptKit +/// +/// @JSGetter var count: Int +/// +/// struct Greeter { +/// @JSGetter var name: String +/// } +/// ``` +@attached(accessor) +@_spi(Experimental) +public macro JSGetter() = + #externalMacro(module: "BridgeJSMacros", type: "JSGetterMacro") + +/// A macro that generates a Swift function body that writes a value to JavaScript. +/// +/// This macro is used by BridgeJS-generated Swift declarations. +/// +/// - Parameter jsName: An optional string that specifies the name of the JavaScript property to write to. +/// If not provided, automatically derived from the Swift property name. (e.g. "setName" -> "name") +/// +/// Example: +/// +/// ```swift +/// @_spi(Experimental) import JavaScriptKit +/// +/// @JSSetter func setName(_ value: String) throws (JSException) +/// ``` +@attached(body) +@_spi(Experimental) +public macro JSSetter(jsName: String? = nil) = + #externalMacro(module: "BridgeJSMacros", type: "JSSetterMacro") + +/// A macro that generates a Swift function body that calls a JavaScript function. +/// +/// This macro is used by BridgeJS-generated Swift declarations. +/// +/// Example: +/// +/// ```swift +/// @_spi(Experimental) import JavaScriptKit +/// +/// @JSFunction func greet() throws (JSException) -> String +/// @JSFunction init(_ name: String) throws (JSException) +/// ``` +@attached(body) +@_spi(Experimental) +public macro JSFunction() = + #externalMacro(module: "BridgeJSMacros", type: "JSFunctionMacro") + +/// A macro that adds bridging members for a Swift type that represents a JavaScript class. +/// +/// This macro is used by BridgeJS-generated Swift declarations. +/// +/// Example: +/// +/// ```swift +/// @_spi(Experimental) import JavaScriptKit +/// +/// @JSClass +/// struct JsGreeter: _JSBridgedClass { +/// @JSGetter var name: String +/// @JSSetter func setName(_ value: String) throws (JSException) +/// @JSFunction init(_ name: String) throws (JSException) +/// @JSFunction func greet() throws (JSException) -> String +/// } +/// ``` +@attached(member, names: arbitrary) +@_spi(Experimental) +public macro JSClass() = + #externalMacro(module: "BridgeJSMacros", type: "JSClassMacro") diff --git a/Tests/BridgeJSGlobalTests/Generated/BridgeJS.ExportSwift.swift b/Tests/BridgeJSGlobalTests/Generated/BridgeJS.swift similarity index 99% rename from Tests/BridgeJSGlobalTests/Generated/BridgeJS.ExportSwift.swift rename to Tests/BridgeJSGlobalTests/Generated/BridgeJS.swift index 09cd79ec..aaa5f1b8 100644 --- a/Tests/BridgeJSGlobalTests/Generated/BridgeJS.ExportSwift.swift +++ b/Tests/BridgeJSGlobalTests/Generated/BridgeJS.swift @@ -1,3 +1,4 @@ +// bridge-js: skip // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, // DO NOT EDIT. // diff --git a/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.ExportSwift.json b/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.ExportSwift.json deleted file mode 100644 index 955b78f6..00000000 --- a/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.ExportSwift.json +++ /dev/null @@ -1,540 +0,0 @@ -{ - "classes" : [ - { - "constructor" : { - "abiName" : "bjs_TestHTTPServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_TestHTTPServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "GlobalNetworking", - "API" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "GlobalNetworking.API.CallMethod" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "TestHTTPServer", - "namespace" : [ - "GlobalNetworking", - "API" - ], - "properties" : [ - - ], - "swiftCallName" : "GlobalNetworking.API.TestHTTPServer" - }, - { - "constructor" : { - "abiName" : "bjs_TestInternalServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_TestInternalServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "GlobalNetworking", - "APIV2", - "Internal" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Internal.SupportedServerMethod" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "TestInternalServer", - "namespace" : [ - "GlobalNetworking", - "APIV2", - "Internal" - ], - "properties" : [ - - ], - "swiftCallName" : "Internal.TestInternalServer" - }, - { - "constructor" : { - "abiName" : "bjs_PublicConverter_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_PublicConverter_toString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "toString", - "namespace" : [ - "GlobalUtils" - ], - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "PublicConverter", - "namespace" : [ - "GlobalUtils" - ], - "properties" : [ - - ], - "swiftCallName" : "GlobalUtils.PublicConverter" - } - ], - "enums" : [ - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "GlobalNetworking", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalNetworking", - "tsFullPath" : "GlobalNetworking" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "API", - "namespace" : [ - "GlobalNetworking" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalNetworking.API", - "tsFullPath" : "GlobalNetworking.API" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - }, - { - "associatedValues" : [ - - ], - "name" : "put" - }, - { - "associatedValues" : [ - - ], - "name" : "delete" - } - ], - "emitStyle" : "const", - "name" : "CallMethod", - "namespace" : [ - "GlobalNetworking", - "API" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalNetworking.API.CallMethod", - "tsFullPath" : "GlobalNetworking.API.CallMethod" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "GlobalConfiguration", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalConfiguration", - "tsFullPath" : "GlobalConfiguration" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "debug", - "rawValue" : "debug" - }, - { - "associatedValues" : [ - - ], - "name" : "info", - "rawValue" : "info" - }, - { - "associatedValues" : [ - - ], - "name" : "warning", - "rawValue" : "warning" - }, - { - "associatedValues" : [ - - ], - "name" : "error", - "rawValue" : "error" - } - ], - "emitStyle" : "const", - "name" : "PublicLogLevel", - "namespace" : [ - "GlobalConfiguration" - ], - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalConfiguration.PublicLogLevel", - "tsFullPath" : "GlobalConfiguration.PublicLogLevel" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "http", - "rawValue" : "80" - }, - { - "associatedValues" : [ - - ], - "name" : "https", - "rawValue" : "443" - }, - { - "associatedValues" : [ - - ], - "name" : "development", - "rawValue" : "3000" - } - ], - "emitStyle" : "const", - "name" : "AvailablePort", - "namespace" : [ - "GlobalConfiguration" - ], - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalConfiguration.AvailablePort", - "tsFullPath" : "GlobalConfiguration.AvailablePort" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Internal", - "namespace" : [ - "GlobalNetworking", - "APIV2" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal", - "tsFullPath" : "GlobalNetworking.APIV2.Internal" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - } - ], - "emitStyle" : "const", - "name" : "SupportedServerMethod", - "namespace" : [ - "GlobalNetworking", - "APIV2", - "Internal" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal.SupportedServerMethod", - "tsFullPath" : "GlobalNetworking.APIV2.Internal.SupportedServerMethod" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "GlobalStaticPropertyNamespace", - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "namespaceProperty", - "namespace" : [ - "GlobalStaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "namespaceConstant", - "namespace" : [ - "GlobalStaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "GlobalStaticPropertyNamespace", - "tsFullPath" : "GlobalStaticPropertyNamespace" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "NestedProperties", - "namespace" : [ - "GlobalStaticPropertyNamespace" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedProperty", - "namespace" : [ - "GlobalStaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "nestedConstant", - "namespace" : [ - "GlobalStaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedDouble", - "namespace" : [ - "GlobalStaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "GlobalStaticPropertyNamespace.NestedProperties", - "tsFullPath" : "GlobalStaticPropertyNamespace.NestedProperties" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "GlobalUtils", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GlobalUtils", - "tsFullPath" : "GlobalUtils" - } - ], - "exposeToGlobal" : true, - "functions" : [ - - ], - "moduleName" : "BridgeJSGlobalTests", - "protocols" : [ - - ], - "structs" : [ - - ] -} \ No newline at end of file diff --git a/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json new file mode 100644 index 00000000..3e7f4a6d --- /dev/null +++ b/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,554 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_TestHTTPServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_TestHTTPServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "GlobalNetworking", + "API" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "GlobalNetworking.API.CallMethod" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "TestHTTPServer", + "namespace" : [ + "GlobalNetworking", + "API" + ], + "properties" : [ + + ], + "swiftCallName" : "GlobalNetworking.API.TestHTTPServer" + }, + { + "constructor" : { + "abiName" : "bjs_TestInternalServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_TestInternalServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "GlobalNetworking", + "APIV2", + "Internal" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Internal.SupportedServerMethod" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "TestInternalServer", + "namespace" : [ + "GlobalNetworking", + "APIV2", + "Internal" + ], + "properties" : [ + + ], + "swiftCallName" : "Internal.TestInternalServer" + }, + { + "constructor" : { + "abiName" : "bjs_PublicConverter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_PublicConverter_toString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "toString", + "namespace" : [ + "GlobalUtils" + ], + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "PublicConverter", + "namespace" : [ + "GlobalUtils" + ], + "properties" : [ + + ], + "swiftCallName" : "GlobalUtils.PublicConverter" + } + ], + "enums" : [ + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "GlobalNetworking", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalNetworking", + "tsFullPath" : "GlobalNetworking" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "API", + "namespace" : [ + "GlobalNetworking" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalNetworking.API", + "tsFullPath" : "GlobalNetworking.API" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + }, + { + "associatedValues" : [ + + ], + "name" : "put" + }, + { + "associatedValues" : [ + + ], + "name" : "delete" + } + ], + "emitStyle" : "const", + "name" : "CallMethod", + "namespace" : [ + "GlobalNetworking", + "API" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalNetworking.API.CallMethod", + "tsFullPath" : "GlobalNetworking.API.CallMethod" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "GlobalConfiguration", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalConfiguration", + "tsFullPath" : "GlobalConfiguration" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "debug", + "rawValue" : "debug" + }, + { + "associatedValues" : [ + + ], + "name" : "info", + "rawValue" : "info" + }, + { + "associatedValues" : [ + + ], + "name" : "warning", + "rawValue" : "warning" + }, + { + "associatedValues" : [ + + ], + "name" : "error", + "rawValue" : "error" + } + ], + "emitStyle" : "const", + "name" : "PublicLogLevel", + "namespace" : [ + "GlobalConfiguration" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalConfiguration.PublicLogLevel", + "tsFullPath" : "GlobalConfiguration.PublicLogLevel" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "http", + "rawValue" : "80" + }, + { + "associatedValues" : [ + + ], + "name" : "https", + "rawValue" : "443" + }, + { + "associatedValues" : [ + + ], + "name" : "development", + "rawValue" : "3000" + } + ], + "emitStyle" : "const", + "name" : "AvailablePort", + "namespace" : [ + "GlobalConfiguration" + ], + "rawType" : "Int", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalConfiguration.AvailablePort", + "tsFullPath" : "GlobalConfiguration.AvailablePort" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Internal", + "namespace" : [ + "GlobalNetworking", + "APIV2" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal", + "tsFullPath" : "GlobalNetworking.APIV2.Internal" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + } + ], + "emitStyle" : "const", + "name" : "SupportedServerMethod", + "namespace" : [ + "GlobalNetworking", + "APIV2", + "Internal" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal.SupportedServerMethod", + "tsFullPath" : "GlobalNetworking.APIV2.Internal.SupportedServerMethod" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "GlobalStaticPropertyNamespace", + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "namespaceProperty", + "namespace" : [ + "GlobalStaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "namespaceConstant", + "namespace" : [ + "GlobalStaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "GlobalStaticPropertyNamespace", + "tsFullPath" : "GlobalStaticPropertyNamespace" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "NestedProperties", + "namespace" : [ + "GlobalStaticPropertyNamespace" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedProperty", + "namespace" : [ + "GlobalStaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "nestedConstant", + "namespace" : [ + "GlobalStaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedDouble", + "namespace" : [ + "GlobalStaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "GlobalStaticPropertyNamespace.NestedProperties", + "tsFullPath" : "GlobalStaticPropertyNamespace.NestedProperties" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "GlobalUtils", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GlobalUtils", + "tsFullPath" : "GlobalUtils" + } + ], + "exposeToGlobal" : true, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + + ] + } + ] + }, + "moduleName" : "BridgeJSGlobalTests" +} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift deleted file mode 100644 index e75febb8..00000000 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift +++ /dev/null @@ -1,271 +0,0 @@ -// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, -// DO NOT EDIT. -// -// To update this file, just rebuild your project or run -// `swift package bridge-js`. - -@_spi(BridgeJS) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripVoid") -fileprivate func bjs_jsRoundTripVoid() -> Void -#else -fileprivate func bjs_jsRoundTripVoid() -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -func jsRoundTripVoid() throws(JSException) -> Void { - bjs_jsRoundTripVoid() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripNumber") -fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 -#else -fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsRoundTripNumber(_ v: Double) throws(JSException) -> Double { - let ret = bjs_jsRoundTripNumber(v.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripBool") -fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsRoundTripBool(_ v: Bool) throws(JSException) -> Bool { - let ret = bjs_jsRoundTripBool(v.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripString") -fileprivate func bjs_jsRoundTripString(_ v: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripString(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsRoundTripString(_ v: String) throws(JSException) -> String { - let ret = bjs_jsRoundTripString(v.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrVoid") -fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void -#else -fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -func jsThrowOrVoid(_ shouldThrow: Bool) throws(JSException) -> Void { - bjs_jsThrowOrVoid(shouldThrow.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrNumber") -fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 -#else -fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsThrowOrNumber(_ shouldThrow: Bool) throws(JSException) -> Double { - let ret = bjs_jsThrowOrNumber(shouldThrow.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrBool") -fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 -#else -fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsThrowOrBool(_ shouldThrow: Bool) throws(JSException) -> Bool { - let ret = bjs_jsThrowOrBool(shouldThrow.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrString") -fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 -#else -fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func jsThrowOrString(_ shouldThrow: Bool) throws(JSException) -> String { - let ret = bjs_jsThrowOrString(shouldThrow.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAsyncWorks") -fileprivate func bjs_runAsyncWorks() -> Int32 -#else -fileprivate func bjs_runAsyncWorks() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -func runAsyncWorks() throws(JSException) -> JSPromise { - let ret = bjs_runAsyncWorks() - if let error = _swift_js_take_exception() { - throw error - } - return JSPromise.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_init") -fileprivate func bjs_JsGreeter_init(_ name: Int32, _ prefix: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_init(_ name: Int32, _ prefix: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_get") -fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_set") -fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValue: Int32) -> Void -#else -fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_prefix_get") -fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_greet") -fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_changeName") -fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ name: Int32) -> Void -#else -fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ name: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif - -struct JsGreeter: _JSBridgedClass { - let jsObject: JSObject - - init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - init(_ name: String, _ prefix: String) throws(JSException) { - let ret = bjs_JsGreeter_init(name.bridgeJSLowerParameter(), prefix.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - self.jsObject = JSObject(id: UInt32(bitPattern: ret)) - } - - var name: String { - get throws(JSException) { - let ret = bjs_JsGreeter_name_get(self.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } - } - - func setName(_ newValue: String) throws(JSException) -> Void { - bjs_JsGreeter_name_set(self.bridgeJSLowerParameter(), newValue.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - } - - var prefix: String { - get throws(JSException) { - let ret = bjs_JsGreeter_prefix_get(self.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } - } - - func greet() throws(JSException) -> String { - let ret = bjs_JsGreeter_greet(self.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) - } - - func changeName(_ name: String) throws(JSException) -> Void { - bjs_JsGreeter_changeName(self.bridgeJSLowerParameter(), name.bridgeJSLowerParameter()) - if let error = _swift_js_take_exception() { - throw error - } - } - -} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift new file mode 100644 index 00000000..f65f5d23 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift @@ -0,0 +1,34 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(Experimental) import JavaScriptKit + +@JSFunction func jsRoundTripVoid() throws (JSException) -> Void + +@JSFunction func jsRoundTripNumber(_ v: Double) throws (JSException) -> Double + +@JSFunction func jsRoundTripBool(_ v: Bool) throws (JSException) -> Bool + +@JSFunction func jsRoundTripString(_ v: String) throws (JSException) -> String + +@JSFunction func jsThrowOrVoid(_ shouldThrow: Bool) throws (JSException) -> Void + +@JSFunction func jsThrowOrNumber(_ shouldThrow: Bool) throws (JSException) -> Double + +@JSFunction func jsThrowOrBool(_ shouldThrow: Bool) throws (JSException) -> Bool + +@JSFunction func jsThrowOrString(_ shouldThrow: Bool) throws (JSException) -> String + +@JSClass struct JsGreeter: _JSBridgedClass { + @JSGetter var name: String + @JSSetter func setName(_ value: String) throws (JSException) + @JSGetter var `prefix`: String + @JSFunction init(_ name: String, _ `prefix`: String) throws (JSException) + @JSFunction func greet() throws (JSException) -> String + @JSFunction func changeName(_ name: String) throws (JSException) -> Void +} + +@JSFunction func runAsyncWorks() throws (JSException) -> JSPromise diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift similarity index 96% rename from Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift rename to Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index 0a95e88f..1b39e77b 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -1,3 +1,4 @@ +// bridge-js: skip // NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, // DO NOT EDIT. // @@ -6163,4 +6164,271 @@ fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int3 fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } -#endif \ No newline at end of file +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripVoid") +fileprivate func bjs_jsRoundTripVoid() -> Void +#else +fileprivate func bjs_jsRoundTripVoid() -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsRoundTripVoid() throws(JSException) -> Void { + bjs_jsRoundTripVoid() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripNumber") +fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 +#else +fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsRoundTripNumber(_ v: Double) throws(JSException) -> Double { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripNumber(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripBool") +fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsRoundTripBool(_ v: Bool) throws(JSException) -> Bool { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripBool(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripString") +fileprivate func bjs_jsRoundTripString(_ v: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripString(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsRoundTripString(_ v: String) throws(JSException) -> String { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripString(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrVoid") +fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void +#else +fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsThrowOrVoid(_ shouldThrow: Bool) throws(JSException) -> Void { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + bjs_jsThrowOrVoid(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrNumber") +fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 +#else +fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsThrowOrNumber(_ shouldThrow: Bool) throws(JSException) -> Double { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrNumber(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrBool") +fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 +#else +fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsThrowOrBool(_ shouldThrow: Bool) throws(JSException) -> Bool { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrBool(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrString") +fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 +#else +fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$jsThrowOrString(_ shouldThrow: Bool) throws(JSException) -> String { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrString(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAsyncWorks") +fileprivate func bjs_runAsyncWorks() -> Int32 +#else +fileprivate func bjs_runAsyncWorks() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +func _$runAsyncWorks() throws(JSException) -> JSPromise { + let ret = bjs_runAsyncWorks() + if let error = _swift_js_take_exception() { + throw error + } + return JSPromise.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_init") +fileprivate func bjs_JsGreeter_init(_ name: Int32, _ prefix: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_init(_ name: Int32, _ prefix: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_get") +fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_prefix_get") +fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_set") +fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_greet") +fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_changeName") +fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ name: Int32) -> Void +#else +fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ name: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +func _$JsGreeter_init(_ name: String, _ prefix: String) throws(JSException) -> JSObject { + let nameValue = name.bridgeJSLowerParameter() + let prefixValue = prefix.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_init(nameValue, prefixValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_name_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_name_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_prefix_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_prefix_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_JsGreeter_name_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$JsGreeter_greet(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_greet(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_changeName(_ self: JSObject, _ name: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let nameValue = name.bridgeJSLowerParameter() + bjs_JsGreeter_changeName(selfValue, nameValue) + if let error = _swift_js_take_exception() { + throw error + } +} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ExportSwift.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ExportSwift.json deleted file mode 100644 index 872af025..00000000 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ExportSwift.json +++ /dev/null @@ -1,8923 +0,0 @@ -{ - "classes" : [ - { - "constructor" : { - "abiName" : "bjs_Greeter_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ] - }, - "explicitAccessControl" : "public", - "methods" : [ - { - "abiName" : "bjs_Greeter_greet", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "greet", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_Greeter_changeName", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "changeName", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_Greeter_greetWith", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "greetWith", - "parameters" : [ - { - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "customGreeting", - "name" : "customGreeting", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_Greeter_makeFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFormatter", - "parameters" : [ - { - "label" : "suffix", - "name" : "suffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_Greeter_static_makeCreator", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeCreator", - "parameters" : [ - { - "label" : "defaultName", - "name" : "defaultName", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_7GreeterC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - }, - "staticContext" : { - "className" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_Greeter_makeCustomGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeCustomGreeter", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "name" : "Greeter", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "Greeter" - }, - { - "methods" : [ - { - "abiName" : "bjs_Calculator_square", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "square", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_Calculator_add", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "int" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - } - ], - "name" : "Calculator", - "properties" : [ - - ], - "swiftCallName" : "Calculator" - }, - { - "explicitAccessControl" : "internal", - "methods" : [ - - ], - "name" : "InternalGreeter", - "properties" : [ - - ], - "swiftCallName" : "InternalGreeter" - }, - { - "explicitAccessControl" : "public", - "methods" : [ - - ], - "name" : "PublicGreeter", - "properties" : [ - - ], - "swiftCallName" : "PublicGreeter" - }, - { - "explicitAccessControl" : "package", - "methods" : [ - - ], - "name" : "PackageGreeter", - "properties" : [ - - ], - "swiftCallName" : "PackageGreeter" - }, - { - "constructor" : { - "abiName" : "bjs_Converter_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_Converter_toString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "toString", - "namespace" : [ - "Utils" - ], - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "Converter", - "namespace" : [ - "Utils" - ], - "properties" : [ - - ], - "swiftCallName" : "Utils.Converter" - }, - { - "constructor" : { - "abiName" : "bjs_HTTPServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_HTTPServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "Networking", - "API" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "HTTPServer", - "namespace" : [ - "Networking", - "API" - ], - "properties" : [ - - ], - "swiftCallName" : "Networking.API.HTTPServer" - }, - { - "constructor" : { - "abiName" : "bjs_TestServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_TestServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "TestServer", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "properties" : [ - - ], - "swiftCallName" : "Internal.TestServer" - }, - { - "constructor" : { - "abiName" : "bjs_OptionalPropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "optionalName", - "name" : "optionalName", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "OptionalPropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalName", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalAge", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalGreeter", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "swiftCallName" : "OptionalPropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_SimplePropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "SimplePropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "swiftCallName" : "SimplePropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_PropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "intValue", - "name" : "intValue", - "type" : { - "int" : { - - } - } - }, - { - "label" : "floatValue", - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "label" : "doubleValue", - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "label" : "boolValue", - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "stringValue", - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "label" : "jsObject", - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - }, - { - "label" : "sibling", - "name" : "sibling", - "type" : { - "swiftHeapObject" : { - "_0" : "SimplePropertyHolder" - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_PropertyHolder_getAllValues", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAllValues", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "PropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "intValue", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyInt", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyFloat", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyDouble", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyBool", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyString", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "sibling", - "type" : { - "swiftHeapObject" : { - "_0" : "SimplePropertyHolder" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "lazyValue", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "computedReadonly", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "computedReadWrite", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "observedProperty", - "type" : { - "int" : { - - } - } - } - ], - "swiftCallName" : "PropertyHolder" - }, - { - "methods" : [ - { - "abiName" : "bjs_MathUtils_static_add", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "int" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - }, - "staticContext" : { - "className" : { - "_0" : "MathUtils" - } - } - }, - { - "abiName" : "bjs_MathUtils_static_substract", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "substract", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "int" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - }, - "staticContext" : { - "className" : { - "_0" : "MathUtils" - } - } - } - ], - "name" : "MathUtils", - "properties" : [ - - ], - "swiftCallName" : "MathUtils" - }, - { - "constructor" : { - "abiName" : "bjs_ConstructorDefaults_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Default" - } - }, - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "int" : { - "_0" : 42 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "defaultValue" : { - "bool" : { - "_0" : true - } - }, - "label" : "enabled", - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "defaultValue" : { - "enumCase" : { - "_0" : "Status", - "_1" : "success" - } - }, - "label" : "status", - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "tag", - "name" : "tag", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_ConstructorDefaults_describe", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "describe", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "ConstructorDefaults", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "swiftCallName" : "ConstructorDefaults" - }, - { - "constructor" : { - "abiName" : "bjs_StaticPropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - - ], - "name" : "StaticPropertyHolder", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : true, - "name" : "staticConstant", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticVariable", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticString", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticBool", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticFloat", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticDouble", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "computedProperty", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "readOnlyComputed", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "optionalString", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "optionalInt", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "jsObjectProperty", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "jsObject" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_DataProcessorManager_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "processor", - "name" : "processor", - "type" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_DataProcessorManager_incrementByAmount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "incrementByAmount", - "parameters" : [ - { - "label" : "_", - "name" : "amount", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorLabel", - "parameters" : [ - { - "label" : "_", - "name" : "prefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "suffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_isProcessorEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isProcessorEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getCurrentValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getCurrentValue", - "parameters" : [ - - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_incrementBoth", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "incrementBoth", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getBackupValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getBackupValue", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_hasBackup", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "hasBackup", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorOptionalTag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorOptionalTag", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorOptionalTag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorOptionalTag", - "parameters" : [ - { - "label" : "_", - "name" : "tag", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorOptionalCount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorOptionalCount", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorOptionalCount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorOptionalCount", - "parameters" : [ - { - "label" : "_", - "name" : "count", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorDirection", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorTheme", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorHttpStatus", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "status", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorAPIResult", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "apiResult", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "DataProcessorManager", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "processor", - "type" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "backupProcessor", - "type" : { - "optional" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - } - } - } - ], - "swiftCallName" : "DataProcessorManager" - }, - { - "constructor" : { - "abiName" : "bjs_SwiftDataProcessor_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_SwiftDataProcessor_increment", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "increment", - "parameters" : [ - { - "label" : "by", - "name" : "amount", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getValue", - "parameters" : [ - - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_setLabelElements", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setLabelElements", - "parameters" : [ - { - "label" : "_", - "name" : "labelPrefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "labelSuffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_isEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_processGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_createGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createGreeter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_createOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createOptionalGreeter", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_handleAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "handleAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAPIResult", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "name" : "SwiftDataProcessor", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalTag", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalCount", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "direction", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalTheme", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "httpStatus", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "apiResult", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "helper", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalHelper", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "swiftCallName" : "SwiftDataProcessor" - }, - { - "constructor" : { - "abiName" : "bjs_TextProcessor_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "transform", - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_TextProcessor_process", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "process", - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processWithCustom", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processWithCustom", - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - }, - { - "label" : "customTransform", - "name" : "customTransform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSSSd_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "int" : { - - } - }, - { - "string" : { - - } - }, - { - "double" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_getTransform", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTransform", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalString", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalInt", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalInt", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSi_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalStringFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalStringFormatter", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalGreeterCreator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalGreeterCreator", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sq7GreeterC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_processDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "caseEnum" : { - "_0" : "Direction" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests5ThemeO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - ], - "returnType" : { - "int" : { - - } - } - } - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeDirectionChecker", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeDirectionChecker", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9DirectionO_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "caseEnum" : { - "_0" : "Direction" - } - } - ], - "returnType" : { - "bool" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeThemeValidator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeThemeValidator", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests5ThemeO_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - ], - "returnType" : { - "bool" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeStatusCodeExtractor", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeStatusCodeExtractor", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - ], - "returnType" : { - "int" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeAPIResultHandler", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultHandler", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq5ThemeO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalDirectionFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalDirectionFormatter", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "name" : "TextProcessor", - "properties" : [ - - ], - "swiftCallName" : "TextProcessor" - }, - { - "constructor" : { - "abiName" : "bjs_Container_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "location", - "name" : "location", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "label" : "config", - "name" : "config", - "type" : { - "optional" : { - "_0" : { - "swiftStruct" : { - "_0" : "Config" - } - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "Container", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "location", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "config", - "type" : { - "optional" : { - "_0" : { - "swiftStruct" : { - "_0" : "Config" - } - } - } - } - } - ], - "swiftCallName" : "Container" - } - ], - "enums" : [ - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "north" - }, - { - "associatedValues" : [ - - ], - "name" : "south" - }, - { - "associatedValues" : [ - - ], - "name" : "east" - }, - { - "associatedValues" : [ - - ], - "name" : "west" - } - ], - "emitStyle" : "const", - "name" : "Direction", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Direction", - "tsFullPath" : "Direction" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "loading" - }, - { - "associatedValues" : [ - - ], - "name" : "success" - }, - { - "associatedValues" : [ - - ], - "name" : "error" - } - ], - "emitStyle" : "const", - "name" : "Status", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Status", - "tsFullPath" : "Status" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "light", - "rawValue" : "light" - }, - { - "associatedValues" : [ - - ], - "name" : "dark", - "rawValue" : "dark" - }, - { - "associatedValues" : [ - - ], - "name" : "auto", - "rawValue" : "auto" - } - ], - "emitStyle" : "const", - "name" : "Theme", - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Theme", - "tsFullPath" : "Theme" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "ok", - "rawValue" : "200" - }, - { - "associatedValues" : [ - - ], - "name" : "notFound", - "rawValue" : "404" - }, - { - "associatedValues" : [ - - ], - "name" : "serverError", - "rawValue" : "500" - }, - { - "associatedValues" : [ - - ], - "name" : "unknown", - "rawValue" : "-1" - } - ], - "emitStyle" : "const", - "name" : "HttpStatus", - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "HttpStatus", - "tsFullPath" : "HttpStatus" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "north" - }, - { - "associatedValues" : [ - - ], - "name" : "south" - }, - { - "associatedValues" : [ - - ], - "name" : "east" - }, - { - "associatedValues" : [ - - ], - "name" : "west" - } - ], - "emitStyle" : "tsEnum", - "name" : "TSDirection", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "TSDirection", - "tsFullPath" : "TSDirection" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "light", - "rawValue" : "light" - }, - { - "associatedValues" : [ - - ], - "name" : "dark", - "rawValue" : "dark" - }, - { - "associatedValues" : [ - - ], - "name" : "auto", - "rawValue" : "auto" - } - ], - "emitStyle" : "tsEnum", - "name" : "TSTheme", - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "TSTheme", - "tsFullPath" : "TSTheme" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Utils", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utils", - "tsFullPath" : "Utils" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Networking", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking", - "tsFullPath" : "Networking" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "API", - "namespace" : [ - "Networking" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking.API", - "tsFullPath" : "Networking.API" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - }, - { - "associatedValues" : [ - - ], - "name" : "put" - }, - { - "associatedValues" : [ - - ], - "name" : "delete" - } - ], - "emitStyle" : "const", - "name" : "Method", - "namespace" : [ - "Networking", - "API" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking.API.Method", - "tsFullPath" : "Networking.API.Method" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Configuration", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration", - "tsFullPath" : "Configuration" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "debug", - "rawValue" : "debug" - }, - { - "associatedValues" : [ - - ], - "name" : "info", - "rawValue" : "info" - }, - { - "associatedValues" : [ - - ], - "name" : "warning", - "rawValue" : "warning" - }, - { - "associatedValues" : [ - - ], - "name" : "error", - "rawValue" : "error" - } - ], - "emitStyle" : "const", - "name" : "LogLevel", - "namespace" : [ - "Configuration" - ], - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration.LogLevel", - "tsFullPath" : "Configuration.LogLevel" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "http", - "rawValue" : "80" - }, - { - "associatedValues" : [ - - ], - "name" : "https", - "rawValue" : "443" - }, - { - "associatedValues" : [ - - ], - "name" : "development", - "rawValue" : "3000" - } - ], - "emitStyle" : "const", - "name" : "Port", - "namespace" : [ - "Configuration" - ], - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration.Port", - "tsFullPath" : "Configuration.Port" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Internal", - "namespace" : [ - "Networking", - "APIV2" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal", - "tsFullPath" : "Networking.APIV2.Internal" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - } - ], - "emitStyle" : "const", - "name" : "SupportedMethod", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal.SupportedMethod", - "tsFullPath" : "Networking.APIV2.Internal.SupportedMethod" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - } - ], - "name" : "flag" - }, - { - "associatedValues" : [ - { - "type" : { - "float" : { - - } - } - } - ], - "name" : "rate" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "precise" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "APIResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "APIResult", - "tsFullPath" : "APIResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "error" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "location" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "status" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "coordinates" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "comprehensive" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "ComplexResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "ComplexResult", - "tsFullPath" : "ComplexResult" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Utilities", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utilities", - "tsFullPath" : "Utilities" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "status" - } - ], - "emitStyle" : "const", - "name" : "Result", - "namespace" : [ - "Utilities" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utilities.Result", - "tsFullPath" : "Utilities.Result" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "API", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "API", - "tsFullPath" : "API" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "int" : { - - } - } - } - ], - "name" : "failure" - } - ], - "emitStyle" : "const", - "name" : "NetworkingResult", - "namespace" : [ - "API" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "API.NetworkingResult", - "tsFullPath" : "API.NetworkingResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "type" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - }, - { - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "name" : "status" - } - ], - "emitStyle" : "const", - "name" : "APIOptionalResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "APIOptionalResult", - "tsFullPath" : "APIOptionalResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "scientific" - }, - { - "associatedValues" : [ - - ], - "name" : "basic" - } - ], - "emitStyle" : "const", - "name" : "StaticCalculator", - "staticMethods" : [ - { - "abiName" : "bjs_StaticCalculator_static_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundtrip", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - }, - "staticContext" : { - "enumName" : { - "_0" : "StaticCalculator" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "StaticCalculator", - "tsFullPath" : "StaticCalculator" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "StaticUtils", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "StaticUtils", - "tsFullPath" : "StaticUtils" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Nested", - "namespace" : [ - "StaticUtils" - ], - "staticMethods" : [ - { - "abiName" : "bjs_StaticUtils_Nested_static_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundtrip", - "namespace" : [ - "StaticUtils", - "Nested" - ], - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "StaticUtils.Nested", - "tsFullPath" : "StaticUtils.Nested" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "option1" - }, - { - "associatedValues" : [ - - ], - "name" : "option2" - } - ], - "emitStyle" : "const", - "name" : "StaticPropertyEnum", - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumProperty", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "enumConstant", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumBool", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumVariable", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "computedReadonly", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "computedReadWrite", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyEnum", - "tsFullPath" : "StaticPropertyEnum" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "StaticPropertyNamespace", - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "namespaceProperty", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "namespaceConstant", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyNamespace", - "tsFullPath" : "StaticPropertyNamespace" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "NestedProperties", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedProperty", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "nestedConstant", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedDouble", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - - } - }, - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyNamespace.NestedProperties", - "tsFullPath" : "StaticPropertyNamespace.NestedProperties" - } - ], - "exposeToGlobal" : false, - "functions" : [ - { - "abiName" : "bjs_roundTripVoid", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_roundTripInt", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripInt", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_roundTripFloat", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripFloat", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_roundTripDouble", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripDouble", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_roundTripBool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripBool", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_roundTripString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripString", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_roundTripSwiftHeapObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripSwiftHeapObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_roundTripJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripJSObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_throwsSwiftError", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsSwiftError", - "parameters" : [ - { - "label" : "shouldThrow", - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithIntResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithIntResult", - "parameters" : [ - - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithStringResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithStringResult", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithBoolResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithBoolResult", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithFloatResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithFloatResult", - "parameters" : [ - - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithDoubleResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithDoubleResult", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithSwiftHeapObjectResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithSwiftHeapObjectResult", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_throwsWithJSObjectResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithJSObjectResult", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripVoid", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripInt", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripInt", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripFloat", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripFloat", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripDouble", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripDouble", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripBool", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripBool", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripString", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripString", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripSwiftHeapObject", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripSwiftHeapObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_asyncRoundTripJSObject", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripJSObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_takeGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeGreeter", - "parameters" : [ - { - "label" : "g", - "name" : "g", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_createCalculator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createCalculator", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Calculator" - } - } - }, - { - "abiName" : "bjs_useCalculator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "useCalculator", - "parameters" : [ - { - "label" : "calc", - "name" : "calc", - "type" : { - "swiftHeapObject" : { - "_0" : "Calculator" - } - } - }, - { - "label" : "x", - "name" : "x", - "type" : { - "int" : { - - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_testGreeterToJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testGreeterToJSValue", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_testCalculatorToJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testCalculatorToJSValue", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_testSwiftClassAsJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testSwiftClassAsJSValue", - "parameters" : [ - { - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_setDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - } - }, - { - "abiName" : "bjs_getDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getDirection", - "parameters" : [ - - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - } - }, - { - "abiName" : "bjs_processDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDirection", - "parameters" : [ - { - "label" : "_", - "name" : "input", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "abiName" : "bjs_setTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_getTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTheme", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_setHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "status", - "type" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_getHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getHttpStatus", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_processTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_setTSDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTSDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - }, - { - "abiName" : "bjs_getTSDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTSDirection", - "parameters" : [ - - ], - "returnType" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - }, - { - "abiName" : "bjs_setTSTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTSTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_getTSTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTSTheme", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_roundtripNetworkingAPIMethod", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripNetworkingAPIMethod", - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - }, - { - "abiName" : "bjs_roundtripConfigurationLogLevel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripConfigurationLogLevel", - "parameters" : [ - { - "label" : "_", - "name" : "level", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_roundtripConfigurationPort", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripConfigurationPort", - "parameters" : [ - { - "label" : "_", - "name" : "port", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_processConfigurationLogLevel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processConfigurationLogLevel", - "parameters" : [ - { - "label" : "_", - "name" : "level", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_roundtripInternalSupportedMethod", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripInternalSupportedMethod", - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - }, - { - "abiName" : "bjs_roundtripAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAPIResult", - "parameters" : [ - { - "label" : "result", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultFlag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultFlag", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultRate", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultRate", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultPrecise", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultPrecise", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_roundtripComplexResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripComplexResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultError", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultError", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultLocation", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultLocation", - "parameters" : [ - { - "label" : "_", - "name" : "lat", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "lng", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultStatus", - "parameters" : [ - { - "label" : "_", - "name" : "active", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "int" : { - - } - } - }, - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultCoordinates", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultCoordinates", - "parameters" : [ - { - "label" : "_", - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "z", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultComprehensive", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultComprehensive", - "parameters" : [ - { - "label" : "_", - "name" : "flag1", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "flag2", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "count1", - "type" : { - "int" : { - - } - } - }, - { - "label" : "_", - "name" : "count2", - "type" : { - "int" : { - - } - } - }, - { - "label" : "_", - "name" : "value1", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "value2", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "text1", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "text2", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "text3", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "error", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultStatus", - "parameters" : [ - { - "label" : "_", - "name" : "active", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "int" : { - - } - } - }, - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeAPINetworkingResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPINetworkingResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_makeAPINetworkingResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPINetworkingResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "error", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_roundtripUtilitiesResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripUtilitiesResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_roundtripAPINetworkingResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAPINetworkingResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_roundTripOptionalString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalString", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalInt", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalInt", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalBool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalBool", - "parameters" : [ - { - "label" : "flag", - "name" : "flag", - "type" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalFloat", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalFloat", - "parameters" : [ - { - "label" : "number", - "name" : "number", - "type" : { - "optional" : { - "_0" : { - "float" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "float" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalDouble", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalDouble", - "parameters" : [ - { - "label" : "precision", - "name" : "precision", - "type" : { - "optional" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalSyntax", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalSyntax", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalMixSyntax", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalMixSyntax", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalSwiftSyntax", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalSwiftSyntax", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalWithSpaces", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalWithSpaces", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalTypeAlias", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalTypeAlias", - "parameters" : [ - { - "label" : "age", - "name" : "age", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalStatus", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalTheme", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalHttpStatus", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalTSDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalTSDirection", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalTSTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalTSTheme", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalNetworkingAPIMethod", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalNetworkingAPIMethod", - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalAPIResult", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "abiName" : "bjs_compareAPIResults", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "compareAPIResults", - "parameters" : [ - { - "label" : "_", - "name" : "r1", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "label" : "_", - "name" : "r2", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_roundTripOptionalComplexResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalComplexResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalClass", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalClass", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalAPIOptionalResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalAPIOptionalResult", - "parameters" : [ - { - "label" : "result", - "name" : "result", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIOptionalResult" - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIOptionalResult" - } - } - } - } - }, - { - "abiName" : "bjs_createPropertyHolder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createPropertyHolder", - "parameters" : [ - { - "label" : "intValue", - "name" : "intValue", - "type" : { - "int" : { - - } - } - }, - { - "label" : "floatValue", - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "label" : "doubleValue", - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "label" : "boolValue", - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "stringValue", - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "label" : "jsObject", - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "PropertyHolder" - } - } - }, - { - "abiName" : "bjs_testPropertyHolder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testPropertyHolder", - "parameters" : [ - { - "label" : "holder", - "name" : "holder", - "type" : { - "swiftHeapObject" : { - "_0" : "PropertyHolder" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_resetObserverCounts", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetObserverCounts", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getObserverStats", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getObserverStats", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_testStringDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testStringDefault", - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Hello World" - } - }, - "label" : "message", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_testIntDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testIntDefault", - "parameters" : [ - { - "defaultValue" : { - "int" : { - "_0" : 42 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_testBoolDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testBoolDefault", - "parameters" : [ - { - "defaultValue" : { - "bool" : { - "_0" : true - } - }, - "label" : "flag", - "name" : "flag", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_testOptionalDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testOptionalDefault", - "parameters" : [ - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "name", - "name" : "name", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "abiName" : "bjs_testMultipleDefaults", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testMultipleDefaults", - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Default Title" - } - }, - "label" : "title", - "name" : "title", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "int" : { - "_0" : -10 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "defaultValue" : { - "bool" : { - "_0" : false - } - }, - "label" : "enabled", - "name" : "enabled", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_testSimpleEnumDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testSimpleEnumDefault", - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Status", - "_1" : "success" - } - }, - "label" : "status", - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "abiName" : "bjs_testDirectionDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testDirectionDefault", - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Direction", - "_1" : "north" - } - }, - "label" : "direction", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - } - }, - { - "abiName" : "bjs_testRawStringEnumDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testRawStringEnumDefault", - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Theme", - "_1" : "light" - } - }, - "label" : "theme", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_testComplexInit", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testComplexInit", - "parameters" : [ - { - "defaultValue" : { - "objectWithArguments" : { - "_0" : "Greeter", - "_1" : [ - { - "string" : { - "_0" : "DefaultGreeter" - } - } - ] - } - }, - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_testEmptyInit", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testEmptyInit", - "parameters" : [ - { - "defaultValue" : { - "object" : { - "_0" : "StaticPropertyHolder" - } - }, - "label" : "_", - "name" : "object", - "type" : { - "swiftHeapObject" : { - "_0" : "StaticPropertyHolder" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "StaticPropertyHolder" - } - } - }, - { - "abiName" : "bjs_formatName", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "formatName", - "parameters" : [ - { - "label" : "_", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "label" : "transform", - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_makeFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFormatter", - "parameters" : [ - { - "label" : "prefix", - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_makeAdder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAdder", - "parameters" : [ - { - "label" : "base", - "name" : "base", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "int" : { - - } - } - ], - "returnType" : { - "int" : { - - } - } - } - } - } - }, - { - "abiName" : "bjs_testStructDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testStructDefault", - "parameters" : [ - { - "defaultValue" : { - "structLiteral" : { - "_0" : "DataPoint", - "_1" : [ - { - "name" : "x", - "value" : { - "float" : { - "_0" : 1 - } - } - }, - { - "name" : "y", - "value" : { - "float" : { - "_0" : 2 - } - } - }, - { - "name" : "label", - "value" : { - "string" : { - "_0" : "default" - } - } - }, - { - "name" : "optCount", - "value" : { - "null" : { - - } - } - }, - { - "name" : "optFlag", - "value" : { - "null" : { - - } - } - } - ] - } - }, - "label" : "point", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_roundTripDataPoint", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripDataPoint", - "parameters" : [ - { - "label" : "_", - "name" : "data", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "abiName" : "bjs_roundTripContact", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripContact", - "parameters" : [ - { - "label" : "_", - "name" : "contact", - "type" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - }, - { - "abiName" : "bjs_roundTripConfig", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripConfig", - "parameters" : [ - { - "label" : "_", - "name" : "config", - "type" : { - "swiftStruct" : { - "_0" : "Config" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Config" - } - } - }, - { - "abiName" : "bjs_roundTripSessionData", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripSessionData", - "parameters" : [ - { - "label" : "_", - "name" : "session", - "type" : { - "swiftStruct" : { - "_0" : "SessionData" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "SessionData" - } - } - }, - { - "abiName" : "bjs_roundTripValidationReport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripValidationReport", - "parameters" : [ - { - "label" : "_", - "name" : "report", - "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - }, - { - "abiName" : "bjs_updateValidationReport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "updateValidationReport", - "parameters" : [ - { - "label" : "_", - "name" : "newResult", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "label" : "_", - "name" : "report", - "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - }, - { - "abiName" : "bjs_testContainerWithStruct", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testContainerWithStruct", - "parameters" : [ - { - "label" : "_", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Container" - } - } - } - ], - "moduleName" : "BridgeJSRuntimeTests", - "protocols" : [ - { - "methods" : [ - { - "abiName" : "bjs_DataProcessor_increment", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "increment", - "parameters" : [ - { - "label" : "by", - "name" : "amount", - "type" : { - "int" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getValue", - "parameters" : [ - - ], - "returnType" : { - "int" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_setLabelElements", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setLabelElements", - "parameters" : [ - { - "label" : "_", - "name" : "labelPrefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "labelSuffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_isEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_processGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_createGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createGreeter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_DataProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_createOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createOptionalGreeter", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - }, - { - "abiName" : "bjs_DataProcessor_handleAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "handleAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAPIResult", - "parameters" : [ - - ], - "returnType" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "name" : "DataProcessor", - "properties" : [ - { - "isReadonly" : false, - "name" : "count", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "name" : "optionalTag", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "optionalCount", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "direction", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "optionalTheme", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "httpStatus", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "apiResult", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - }, - { - "isReadonly" : false, - "name" : "helper", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "isReadonly" : false, - "name" : "optionalHelper", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ] - } - ], - "structs" : [ - { - "constructor" : { - "abiName" : "bjs_DataPoint_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "x", - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "label" : "label", - "name" : "label", - "type" : { - "string" : { - - } - } - }, - { - "label" : "optCount", - "name" : "optCount", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "label" : "optFlag", - "name" : "optFlag", - "type" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "DataPoint", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optCount", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optFlag", - "type" : { - "optional" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "swiftCallName" : "DataPoint" - }, - { - "methods" : [ - - ], - "name" : "Address", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "city", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "zipCode", - "type" : { - "optional" : { - "_0" : { - "int" : { - - } - } - } - } - } - ], - "swiftCallName" : "Address" - }, - { - "methods" : [ - - ], - "name" : "Contact", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "age", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "address", - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "email", - "type" : { - "optional" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "secondaryAddress", - "type" : { - "optional" : { - "_0" : { - "swiftStruct" : { - "_0" : "Address" - } - } - } - } - } - ], - "swiftCallName" : "Contact" - }, - { - "methods" : [ - - ], - "name" : "Config", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "theme", - "type" : { - "optional" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "direction", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - ], - "swiftCallName" : "Config" - }, - { - "methods" : [ - - ], - "name" : "SessionData", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "owner", - "type" : { - "optional" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "swiftCallName" : "SessionData" - }, - { - "methods" : [ - - ], - "name" : "ValidationReport", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", - "type" : { - "optional" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "outcome", - "type" : { - "optional" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - } - } - ], - "swiftCallName" : "ValidationReport" - }, - { - "constructor" : { - "abiName" : "bjs_MathOperations_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "defaultValue" : { - "double" : { - "_0" : 0 - } - }, - "label" : "baseValue", - "name" : "baseValue", - "type" : { - "double" : { - - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_MathOperations_add", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "defaultValue" : { - "double" : { - "_0" : 10 - } - }, - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_MathOperations_multiply", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "multiply", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_MathOperations_static_subtract", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "subtract", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - }, - "staticContext" : { - "structName" : { - "_0" : "MathOperations" - } - } - } - ], - "name" : "MathOperations", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "baseValue", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "MathOperations" - }, - { - "methods" : [ - - ], - "name" : "ConfigStruct", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "value", - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "defaultConfig", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "maxRetries", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "int" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "timeout", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "computedSetting", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "ConfigStruct" - } - ] -} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ImportTS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ImportTS.json deleted file mode 100644 index 82515fec..00000000 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.ImportTS.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "children" : [ - { - "functions" : [ - { - "name" : "jsRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "name" : "jsRoundTripNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "name" : "jsRoundTripBool", - "parameters" : [ - { - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "name" : "jsRoundTripString", - "parameters" : [ - { - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "name" : "jsThrowOrVoid", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "name" : "jsThrowOrNumber", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "name" : "jsThrowOrBool", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "name" : "jsThrowOrString", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "name" : "runAsyncWorks", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - "_0" : "JSPromise" - } - } - } - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ] - }, - "methods" : [ - { - "name" : "greet", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "name" : "changeName", - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "JsGreeter", - "properties" : [ - { - "isReadonly" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ] - } - ] - } - ], - "moduleName" : "BridgeJSRuntimeTests" -} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json new file mode 100644 index 00000000..727508f3 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,9182 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_Greeter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "explicitAccessControl" : "public", + "methods" : [ + { + "abiName" : "bjs_Greeter_greet", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greet", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_changeName", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "changeName", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_greetWith", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greetWith", + "parameters" : [ + { + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "customGreeting", + "name" : "customGreeting", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_makeFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFormatter", + "parameters" : [ + { + "label" : "suffix", + "name" : "suffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_Greeter_static_makeCreator", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeCreator", + "parameters" : [ + { + "label" : "defaultName", + "name" : "defaultName", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_7GreeterC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_Greeter_makeCustomGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeCustomGreeter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "name" : "Greeter", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Greeter" + }, + { + "methods" : [ + { + "abiName" : "bjs_Calculator_square", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "square", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_Calculator_add", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "int" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + } + ], + "name" : "Calculator", + "properties" : [ + + ], + "swiftCallName" : "Calculator" + }, + { + "explicitAccessControl" : "internal", + "methods" : [ + + ], + "name" : "InternalGreeter", + "properties" : [ + + ], + "swiftCallName" : "InternalGreeter" + }, + { + "explicitAccessControl" : "public", + "methods" : [ + + ], + "name" : "PublicGreeter", + "properties" : [ + + ], + "swiftCallName" : "PublicGreeter" + }, + { + "explicitAccessControl" : "package", + "methods" : [ + + ], + "name" : "PackageGreeter", + "properties" : [ + + ], + "swiftCallName" : "PackageGreeter" + }, + { + "constructor" : { + "abiName" : "bjs_Converter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_Converter_toString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "toString", + "namespace" : [ + "Utils" + ], + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "Converter", + "namespace" : [ + "Utils" + ], + "properties" : [ + + ], + "swiftCallName" : "Utils.Converter" + }, + { + "constructor" : { + "abiName" : "bjs_HTTPServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_HTTPServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "Networking", + "API" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "HTTPServer", + "namespace" : [ + "Networking", + "API" + ], + "properties" : [ + + ], + "swiftCallName" : "Networking.API.HTTPServer" + }, + { + "constructor" : { + "abiName" : "bjs_TestServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_TestServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "TestServer", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "properties" : [ + + ], + "swiftCallName" : "Internal.TestServer" + }, + { + "constructor" : { + "abiName" : "bjs_OptionalPropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "optionalName", + "name" : "optionalName", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "OptionalPropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalName", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalAge", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalGreeter", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "swiftCallName" : "OptionalPropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_SimplePropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "SimplePropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "swiftCallName" : "SimplePropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_PropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "intValue", + "name" : "intValue", + "type" : { + "int" : { + + } + } + }, + { + "label" : "floatValue", + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "label" : "doubleValue", + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "label" : "boolValue", + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "stringValue", + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "label" : "jsObject", + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + }, + { + "label" : "sibling", + "name" : "sibling", + "type" : { + "swiftHeapObject" : { + "_0" : "SimplePropertyHolder" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_PropertyHolder_getAllValues", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAllValues", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "PropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "intValue", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyInt", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyFloat", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyDouble", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyBool", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyString", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "sibling", + "type" : { + "swiftHeapObject" : { + "_0" : "SimplePropertyHolder" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "lazyValue", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "computedReadonly", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "computedReadWrite", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "observedProperty", + "type" : { + "int" : { + + } + } + } + ], + "swiftCallName" : "PropertyHolder" + }, + { + "methods" : [ + { + "abiName" : "bjs_MathUtils_static_add", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "int" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + }, + "staticContext" : { + "className" : { + "_0" : "MathUtils" + } + } + }, + { + "abiName" : "bjs_MathUtils_static_substract", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "substract", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "int" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + }, + "staticContext" : { + "className" : { + "_0" : "MathUtils" + } + } + } + ], + "name" : "MathUtils", + "properties" : [ + + ], + "swiftCallName" : "MathUtils" + }, + { + "constructor" : { + "abiName" : "bjs_ConstructorDefaults_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Default" + } + }, + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "int" : { + "_0" : 42 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "defaultValue" : { + "bool" : { + "_0" : true + } + }, + "label" : "enabled", + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "defaultValue" : { + "enumCase" : { + "_0" : "Status", + "_1" : "success" + } + }, + "label" : "status", + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "tag", + "name" : "tag", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_ConstructorDefaults_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "ConstructorDefaults", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "swiftCallName" : "ConstructorDefaults" + }, + { + "constructor" : { + "abiName" : "bjs_StaticPropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + + ], + "name" : "StaticPropertyHolder", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : true, + "name" : "staticConstant", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticVariable", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticString", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticBool", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticFloat", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticDouble", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "computedProperty", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "readOnlyComputed", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "optionalString", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "optionalInt", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "jsObjectProperty", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "jsObject" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_DataProcessorManager_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "processor", + "name" : "processor", + "type" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_DataProcessorManager_incrementByAmount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "incrementByAmount", + "parameters" : [ + { + "label" : "_", + "name" : "amount", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorLabel", + "parameters" : [ + { + "label" : "_", + "name" : "prefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "suffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_isProcessorEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isProcessorEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getCurrentValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getCurrentValue", + "parameters" : [ + + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_incrementBoth", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "incrementBoth", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getBackupValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getBackupValue", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_hasBackup", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "hasBackup", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorOptionalTag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorOptionalTag", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorOptionalTag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorOptionalTag", + "parameters" : [ + { + "label" : "_", + "name" : "tag", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorOptionalCount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorOptionalCount", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorOptionalCount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorOptionalCount", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorDirection", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorTheme", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorHttpStatus", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "status", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorAPIResult", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "apiResult", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "DataProcessorManager", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "processor", + "type" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "backupProcessor", + "type" : { + "optional" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + } + } + } + ], + "swiftCallName" : "DataProcessorManager" + }, + { + "constructor" : { + "abiName" : "bjs_SwiftDataProcessor_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_SwiftDataProcessor_increment", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "increment", + "parameters" : [ + { + "label" : "by", + "name" : "amount", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getValue", + "parameters" : [ + + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_setLabelElements", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setLabelElements", + "parameters" : [ + { + "label" : "_", + "name" : "labelPrefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "labelSuffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_isEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_processGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_createGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createGreeter", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_createOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createOptionalGreeter", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_handleAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "handleAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAPIResult", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "name" : "SwiftDataProcessor", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalTag", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalCount", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "direction", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalTheme", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "httpStatus", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "apiResult", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "helper", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalHelper", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "swiftCallName" : "SwiftDataProcessor" + }, + { + "constructor" : { + "abiName" : "bjs_TextProcessor_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "transform", + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_TextProcessor_process", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "process", + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processWithCustom", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processWithCustom", + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + }, + { + "label" : "customTransform", + "name" : "customTransform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSSSd_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "int" : { + + } + }, + { + "string" : { + + } + }, + { + "double" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_getTransform", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTransform", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalString", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalInt", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSi_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalStringFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalStringFormatter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalGreeterCreator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalGreeterCreator", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sq7GreeterC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_processDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processDirection", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processTheme", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests5ThemeO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + ], + "returnType" : { + "int" : { + + } + } + } + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeDirectionChecker", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeDirectionChecker", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9DirectionO_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "bool" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeThemeValidator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeThemeValidator", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests5ThemeO_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + ], + "returnType" : { + "bool" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeStatusCodeExtractor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeStatusCodeExtractor", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + ], + "returnType" : { + "int" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeAPIResultHandler", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultHandler", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalDirection", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalTheme", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq5ThemeO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalDirectionFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalDirectionFormatter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "name" : "TextProcessor", + "properties" : [ + + ], + "swiftCallName" : "TextProcessor" + }, + { + "constructor" : { + "abiName" : "bjs_Container_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "location", + "name" : "location", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "label" : "config", + "name" : "config", + "type" : { + "optional" : { + "_0" : { + "swiftStruct" : { + "_0" : "Config" + } + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Container", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "location", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "config", + "type" : { + "optional" : { + "_0" : { + "swiftStruct" : { + "_0" : "Config" + } + } + } + } + } + ], + "swiftCallName" : "Container" + } + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "north" + }, + { + "associatedValues" : [ + + ], + "name" : "south" + }, + { + "associatedValues" : [ + + ], + "name" : "east" + }, + { + "associatedValues" : [ + + ], + "name" : "west" + } + ], + "emitStyle" : "const", + "name" : "Direction", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Direction", + "tsFullPath" : "Direction" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "loading" + }, + { + "associatedValues" : [ + + ], + "name" : "success" + }, + { + "associatedValues" : [ + + ], + "name" : "error" + } + ], + "emitStyle" : "const", + "name" : "Status", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Status", + "tsFullPath" : "Status" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "light", + "rawValue" : "light" + }, + { + "associatedValues" : [ + + ], + "name" : "dark", + "rawValue" : "dark" + }, + { + "associatedValues" : [ + + ], + "name" : "auto", + "rawValue" : "auto" + } + ], + "emitStyle" : "const", + "name" : "Theme", + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Theme", + "tsFullPath" : "Theme" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "ok", + "rawValue" : "200" + }, + { + "associatedValues" : [ + + ], + "name" : "notFound", + "rawValue" : "404" + }, + { + "associatedValues" : [ + + ], + "name" : "serverError", + "rawValue" : "500" + }, + { + "associatedValues" : [ + + ], + "name" : "unknown", + "rawValue" : "-1" + } + ], + "emitStyle" : "const", + "name" : "HttpStatus", + "rawType" : "Int", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "HttpStatus", + "tsFullPath" : "HttpStatus" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "north" + }, + { + "associatedValues" : [ + + ], + "name" : "south" + }, + { + "associatedValues" : [ + + ], + "name" : "east" + }, + { + "associatedValues" : [ + + ], + "name" : "west" + } + ], + "emitStyle" : "tsEnum", + "name" : "TSDirection", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "TSDirection", + "tsFullPath" : "TSDirection" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "light", + "rawValue" : "light" + }, + { + "associatedValues" : [ + + ], + "name" : "dark", + "rawValue" : "dark" + }, + { + "associatedValues" : [ + + ], + "name" : "auto", + "rawValue" : "auto" + } + ], + "emitStyle" : "tsEnum", + "name" : "TSTheme", + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "TSTheme", + "tsFullPath" : "TSTheme" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Utils", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utils", + "tsFullPath" : "Utils" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Networking", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking", + "tsFullPath" : "Networking" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "API", + "namespace" : [ + "Networking" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking.API", + "tsFullPath" : "Networking.API" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + }, + { + "associatedValues" : [ + + ], + "name" : "put" + }, + { + "associatedValues" : [ + + ], + "name" : "delete" + } + ], + "emitStyle" : "const", + "name" : "Method", + "namespace" : [ + "Networking", + "API" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking.API.Method", + "tsFullPath" : "Networking.API.Method" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Configuration", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration", + "tsFullPath" : "Configuration" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "debug", + "rawValue" : "debug" + }, + { + "associatedValues" : [ + + ], + "name" : "info", + "rawValue" : "info" + }, + { + "associatedValues" : [ + + ], + "name" : "warning", + "rawValue" : "warning" + }, + { + "associatedValues" : [ + + ], + "name" : "error", + "rawValue" : "error" + } + ], + "emitStyle" : "const", + "name" : "LogLevel", + "namespace" : [ + "Configuration" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration.LogLevel", + "tsFullPath" : "Configuration.LogLevel" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "http", + "rawValue" : "80" + }, + { + "associatedValues" : [ + + ], + "name" : "https", + "rawValue" : "443" + }, + { + "associatedValues" : [ + + ], + "name" : "development", + "rawValue" : "3000" + } + ], + "emitStyle" : "const", + "name" : "Port", + "namespace" : [ + "Configuration" + ], + "rawType" : "Int", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration.Port", + "tsFullPath" : "Configuration.Port" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Internal", + "namespace" : [ + "Networking", + "APIV2" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal", + "tsFullPath" : "Networking.APIV2.Internal" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + } + ], + "emitStyle" : "const", + "name" : "SupportedMethod", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal.SupportedMethod", + "tsFullPath" : "Networking.APIV2.Internal.SupportedMethod" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + } + ], + "name" : "flag" + }, + { + "associatedValues" : [ + { + "type" : { + "float" : { + + } + } + } + ], + "name" : "rate" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "precise" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "APIResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIResult", + "tsFullPath" : "APIResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "error" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "location" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "status" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "coordinates" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "comprehensive" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "ComplexResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ComplexResult", + "tsFullPath" : "ComplexResult" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Utilities", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utilities", + "tsFullPath" : "Utilities" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "status" + } + ], + "emitStyle" : "const", + "name" : "Result", + "namespace" : [ + "Utilities" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utilities.Result", + "tsFullPath" : "Utilities.Result" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "API", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "API", + "tsFullPath" : "API" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "int" : { + + } + } + } + ], + "name" : "failure" + } + ], + "emitStyle" : "const", + "name" : "NetworkingResult", + "namespace" : [ + "API" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "API.NetworkingResult", + "tsFullPath" : "API.NetworkingResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "type" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "name" : "status" + } + ], + "emitStyle" : "const", + "name" : "APIOptionalResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIOptionalResult", + "tsFullPath" : "APIOptionalResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "scientific" + }, + { + "associatedValues" : [ + + ], + "name" : "basic" + } + ], + "emitStyle" : "const", + "name" : "StaticCalculator", + "staticMethods" : [ + { + "abiName" : "bjs_StaticCalculator_static_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundtrip", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + }, + "staticContext" : { + "enumName" : { + "_0" : "StaticCalculator" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "StaticCalculator", + "tsFullPath" : "StaticCalculator" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "StaticUtils", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "StaticUtils", + "tsFullPath" : "StaticUtils" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Nested", + "namespace" : [ + "StaticUtils" + ], + "staticMethods" : [ + { + "abiName" : "bjs_StaticUtils_Nested_static_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundtrip", + "namespace" : [ + "StaticUtils", + "Nested" + ], + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "StaticUtils.Nested", + "tsFullPath" : "StaticUtils.Nested" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "option1" + }, + { + "associatedValues" : [ + + ], + "name" : "option2" + } + ], + "emitStyle" : "const", + "name" : "StaticPropertyEnum", + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumProperty", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "enumConstant", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumBool", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumVariable", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "computedReadonly", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "computedReadWrite", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyEnum", + "tsFullPath" : "StaticPropertyEnum" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "StaticPropertyNamespace", + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "namespaceProperty", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "namespaceConstant", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyNamespace", + "tsFullPath" : "StaticPropertyNamespace" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "NestedProperties", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedProperty", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "nestedConstant", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedDouble", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + + } + }, + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyNamespace.NestedProperties", + "tsFullPath" : "StaticPropertyNamespace.NestedProperties" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_roundTripVoid", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_roundTripInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripInt", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_roundTripFloat", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripFloat", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_roundTripDouble", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDouble", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_roundTripBool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripBool", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_roundTripString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripString", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_roundTripSwiftHeapObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripSwiftHeapObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_roundTripJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripJSObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_throwsSwiftError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsSwiftError", + "parameters" : [ + { + "label" : "shouldThrow", + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithIntResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithIntResult", + "parameters" : [ + + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithStringResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithStringResult", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithBoolResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithBoolResult", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithFloatResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithFloatResult", + "parameters" : [ + + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithDoubleResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithDoubleResult", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithSwiftHeapObjectResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithSwiftHeapObjectResult", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_throwsWithJSObjectResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithJSObjectResult", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripVoid", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripInt", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripInt", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripFloat", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripFloat", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripDouble", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripDouble", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripBool", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripBool", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripString", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripString", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripSwiftHeapObject", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripSwiftHeapObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripJSObject", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripJSObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_takeGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeGreeter", + "parameters" : [ + { + "label" : "g", + "name" : "g", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_createCalculator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createCalculator", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Calculator" + } + } + }, + { + "abiName" : "bjs_useCalculator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "useCalculator", + "parameters" : [ + { + "label" : "calc", + "name" : "calc", + "type" : { + "swiftHeapObject" : { + "_0" : "Calculator" + } + } + }, + { + "label" : "x", + "name" : "x", + "type" : { + "int" : { + + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_testGreeterToJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testGreeterToJSValue", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_testCalculatorToJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testCalculatorToJSValue", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_testSwiftClassAsJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testSwiftClassAsJSValue", + "parameters" : [ + { + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_setDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + } + }, + { + "abiName" : "bjs_getDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getDirection", + "parameters" : [ + + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + } + }, + { + "abiName" : "bjs_processDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processDirection", + "parameters" : [ + { + "label" : "_", + "name" : "input", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "abiName" : "bjs_setTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_getTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTheme", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_setHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "status", + "type" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_getHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getHttpStatus", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_processTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_setTSDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTSDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + }, + { + "abiName" : "bjs_getTSDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTSDirection", + "parameters" : [ + + ], + "returnType" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + }, + { + "abiName" : "bjs_setTSTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTSTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_getTSTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTSTheme", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_roundtripNetworkingAPIMethod", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripNetworkingAPIMethod", + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + }, + { + "abiName" : "bjs_roundtripConfigurationLogLevel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripConfigurationLogLevel", + "parameters" : [ + { + "label" : "_", + "name" : "level", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_roundtripConfigurationPort", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripConfigurationPort", + "parameters" : [ + { + "label" : "_", + "name" : "port", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_processConfigurationLogLevel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processConfigurationLogLevel", + "parameters" : [ + { + "label" : "_", + "name" : "level", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_roundtripInternalSupportedMethod", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripInternalSupportedMethod", + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + }, + { + "abiName" : "bjs_roundtripAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAPIResult", + "parameters" : [ + { + "label" : "result", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultFlag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultFlag", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultRate", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultRate", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultPrecise", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultPrecise", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_roundtripComplexResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripComplexResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultError", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultLocation", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultLocation", + "parameters" : [ + { + "label" : "_", + "name" : "lat", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "lng", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultStatus", + "parameters" : [ + { + "label" : "_", + "name" : "active", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "int" : { + + } + } + }, + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultCoordinates", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultCoordinates", + "parameters" : [ + { + "label" : "_", + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "z", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultComprehensive", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultComprehensive", + "parameters" : [ + { + "label" : "_", + "name" : "flag1", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "flag2", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "count1", + "type" : { + "int" : { + + } + } + }, + { + "label" : "_", + "name" : "count2", + "type" : { + "int" : { + + } + } + }, + { + "label" : "_", + "name" : "value1", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "value2", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "text1", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "text2", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "text3", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "error", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultStatus", + "parameters" : [ + { + "label" : "_", + "name" : "active", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "int" : { + + } + } + }, + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeAPINetworkingResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPINetworkingResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_makeAPINetworkingResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPINetworkingResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "error", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_roundtripUtilitiesResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripUtilitiesResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_roundtripAPINetworkingResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAPINetworkingResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_roundTripOptionalString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalString", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalInt", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalBool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalBool", + "parameters" : [ + { + "label" : "flag", + "name" : "flag", + "type" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalFloat", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalFloat", + "parameters" : [ + { + "label" : "number", + "name" : "number", + "type" : { + "optional" : { + "_0" : { + "float" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "float" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalDouble", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalDouble", + "parameters" : [ + { + "label" : "precision", + "name" : "precision", + "type" : { + "optional" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalSyntax", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalSyntax", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalMixSyntax", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalMixSyntax", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalSwiftSyntax", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalSwiftSyntax", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalWithSpaces", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalWithSpaces", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalTypeAlias", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalTypeAlias", + "parameters" : [ + { + "label" : "age", + "name" : "age", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalStatus", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalTheme", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalHttpStatus", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalTSDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalTSDirection", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalTSTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalTSTheme", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalNetworkingAPIMethod", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalNetworkingAPIMethod", + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalAPIResult", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "abiName" : "bjs_compareAPIResults", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "compareAPIResults", + "parameters" : [ + { + "label" : "_", + "name" : "r1", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "label" : "_", + "name" : "r2", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_roundTripOptionalComplexResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalComplexResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalClass", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalAPIOptionalResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalAPIOptionalResult", + "parameters" : [ + { + "label" : "result", + "name" : "result", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIOptionalResult" + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIOptionalResult" + } + } + } + } + }, + { + "abiName" : "bjs_createPropertyHolder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createPropertyHolder", + "parameters" : [ + { + "label" : "intValue", + "name" : "intValue", + "type" : { + "int" : { + + } + } + }, + { + "label" : "floatValue", + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "label" : "doubleValue", + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "label" : "boolValue", + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "stringValue", + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "label" : "jsObject", + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "PropertyHolder" + } + } + }, + { + "abiName" : "bjs_testPropertyHolder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testPropertyHolder", + "parameters" : [ + { + "label" : "holder", + "name" : "holder", + "type" : { + "swiftHeapObject" : { + "_0" : "PropertyHolder" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_resetObserverCounts", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetObserverCounts", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getObserverStats", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getObserverStats", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_testStringDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testStringDefault", + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Hello World" + } + }, + "label" : "message", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_testIntDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testIntDefault", + "parameters" : [ + { + "defaultValue" : { + "int" : { + "_0" : 42 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_testBoolDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testBoolDefault", + "parameters" : [ + { + "defaultValue" : { + "bool" : { + "_0" : true + } + }, + "label" : "flag", + "name" : "flag", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_testOptionalDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testOptionalDefault", + "parameters" : [ + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "name", + "name" : "name", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "abiName" : "bjs_testMultipleDefaults", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testMultipleDefaults", + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Default Title" + } + }, + "label" : "title", + "name" : "title", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "int" : { + "_0" : -10 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "defaultValue" : { + "bool" : { + "_0" : false + } + }, + "label" : "enabled", + "name" : "enabled", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_testSimpleEnumDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testSimpleEnumDefault", + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Status", + "_1" : "success" + } + }, + "label" : "status", + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "abiName" : "bjs_testDirectionDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testDirectionDefault", + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Direction", + "_1" : "north" + } + }, + "label" : "direction", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + } + }, + { + "abiName" : "bjs_testRawStringEnumDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testRawStringEnumDefault", + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Theme", + "_1" : "light" + } + }, + "label" : "theme", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_testComplexInit", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testComplexInit", + "parameters" : [ + { + "defaultValue" : { + "objectWithArguments" : { + "_0" : "Greeter", + "_1" : [ + { + "string" : { + "_0" : "DefaultGreeter" + } + } + ] + } + }, + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_testEmptyInit", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testEmptyInit", + "parameters" : [ + { + "defaultValue" : { + "object" : { + "_0" : "StaticPropertyHolder" + } + }, + "label" : "_", + "name" : "object", + "type" : { + "swiftHeapObject" : { + "_0" : "StaticPropertyHolder" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "StaticPropertyHolder" + } + } + }, + { + "abiName" : "bjs_formatName", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "formatName", + "parameters" : [ + { + "label" : "_", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "label" : "transform", + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFormatter", + "parameters" : [ + { + "label" : "prefix", + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_makeAdder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAdder", + "parameters" : [ + { + "label" : "base", + "name" : "base", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "int" : { + + } + } + ], + "returnType" : { + "int" : { + + } + } + } + } + } + }, + { + "abiName" : "bjs_testStructDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testStructDefault", + "parameters" : [ + { + "defaultValue" : { + "structLiteral" : { + "_0" : "DataPoint", + "_1" : [ + { + "name" : "x", + "value" : { + "float" : { + "_0" : 1 + } + } + }, + { + "name" : "y", + "value" : { + "float" : { + "_0" : 2 + } + } + }, + { + "name" : "label", + "value" : { + "string" : { + "_0" : "default" + } + } + }, + { + "name" : "optCount", + "value" : { + "null" : { + + } + } + }, + { + "name" : "optFlag", + "value" : { + "null" : { + + } + } + } + ] + } + }, + "label" : "point", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_roundTripDataPoint", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDataPoint", + "parameters" : [ + { + "label" : "_", + "name" : "data", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "abiName" : "bjs_roundTripContact", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripContact", + "parameters" : [ + { + "label" : "_", + "name" : "contact", + "type" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + }, + { + "abiName" : "bjs_roundTripConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripConfig", + "parameters" : [ + { + "label" : "_", + "name" : "config", + "type" : { + "swiftStruct" : { + "_0" : "Config" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Config" + } + } + }, + { + "abiName" : "bjs_roundTripSessionData", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripSessionData", + "parameters" : [ + { + "label" : "_", + "name" : "session", + "type" : { + "swiftStruct" : { + "_0" : "SessionData" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "SessionData" + } + } + }, + { + "abiName" : "bjs_roundTripValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripValidationReport", + "parameters" : [ + { + "label" : "_", + "name" : "report", + "type" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_updateValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "updateValidationReport", + "parameters" : [ + { + "label" : "_", + "name" : "newResult", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "label" : "_", + "name" : "report", + "type" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_testContainerWithStruct", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testContainerWithStruct", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Container" + } + } + } + ], + "protocols" : [ + { + "methods" : [ + { + "abiName" : "bjs_DataProcessor_increment", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "increment", + "parameters" : [ + { + "label" : "by", + "name" : "amount", + "type" : { + "int" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getValue", + "parameters" : [ + + ], + "returnType" : { + "int" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_setLabelElements", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setLabelElements", + "parameters" : [ + { + "label" : "_", + "name" : "labelPrefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "labelSuffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_isEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_processGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_createGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createGreeter", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_DataProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_createOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createOptionalGreeter", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + }, + { + "abiName" : "bjs_DataProcessor_handleAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "handleAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAPIResult", + "parameters" : [ + + ], + "returnType" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "name" : "DataProcessor", + "properties" : [ + { + "isReadonly" : false, + "name" : "count", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "name" : "optionalTag", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "optionalCount", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "direction", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "optionalTheme", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "httpStatus", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "apiResult", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + }, + { + "isReadonly" : false, + "name" : "helper", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalHelper", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ] + } + ], + "structs" : [ + { + "constructor" : { + "abiName" : "bjs_DataPoint_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "x", + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "label" : "optCount", + "name" : "optCount", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "label" : "optFlag", + "name" : "optFlag", + "type" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "DataPoint", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optCount", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optFlag", + "type" : { + "optional" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "swiftCallName" : "DataPoint" + }, + { + "methods" : [ + + ], + "name" : "Address", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "street", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "city", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "zipCode", + "type" : { + "optional" : { + "_0" : { + "int" : { + + } + } + } + } + } + ], + "swiftCallName" : "Address" + }, + { + "methods" : [ + + ], + "name" : "Contact", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "age", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "address", + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "email", + "type" : { + "optional" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "secondaryAddress", + "type" : { + "optional" : { + "_0" : { + "swiftStruct" : { + "_0" : "Address" + } + } + } + } + } + ], + "swiftCallName" : "Contact" + }, + { + "methods" : [ + + ], + "name" : "Config", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "theme", + "type" : { + "optional" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "direction", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + ], + "swiftCallName" : "Config" + }, + { + "methods" : [ + + ], + "name" : "SessionData", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "owner", + "type" : { + "optional" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "swiftCallName" : "SessionData" + }, + { + "methods" : [ + + ], + "name" : "ValidationReport", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "optional" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "outcome", + "type" : { + "optional" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + } + } + ], + "swiftCallName" : "ValidationReport" + }, + { + "constructor" : { + "abiName" : "bjs_MathOperations_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "defaultValue" : { + "double" : { + "_0" : 0 + } + }, + "label" : "baseValue", + "name" : "baseValue", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_MathOperations_add", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "defaultValue" : { + "double" : { + "_0" : 10 + } + }, + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_MathOperations_multiply", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "multiply", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_MathOperations_static_subtract", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "subtract", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + }, + "staticContext" : { + "structName" : { + "_0" : "MathOperations" + } + } + } + ], + "name" : "MathOperations", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "baseValue", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "MathOperations" + }, + { + "methods" : [ + + ], + "name" : "ConfigStruct", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "value", + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "defaultConfig", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "maxRetries", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "int" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "timeout", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "computedSetting", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "ConfigStruct" + } + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + + ] + }, + { + "functions" : [ + { + "name" : "jsRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "name" : "jsRoundTripNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "name" : "jsRoundTripBool", + "parameters" : [ + { + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "name" : "jsRoundTripString", + "parameters" : [ + { + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "name" : "jsThrowOrVoid", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "name" : "jsThrowOrNumber", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "name" : "jsThrowOrBool", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "name" : "jsThrowOrString", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "name" : "runAsyncWorks", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + "_0" : "JSPromise" + } + } + } + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + { + "name" : "greet", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "name" : "changeName", + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "JsGreeter", + "setters" : [ + { + "functionName" : "name_set", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + + ] + } + ] + }, + "moduleName" : "BridgeJSRuntimeTests" +} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts index e69de29b..86a72ca0 100644 --- a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts +++ b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts @@ -0,0 +1,18 @@ +export function jsRoundTripVoid(): void +export function jsRoundTripNumber(v: number): number +export function jsRoundTripBool(v: boolean): boolean +export function jsRoundTripString(v: string): string +export function jsThrowOrVoid(shouldThrow: boolean): void +export function jsThrowOrNumber(shouldThrow: boolean): number +export function jsThrowOrBool(shouldThrow: boolean): boolean +export function jsThrowOrString(shouldThrow: boolean): string + +export class JsGreeter { + name: string; + readonly prefix: string; + constructor(name: string, prefix: string); + greet(): string; + changeName(name: string): void; +} + +export function runAsyncWorks(): Promise; \ No newline at end of file diff --git a/Utilities/bridge-js-generate.sh b/Utilities/bridge-js-generate.sh index b79befa2..22182d24 100755 --- a/Utilities/bridge-js-generate.sh +++ b/Utilities/bridge-js-generate.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash -env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package plugin --allow-writing-to-package-directory bridge-js -env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --package-path ./Benchmarks plugin --allow-writing-to-package-directory bridge-js -env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --package-path ./Examples/PlayBridgeJS plugin --allow-writing-to-package-directory bridge-js +set -euxo pipefail +swift build --package-path ./Plugins/BridgeJS --product BridgeJSTool + +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSRuntimeTests --target-dir ./Tests/BridgeJSRuntimeTests --output-dir ./Tests/BridgeJSRuntimeTests/Generated +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSGlobalTests --target-dir ./Tests/BridgeJSGlobalTests --output-dir ./Tests/BridgeJSGlobalTests/Generated +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name Benchmarks --target-dir ./Benchmarks/Sources --output-dir ./Benchmarks/Sources/Generated +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name PlayBridgeJS --target-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS --output-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated