Skip to content

Commit 79a58f2

Browse files
committed
BridgeJS: Add runtime coverage for nested static members
1 parent 8609706 commit 79a58f2

4 files changed

Lines changed: 69 additions & 0 deletions

File tree

Tests/BridgeJSRuntimeTests/ExportAPITests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,12 @@ enum GraphOperations {
13711371
@JS init(text: String) {
13721372
self.text = text
13731373
}
1374+
1375+
@JS static var maxLength: Int { 64 }
1376+
1377+
@JS static func untitled() -> Label {
1378+
Label(text: "untitled")
1379+
}
13741380
}
13751381

13761382
@JS init() {}

Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6633,6 +6633,28 @@ public func _bjs_NestedTypeHost_Label_init(_ textBytes: Int32, _ textLength: Int
66336633
#endif
66346634
}
66356635

6636+
@_expose(wasm, "bjs_NestedTypeHost_Label_static_maxLength_get")
6637+
@_cdecl("bjs_NestedTypeHost_Label_static_maxLength_get")
6638+
public func _bjs_NestedTypeHost_Label_static_maxLength_get() -> Int32 {
6639+
#if arch(wasm32)
6640+
let ret = NestedTypeHost.Label.maxLength
6641+
return ret.bridgeJSLowerReturn()
6642+
#else
6643+
fatalError("Only available on WebAssembly")
6644+
#endif
6645+
}
6646+
6647+
@_expose(wasm, "bjs_NestedTypeHost_Label_static_untitled")
6648+
@_cdecl("bjs_NestedTypeHost_Label_static_untitled")
6649+
public func _bjs_NestedTypeHost_Label_static_untitled() -> Void {
6650+
#if arch(wasm32)
6651+
let ret = NestedTypeHost.Label.untitled()
6652+
return ret.bridgeJSLowerReturn()
6653+
#else
6654+
fatalError("Only available on WebAssembly")
6655+
#endif
6656+
}
6657+
66366658
extension Point: _BridgedSwiftStruct {
66376659
@_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point {
66386660
let y = Int.bridgeJSStackPop()

Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18125,7 +18125,28 @@
1812518125
]
1812618126
},
1812718127
"methods" : [
18128+
{
18129+
"abiName" : "bjs_NestedTypeHost_Label_static_untitled",
18130+
"effects" : {
18131+
"isAsync" : false,
18132+
"isStatic" : true,
18133+
"isThrows" : false
18134+
},
18135+
"name" : "untitled",
18136+
"parameters" : [
1812818137

18138+
],
18139+
"returnType" : {
18140+
"swiftStruct" : {
18141+
"_0" : "NestedTypeHost.Label"
18142+
}
18143+
},
18144+
"staticContext" : {
18145+
"structName" : {
18146+
"_0" : "NestedTypeHost_Label"
18147+
}
18148+
}
18149+
}
1812918150
],
1813018151
"name" : "Label",
1813118152
"namespace" : [
@@ -18144,6 +18165,24 @@
1814418165

1814518166
}
1814618167
}
18168+
},
18169+
{
18170+
"isReadonly" : true,
18171+
"isStatic" : true,
18172+
"name" : "maxLength",
18173+
"staticContext" : {
18174+
"structName" : {
18175+
"_0" : "NestedTypeHost_Label"
18176+
}
18177+
},
18178+
"type" : {
18179+
"integer" : {
18180+
"_0" : {
18181+
"isSigned" : true,
18182+
"width" : "word"
18183+
}
18184+
}
18185+
}
1814718186
}
1814818187
],
1814918188
"swiftCallName" : "NestedTypeHost.Label"

Tests/prelude.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) {
689689
assert.equal(exports.NestedTypeHost.Variant.Secondary, "secondary");
690690
const hostLabel = exports.NestedTypeHost.Label.init("Save");
691691
assert.equal(hostLabel.text, "Save");
692+
assert.equal(exports.NestedTypeHost.Label.maxLength, 64);
693+
assert.equal(exports.NestedTypeHost.Label.untitled().text, "untitled");
692694
nestedHost.release();
693695

694696
const s1 = { tag: exports.APIResult.Tag.Success, param0: "Cześć 🙋‍♂️" };

0 commit comments

Comments
 (0)