Skip to content

Commit e882a22

Browse files
committed
Fix: Ensure BridgeJS.Macros.swift is processed by SwiftToSkeleton
Regenerate BridgeJS files
1 parent d8b0e17 commit e882a22

File tree

7 files changed

+1179
-1
lines changed

7 files changed

+1179
-1
lines changed

Benchmarks/Sources/Generated/BridgeJS.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,57 @@ fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void {
21582158
}
21592159
#endif
21602160

2161+
func _$benchmarkRunner(_ name: String, _ body: JSObject) throws(JSException) -> Void {
2162+
let nameValue = name.bridgeJSLowerParameter()
2163+
let bodyValue = body.bridgeJSLowerParameter()
2164+
bjs_benchmarkRunner(nameValue, bodyValue)
2165+
if let error = _swift_js_take_exception() {
2166+
throw error
2167+
}
2168+
}
2169+
2170+
#if arch(wasm32)
2171+
@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoop")
2172+
fileprivate func bjs_benchmarkHelperNoop() -> Void
2173+
#else
2174+
fileprivate func bjs_benchmarkHelperNoop() -> Void {
2175+
fatalError("Only available on WebAssembly")
2176+
}
2177+
#endif
2178+
2179+
func _$benchmarkHelperNoop() throws(JSException) -> Void {
2180+
bjs_benchmarkHelperNoop()
2181+
if let error = _swift_js_take_exception() {
2182+
throw error
2183+
}
2184+
}
2185+
2186+
#if arch(wasm32)
2187+
@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkHelperNoopWithNumber")
2188+
fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void
2189+
#else
2190+
fileprivate func bjs_benchmarkHelperNoopWithNumber(_ n: Float64) -> Void {
2191+
fatalError("Only available on WebAssembly")
2192+
}
2193+
#endif
2194+
2195+
func _$benchmarkHelperNoopWithNumber(_ n: Double) throws(JSException) -> Void {
2196+
let nValue = n.bridgeJSLowerParameter()
2197+
bjs_benchmarkHelperNoopWithNumber(nValue)
2198+
if let error = _swift_js_take_exception() {
2199+
throw error
2200+
}
2201+
}
2202+
2203+
#if arch(wasm32)
2204+
@_extern(wasm, module: "Benchmarks", name: "bjs_benchmarkRunner")
2205+
fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void
2206+
#else
2207+
fileprivate func bjs_benchmarkRunner(_ name: Int32, _ body: Int32) -> Void {
2208+
fatalError("Only available on WebAssembly")
2209+
}
2210+
#endif
2211+
21612212
func _$benchmarkRunner(_ name: String, _ body: JSObject) throws(JSException) -> Void {
21622213
let nameValue = name.bridgeJSLowerParameter()
21632214
let bodyValue = body.bridgeJSLowerParameter()

Benchmarks/Sources/Generated/JavaScript/BridgeJS.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,68 @@
27832783
],
27842784
"types" : [
27852785

2786+
]
2787+
},
2788+
{
2789+
"functions" : [
2790+
{
2791+
"name" : "benchmarkHelperNoop",
2792+
"parameters" : [
2793+
2794+
],
2795+
"returnType" : {
2796+
"void" : {
2797+
2798+
}
2799+
}
2800+
},
2801+
{
2802+
"name" : "benchmarkHelperNoopWithNumber",
2803+
"parameters" : [
2804+
{
2805+
"name" : "n",
2806+
"type" : {
2807+
"double" : {
2808+
2809+
}
2810+
}
2811+
}
2812+
],
2813+
"returnType" : {
2814+
"void" : {
2815+
2816+
}
2817+
}
2818+
},
2819+
{
2820+
"name" : "benchmarkRunner",
2821+
"parameters" : [
2822+
{
2823+
"name" : "name",
2824+
"type" : {
2825+
"string" : {
2826+
2827+
}
2828+
}
2829+
},
2830+
{
2831+
"name" : "body",
2832+
"type" : {
2833+
"jsObject" : {
2834+
2835+
}
2836+
}
2837+
}
2838+
],
2839+
"returnType" : {
2840+
"void" : {
2841+
2842+
}
2843+
}
2844+
}
2845+
],
2846+
"types" : [
2847+
27862848
]
27872849
}
27882850
]

Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,42 @@ fileprivate func bjs_TS2Swift_convert(_ self: Int32, _ ts: Int32) -> Int32 {
163163
}
164164
#endif
165165

