Skip to content

Commit b8b5725

Browse files
committed
BridgeJS: Migrate to code fragment printer
1 parent eee230f commit b8b5725

28 files changed

+619
-624
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 583 additions & 473 deletions
Large diffs are not rendered by default.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function createInstantiator(options, swift) {
2121
let tmpParamInts = [];
2222
let tmpParamF32s = [];
2323
let tmpParamF64s = [];
24-
2524

2625
return {
2726
/**
@@ -84,7 +83,6 @@ export async function createInstantiator(options, swift) {
8483
bjs["swift_js_pop_param_f64"] = function() {
8584
return tmpParamF64s.pop();
8685
}
87-
8886
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
8987
TestModule["bjs_checkArray"] = function bjs_checkArray(a) {
9088
try {
@@ -111,17 +109,15 @@ export async function createInstantiator(options, swift) {
111109
setInstance: (i) => {
112110
instance = i;
113111
memory = instance.exports.memory;
114-
112+
115113
setException = (error) => {
116114
instance.exports._swift_js_exception.value = swift.memory.retain(error)
117115
}
118116
},
119117
/** @param {WebAssembly.Instance} instance */
120118
createExports: (instance) => {
121119
const js = swift.memory.heap;
122-
123120
return {
124-
125121
};
126122
},
127123
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.Export.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function createInstantiator(options, swift) {
2121
let tmpParamInts = [];
2222
let tmpParamF32s = [];
2323
let tmpParamF64s = [];
24-
2524

2625
return {
2726
/**
@@ -84,21 +83,18 @@ export async function createInstantiator(options, swift) {
8483
bjs["swift_js_pop_param_f64"] = function() {
8584
return tmpParamF64s.pop();
8685
}
87-
88-
8986
},
9087
setInstance: (i) => {
9188
instance = i;
9289
memory = instance.exports.memory;
93-
90+
9491
setException = (error) => {
9592
instance.exports._swift_js_exception.value = swift.memory.retain(error)
9693
}
9794
},
9895
/** @param {WebAssembly.Instance} instance */
9996
createExports: (instance) => {
10097
const js = swift.memory.heap;
101-
10298
return {
10399
asyncReturnVoid: function bjs_asyncReturnVoid() {
104100
const ret = instance.exports.bjs_asyncReturnVoid();

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.Import.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function createInstantiator(options, swift) {
2121
let tmpParamInts = [];
2222
let tmpParamF32s = [];
2323
let tmpParamF64s = [];
24-
2524

2625
return {
2726
/**
@@ -84,7 +83,6 @@ export async function createInstantiator(options, swift) {
8483
bjs["swift_js_pop_param_f64"] = function() {
8584
return tmpParamF64s.pop();
8685
}
87-
8886
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
8987
TestModule["bjs_asyncReturnVoid"] = function bjs_asyncReturnVoid() {
9088
try {
@@ -155,17 +153,15 @@ export async function createInstantiator(options, swift) {
155153
setInstance: (i) => {
156154
instance = i;
157155
memory = instance.exports.memory;
158-
156+
159157
setException = (error) => {
160158
instance.exports._swift_js_exception.value = swift.memory.retain(error)
161159
}
162160
},
163161
/** @param {WebAssembly.Instance} instance */
164162
createExports: (instance) => {
165163
const js = swift.memory.heap;
166-
167164
return {
168-
169165
};
170166
},
171167
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.Export.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ const __bjs_createNetworkingResultHelpers = () => {
342342
}
343343
});
344344
};
345-
346345
if (typeof globalThis.Utilities === 'undefined') {
347346
globalThis.Utilities = {};
348347
}
@@ -433,13 +432,10 @@ export async function createInstantiator(options, swift) {
433432
bjs["swift_js_pop_param_f64"] = function() {
434433
return tmpParamF64s.pop();
435434
}
436-
437-
438435
},
439436
setInstance: (i) => {
440437
instance = i;
441438
memory = instance.exports.memory;
442-
443439

444440
const APIResultHelpers = __bjs_createAPIResultHelpers()(tmpParamInts, tmpParamF32s, tmpParamF64s, textEncoder, swift);
445441
enumHelpers.APIResult = APIResultHelpers;
@@ -460,7 +456,6 @@ export async function createInstantiator(options, swift) {
460456
/** @param {WebAssembly.Instance} instance */
461457
createExports: (instance) => {
462458
const js = swift.memory.heap;
463-
464459
return {
465460
handle: function bjs_handle(result) {
466461
const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.APIResult.lower(result);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.Export.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const PublicStatus = {
2828
Success: 0,
2929
};
3030

31-
3231
export async function createInstantiator(options, swift) {
3332
let instance;
3433
let memory;
@@ -46,7 +45,6 @@ export async function createInstantiator(options, swift) {
4645
let tmpParamInts = [];
4746
let tmpParamF32s = [];
4847
let tmpParamF64s = [];
49-
5048

5149
return {
5250
/**
@@ -109,21 +107,18 @@ export async function createInstantiator(options, swift) {
109107
bjs["swift_js_pop_param_f64"] = function() {
110108
return tmpParamF64s.pop();
111109
}
112-
113-
114110
},
115111
setInstance: (i) => {
116112
instance = i;
117113
memory = instance.exports.memory;
118-
114+
119115
setException = (error) => {
120116
instance.exports._swift_js_exception.value = swift.memory.retain(error)
121117
}
122118
},
123119
/** @param {WebAssembly.Instance} instance */
124120
createExports: (instance) => {
125121
const js = swift.memory.heap;
126-
127122
return {
128123
setDirection: function bjs_setDirection(direction) {
129124
instance.exports.bjs_setDirection(direction);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Export.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const SupportedMethod = {
2929
Post: 1,
3030
};
3131

32-
3332
if (typeof globalThis.Networking === 'undefined') {
3433
globalThis.Networking = {};
3534
}
@@ -68,7 +67,6 @@ export async function createInstantiator(options, swift) {
6867
let tmpParamInts = [];
6968
let tmpParamF32s = [];
7069
let tmpParamF64s = [];
71-
7270

7371
return {
7472
/**
@@ -147,12 +145,11 @@ export async function createInstantiator(options, swift) {
147145
const obj = TestServer.__construct(pointer);
148146
return swift.memory.retain(obj);
149147
};
150-
151148
},
152149
setInstance: (i) => {
153150
instance = i;
154151
memory = instance.exports.memory;
155-
152+
156153
setException = (error) => {
157154
instance.exports._swift_js_exception.value = swift.memory.retain(error)
158155
}
@@ -183,8 +180,7 @@ export async function createInstantiator(options, swift) {
183180
static __construct(ptr) {
184181
return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype);
185182
}
186-
187-
183+
188184
constructor() {
189185
const ret = instance.exports.bjs_Converter_init();
190186
return Converter.__construct(ret);
@@ -200,8 +196,7 @@ export async function createInstantiator(options, swift) {
200196
static __construct(ptr) {
201197
return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_HTTPServer_deinit, HTTPServer.prototype);
202198
}
203-
204-
199+
205200
constructor() {
206201
const ret = instance.exports.bjs_HTTPServer_init();
207202
return HTTPServer.__construct(ret);
@@ -214,8 +209,7 @@ export async function createInstantiator(options, swift) {
214209
static __construct(ptr) {
215210
return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestServer_deinit, TestServer.prototype);
216211
}
217-
218-
212+
219213
constructor() {
220214
const ret = instance.exports.bjs_TestServer_init();
221215
return TestServer.__construct(ret);
@@ -229,7 +223,6 @@ export async function createInstantiator(options, swift) {
229223
HTTPServer,
230224
TestServer,
231225
};
232-
233226
if (typeof globalThis.Networking === 'undefined') {
234227
globalThis.Networking = {};
235228
}
@@ -248,7 +241,6 @@ export async function createInstantiator(options, swift) {
248241
globalThis.Utils.Converter = exports.Converter;
249242
globalThis.Networking.API.HTTPServer = exports.HTTPServer;
250243
globalThis.Networking.APIV2.Internal.TestServer = exports.TestServer;
251-
252244
return exports;
253245
},
254246
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.Export.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const Ratio = {
7979
Pi: 3.14159,
8080
};
8181

82-
8382
export async function createInstantiator(options, swift) {
8483
let instance;
8584
let memory;
@@ -97,7 +96,6 @@ export async function createInstantiator(options, swift) {
9796
let tmpParamInts = [];
9897
let tmpParamF32s = [];
9998
let tmpParamF64s = [];
100-
10199

102100
return {
103101
/**
@@ -160,21 +158,18 @@ export async function createInstantiator(options, swift) {
160158
bjs["swift_js_pop_param_f64"] = function() {
161159
return tmpParamF64s.pop();
162160
}
163-
164-
165161
},
166162
setInstance: (i) => {
167163
instance = i;
168164
memory = instance.exports.memory;
169-
165+
170166
setException = (error) => {
171167
instance.exports._swift_js_exception.value = swift.memory.retain(error)
172168
}
173169
},
174170
/** @param {WebAssembly.Instance} instance */
175171
createExports: (instance) => {
176172
const js = swift.memory.heap;
177-
178173
return {
179174
setTheme: function bjs_setTheme(theme) {
180175
const themeBytes = textEncoder.encode(theme);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Interface.Import.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function createInstantiator(options, swift) {
2121
let tmpParamInts = [];
2222
let tmpParamF32s = [];
2323
let tmpParamF64s = [];
24-
2524

2625
return {
2726
/**
@@ -84,7 +83,6 @@ export async function createInstantiator(options, swift) {
8483
bjs["swift_js_pop_param_f64"] = function() {
8584
return tmpParamF64s.pop();
8685
}
87-
8886
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
8987
TestModule["bjs_returnAnimatable"] = function bjs_returnAnimatable() {
9088
try {
@@ -117,17 +115,15 @@ export async function createInstantiator(options, swift) {
117115
setInstance: (i) => {
118116
instance = i;
119117
memory = instance.exports.memory;
120-
118+
121119
setException = (error) => {
122120
instance.exports._swift_js_exception.value = swift.memory.retain(error)
123121
}
124122
},
125123
/** @param {WebAssembly.Instance} instance */
126124
createExports: (instance) => {
127125
const js = swift.memory.heap;
128-
129126
return {
130-
131127
};
132128
},
133129
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function createInstantiator(options, swift) {
2121
let tmpParamInts = [];
2222
let tmpParamF32s = [];
2323
let tmpParamF64s = [];
24-
2524

2625
return {
2726
/**
@@ -84,7 +83,6 @@ export async function createInstantiator(options, swift) {
8483
bjs["swift_js_pop_param_f64"] = function() {
8584
return tmpParamF64s.pop();
8685
}
87-
8886
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
8987
TestModule["bjs_createArrayBuffer"] = function bjs_createArrayBuffer() {
9088
try {
@@ -187,17 +185,15 @@ export async function createInstantiator(options, swift) {
187185
setInstance: (i) => {
188186
instance = i;
189187
memory = instance.exports.memory;
190-
188+
191189
setException = (error) => {
192190
instance.exports._swift_js_exception.value = swift.memory.retain(error)
193191
}
194192
},
195193
/** @param {WebAssembly.Instance} instance */
196194
createExports: (instance) => {
197195
const js = swift.memory.heap;
198-
199196
return {
200-
201197
};
202198
},
203199
}

0 commit comments

Comments
 (0)