Skip to content

Commit e55d927

Browse files
authored
Merge pull request #569 from swiftwasm/katei/5e7d-bridgejs-import
BridgeJS: T | null and T | undefined support
2 parents e4b688f + 966b2d7 commit e55d927

39 files changed

+3493
-783
lines changed

Benchmarks/Sources/Generated/JavaScript/BridgeJS.json

Lines changed: 66 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,13 @@
449449

450450
],
451451
"returnType" : {
452-
"optional" : {
452+
"nullable" : {
453453
"_0" : {
454454
"int" : {
455455

456456
}
457-
}
457+
},
458+
"_1" : "null"
458459
}
459460
}
460461
},
@@ -470,12 +471,13 @@
470471

471472
],
472473
"returnType" : {
473-
"optional" : {
474+
"nullable" : {
474475
"_0" : {
475476
"int" : {
476477

477478
}
478-
}
479+
},
480+
"_1" : "null"
479481
}
480482
}
481483
},
@@ -491,12 +493,13 @@
491493

492494
],
493495
"returnType" : {
494-
"optional" : {
496+
"nullable" : {
495497
"_0" : {
496498
"bool" : {
497499

498500
}
499-
}
501+
},
502+
"_1" : "null"
500503
}
501504
}
502505
},
@@ -512,12 +515,13 @@
512515

513516
],
514517
"returnType" : {
515-
"optional" : {
518+
"nullable" : {
516519
"_0" : {
517520
"bool" : {
518521

519522
}
520-
}
523+
},
524+
"_1" : "null"
521525
}
522526
}
523527
},
@@ -533,12 +537,13 @@
533537

534538
],
535539
"returnType" : {
536-
"optional" : {
540+
"nullable" : {
537541
"_0" : {
538542
"double" : {
539543

540544
}
541-
}
545+
},
546+
"_1" : "null"
542547
}
543548
}
544549
},
@@ -554,12 +559,13 @@
554559

555560
],
556561
"returnType" : {
557-
"optional" : {
562+
"nullable" : {
558563
"_0" : {
559564
"double" : {
560565

561566
}
562-
}
567+
},
568+
"_1" : "null"
563569
}
564570
}
565571
},
@@ -575,12 +581,13 @@
575581

576582
],
577583
"returnType" : {
578-
"optional" : {
584+
"nullable" : {
579585
"_0" : {
580586
"string" : {
581587

582588
}
583-
}
589+
},
590+
"_1" : "null"
584591
}
585592
}
586593
},
@@ -596,12 +603,13 @@
596603

