diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift index 129f53b50..791b1b7a9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift @@ -9,41 +9,34 @@ import JavaScriptKit } @JS class TestProcessor { - private var transform: (String) -> String - - @JS init(transform: @escaping (String) -> String) { - self.transform = transform - } - - @JS func getTransform() -> (String) -> String - - @JS func processWithCustom(_ text: String, customTransform: (String) -> String) -> String + @JS init(transform: @escaping (String) -> String) {} +} - @JS func printTogether( - person: Person, - name: String, - ratio: Double, - customTransform: (Person?, String?, Double?) -> String - ) -> String +@JS func roundtripString(_ stringClosure: (String) -> String) -> (String) -> String +@JS func roundtripInt(_ intClosure: (Int) -> Int) -> (Int) -> Int +@JS func roundtripBool(_ boolClosure: (Bool) -> Bool) -> (Bool) -> Bool +@JS func roundtripFloat(_ floatClosure: (Float) -> Float) -> (Float) -> Float +@JS func roundtripDouble(_ doubleClosure: (Double) -> Double) -> (Double) -> Double - @JS func roundtrip(_ personClosure: (Person) -> String) -> (Person) -> String - @JS func roundtripOptional(_ personClosure: (Person?) -> String) -> (Person?) -> String +@JS func roundtripOptionalString(_ stringClosure: (String?) -> String?) -> (String?) -> String? +@JS func roundtripOptionalInt(_ intClosure: (Int?) -> Int?) -> (Int?) -> Int? +@JS func roundtripOptionalBool(_ boolClosure: (Bool?) -> Bool?) -> (Bool?) -> Bool? +@JS func roundtripOptionalFloat(_ floatClosure: (Float?) -> Float?) -> (Float?) -> Float? +@JS func roundtripOptionalDouble(_ doubleClosure: (Double?) -> Double?) -> (Double?) -> Double? - @JS func processDirection(_ callback: (Direction) -> String) -> String - @JS func processTheme(_ callback: (Theme) -> String) -> String - @JS func processHttpStatus(_ callback: (HttpStatus) -> Int) -> Int - @JS func processAPIResult(_ callback: (APIResult) -> String) -> String +@JS func roundtripPerson(_ personClosure: (Person) -> Person) -> (Person) -> Person +@JS func roundtripOptionalPerson(_ personClosure: (Person?) -> Person?) -> (Person?) -> Person? - @JS func makeDirectionChecker() -> (Direction) -> Bool - @JS func makeThemeValidator() -> (Theme) -> Bool - @JS func makeStatusCodeExtractor() -> (HttpStatus) -> Int - @JS func makeAPIResultHandler() -> (APIResult) -> String +@JS func roundtripDirection(_ callback: (Direction) -> Direction) -> (Direction) -> Direction +@JS func roundtripTheme(_ callback: (Theme) -> Theme) -> (Theme) -> Theme +@JS func roundtripHttpStatus(_ callback: (HttpStatus) -> HttpStatus) -> (HttpStatus) -> HttpStatus +@JS func roundtripAPIResult(_ callback: (APIResult) -> APIResult) -> (APIResult) -> APIResult - @JS func processOptionalDirection(_ callback: (Direction?) -> String) -> String - @JS func processOptionalTheme(_ callback: (Theme?) -> String) -> String - @JS func processOptionalAPIResult(_ callback: (APIResult?) -> String) -> String - @JS func makeOptionalDirectionFormatter() -> (Direction?) -> String -} +@JS func roundtripOptionalDirection(_ callback: (Direction?) -> Direction?) -> (Direction?) -> Direction? +@JS func roundtripOptionalTheme(_ callback: (Theme?) -> Theme?) -> (Theme?) -> Theme? +@JS func roundtripOptionalHttpStatus(_ callback: (HttpStatus?) -> HttpStatus?) -> (HttpStatus?) -> HttpStatus? +@JS func roundtripOptionalAPIResult(_ callback: (APIResult?) -> APIResult?) -> (APIResult?) -> APIResult? +@JS func roundtripOptionalDirection(_ callback: (Direction?) -> Direction?) -> (Direction?) -> Direction? @JS enum Direction { case north diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json index ee551fa47..11c6cb893 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json @@ -70,236 +70,239 @@ ] }, "methods" : [ + + ], + "name" : "TestProcessor", + "properties" : [ + + ], + "swiftCallName" : "TestProcessor" + } + ], + "enums" : [ + { + "cases" : [ { - "abiName" : "bjs_TestProcessor_getTransform", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTransform", - "parameters" : [ + "associatedValues" : [ ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSS_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "string" : { + "name" : "north" + }, + { + "associatedValues" : [ - } - } - ], - "returnType" : { - "string" : { + ], + "name" : "south" + }, + { + "associatedValues" : [ - } - } - }, - "useJSTypedClosure" : false - } - } + ], + "name" : "east" }, { - "abiName" : "bjs_TestProcessor_processWithCustom", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processWithCustom", - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { + "associatedValues" : [ - } - } - }, - { - "label" : "customTransform", - "name" : "customTransform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSS_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "string" : { + ], + "name" : "west" + } + ], + "emitStyle" : "const", + "name" : "Direction", + "staticMethods" : [ - } - } - ], - "returnType" : { - "string" : { + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Direction", + "tsFullPath" : "Direction" + }, + { + "cases" : [ + { + "associatedValues" : [ - } - } - }, - "useJSTypedClosure" : false - } - } - } ], - "returnType" : { - "string" : { + "name" : "light", + "rawValue" : "light" + }, + { + "associatedValues" : [ - } - } + ], + "name" : "dark", + "rawValue" : "dark" }, { - "abiName" : "bjs_TestProcessor_printTogether", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "printTogether", - "parameters" : [ + "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" : [ { - "label" : "person", - "name" : "person", "type" : { - "swiftHeapObject" : { - "_0" : "Person" + "string" : { + } } - }, + } + ], + "name" : "success" + }, + { + "associatedValues" : [ { - "label" : "name", - "name" : "name", "type" : { - "string" : { + "int" : { } } - }, + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ { - "label" : "ratio", - "name" : "ratio", "type" : { - "double" : { + "bool" : { } } - }, + } + ], + "name" : "flag" + }, + { + "associatedValues" : [ { - "label" : "customTransform", - "name" : "customTransform", "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSq6PersonCSqSSSqSd_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Person" - } - }, - "_1" : "null" - } - }, - { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - }, - { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { + "float" : { - } - } - }, - "useJSTypedClosure" : false } } } ], - "returnType" : { - "string" : { - - } - } + "name" : "rate" }, { - "abiName" : "bjs_TestProcessor_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtrip", - "parameters" : [ + "associatedValues" : [ { - "label" : "_", - "name" : "personClosure", "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModule6PersonC_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "swiftHeapObject" : { - "_0" : "Person" - } - } - ], - "returnType" : { - "string" : { + "double" : { - } - } - }, - "useJSTypedClosure" : false } } } ], - "returnType" : { + "name" : "precise" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "APIResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIResult", + "tsFullPath" : "APIResult" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_roundtripString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripString", + "parameters" : [ + { + "label" : "_", + "name" : "stringClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModule6PersonC_SS", + "mangleName" : "10TestModuleSS_SS", "moduleName" : "TestModule", "parameters" : [ { - "swiftHeapObject" : { - "_0" : "Person" + "string" : { + } } ], @@ -312,70 +315,60 @@ "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_roundtripOptional", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripOptional", - "parameters" : [ - { - "label" : "_", - "name" : "personClosure", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSq6PersonC_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Person" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { + "isThrows" : false, + "mangleName" : "10TestModuleSS_SS", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { - } - } - }, - "useJSTypedClosure" : false } } + ], + "returnType" : { + "string" : { + + } } - ], - "returnType" : { + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripInt", + "parameters" : [ + { + "label" : "_", + "name" : "intClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModuleSq6PersonC_SS", + "mangleName" : "10TestModuleSi_Si", "moduleName" : "TestModule", "parameters" : [ { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Person" - } - }, - "_1" : "null" + "int" : { + } } ], "returnType" : { - "string" : { + "int" : { } } @@ -383,208 +376,121 @@ "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_processDirection", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModule9DirectionO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "caseEnum" : { - "_0" : "Direction" - } - } - ], - "returnType" : { - "string" : { + "isThrows" : false, + "mangleName" : "10TestModuleSi_Si", + "moduleName" : "TestModule", + "parameters" : [ + { + "int" : { - } - } - }, - "useJSTypedClosure" : false } } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TestProcessor_processTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModule5ThemeO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "int" : { - } - } - }, - "useJSTypedClosure" : false - } } } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TestProcessor_processHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "name" : "processHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModule10HttpStatusO_Si", - "moduleName" : "TestModule", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - ], - "returnType" : { - "int" : { + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripBool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripBool", + "parameters" : [ + { + "label" : "_", + "name" : "boolClosure", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSb_Sb", + "moduleName" : "TestModule", + "parameters" : [ + { + "bool" : { - } } - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "int" : { + } + ], + "returnType" : { + "bool" : { + } + } + }, + "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_processAPIResult", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModule9APIResultO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - ], - "returnType" : { - "string" : { + "isThrows" : false, + "mangleName" : "10TestModuleSb_Sb", + "moduleName" : "TestModule", + "parameters" : [ + { + "bool" : { - } - } - }, - "useJSTypedClosure" : false } } - } - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "bool" : { + } } - } - }, - { - "abiName" : "bjs_TestProcessor_makeDirectionChecker", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "name" : "makeDirectionChecker", - "parameters" : [ - - ], - "returnType" : { + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripFloat", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripFloat", + "parameters" : [ + { + "label" : "_", + "name" : "floatClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModule9DirectionO_Sb", + "mangleName" : "10TestModuleSf_Sf", "moduleName" : "TestModule", "parameters" : [ { - "caseEnum" : { - "_0" : "Direction" + "float" : { + } } ], "returnType" : { - "bool" : { + "float" : { } } @@ -592,35 +498,60 @@ "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_makeThemeValidator", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeThemeValidator", - "parameters" : [ + "isThrows" : false, + "mangleName" : "10TestModuleSf_Sf", + "moduleName" : "TestModule", + "parameters" : [ + { + "float" : { - ], - "returnType" : { + } + } + ], + "returnType" : { + "float" : { + + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripDouble", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripDouble", + "parameters" : [ + { + "label" : "_", + "name" : "doubleClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModule5ThemeO_Sb", + "mangleName" : "10TestModuleSd_Sd", "moduleName" : "TestModule", "parameters" : [ { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "double" : { + } } ], "returnType" : { - "bool" : { + "double" : { } } @@ -628,247 +559,300 @@ "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_makeStatusCodeExtractor", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeStatusCodeExtractor", - "parameters" : [ + "isThrows" : false, + "mangleName" : "10TestModuleSd_Sd", + "moduleName" : "TestModule", + "parameters" : [ + { + "double" : { - ], - "returnType" : { + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalString", + "parameters" : [ + { + "label" : "_", + "name" : "stringClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModule10HttpStatusO_Si", + "mangleName" : "10TestModuleSqSS_SqSS", "moduleName" : "TestModule", "parameters" : [ { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" } } ], "returnType" : { - "int" : { + "nullable" : { + "_0" : { + "string" : { + } + }, + "_1" : "null" } } }, "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_makeAPIResultHandler", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultHandler", - "parameters" : [ + "isThrows" : false, + "mangleName" : "10TestModuleSqSS_SqSS", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "string" : { - ], - "returnType" : { + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalInt", + "parameters" : [ + { + "label" : "_", + "name" : "intClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModule9APIResultO_SS", + "mangleName" : "10TestModuleSqSi_SqSi", "moduleName" : "TestModule", "parameters" : [ { - "associatedValueEnum" : { - "_0" : "APIResult" + "nullable" : { + "_0" : { + "int" : { + + } + }, + "_1" : "null" } } ], "returnType" : { - "string" : { + "nullable" : { + "_0" : { + "int" : { + } + }, + "_1" : "null" } } }, "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_processOptionalDirection", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { + "isThrows" : false, + "mangleName" : "10TestModuleSqSi_SqSi", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSq9DirectionO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { + "int" : { - } } }, - "useJSTypedClosure" : false + "_1" : "null" } } - } - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "nullable" : { + "_0" : { + "int" : { + } + }, + "_1" : "null" + } } - } - }, - { - "abiName" : "bjs_TestProcessor_processOptionalTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "name" : "processOptionalTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSq5ThemeO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalBool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalBool", + "parameters" : [ + { + "label" : "_", + "name" : "boolClosure", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSqSb_SqSb", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "bool" : { + } - } - ], - "returnType" : { - "string" : { + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "bool" : { } - } - }, - "useJSTypedClosure" : false + }, + "_1" : "null" + } } - } - } - ], - "returnType" : { - "string" : { - + }, + "useJSTypedClosure" : false } } - }, - { - "abiName" : "bjs_TestProcessor_processOptionalAPIResult", - "effects" : { + } + ], + "returnType" : { + "closure" : { + "_0" : { "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { + "isThrows" : false, + "mangleName" : "10TestModuleSqSb_SqSb", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "10TestModuleSq9APIResultO_SS", - "moduleName" : "TestModule", - "parameters" : [ - { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { + "bool" : { - } } }, - "useJSTypedClosure" : false + "_1" : "null" } } - } - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "nullable" : { + "_0" : { + "bool" : { + } + }, + "_1" : "null" + } } - } - }, - { - "abiName" : "bjs_TestProcessor_makeOptionalDirectionFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false }, - "name" : "makeOptionalDirectionFormatter", - "parameters" : [ - - ], - "returnType" : { + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalFloat", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalFloat", + "parameters" : [ + { + "label" : "_", + "name" : "floatClosure", + "type" : { "closure" : { "_0" : { "isAsync" : false, "isThrows" : false, - "mangleName" : "10TestModuleSq9DirectionO_SS", + "mangleName" : "10TestModuleSqSf_SqSf", "moduleName" : "TestModule", "parameters" : [ { "nullable" : { "_0" : { - "caseEnum" : { - "_0" : "Direction" + "float" : { + } }, "_1" : "null" @@ -876,8 +860,13 @@ } ], "returnType" : { - "string" : { + "nullable" : { + "_0" : { + "float" : { + } + }, + "_1" : "null" } } }, @@ -886,215 +875,928 @@ } } ], - "name" : "TestProcessor", - "properties" : [ - - ], - "swiftCallName" : "TestProcessor" - } - ], - "enums" : [ - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "north" - }, - { - "associatedValues" : [ - - ], - "name" : "south" - }, - { - "associatedValues" : [ + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSqSf_SqSf", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "float" : { - ], - "name" : "east" - }, - { - "associatedValues" : [ + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "float" : { - ], - "name" : "west" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false } - ], - "emitStyle" : "const", - "name" : "Direction", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Direction", - "tsFullPath" : "Direction" + } }, { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "light", - "rawValue" : "light" - }, + "abiName" : "bjs_roundtripOptionalDouble", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalDouble", + "parameters" : [ { - "associatedValues" : [ + "label" : "_", + "name" : "doubleClosure", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSqSd_SqSd", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "double" : { - ], - "name" : "dark", - "rawValue" : "dark" - }, - { - "associatedValues" : [ + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "double" : { - ], - "name" : "auto", - "rawValue" : "auto" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } } ], - "emitStyle" : "const", - "name" : "Theme", - "rawType" : "String", - "staticMethods" : [ + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSqSd_SqSd", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "double" : { - ], - "staticProperties" : [ + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "double" : { - ], - "swiftCallName" : "Theme", - "tsFullPath" : "Theme" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } }, { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "ok", - "rawValue" : "200" - }, - { - "associatedValues" : [ - - ], - "name" : "notFound", - "rawValue" : "404" - }, - { - "associatedValues" : [ - - ], - "name" : "serverError", - "rawValue" : "500" - }, + "abiName" : "bjs_roundtripPerson", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripPerson", + "parameters" : [ { - "associatedValues" : [ - - ], - "name" : "unknown", - "rawValue" : "-1" + "label" : "_", + "name" : "personClosure", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule6PersonC_6PersonC", + "moduleName" : "TestModule", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Person" + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Person" + } + } + }, + "useJSTypedClosure" : false + } + } } ], - "emitStyle" : "const", - "name" : "HttpStatus", - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "HttpStatus", - "tsFullPath" : "HttpStatus" + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule6PersonC_6PersonC", + "moduleName" : "TestModule", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Person" + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Person" + } + } + }, + "useJSTypedClosure" : false + } + } }, { - "cases" : [ + "abiName" : "bjs_roundtripOptionalPerson", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalPerson", + "parameters" : [ { - "associatedValues" : [ - { - "type" : { - "string" : { - + "label" : "_", + "name" : "personClosure", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq6PersonC_Sq6PersonC", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Person" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Person" + } + }, + "_1" : "null" + } } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq6PersonC_Sq6PersonC", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Person" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Person" + } + }, + "_1" : "null" } } - ], - "name" : "success" - }, + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripDirection", + "parameters" : [ { - "associatedValues" : [ - { - "type" : { - "int" : { - + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule9DirectionO_9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule9DirectionO_9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" } } - ], - "name" : "failure" - }, + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripTheme", + "parameters" : [ { - "associatedValues" : [ - { - "type" : { - "bool" : { - + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule5ThemeO_5ThemeO", + "moduleName" : "TestModule", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule5ThemeO_5ThemeO", + "moduleName" : "TestModule", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } } - ], - "name" : "flag" - }, + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripHttpStatus", + "parameters" : [ { - "associatedValues" : [ - { - "type" : { - "float" : { - + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule10HttpStatusO_10HttpStatusO", + "moduleName" : "TestModule", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule10HttpStatusO_10HttpStatusO", + "moduleName" : "TestModule", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" } } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } } - ], - "name" : "rate" - }, + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAPIResult", + "parameters" : [ { - "associatedValues" : [ - { - "type" : { - "double" : { - + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule9APIResultO_9APIResultO", + "moduleName" : "TestModule", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModule9APIResultO_9APIResultO", + "moduleName" : "TestModule", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" } } - ], - "name" : "precise" - }, + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalDirection", + "parameters" : [ { - "associatedValues" : [ - - ], - "name" : "info" + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9DirectionO_Sq9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } } ], - "emitStyle" : "const", - "name" : "APIResult", - "staticMethods" : [ - + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9DirectionO_Sq9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalTheme", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq5ThemeO_Sq5ThemeO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + } ], - "staticProperties" : [ - + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq5ThemeO_Sq5ThemeO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq10HttpStatusO_Sq10HttpStatusO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + } ], - "swiftCallName" : "APIResult", - "tsFullPath" : "APIResult" + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq10HttpStatusO_Sq10HttpStatusO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9APIResultO_Sq9APIResultO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9APIResultO_Sq9APIResultO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_roundtripOptionalDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripOptionalDirection", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9DirectionO_Sq9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleSq9DirectionO_Sq9DirectionO", + "moduleName" : "TestModule", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + "useJSTypedClosure" : false + } + } } - ], - "exposeToGlobal" : false, - "functions" : [ - ], "protocols" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift index e659988d1..8aa9efd65 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift @@ -1,30 +1,30 @@ #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule10HttpStatusO_10HttpStatusO") +fileprivate func invoke_js_callback_TestModule_10TestModule10HttpStatusO_10HttpStatusO(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule10HttpStatusO_Si(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModule10HttpStatusO_10HttpStatusO(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule10HttpStatusO_Si") -fileprivate func make_swift_closure_TestModule_10TestModule10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO") +fileprivate func make_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule10HttpStatusO_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (HttpStatus) -> Int { +private enum _BJS_Closure_10TestModule10HttpStatusO_10HttpStatusO { + static func bridgeJSLift(_ callbackId: Int32) -> (HttpStatus) -> HttpStatus { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule10HttpStatusO_Si(callbackValue, param0Value) - return Int.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModule10HttpStatusO_10HttpStatusO(callbackValue, param0Value) + return HttpStatus.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -32,10 +32,10 @@ private enum _BJS_Closure_10TestModule10HttpStatusO_Si { } } -extension JSTypedClosure where Signature == (HttpStatus) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (HttpStatus) -> Int) { +extension JSTypedClosure where Signature == (HttpStatus) -> HttpStatus { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (HttpStatus) -> HttpStatus) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule10HttpStatusO_Si, + makeClosure: make_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO, body: body, fileID: fileID, line: line @@ -43,11 +43,11 @@ extension JSTypedClosure where Signature == (HttpStatus) -> Int { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule10HttpStatusO_Si") -@_cdecl("invoke_swift_closure_TestModule_10TestModule10HttpStatusO_Si") -public func _invoke_swift_closure_TestModule_10TestModule10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO") +@_cdecl("invoke_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO") +public func _invoke_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(HttpStatus) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let closure = Unmanaged<_BridgeJSTypedClosureBox<(HttpStatus) -> HttpStatus>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure(HttpStatus.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else @@ -56,32 +56,32 @@ public func _invoke_swift_closure_TestModule_10TestModule10HttpStatusO_Si(_ boxP } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule5ThemeO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_SS(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule5ThemeO_5ThemeO") +fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_5ThemeO(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_5ThemeO(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule5ThemeO_SS") -fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO") +fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule5ThemeO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> String { +private enum _BJS_Closure_10TestModule5ThemeO_5ThemeO { + static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> Theme { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule5ThemeO_SS(callbackValue, param0Value) - return String.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModule5ThemeO_5ThemeO(callbackValue, param0Value) + return Theme.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -89,10 +89,10 @@ private enum _BJS_Closure_10TestModule5ThemeO_SS { } } -extension JSTypedClosure where Signature == (Theme) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> String) { +extension JSTypedClosure where Signature == (Theme) -> Theme { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> Theme) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule5ThemeO_SS, + makeClosure: make_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO, body: body, fileID: fileID, line: line @@ -100,11 +100,11 @@ extension JSTypedClosure where Signature == (Theme) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule5ThemeO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModule5ThemeO_SS") -public func _invoke_swift_closure_TestModule_10TestModule5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO") +@_cdecl("invoke_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO") +public func _invoke_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> Theme>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) return result.bridgeJSLowerReturn() #else @@ -113,32 +113,32 @@ public func _invoke_swift_closure_TestModule_10TestModule5ThemeO_SS(_ boxPtr: Un } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule5ThemeO_Sb") -fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule6PersonC_6PersonC") +fileprivate func invoke_js_callback_TestModule_10TestModule6PersonC_6PersonC(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer #else -fileprivate func invoke_js_callback_TestModule_10TestModule5ThemeO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModule6PersonC_6PersonC(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule5ThemeO_Sb") -fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule6PersonC_6PersonC") +fileprivate func make_swift_closure_TestModule_10TestModule6PersonC_6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModule6PersonC_6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule5ThemeO_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> Bool { +private enum _BJS_Closure_10TestModule6PersonC_6PersonC { + static func bridgeJSLift(_ callbackId: Int32) -> (Person) -> Person { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule5ThemeO_Sb(callbackValue, param0Value) - return Bool.bridgeJSLiftReturn(ret) + let param0Pointer = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModule6PersonC_6PersonC(callbackValue, param0Pointer) + return Person.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -146,10 +146,10 @@ private enum _BJS_Closure_10TestModule5ThemeO_Sb { } } -extension JSTypedClosure where Signature == (Theme) -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> Bool) { +extension JSTypedClosure where Signature == (Person) -> Person { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Person) -> Person) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule5ThemeO_Sb, + makeClosure: make_swift_closure_TestModule_10TestModule6PersonC_6PersonC, body: body, fileID: fileID, line: line @@ -157,12 +157,12 @@ extension JSTypedClosure where Signature == (Theme) -> Bool { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule5ThemeO_Sb") -@_cdecl("invoke_swift_closure_TestModule_10TestModule5ThemeO_Sb") -public func _invoke_swift_closure_TestModule_10TestModule5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule6PersonC_6PersonC") +@_cdecl("invoke_swift_closure_TestModule_10TestModule6PersonC_6PersonC") +public func _invoke_swift_closure_TestModule_10TestModule6PersonC_6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Person) -> Person>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Person.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -170,32 +170,32 @@ public func _invoke_swift_closure_TestModule_10TestModule5ThemeO_Sb(_ boxPtr: Un } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule6PersonC_SS") -fileprivate func invoke_js_callback_TestModule_10TestModule6PersonC_SS(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule9APIResultO_9APIResultO") +fileprivate func invoke_js_callback_TestModule_10TestModule9APIResultO_9APIResultO(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule6PersonC_SS(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModule9APIResultO_9APIResultO(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule6PersonC_SS") -fileprivate func make_swift_closure_TestModule_10TestModule6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO") +fileprivate func make_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule6PersonC_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Person) -> String { +private enum _BJS_Closure_10TestModule9APIResultO_9APIResultO { + static func bridgeJSLift(_ callbackId: Int32) -> (APIResult) -> APIResult { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let param0Pointer = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule6PersonC_SS(callbackValue, param0Pointer) - return String.bridgeJSLiftReturn(ret) + let param0CaseId = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModule9APIResultO_9APIResultO(callbackValue, param0CaseId) + return APIResult.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -203,10 +203,10 @@ private enum _BJS_Closure_10TestModule6PersonC_SS { } } -extension JSTypedClosure where Signature == (Person) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Person) -> String) { +extension JSTypedClosure where Signature == (APIResult) -> APIResult { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (APIResult) -> APIResult) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule6PersonC_SS, + makeClosure: make_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO, body: body, fileID: fileID, line: line @@ -214,12 +214,12 @@ extension JSTypedClosure where Signature == (Person) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule6PersonC_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModule6PersonC_SS") -public func _invoke_swift_closure_TestModule_10TestModule6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO") +@_cdecl("invoke_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO") +public func _invoke_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Person) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Person.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(APIResult) -> APIResult>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(APIResult.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -227,32 +227,32 @@ public func _invoke_swift_closure_TestModule_10TestModule6PersonC_SS(_ boxPtr: U } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule9APIResultO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModule9APIResultO_SS(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule9DirectionO_9DirectionO") +fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_9DirectionO(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule9APIResultO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_9DirectionO(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule9APIResultO_SS") -fileprivate func make_swift_closure_TestModule_10TestModule9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO") +fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule9APIResultO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (APIResult) -> String { +private enum _BJS_Closure_10TestModule9DirectionO_9DirectionO { + static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> Direction { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let param0CaseId = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule9APIResultO_SS(callbackValue, param0CaseId) - return String.bridgeJSLiftReturn(ret) + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModule9DirectionO_9DirectionO(callbackValue, param0Value) + return Direction.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -260,10 +260,10 @@ private enum _BJS_Closure_10TestModule9APIResultO_SS { } } -extension JSTypedClosure where Signature == (APIResult) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (APIResult) -> String) { +extension JSTypedClosure where Signature == (Direction) -> Direction { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> Direction) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule9APIResultO_SS, + makeClosure: make_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO, body: body, fileID: fileID, line: line @@ -271,12 +271,12 @@ extension JSTypedClosure where Signature == (APIResult) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule9APIResultO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModule9APIResultO_SS") -public func _invoke_swift_closure_TestModule_10TestModule9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO") +@_cdecl("invoke_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO") +public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(APIResult) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(APIResult.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> Direction>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Direction.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -284,31 +284,31 @@ public func _invoke_swift_closure_TestModule_10TestModule9APIResultO_SS(_ boxPtr } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule9DirectionO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_SS(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSS_SS") +fileprivate func invoke_js_callback_TestModule_10TestModuleSS_SS(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSS_SS(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule9DirectionO_SS") -fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSS_SS") +fileprivate func make_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule9DirectionO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> String { +private enum _BJS_Closure_10TestModuleSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) -> String { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule9DirectionO_SS(callbackValue, param0Value) + let ret = invoke_js_callback_TestModule_10TestModuleSS_SS(callbackValue, param0Value) return String.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") @@ -317,10 +317,10 @@ private enum _BJS_Closure_10TestModule9DirectionO_SS { } } -extension JSTypedClosure where Signature == (Direction) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> String) { +extension JSTypedClosure where Signature == (String) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> String) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule9DirectionO_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSS_SS, body: body, fileID: fileID, line: line @@ -328,12 +328,12 @@ extension JSTypedClosure where Signature == (Direction) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule9DirectionO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModule9DirectionO_SS") -public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSS_SS") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSS_SS") +public func _invoke_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Direction.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -341,31 +341,31 @@ public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_SS(_ boxPtr } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModule9DirectionO_Sb") -fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSb_Sb") +fileprivate func invoke_js_callback_TestModule_10TestModuleSb_Sb(_ callback: Int32, _ param0: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModule9DirectionO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSb_Sb(_ callback: Int32, _ param0: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModule9DirectionO_Sb") -fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSb_Sb") +fileprivate func make_swift_closure_TestModule_10TestModuleSb_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModule9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSb_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModule9DirectionO_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> Bool { +private enum _BJS_Closure_10TestModuleSb_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (Bool) -> Bool { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModule9DirectionO_Sb(callbackValue, param0Value) + let ret = invoke_js_callback_TestModule_10TestModuleSb_Sb(callbackValue, param0Value) return Bool.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") @@ -374,10 +374,10 @@ private enum _BJS_Closure_10TestModule9DirectionO_Sb { } } -extension JSTypedClosure where Signature == (Direction) -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> Bool) { +extension JSTypedClosure where Signature == (Bool) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Bool) -> Bool) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModule9DirectionO_Sb, + makeClosure: make_swift_closure_TestModule_10TestModuleSb_Sb, body: body, fileID: fileID, line: line @@ -385,12 +385,12 @@ extension JSTypedClosure where Signature == (Direction) -> Bool { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModule9DirectionO_Sb") -@_cdecl("invoke_swift_closure_TestModule_10TestModule9DirectionO_Sb") -public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSb_Sb") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSb_Sb") +public func _invoke_swift_closure_TestModule_10TestModuleSb_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Direction.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Bool) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Bool.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -398,32 +398,32 @@ public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_Sb(_ boxPtr } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSS_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSS_SS(_ callback: Int32, _ param0: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSd_Sd") +fileprivate func invoke_js_callback_TestModule_10TestModuleSd_Sd(_ callback: Int32, _ param0: Float64) -> Float64 #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSS_SS(_ callback: Int32, _ param0: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSd_Sd(_ callback: Int32, _ param0: Float64) -> Float64 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSS_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSd_Sd") +fileprivate func make_swift_closure_TestModule_10TestModuleSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (String) -> String { +private enum _BJS_Closure_10TestModuleSd_Sd { + static func bridgeJSLift(_ callbackId: Int32) -> (Double) -> Double { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSS_SS(callbackValue, param0Value) - return String.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModuleSd_Sd(callbackValue, param0Value) + return Double.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -431,10 +431,10 @@ private enum _BJS_Closure_10TestModuleSS_SS { } } -extension JSTypedClosure where Signature == (String) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> String) { +extension JSTypedClosure where Signature == (Double) -> Double { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) -> Double) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSS_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSd_Sd, body: body, fileID: fileID, line: line @@ -442,12 +442,126 @@ extension JSTypedClosure where Signature == (String) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSS_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSS_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSd_Sd") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSd_Sd") +public func _invoke_swift_closure_TestModule_10TestModuleSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Float64 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Double) -> Double>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Double.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSf_Sf") +fileprivate func invoke_js_callback_TestModule_10TestModuleSf_Sf(_ callback: Int32, _ param0: Float32) -> Float32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSf_Sf(_ callback: Int32, _ param0: Float32) -> Float32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSf_Sf") +fileprivate func make_swift_closure_TestModule_10TestModuleSf_Sf(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSf_Sf(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSf_Sf { + static func bridgeJSLift(_ callbackId: Int32) -> (Float) -> Float { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleSf_Sf(callbackValue, param0Value) + return Float.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Float) -> Float { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Float) -> Float) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSf_Sf, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSf_Sf") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSf_Sf") +public func _invoke_swift_closure_TestModule_10TestModuleSf_Sf(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float32) -> Float32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Float) -> Float>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Float.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSi_Si") +fileprivate func invoke_js_callback_TestModule_10TestModuleSi_Si(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSi_Si(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSi_Si") +fileprivate func make_swift_closure_TestModule_10TestModuleSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSi_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Int) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleSi_Si(callbackValue, param0Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int) -> Int) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSi_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSi_Si") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSi_Si") +public func _invoke_swift_closure_TestModule_10TestModuleSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Int.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -455,32 +569,32 @@ public func _invoke_swift_closure_TestModule_10TestModuleSS_SS(_ boxPtr: UnsafeM } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq5ThemeO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO") +fileprivate func invoke_js_callback_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq5ThemeO_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO") +fileprivate func make_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSq5ThemeO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_10TestModuleSq10HttpStatusO_Sq10HttpStatusO { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSq5ThemeO_SS(callbackValue, param0IsSome, param0Value) - return String.bridgeJSLiftReturn(ret) + invoke_js_callback_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() #else fatalError("Only available on WebAssembly") #endif @@ -488,10 +602,10 @@ private enum _BJS_Closure_10TestModuleSq5ThemeO_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSq5ThemeO_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO, body: body, fileID: fileID, line: line @@ -499,12 +613,12 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO") +public func _invoke_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -512,34 +626,32 @@ public func _invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_SS(_ boxPtr: } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer, _ param1IsSome: Int32, _ param1Value: Int32, _ param2IsSome: Int32, _ param2Value: Float64) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO") +fileprivate func invoke_js_callback_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer, _ param1IsSome: Int32, _ param1Value: Int32, _ param2IsSome: Int32, _ param2Value: Float64) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO") +fileprivate func make_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSq6PersonCSqSSSqSd_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional, Optional, Optional) -> String { +private enum _BJS_Closure_10TestModuleSq5ThemeO_Sq5ThemeO { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0, param1, param2 in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() - let (param1IsSome, param1Value) = param1.bridgeJSLowerParameter() - let (param2IsSome, param2Value) = param2.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(callbackValue, param0IsSome, param0Pointer, param1IsSome, param1Value, param2IsSome, param2Value) - return String.bridgeJSLiftReturn(ret) + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() #else fatalError("Only available on WebAssembly") #endif @@ -547,10 +659,10 @@ private enum _BJS_Closure_10TestModuleSq6PersonCSqSSSqSd_SS { } } -extension JSTypedClosure where Signature == (Optional, Optional, Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional, Optional, Optional) -> String) { +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO, body: body, fileID: fileID, line: line @@ -558,12 +670,12 @@ extension JSTypedClosure where Signature == (Optional, Optional, } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer, _ param1IsSome: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2IsSome: Int32, _ param2Value: Float64) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO") +public func _invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional, Optional, Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value), Optional.bridgeJSLiftParameter(param1IsSome, param1Bytes, param1Length), Optional.bridgeJSLiftParameter(param2IsSome, param2Value)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -571,32 +683,32 @@ public func _invoke_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(_ } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq6PersonC_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq6PersonC_Sq6PersonC") +fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonC_Sq6PersonC(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSq6PersonC_Sq6PersonC(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq6PersonC_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC") +fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSq6PersonC_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_10TestModuleSq6PersonC_Sq6PersonC { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSq6PersonC_SS(callbackValue, param0IsSome, param0Pointer) - return String.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModuleSq6PersonC_Sq6PersonC(callbackValue, param0IsSome, param0Pointer) + return Optional.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -604,10 +716,10 @@ private enum _BJS_Closure_10TestModuleSq6PersonC_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSq6PersonC_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC, body: body, fileID: fileID, line: line @@ -615,11 +727,11 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq6PersonC_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq6PersonC_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSq6PersonC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC") +public func _invoke_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) return result.bridgeJSLowerReturn() #else @@ -628,32 +740,32 @@ public func _invoke_swift_closure_TestModule_10TestModuleSq6PersonC_SS(_ boxPtr: } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq9APIResultO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSq9APIResultO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO") +fileprivate func invoke_js_callback_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSq9APIResultO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq9APIResultO_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO") +fileprivate func make_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSq9APIResultO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_10TestModuleSq9APIResultO_Sq9APIResultO { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let (param0IsSome, param0CaseId) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSq9APIResultO_SS(callbackValue, param0IsSome, param0CaseId) - return String.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(callbackValue, param0IsSome, param0CaseId) + return Optional.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -661,10 +773,10 @@ private enum _BJS_Closure_10TestModuleSq9APIResultO_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSq9APIResultO_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO, body: body, fileID: fileID, line: line @@ -672,11 +784,11 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO") +public func _invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) return result.bridgeJSLowerReturn() #else @@ -685,32 +797,32 @@ public func _invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_SS(_ boxP } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq9DirectionO_SS") -fileprivate func invoke_js_callback_TestModule_10TestModuleSq9DirectionO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO") +fileprivate func invoke_js_callback_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 #else -fileprivate func invoke_js_callback_TestModule_10TestModuleSq9DirectionO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { +fileprivate func invoke_js_callback_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq9DirectionO_SS") -fileprivate func make_swift_closure_TestModule_10TestModuleSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO") +fileprivate func make_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_TestModule_10TestModuleSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -private enum _BJS_Closure_10TestModuleSq9DirectionO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_10TestModuleSq9DirectionO_Sq9DirectionO { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { let callback = JSObject.bridgeJSLiftParameter(callbackId) return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_TestModule_10TestModuleSq9DirectionO_SS(callbackValue, param0IsSome, param0Value) - return String.bridgeJSLiftReturn(ret) + let ret = invoke_js_callback_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -718,10 +830,10 @@ private enum _BJS_Closure_10TestModuleSq9DirectionO_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { self.init( - makeClosure: make_swift_closure_TestModule_10TestModuleSq9DirectionO_SS, + makeClosure: make_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO, body: body, fileID: fileID, line: line @@ -729,11 +841,11 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_SS") -@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_SS") -public func _invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO") +public func _invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) return result.bridgeJSLowerReturn() #else @@ -741,6 +853,291 @@ public func _invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_SS(_ boxP #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSqSS_SqSS") +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSS_SqSS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSS_SqSS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSqSS_SqSS") +fileprivate func make_swift_closure_TestModule_10TestModuleSqSS_SqSS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSqSS_SqSS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSqSS_SqSS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleSqSS_SqSS(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSqSS_SqSS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSqSS_SqSS") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSqSS_SqSS") +public func _invoke_swift_closure_TestModule_10TestModuleSqSS_SqSS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSqSb_SqSb") +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSb_SqSb(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSb_SqSb(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSqSb_SqSb") +fileprivate func make_swift_closure_TestModule_10TestModuleSqSb_SqSb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSqSb_SqSb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSqSb_SqSb { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleSqSb_SqSb(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSqSb_SqSb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSqSb_SqSb") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSqSb_SqSb") +public func _invoke_swift_closure_TestModule_10TestModuleSqSb_SqSb(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSqSd_SqSd") +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSd_SqSd(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSd_SqSd(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSqSd_SqSd") +fileprivate func make_swift_closure_TestModule_10TestModuleSqSd_SqSd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSqSd_SqSd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSqSd_SqSd { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleSqSd_SqSd(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSqSd_SqSd, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSqSd_SqSd") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSqSd_SqSd") +public func _invoke_swift_closure_TestModule_10TestModuleSqSd_SqSd(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSqSf_SqSf") +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSf_SqSf(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSf_SqSf(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSqSf_SqSf") +fileprivate func make_swift_closure_TestModule_10TestModuleSqSf_SqSf(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSqSf_SqSf(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSqSf_SqSf { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleSqSf_SqSf(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSqSf_SqSf, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSqSf_SqSf") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSqSf_SqSf") +public func _invoke_swift_closure_TestModule_10TestModuleSqSf_SqSf(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Float32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSqSi_SqSi") +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSi_SqSi(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleSqSi_SqSi(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleSqSi_SqSi") +fileprivate func make_swift_closure_TestModule_10TestModuleSqSi_SqSi(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleSqSi_SqSi(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +private enum _BJS_Closure_10TestModuleSqSi_SqSi { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleSqSi_SqSi(callbackValue, param0IsSome, param0Value) + return Optional.bridgeJSLiftReturnFromSideChannel() + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleSqSi_SqSi, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleSqSi_SqSi") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleSqSi_SqSi") +public func _invoke_swift_closure_TestModule_10TestModuleSqSi_SqSi(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + extension Direction: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue @@ -867,235 +1264,279 @@ extension APIResult: _BridgedSwiftAssociatedValueEnum { } } -@_expose(wasm, "bjs_Person_init") -@_cdecl("bjs_Person_init") -public func _bjs_Person_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundtripString") +@_cdecl("bjs_roundtripString") +public func _bjs_roundtripString(_ stringClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = Person(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeJSLowerReturn() + let ret = roundtripString(_: _BJS_Closure_10TestModuleSS_SS.bridgeJSLift(stringClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_Person_deinit") -@_cdecl("bjs_Person_deinit") -public func _bjs_Person_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_roundtripInt") +@_cdecl("bjs_roundtripInt") +public func _bjs_roundtripInt(_ intClosure: Int32) -> Int32 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = roundtripInt(_: _BJS_Closure_10TestModuleSi_Si.bridgeJSLift(intClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -extension Person: ConvertibleToJSValue, _BridgedSwiftHeapObject { - public var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Person_wrap(Unmanaged.passRetained(self).toOpaque())))) - } +@_expose(wasm, "bjs_roundtripBool") +@_cdecl("bjs_roundtripBool") +public func _bjs_roundtripBool(_ boolClosure: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundtripBool(_: _BJS_Closure_10TestModuleSb_Sb.bridgeJSLift(boolClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -#if arch(wasm32) -@_extern(wasm, module: "TestModule", name: "bjs_Person_wrap") -fileprivate func _bjs_Person_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Person_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripFloat") +@_cdecl("bjs_roundtripFloat") +public func _bjs_roundtripFloat(_ floatClosure: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundtripFloat(_: _BJS_Closure_10TestModuleSf_Sf.bridgeJSLift(floatClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@_expose(wasm, "bjs_TestProcessor_init") -@_cdecl("bjs_TestProcessor_init") -public func _bjs_TestProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundtripDouble") +@_cdecl("bjs_roundtripDouble") +public func _bjs_roundtripDouble(_ doubleClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor(transform: _BJS_Closure_10TestModuleSS_SS.bridgeJSLift(transform)) - return ret.bridgeJSLowerReturn() + let ret = roundtripDouble(_: _BJS_Closure_10TestModuleSd_Sd.bridgeJSLift(doubleClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_getTransform") -@_cdecl("bjs_TestProcessor_getTransform") -public func _bjs_TestProcessor_getTransform(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripOptionalString") +@_cdecl("bjs_roundtripOptionalString") +public func _bjs_roundtripOptionalString(_ stringClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).getTransform() + let ret = roundtripOptionalString(_: _BJS_Closure_10TestModuleSqSS_SqSS.bridgeJSLift(stringClosure)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processWithCustom") -@_cdecl("bjs_TestProcessor_processWithCustom") -public func _bjs_TestProcessor_processWithCustom(_ _self: UnsafeMutableRawPointer, _ textBytes: Int32, _ textLength: Int32, _ customTransform: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalInt") +@_cdecl("bjs_roundtripOptionalInt") +public func _bjs_roundtripOptionalInt(_ intClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processWithCustom(_: String.bridgeJSLiftParameter(textBytes, textLength), customTransform: _BJS_Closure_10TestModuleSS_SS.bridgeJSLift(customTransform)) - return ret.bridgeJSLowerReturn() + let ret = roundtripOptionalInt(_: _BJS_Closure_10TestModuleSqSi_SqSi.bridgeJSLift(intClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_printTogether") -@_cdecl("bjs_TestProcessor_printTogether") -public func _bjs_TestProcessor_printTogether(_ _self: UnsafeMutableRawPointer, _ person: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32, _ ratio: Float64, _ customTransform: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalBool") +@_cdecl("bjs_roundtripOptionalBool") +public func _bjs_roundtripOptionalBool(_ boolClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).printTogether(person: Person.bridgeJSLiftParameter(person), name: String.bridgeJSLiftParameter(nameBytes, nameLength), ratio: Double.bridgeJSLiftParameter(ratio), customTransform: _BJS_Closure_10TestModuleSq6PersonCSqSSSqSd_SS.bridgeJSLift(customTransform)) - return ret.bridgeJSLowerReturn() + let ret = roundtripOptionalBool(_: _BJS_Closure_10TestModuleSqSb_SqSb.bridgeJSLift(boolClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_roundtrip") -@_cdecl("bjs_TestProcessor_roundtrip") -public func _bjs_TestProcessor_roundtrip(_ _self: UnsafeMutableRawPointer, _ personClosure: Int32) -> Int32 { +@_expose(wasm, "bjs_roundtripOptionalFloat") +@_cdecl("bjs_roundtripOptionalFloat") +public func _bjs_roundtripOptionalFloat(_ floatClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).roundtrip(_: _BJS_Closure_10TestModule6PersonC_SS.bridgeJSLift(personClosure)) + let ret = roundtripOptionalFloat(_: _BJS_Closure_10TestModuleSqSf_SqSf.bridgeJSLift(floatClosure)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_roundtripOptional") -@_cdecl("bjs_TestProcessor_roundtripOptional") -public func _bjs_TestProcessor_roundtripOptional(_ _self: UnsafeMutableRawPointer, _ personClosure: Int32) -> Int32 { +@_expose(wasm, "bjs_roundtripOptionalDouble") +@_cdecl("bjs_roundtripOptionalDouble") +public func _bjs_roundtripOptionalDouble(_ doubleClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).roundtripOptional(_: _BJS_Closure_10TestModuleSq6PersonC_SS.bridgeJSLift(personClosure)) + let ret = roundtripOptionalDouble(_: _BJS_Closure_10TestModuleSqSd_SqSd.bridgeJSLift(doubleClosure)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processDirection") -@_cdecl("bjs_TestProcessor_processDirection") -public func _bjs_TestProcessor_processDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripPerson") +@_cdecl("bjs_roundtripPerson") +public func _bjs_roundtripPerson(_ personClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processDirection(_: _BJS_Closure_10TestModule9DirectionO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripPerson(_: _BJS_Closure_10TestModule6PersonC_6PersonC.bridgeJSLift(personClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processTheme") -@_cdecl("bjs_TestProcessor_processTheme") -public func _bjs_TestProcessor_processTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalPerson") +@_cdecl("bjs_roundtripOptionalPerson") +public func _bjs_roundtripOptionalPerson(_ personClosure: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processTheme(_: _BJS_Closure_10TestModule5ThemeO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripOptionalPerson(_: _BJS_Closure_10TestModuleSq6PersonC_Sq6PersonC.bridgeJSLift(personClosure)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processHttpStatus") -@_cdecl("bjs_TestProcessor_processHttpStatus") -public func _bjs_TestProcessor_processHttpStatus(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { +@_expose(wasm, "bjs_roundtripDirection") +@_cdecl("bjs_roundtripDirection") +public func _bjs_roundtripDirection(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processHttpStatus(_: _BJS_Closure_10TestModule10HttpStatusO_Si.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripDirection(_: _BJS_Closure_10TestModule9DirectionO_9DirectionO.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processAPIResult") -@_cdecl("bjs_TestProcessor_processAPIResult") -public func _bjs_TestProcessor_processAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripTheme") +@_cdecl("bjs_roundtripTheme") +public func _bjs_roundtripTheme(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processAPIResult(_: _BJS_Closure_10TestModule9APIResultO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripTheme(_: _BJS_Closure_10TestModule5ThemeO_5ThemeO.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_makeDirectionChecker") -@_cdecl("bjs_TestProcessor_makeDirectionChecker") -public func _bjs_TestProcessor_makeDirectionChecker(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripHttpStatus") +@_cdecl("bjs_roundtripHttpStatus") +public func _bjs_roundtripHttpStatus(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).makeDirectionChecker() + let ret = roundtripHttpStatus(_: _BJS_Closure_10TestModule10HttpStatusO_10HttpStatusO.bridgeJSLift(callback)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_makeThemeValidator") -@_cdecl("bjs_TestProcessor_makeThemeValidator") -public func _bjs_TestProcessor_makeThemeValidator(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripAPIResult") +@_cdecl("bjs_roundtripAPIResult") +public func _bjs_roundtripAPIResult(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).makeThemeValidator() + let ret = roundtripAPIResult(_: _BJS_Closure_10TestModule9APIResultO_9APIResultO.bridgeJSLift(callback)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_makeStatusCodeExtractor") -@_cdecl("bjs_TestProcessor_makeStatusCodeExtractor") -public func _bjs_TestProcessor_makeStatusCodeExtractor(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripOptionalDirection") +@_cdecl("bjs_roundtripOptionalDirection") +public func _bjs_roundtripOptionalDirection(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).makeStatusCodeExtractor() + let ret = roundtripOptionalDirection(_: _BJS_Closure_10TestModuleSq9DirectionO_Sq9DirectionO.bridgeJSLift(callback)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_makeAPIResultHandler") -@_cdecl("bjs_TestProcessor_makeAPIResultHandler") -public func _bjs_TestProcessor_makeAPIResultHandler(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundtripOptionalTheme") +@_cdecl("bjs_roundtripOptionalTheme") +public func _bjs_roundtripOptionalTheme(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).makeAPIResultHandler() + let ret = roundtripOptionalTheme(_: _BJS_Closure_10TestModuleSq5ThemeO_Sq5ThemeO.bridgeJSLift(callback)) return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processOptionalDirection") -@_cdecl("bjs_TestProcessor_processOptionalDirection") -public func _bjs_TestProcessor_processOptionalDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalHttpStatus") +@_cdecl("bjs_roundtripOptionalHttpStatus") +public func _bjs_roundtripOptionalHttpStatus(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processOptionalDirection(_: _BJS_Closure_10TestModuleSq9DirectionO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripOptionalHttpStatus(_: _BJS_Closure_10TestModuleSq10HttpStatusO_Sq10HttpStatusO.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processOptionalTheme") -@_cdecl("bjs_TestProcessor_processOptionalTheme") -public func _bjs_TestProcessor_processOptionalTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalAPIResult") +@_cdecl("bjs_roundtripOptionalAPIResult") +public func _bjs_roundtripOptionalAPIResult(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processOptionalTheme(_: _BJS_Closure_10TestModuleSq5ThemeO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + let ret = roundtripOptionalAPIResult(_: _BJS_Closure_10TestModuleSq9APIResultO_Sq9APIResultO.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_processOptionalAPIResult") -@_cdecl("bjs_TestProcessor_processOptionalAPIResult") -public func _bjs_TestProcessor_processOptionalAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_roundtripOptionalDirection") +@_cdecl("bjs_roundtripOptionalDirection") +public func _bjs_roundtripOptionalDirection(_ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).processOptionalAPIResult(_: _BJS_Closure_10TestModuleSq9APIResultO_SS.bridgeJSLift(callback)) + let ret = roundtripOptionalDirection(_: _BJS_Closure_10TestModuleSq9DirectionO_Sq9DirectionO.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Person_init") +@_cdecl("bjs_Person_init") +public func _bjs_Person_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Person(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TestProcessor_makeOptionalDirectionFormatter") -@_cdecl("bjs_TestProcessor_makeOptionalDirectionFormatter") -public func _bjs_TestProcessor_makeOptionalDirectionFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_Person_deinit") +@_cdecl("bjs_Person_deinit") +public func _bjs_Person_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TestProcessor.bridgeJSLiftParameter(_self).makeOptionalDirectionFormatter() - return JSTypedClosure(ret).bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Person: ConvertibleToJSValue, _BridgedSwiftHeapObject { + public var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Person_wrap(Unmanaged.passRetained(self).toOpaque())))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Person_wrap") +fileprivate func _bjs_Person_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Person_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif + +@_expose(wasm, "bjs_TestProcessor_init") +@_cdecl("bjs_TestProcessor_init") +public func _bjs_TestProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = TestProcessor(transform: _BJS_Closure_10TestModuleSS_SS.bridgeJSLift(transform)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts index 942b18269..ccc95eb3b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts @@ -59,23 +59,6 @@ export interface SwiftHeapObject { export interface Person extends SwiftHeapObject { } export interface TestProcessor extends SwiftHeapObject { - getTransform(): (arg0: string) => string; - processWithCustom(text: string, customTransform: (arg0: string) => string): string; - printTogether(person: Person, name: string, ratio: number, customTransform: (arg0: Person | null, arg1: string | null, arg2: number | null) => string): string; - roundtrip(personClosure: (arg0: Person) => string): (arg0: Person) => string; - roundtripOptional(personClosure: (arg0: Person | null) => string): (arg0: Person | null) => string; - processDirection(callback: (arg0: DirectionTag) => string): string; - processTheme(callback: (arg0: ThemeTag) => string): string; - processHttpStatus(callback: (arg0: HttpStatusTag) => number): number; - processAPIResult(callback: (arg0: APIResultTag) => string): string; - makeDirectionChecker(): (arg0: DirectionTag) => boolean; - makeThemeValidator(): (arg0: ThemeTag) => boolean; - makeStatusCodeExtractor(): (arg0: HttpStatusTag) => number; - makeAPIResultHandler(): (arg0: APIResultTag) => string; - processOptionalDirection(callback: (arg0: DirectionTag | null) => string): string; - processOptionalTheme(callback: (arg0: ThemeTag | null) => string): string; - processOptionalAPIResult(callback: (arg0: APIResultTag | null) => string): string; - makeOptionalDirectionFormatter(): (arg0: DirectionTag | null) => string; } export type Exports = { Person: { @@ -84,6 +67,27 @@ export type Exports = { TestProcessor: { new(transform: (arg0: string) => string): TestProcessor; } + roundtripString(stringClosure: (arg0: string) => string): (arg0: string) => string; + roundtripInt(intClosure: (arg0: number) => number): (arg0: number) => number; + roundtripBool(boolClosure: (arg0: boolean) => boolean): (arg0: boolean) => boolean; + roundtripFloat(floatClosure: (arg0: number) => number): (arg0: number) => number; + roundtripDouble(doubleClosure: (arg0: number) => number): (arg0: number) => number; + roundtripOptionalString(stringClosure: (arg0: string | null) => string | null): (arg0: string | null) => string | null; + roundtripOptionalInt(intClosure: (arg0: number | null) => number | null): (arg0: number | null) => number | null; + roundtripOptionalBool(boolClosure: (arg0: boolean | null) => boolean | null): (arg0: boolean | null) => boolean | null; + roundtripOptionalFloat(floatClosure: (arg0: number | null) => number | null): (arg0: number | null) => number | null; + roundtripOptionalDouble(doubleClosure: (arg0: number | null) => number | null): (arg0: number | null) => number | null; + roundtripPerson(personClosure: (arg0: Person) => Person): (arg0: Person) => Person; + roundtripOptionalPerson(personClosure: (arg0: Person | null) => Person | null): (arg0: Person | null) => Person | null; + roundtripDirection(callback: (arg0: DirectionTag) => DirectionTag): (arg0: DirectionTag) => DirectionTag; + roundtripTheme(callback: (arg0: ThemeTag) => ThemeTag): (arg0: ThemeTag) => ThemeTag; + roundtripHttpStatus(callback: (arg0: HttpStatusTag) => HttpStatusTag): (arg0: HttpStatusTag) => HttpStatusTag; + roundtripAPIResult(callback: (arg0: APIResultTag) => APIResultTag): (arg0: APIResultTag) => APIResultTag; + roundtripOptionalDirection(callback: (arg0: DirectionTag | null) => DirectionTag | null): (arg0: DirectionTag | null) => DirectionTag | null; + roundtripOptionalTheme(callback: (arg0: ThemeTag | null) => ThemeTag | null): (arg0: ThemeTag | null) => ThemeTag | null; + roundtripOptionalHttpStatus(callback: (arg0: HttpStatusTag | null) => HttpStatusTag | null): (arg0: HttpStatusTag | null) => HttpStatusTag | null; + roundtripOptionalAPIResult(callback: (arg0: APIResultTag | null) => APIResultTag | null): (arg0: APIResultTag | null) => APIResultTag | null; + roundtripOptionalDirection(callback: (arg0: DirectionTag | null) => DirectionTag | null): (arg0: DirectionTag | null) => DirectionTag | null; Direction: DirectionObject Theme: ThemeObject HttpStatus: HttpStatusObject diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 38c248cae..09f9aee59 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -329,7 +329,7 @@ export async function createInstantiator(options, swift) { func.__unregister(); } - bjs["invoke_js_callback_TestModule_10TestModule10HttpStatusO_Si"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModule10HttpStatusO_10HttpStatusO"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); let param0 = param0Id; @@ -340,9 +340,9 @@ export async function createInstantiator(options, swift) { return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule10HttpStatusO_Si"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule10HttpStatusO_Si = function(param0) { - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule10HttpStatusO_Si(boxPtr, param0); + bjs["make_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO(boxPtr, param0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); @@ -351,19 +351,16 @@ export async function createInstantiator(options, swift) { } return invokeResult | 0; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule10HttpStatusO_Si); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule10HttpStatusO_10HttpStatusO); } - bjs["invoke_js_callback_TestModule_10TestModule5ThemeO_SS"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModule5ThemeO_5ThemeO"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); const param0IdObject = swift.memory.getObject(param0Id); swift.memory.release(param0Id); let param0 = String(param0IdObject); const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } tmpRetBytes = textEncoder.encode(result); return tmpRetBytes.length; } catch (error) { @@ -372,11 +369,11 @@ export async function createInstantiator(options, swift) { return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule5ThemeO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule5ThemeO_SS = function(param0) { + bjs["make_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule5ThemeO_5ThemeO = function(param0) { const param0Bytes = textEncoder.encode(param0); const param0Id = swift.memory.retain(param0Bytes); - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule5ThemeO_SS(boxPtr, param0Id, param0Bytes.length); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule5ThemeO_5ThemeO(boxPtr, param0Id, param0Bytes.length); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); @@ -388,109 +385,95 @@ export async function createInstantiator(options, swift) { tmpRetString = undefined; return ret; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule5ThemeO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule5ThemeO_5ThemeO); } - bjs["invoke_js_callback_TestModule_10TestModule5ThemeO_Sb"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModule6PersonC_6PersonC"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - const param0IdObject = swift.memory.getObject(param0Id); - swift.memory.release(param0Id); - let param0 = String(param0IdObject); + let param0 = _exports['Person'].__construct(param0Id); const result = callback(param0); - return result ? 1 : 0; + return result.pointer; } catch (error) { setException?.(error); return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule5ThemeO_Sb"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule5ThemeO_Sb = function(param0) { - const param0Bytes = textEncoder.encode(param0); - const param0Id = swift.memory.retain(param0Bytes); - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule5ThemeO_Sb(boxPtr, param0Id, param0Bytes.length); + bjs["make_swift_closure_TestModule_10TestModule6PersonC_6PersonC"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule6PersonC_6PersonC = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule6PersonC_6PersonC(boxPtr, param0.pointer); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - return invokeResult !== 0; + const resultPtr = invokeResult; + return _exports['Person'].__construct(resultPtr); }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule5ThemeO_Sb); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule6PersonC_6PersonC); } - bjs["invoke_js_callback_TestModule_10TestModule6PersonC_SS"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModule9APIResultO_9APIResultO"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - let param0 = _exports['Person'].__construct(param0Id); + let param0 = enumHelpers.APIResult.lift(param0Id); const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + const { caseId: caseId, cleanup: cleanup } = enumHelpers.APIResult.lower(result); + return caseId; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModule6PersonC_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule6PersonC_SS = function(param0) { - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule6PersonC_SS(boxPtr, param0.pointer); + bjs["make_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule9APIResultO_9APIResultO = function(param0) { + const { caseId: param0CaseId, cleanup: param0Cleanup } = enumHelpers.APIResult.lower(param0); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule9APIResultO_9APIResultO(boxPtr, param0CaseId); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + invokeResult; + const result = enumHelpers.APIResult.lift(tagStack.pop()); + return result; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule6PersonC_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9APIResultO_9APIResultO); } - bjs["invoke_js_callback_TestModule_10TestModule9APIResultO_SS"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModule9DirectionO_9DirectionO"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - let param0 = enumHelpers.APIResult.lift(param0Id); + let param0 = param0Id; const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + return result | 0; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule9APIResultO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule9APIResultO_SS = function(param0) { - const { caseId: param0CaseId, cleanup: param0Cleanup } = enumHelpers.APIResult.lower(param0); - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule9APIResultO_SS(boxPtr, param0CaseId); + bjs["make_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModule9DirectionO_9DirectionO = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO(boxPtr, param0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + return invokeResult | 0; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9APIResultO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9DirectionO_9DirectionO); } - bjs["invoke_js_callback_TestModule_10TestModule9DirectionO_SS"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModuleSS_SS"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - let param0 = param0Id; + const param0IdObject = swift.memory.getObject(param0Id); + swift.memory.release(param0Id); + let param0 = String(param0IdObject); const result = callback(param0); if (typeof result !== "string") { throw new TypeError("Callback must return a string"); @@ -503,9 +486,11 @@ export async function createInstantiator(options, swift) { return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule9DirectionO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule9DirectionO_SS = function(param0) { - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule9DirectionO_SS(boxPtr, param0); + bjs["make_swift_closure_TestModule_10TestModuleSS_SS"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSS_SS = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSS_SS(boxPtr, param0Id, param0Bytes.length); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); @@ -517,13 +502,13 @@ export async function createInstantiator(options, swift) { tmpRetString = undefined; return ret; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9DirectionO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSS_SS); } - bjs["invoke_js_callback_TestModule_10TestModule9DirectionO_Sb"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModuleSb_Sb"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - let param0 = param0Id; + let param0 = param0Id !== 0; const result = callback(param0); return result ? 1 : 0; } catch (error) { @@ -531,9 +516,9 @@ export async function createInstantiator(options, swift) { return 0; } }; - bjs["make_swift_closure_TestModule_10TestModule9DirectionO_Sb"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModule9DirectionO_Sb = function(param0) { - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModule9DirectionO_Sb(boxPtr, param0); + bjs["make_swift_closure_TestModule_10TestModuleSb_Sb"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSb_Sb = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSb_Sb(boxPtr, param0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); @@ -542,47 +527,120 @@ export async function createInstantiator(options, swift) { } return invokeResult !== 0; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9DirectionO_Sb); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSb_Sb); } - bjs["invoke_js_callback_TestModule_10TestModuleSS_SS"] = function(callbackId, param0Id) { + bjs["invoke_js_callback_TestModule_10TestModuleSd_Sd"] = function(callbackId, param0Id) { try { const callback = swift.memory.getObject(callbackId); - const param0IdObject = swift.memory.getObject(param0Id); - swift.memory.release(param0Id); - let param0 = String(param0IdObject); + let param0 = param0Id; const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); + return result; + } catch (error) { + setException?.(error); + return 0.0; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSd_Sd"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSd_Sd = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSd_Sd(boxPtr, param0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + return invokeResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSd_Sd); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSf_Sf"] = function(callbackId, param0Id) { + try { + const callback = swift.memory.getObject(callbackId); + let param0 = param0Id; + const result = callback(param0); + return Math.fround(result); + } catch (error) { + setException?.(error); + return 0.0; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSf_Sf"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSf_Sf = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSf_Sf(boxPtr, param0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return invokeResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSf_Sf); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSi_Si"] = function(callbackId, param0Id) { + try { + const callback = swift.memory.getObject(callbackId); + let param0 = param0Id; + const result = callback(param0); + return result | 0; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); return 0; } }; - bjs["make_swift_closure_TestModule_10TestModuleSS_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSS_SS = function(param0) { - const param0Bytes = textEncoder.encode(param0); - const param0Id = swift.memory.retain(param0Bytes); - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSS_SS(boxPtr, param0Id, param0Bytes.length); + bjs["make_swift_closure_TestModule_10TestModuleSi_Si"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSi_Si = function(param0) { + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSi_Si(boxPtr, param0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + return invokeResult | 0; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSS_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSi_Si); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO"] = function(callbackId, param0IsSome, param0Value) { + try { + const callback = swift.memory.getObject(callbackId); + let param0; + if (param0IsSome) { + param0 = param0Value; + } else { + param0 = null; + } + const result = callback(param0); + tmpRetOptionalInt = result; + return; + } catch (error) { + setException?.(error); + return; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO = function(param0) { + const isSome = param0 != null; + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO(boxPtr, +isSome, isSome ? param0 : 0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + invokeResult; + const optResult = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return optResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq10HttpStatusO_Sq10HttpStatusO); } - bjs["invoke_js_callback_TestModule_10TestModuleSq5ThemeO_SS"] = function(callbackId, param0IsSome, param0Value) { + bjs["invoke_js_callback_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO"] = function(callbackId, param0IsSome, param0Value) { try { const callback = swift.memory.getObject(callbackId); let param0; @@ -594,41 +652,37 @@ export async function createInstantiator(options, swift) { param0 = null; } const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + tmpRetString = result; + return; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModuleSq5ThemeO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSq5ThemeO_SS = function(param0) { + bjs["make_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO = function(param0) { const isSome = param0 != null; let param0Id, param0Bytes; if (isSome) { param0Bytes = textEncoder.encode(param0); param0Id = swift.memory.retain(param0Bytes); } - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_SS(boxPtr, +isSome, isSome ? param0Id : 0, isSome ? param0Bytes.length : 0); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO(boxPtr, +isSome, isSome ? param0Id : 0, isSome ? param0Bytes.length : 0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; + invokeResult; + const optResult = tmpRetString; tmpRetString = undefined; - return ret; + return optResult; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq5ThemeO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq5ThemeO_Sq5ThemeO); } - bjs["invoke_js_callback_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS"] = function(callbackId, param0IsSome, param0Value, param1IsSome, param1Value, param2IsSome, param2Value) { + bjs["invoke_js_callback_TestModule_10TestModuleSq6PersonC_Sq6PersonC"] = function(callbackId, param0IsSome, param0Value) { try { const callback = swift.memory.getObject(callbackId); let param0; @@ -637,142 +691,197 @@ export async function createInstantiator(options, swift) { } else { param0 = null; } - let param1; - if (param1IsSome) { - const param1Object = swift.memory.getObject(param1Value); - swift.memory.release(param1Value); - param1 = String(param1Object); - } else { - param1 = null; + const result = callback(param0); + return result ? result.pointer : 0; + } catch (error) { + setException?.(error); + return 0; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC = function(param0) { + const isSome = param0 != null; + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC(boxPtr, +isSome, isSome ? param0.pointer : 0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; } - let param2; - if (param2IsSome) { - param2 = param2Value; + invokeResult; + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + const optResult = pointer === null ? null : _exports['Person'].__construct(pointer); + return optResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq6PersonC_Sq6PersonC); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO"] = function(callbackId, param0IsSome, param0Value) { + try { + const callback = swift.memory.getObject(callbackId); + let param0; + if (param0IsSome) { + param0 = enumHelpers.APIResult.lift(param0Value); } else { - param2 = null; + param0 = null; } - const result = callback(param0, param1, param2); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); + const result = callback(param0); + if (result) { + const { caseId: caseId, cleanup: cleanup } = enumHelpers.APIResult.lower(result); + tmpRetOptionalInt = caseId; + } else { + tmpRetOptionalInt = null; } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + return; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS = function(param0, param1, param2) { + bjs["make_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO = function(param0) { const isSome = param0 != null; - const isSome1 = param1 != null; - let param1Id, param1Bytes; - if (isSome1) { - param1Bytes = textEncoder.encode(param1); - param1Id = swift.memory.retain(param1Bytes); - } - const isSome2 = param2 != null; - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS(boxPtr, +isSome, isSome ? param0.pointer : 0, +isSome1, isSome1 ? param1Id : 0, isSome1 ? param1Bytes.length : 0, +isSome2, isSome2 ? param2 : 0); + let param0CaseId, param0Cleanup; + if (isSome) { + const enumResult = enumHelpers.APIResult.lower(param0); + param0CaseId = enumResult.caseId; + param0Cleanup = enumResult.cleanup; + } + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO(boxPtr, +isSome, isSome ? param0CaseId : 0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + invokeResult; + const tag = tagStack.pop(); + const isNull = (tag === -1); + let optResult; + if (isNull) { + optResult = null; + } else { + optResult = enumHelpers.APIResult.lift(tag); + } + return optResult; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq6PersonCSqSSSqSd_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq9APIResultO_Sq9APIResultO); } - bjs["invoke_js_callback_TestModule_10TestModuleSq6PersonC_SS"] = function(callbackId, param0IsSome, param0Value) { + bjs["invoke_js_callback_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO"] = function(callbackId, param0IsSome, param0Value) { try { const callback = swift.memory.getObject(callbackId); let param0; if (param0IsSome) { - param0 = _exports['Person'].__construct(param0Value); + param0 = param0Value; } else { param0 = null; } const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + tmpRetOptionalInt = result; + return; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModuleSq6PersonC_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSq6PersonC_SS = function(param0) { + bjs["make_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO = function(param0) { const isSome = param0 != null; - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq6PersonC_SS(boxPtr, +isSome, isSome ? param0.pointer : 0); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO(boxPtr, +isSome, isSome ? param0 : 0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + invokeResult; + const optResult = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return optResult; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq6PersonC_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq9DirectionO_Sq9DirectionO); } - bjs["invoke_js_callback_TestModule_10TestModuleSq9APIResultO_SS"] = function(callbackId, param0IsSome, param0Value) { + bjs["invoke_js_callback_TestModule_10TestModuleSqSS_SqSS"] = function(callbackId, param0IsSome, param0Value) { try { const callback = swift.memory.getObject(callbackId); let param0; if (param0IsSome) { - param0 = enumHelpers.APIResult.lift(param0Value); + const param0Object = swift.memory.getObject(param0Value); + swift.memory.release(param0Value); + param0 = String(param0Object); } else { param0 = null; } const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); - } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + tmpRetString = result; + return; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModuleSq9APIResultO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSq9APIResultO_SS = function(param0) { + bjs["make_swift_closure_TestModule_10TestModuleSqSS_SqSS"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSqSS_SqSS = function(param0) { const isSome = param0 != null; - let param0CaseId, param0Cleanup; + let param0Id, param0Bytes; if (isSome) { - const enumResult = enumHelpers.APIResult.lower(param0); - param0CaseId = enumResult.caseId; - param0Cleanup = enumResult.cleanup; + param0Bytes = textEncoder.encode(param0); + param0Id = swift.memory.retain(param0Bytes); } - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq9APIResultO_SS(boxPtr, +isSome, isSome ? param0CaseId : 0); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSqSS_SqSS(boxPtr, +isSome, isSome ? param0Id : 0, isSome ? param0Bytes.length : 0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; + invokeResult; + const optResult = tmpRetString; tmpRetString = undefined; - return ret; + return optResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSS_SqSS); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSqSb_SqSb"] = function(callbackId, param0IsSome, param0Value) { + try { + const callback = swift.memory.getObject(callbackId); + let param0; + if (param0IsSome) { + param0 = param0Value !== 0; + } else { + param0 = null; + } + const result = callback(param0); + tmpRetOptionalBool = result; + return; + } catch (error) { + setException?.(error); + return; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSqSb_SqSb"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSqSb_SqSb = function(param0) { + const isSome = param0 != null; + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSqSb_SqSb(boxPtr, +isSome, isSome ? param0 : 0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + invokeResult; + const optResult = tmpRetOptionalBool; + tmpRetOptionalBool = undefined; + return optResult; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq9APIResultO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSb_SqSb); } - bjs["invoke_js_callback_TestModule_10TestModuleSq9DirectionO_SS"] = function(callbackId, param0IsSome, param0Value) { + bjs["invoke_js_callback_TestModule_10TestModuleSqSd_SqSd"] = function(callbackId, param0IsSome, param0Value) { try { const callback = swift.memory.getObject(callbackId); let param0; @@ -782,33 +891,99 @@ export async function createInstantiator(options, swift) { param0 = null; } const result = callback(param0); - if (typeof result !== "string") { - throw new TypeError("Callback must return a string"); + tmpRetOptionalDouble = result; + return; + } catch (error) { + setException?.(error); + return; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSqSd_SqSd"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSqSd_SqSd = function(param0) { + const isSome = param0 != null; + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSqSd_SqSd(boxPtr, +isSome, isSome ? param0 : 0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; } - tmpRetBytes = textEncoder.encode(result); - return tmpRetBytes.length; + invokeResult; + const optResult = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return optResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSd_SqSd); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSqSf_SqSf"] = function(callbackId, param0IsSome, param0Value) { + try { + const callback = swift.memory.getObject(callbackId); + let param0; + if (param0IsSome) { + param0 = Math.fround(param0Value); + } else { + param0 = null; + } + const result = callback(param0); + tmpRetOptionalFloat = result; + return; } catch (error) { setException?.(error); - tmpRetBytes = new Uint8Array(0); - return 0; + return; } }; - bjs["make_swift_closure_TestModule_10TestModuleSq9DirectionO_SS"] = function(boxPtr, file, line) { - const lower_closure_TestModule_10TestModuleSq9DirectionO_SS = function(param0) { + bjs["make_swift_closure_TestModule_10TestModuleSqSf_SqSf"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSqSf_SqSf = function(param0) { const isSome = param0 != null; - const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSq9DirectionO_SS(boxPtr, +isSome, isSome ? param0 : 0); + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSqSf_SqSf(boxPtr, +isSome, isSome ? param0 : 0); if (tmpRetException) { const error = swift.memory.getObject(tmpRetException); swift.memory.release(tmpRetException); tmpRetException = undefined; throw error; } - const resultLen = invokeResult; - const ret = tmpRetString; - tmpRetString = undefined; - return ret; + invokeResult; + const optResult = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return optResult; }; - return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSq9DirectionO_SS); + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSf_SqSf); + } + + bjs["invoke_js_callback_TestModule_10TestModuleSqSi_SqSi"] = function(callbackId, param0IsSome, param0Value) { + try { + const callback = swift.memory.getObject(callbackId); + let param0; + if (param0IsSome) { + param0 = param0Value | 0; + } else { + param0 = null; + } + const result = callback(param0); + tmpRetOptionalInt = result; + return; + } catch (error) { + setException?.(error); + return; + } + }; + bjs["make_swift_closure_TestModule_10TestModuleSqSi_SqSi"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleSqSi_SqSi = function(param0) { + const isSome = param0 != null; + const invokeResult = instance.exports.invoke_swift_closure_TestModule_10TestModuleSqSi_SqSi(boxPtr, +isSome, isSome ? param0 : 0); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + invokeResult; + const optResult = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return optResult; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSi_SqSi); } // Wrapper functions for module: TestModule if (!importObject["TestModule"]) { @@ -876,114 +1051,118 @@ export async function createInstantiator(options, swift) { const ret = instance.exports.bjs_TestProcessor_init(callbackId); return TestProcessor.__construct(ret); } - getTransform() { - const ret = instance.exports.bjs_TestProcessor_getTransform(this.pointer); + } + const APIResultHelpers = __bjs_createAPIResultValuesHelpers()(); + enumHelpers.APIResult = APIResultHelpers; + + const exports = { + Person, + TestProcessor, + roundtripString: function bjs_roundtripString(stringClosure) { + const callbackId = swift.memory.retain(stringClosure); + const ret = instance.exports.bjs_roundtripString(callbackId); return swift.memory.getObject(ret); - } - processWithCustom(text, customTransform) { - const textBytes = textEncoder.encode(text); - const textId = swift.memory.retain(textBytes); - const callbackId = swift.memory.retain(customTransform); - instance.exports.bjs_TestProcessor_processWithCustom(this.pointer, textId, textBytes.length, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - swift.memory.release(textId); - return ret; - } - printTogether(person, name, ratio, customTransform) { - const nameBytes = textEncoder.encode(name); - const nameId = swift.memory.retain(nameBytes); - const callbackId = swift.memory.retain(customTransform); - instance.exports.bjs_TestProcessor_printTogether(this.pointer, person.pointer, nameId, nameBytes.length, ratio, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - swift.memory.release(nameId); - return ret; - } - roundtrip(personClosure) { + }, + roundtripInt: function bjs_roundtripInt(intClosure) { + const callbackId = swift.memory.retain(intClosure); + const ret = instance.exports.bjs_roundtripInt(callbackId); + return swift.memory.getObject(ret); + }, + roundtripBool: function bjs_roundtripBool(boolClosure) { + const callbackId = swift.memory.retain(boolClosure); + const ret = instance.exports.bjs_roundtripBool(callbackId); + return swift.memory.getObject(ret); + }, + roundtripFloat: function bjs_roundtripFloat(floatClosure) { + const callbackId = swift.memory.retain(floatClosure); + const ret = instance.exports.bjs_roundtripFloat(callbackId); + return swift.memory.getObject(ret); + }, + roundtripDouble: function bjs_roundtripDouble(doubleClosure) { + const callbackId = swift.memory.retain(doubleClosure); + const ret = instance.exports.bjs_roundtripDouble(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalString: function bjs_roundtripOptionalString(stringClosure) { + const callbackId = swift.memory.retain(stringClosure); + const ret = instance.exports.bjs_roundtripOptionalString(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalInt: function bjs_roundtripOptionalInt(intClosure) { + const callbackId = swift.memory.retain(intClosure); + const ret = instance.exports.bjs_roundtripOptionalInt(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalBool: function bjs_roundtripOptionalBool(boolClosure) { + const callbackId = swift.memory.retain(boolClosure); + const ret = instance.exports.bjs_roundtripOptionalBool(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalFloat: function bjs_roundtripOptionalFloat(floatClosure) { + const callbackId = swift.memory.retain(floatClosure); + const ret = instance.exports.bjs_roundtripOptionalFloat(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalDouble: function bjs_roundtripOptionalDouble(doubleClosure) { + const callbackId = swift.memory.retain(doubleClosure); + const ret = instance.exports.bjs_roundtripOptionalDouble(callbackId); + return swift.memory.getObject(ret); + }, + roundtripPerson: function bjs_roundtripPerson(personClosure) { const callbackId = swift.memory.retain(personClosure); - const ret = instance.exports.bjs_TestProcessor_roundtrip(this.pointer, callbackId); + const ret = instance.exports.bjs_roundtripPerson(callbackId); return swift.memory.getObject(ret); - } - roundtripOptional(personClosure) { + }, + roundtripOptionalPerson: function bjs_roundtripOptionalPerson(personClosure) { const callbackId = swift.memory.retain(personClosure); - const ret = instance.exports.bjs_TestProcessor_roundtripOptional(this.pointer, callbackId); + const ret = instance.exports.bjs_roundtripOptionalPerson(callbackId); return swift.memory.getObject(ret); - } - processDirection(callback) { + }, + roundtripDirection: function bjs_roundtripDirection(callback) { const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processDirection(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - processTheme(callback) { - const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processTheme(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - processHttpStatus(callback) { + const ret = instance.exports.bjs_roundtripDirection(callbackId); + return swift.memory.getObject(ret); + }, + roundtripTheme: function bjs_roundtripTheme(callback) { const callbackId = swift.memory.retain(callback); - const ret = instance.exports.bjs_TestProcessor_processHttpStatus(this.pointer, callbackId); - return ret; - } - processAPIResult(callback) { + const ret = instance.exports.bjs_roundtripTheme(callbackId); + return swift.memory.getObject(ret); + }, + roundtripHttpStatus: function bjs_roundtripHttpStatus(callback) { const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processAPIResult(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - makeDirectionChecker() { - const ret = instance.exports.bjs_TestProcessor_makeDirectionChecker(this.pointer); + const ret = instance.exports.bjs_roundtripHttpStatus(callbackId); return swift.memory.getObject(ret); - } - makeThemeValidator() { - const ret = instance.exports.bjs_TestProcessor_makeThemeValidator(this.pointer); + }, + roundtripAPIResult: function bjs_roundtripAPIResult(callback) { + const callbackId = swift.memory.retain(callback); + const ret = instance.exports.bjs_roundtripAPIResult(callbackId); return swift.memory.getObject(ret); - } - makeStatusCodeExtractor() { - const ret = instance.exports.bjs_TestProcessor_makeStatusCodeExtractor(this.pointer); + }, + roundtripOptionalDirection: function bjs_roundtripOptionalDirection(callback) { + const callbackId = swift.memory.retain(callback); + const ret = instance.exports.bjs_roundtripOptionalDirection(callbackId); return swift.memory.getObject(ret); - } - makeAPIResultHandler() { - const ret = instance.exports.bjs_TestProcessor_makeAPIResultHandler(this.pointer); + }, + roundtripOptionalTheme: function bjs_roundtripOptionalTheme(callback) { + const callbackId = swift.memory.retain(callback); + const ret = instance.exports.bjs_roundtripOptionalTheme(callbackId); return swift.memory.getObject(ret); - } - processOptionalDirection(callback) { + }, + roundtripOptionalHttpStatus: function bjs_roundtripOptionalHttpStatus(callback) { const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processOptionalDirection(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - processOptionalTheme(callback) { + const ret = instance.exports.bjs_roundtripOptionalHttpStatus(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalAPIResult: function bjs_roundtripOptionalAPIResult(callback) { const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processOptionalTheme(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - processOptionalAPIResult(callback) { + const ret = instance.exports.bjs_roundtripOptionalAPIResult(callbackId); + return swift.memory.getObject(ret); + }, + roundtripOptionalDirection: function bjs_roundtripOptionalDirection(callback) { const callbackId = swift.memory.retain(callback); - instance.exports.bjs_TestProcessor_processOptionalAPIResult(this.pointer, callbackId); - const ret = tmpRetString; - tmpRetString = undefined; - return ret; - } - makeOptionalDirectionFormatter() { - const ret = instance.exports.bjs_TestProcessor_makeOptionalDirectionFormatter(this.pointer); + const ret = instance.exports.bjs_roundtripOptionalDirection(callbackId); return swift.memory.getObject(ret); - } - } - const APIResultHelpers = __bjs_createAPIResultValuesHelpers()(); - enumHelpers.APIResult = APIResultHelpers; - - const exports = { - Person, - TestProcessor, + }, Direction: DirectionValues, Theme: ThemeValues, HttpStatus: HttpStatusValues,