166+
func _$TS2Swift_convert(_ self: JSObject, _ ts: String) throws(JSException) -> String {
167+
let selfValue = self.bridgeJSLowerParameter()
168+
let tsValue = ts.bridgeJSLowerParameter()
169+
let ret = bjs_TS2Swift_convert(selfValue, tsValue)
170+
if let error = _swift_js_take_exception() {
171+
throw error
172+
}
173+
return String.bridgeJSLiftReturn(ret)
174+
}
175+
176+
#if arch(wasm32)
177+
@_extern(wasm, module: "PlayBridgeJS", name: "bjs_createTS2Swift")
178+
fileprivate func bjs_createTS2Swift() -> Int32
179+
#else
180+
fileprivate func bjs_createTS2Swift() -> Int32 {
181+
fatalError("Only available on WebAssembly")
182+
}
183+
#endif
184+
185+
func _$createTS2Swift() throws(JSException) -> TS2Swift {
186+
let ret = bjs_createTS2Swift()
187+
if let error = _swift_js_take_exception() {
188+
throw error
189+
}
190+
return TS2Swift.bridgeJSLiftReturn(ret)
191+
}
192+
193+
#if arch(wasm32)
194+
@_extern(wasm, module: "PlayBridgeJS", name: "bjs_TS2Swift_convert")
195+
fileprivate func bjs_TS2Swift_convert(_ self: Int32, _ ts: Int32) -> Int32
196+
#else
197+
fileprivate func bjs_TS2Swift_convert(_ self: Int32, _ ts: Int32) -> Int32 {
198+
fatalError("Only available on WebAssembly")
199+
}
200+
#endif
201+
166202
func _$TS2Swift_convert(_ self: JSObject, _ ts: String) throws(JSException) -> String {
167203
let selfValue = self.bridgeJSLowerParameter()
168204
let tsValue = ts.bridgeJSLowerParameter()

Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,52 @@
195195
}
196196
]
197197
},
198+
{
199+
"functions" : [
200+
{
201+
"name" : "createTS2Swift",
202+
"parameters" : [
203+
204+
],
205+
"returnType" : {
206+
"jsObject" : {
207+
"_0" : "TS2Swift"
208+
}
209+
}
210+
}
211+
],
212+
"types" : [
213+
{
214+
"getters" : [
215+
216+
],
217+
"methods" : [
218+
{
219+
"name" : "convert",
220+
"parameters" : [
221+
{
222+
"name" : "ts",
223+
"type" : {
224+
"string" : {
225+
226+
}
227+
}
228+
}
229+
],
230+
"returnType" : {
231+
"string" : {
232+
233+
}
234+
}
235+
}
236+
],
237+
"name" : "TS2Swift",
238+
"setters" : [
239+
240+
]
241+
}
242+
]
243+
},
198244
{
199245
"functions" : [
200246

Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import BridgeJSUtilities
113113
let bridgeJsGlobalDtsPath = targetDirectory.appending(path: "bridge-js.global.d.ts")
114114
let hasDts = FileManager.default.fileExists(atPath: bridgeJsDtsPath.path)
115115
let hasGlobalDts = FileManager.default.fileExists(atPath: bridgeJsGlobalDtsPath.path)
116+
var generatedMacrosPath: String? = nil
116117
if hasDts || hasGlobalDts {
117118
guard let tsconfigPath = doubleDashOptions["project"] else {
118119
throw BridgeJSToolError("--project option is required when processing .d.ts files")
@@ -128,9 +129,16 @@ import BridgeJSUtilities
128129
progress: progress,
129130
outputPath: bridgeJSMacrosPath.path
130131
)
132+
generatedMacrosPath = bridgeJSMacrosPath.path
131133
}
132134

133-
let inputFiles = inputSwiftFiles(targetDirectory: targetDirectory, positionalArguments: positionalArguments)
135+
var inputFiles = inputSwiftFiles(targetDirectory: targetDirectory, positionalArguments: positionalArguments)
136+
// BridgeJS.Macros.swift contains imported declarations (@JSFunction, @JSClass, etc.) that need
137+
// to be processed by SwiftToSkeleton to populate the imported skeleton. The command plugin
138+
// filters out Generated/ files, so we explicitly add it here after generation.
139+
if let macrosPath = generatedMacrosPath, FileManager.default.fileExists(atPath: macrosPath) {
140+
inputFiles.append(macrosPath)
141+
}
134142
let swiftToSkeleton = SwiftToSkeleton(
135143
progress: progress,
136144
moduleName: moduleName,

0 commit comments

Comments
 (0)