597604
],
598605
"returnType" : {
599-
"optional" : {
606+
"nullable" : {
600607
"_0" : {
601608
"string" : {
602609

603610
}
604-
}
611+
},
612+
"_1" : "null"
605613
}
606614
}
607615
}
@@ -1844,12 +1852,13 @@
18441852
"type" : {
18451853
"array" : {
18461854
"_0" : {
1847-
"optional" : {
1855+
"nullable" : {
18481856
"_0" : {
18491857
"int" : {
18501858

18511859
}
1852-
}
1860+
},
1861+
"_1" : "null"
18531862
}
18541863
}
18551864
}
@@ -1876,12 +1885,13 @@
18761885
"returnType" : {
18771886
"array" : {
18781887
"_0" : {
1879-
"optional" : {
1888+
"nullable" : {
18801889
"_0" : {
18811890
"int" : {
18821891

18831892
}
1884-
}
1893+
},
1894+
"_1" : "null"
18851895
}
18861896
}
18871897
}
@@ -1902,12 +1912,13 @@
19021912
"type" : {
19031913
"array" : {
19041914
"_0" : {
1905-
"optional" : {
1915+
"nullable" : {
19061916
"_0" : {
19071917
"int" : {
19081918

19091919
}
1910-
}
1920+
},
1921+
"_1" : "null"
19111922
}
19121923
}
19131924
}
@@ -1917,12 +1928,13 @@
19171928
"returnType" : {
19181929
"array" : {
19191930
"_0" : {
1920-
"optional" : {
1931+
"nullable" : {
19211932
"_0" : {
19221933
"int" : {
19231934

19241935
}
1925-
}
1936+
},
1937+
"_1" : "null"
19261938
}
19271939
}
19281940
}
@@ -1943,12 +1955,13 @@
19431955
"type" : {
19441956
"array" : {
19451957
"_0" : {
1946-
"optional" : {
1958+
"nullable" : {
19471959
"_0" : {
19481960
"swiftStruct" : {
19491961
"_0" : "Point"
19501962
}
1951-
}
1963+
},
1964+
"_1" : "null"
19521965
}
19531966
}
19541967
}
@@ -1975,12 +1988,13 @@
19751988
"returnType" : {
19761989
"array" : {
19771990
"_0" : {
1978-
"optional" : {
1991+
"nullable" : {
19791992
"_0" : {
19801993
"swiftStruct" : {
19811994
"_0" : "Point"
19821995
}
1983-
}
1996+
},
1997+
"_1" : "null"
19841998
}
19851999
}
19862000
}
@@ -2001,12 +2015,13 @@
20012015
"type" : {
20022016
"array" : {
20032017
"_0" : {
2004-
"optional" : {
2018+
"nullable" : {
20052019
"_0" : {
20062020
"swiftStruct" : {
20072021
"_0" : "Point"
20082022
}
2009-
}
2023+
},
2024+
"_1" : "null"
20102025
}
20112026
}
20122027
}
@@ -2016,12 +2031,13 @@
20162031
"returnType" : {
20172032
"array" : {
20182033
"_0" : {
2019-
"optional" : {
2034+
"nullable" : {
20202035
"_0" : {
20212036
"swiftStruct" : {
20222037
"_0" : "Point"
20232038
}
2024-
}
2039+
},
2040+
"_1" : "null"
20252041
}
20262042
}
20272043
}
@@ -2040,7 +2056,7 @@
20402056
"label" : "_",
20412057
"name" : "values",
20422058
"type" : {
2043-
"optional" : {
2059+
"nullable" : {
20442060
"_0" : {
20452061
"array" : {
20462062
"_0" : {
@@ -2049,7 +2065,8 @@
20492065
}
20502066
}
20512067
}
2052-
}
2068+
},
2069+
"_1" : "null"
20532070
}
20542071
}
20552072
}
@@ -2072,7 +2089,7 @@
20722089

20732090
],
20742091
"returnType" : {
2075-
"optional" : {
2092+
"nullable" : {
20762093
"_0" : {
20772094
"array" : {
20782095
"_0" : {
@@ -2081,7 +2098,8 @@
20812098
}
20822099
}
20832100
}
2084-
}
2101+
},
2102+
"_1" : "null"
20852103
}
20862104
}
20872105
},
@@ -2097,7 +2115,7 @@
20972115

20982116
],
20992117
"returnType" : {
2100-
"optional" : {
2118+
"nullable" : {
21012119
"_0" : {
21022120
"array" : {
21032121
"_0" : {
@@ -2106,7 +2124,8 @@
21062124
}
21072125
}
21082126
}
2109-
}
2127+
},
2128+
"_1" : "null"
21102129
}
21112130
}
21122131
},
@@ -2123,7 +2142,7 @@
21232142
"label" : "_",
21242143
"name" : "values",
21252144
"type" : {
2126-
"optional" : {
2145+
"nullable" : {
21272146
"_0" : {
21282147
"array" : {
21292148
"_0" : {
@@ -2132,13 +2151,14 @@
21322151
}
21332152
}
21342153
}
2135-
}
2154+
},
2155+
"_1" : "null"
21362156
}
21372157
}
21382158
}
21392159
],
21402160
"returnType" : {
2141-
"optional" : {
2161+
"nullable" : {
21422162
"_0" : {
21432163
"array" : {
21442164
"_0" : {
@@ -2147,7 +2167,8 @@
21472167
}
21482168
}
21492169
}
2150-
}
2170+
},
2171+
"_1" : "null"
21512172
}
21522173
}
21532174
}
@@ -2601,12 +2622,13 @@
26012622
"isStatic" : false,
26022623
"name" : "email",
26032624
"type" : {
2604-
"optional" : {
2625+
"nullable" : {
26052626
"_0" : {
26062627
"string" : {
26072628

26082629
}
2609-
}
2630+
},
2631+
"_1" : "null"
26102632
}
26112633
}
26122634
}

Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct ClosureCodegen {
2222
collectClosureSignatures(from: paramType, into: &signatures)
2323
}
2424
collectClosureSignatures(from: signature.returnType, into: &signatures)
25-
case .optional(let wrapped):
25+
case .nullable(let wrapped, _):
2626
collectClosureSignatures(from: wrapped, into: &signatures)
2727
default:
2828
break

0 commit comments

Comments
 (0)