|
1 |
| -var WasmFSLibrary = { |
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2022 The Emscripten Authors |
| 4 | + * SPDX-License-Identifier: MIT |
| 5 | + */ |
| 6 | + |
| 7 | +mergeInto(LibraryManager.library, { |
2 | 8 | $wasmFS$preloadedFiles: [],
|
3 | 9 | $wasmFS$preloadedDirs: [],
|
4 | 10 | #if USE_CLOSURE_COMPILER
|
@@ -161,128 +167,7 @@ var WasmFSLibrary = {
|
161 | 167 | },
|
162 | 168 | _wasmfs_copy_preloaded_file_data: function(index, buffer) {
|
163 | 169 | HEAPU8.set(wasmFS$preloadedFiles[index].fileData, buffer);
|
164 |
| - }, |
165 |
| - |
166 |
| - // Backend support. wasmFS$backends will contain a mapping of backend IDs to |
167 |
| - // the JS code that implements them. This is the JS side of the JSImpl* class |
168 |
| - // in C++, together with the js_impl calls defined right after it. |
169 |
| - $wasmFS$backends: {}, |
170 |
| - |
171 |
| - // JSImpl |
172 |
| - |
173 |
| - _wasmfs_jsimpl_alloc_file: function(backend, file) { |
174 |
| -#if ASSERTIONS |
175 |
| - assert(wasmFS$backends[backend]); |
176 |
| -#endif |
177 |
| - return wasmFS$backends[backend].allocFile(file); |
178 |
| - }, |
179 |
| - |
180 |
| - _wasmfs_jsimpl_free_file: function(backend, file) { |
181 |
| -#if ASSERTIONS |
182 |
| - assert(wasmFS$backends[backend]); |
183 |
| -#endif |
184 |
| - return wasmFS$backends[backend].freeFile(file); |
185 |
| - }, |
186 |
| - |
187 |
| - _wasmfs_jsimpl_write: function(backend, file, buffer, length, {{{ defineI64Param('offset') }}}) { |
188 |
| - {{{ receiveI64ParamAsDouble('offset') }}} |
189 |
| -#if ASSERTIONS |
190 |
| - assert(wasmFS$backends[backend]); |
191 |
| -#endif |
192 |
| - return wasmFS$backends[backend].write(file, buffer, length, offset); |
193 |
| - }, |
194 |
| - |
195 |
| - _wasmfs_jsimpl_read: function(backend, file, buffer, length, {{{ defineI64Param('offset') }}}) { |
196 |
| - {{{ receiveI64ParamAsDouble('offset') }}} |
197 |
| -#if ASSERTIONS |
198 |
| - assert(wasmFS$backends[backend]); |
199 |
| -#endif |
200 |
| - return wasmFS$backends[backend].read(file, buffer, length, offset); |
201 |
| - }, |
202 |
| - |
203 |
| - _wasmfs_jsimpl_get_size: function(backend, file) { |
204 |
| -#if ASSERTIONS |
205 |
| - assert(wasmFS$backends[backend]); |
206 |
| -#endif |
207 |
| - return wasmFS$backends[backend].getSize(file); |
208 |
| - }, |
209 |
| - |
210 |
| - // ProxiedAsyncJSImpl. Each function receives a function pointer and a |
211 |
| - // parameter. We convert those into a convenient Promise API for the |
212 |
| - // implementors of backends: the hooks we call should return Promises, which |
213 |
| - // we then connect to the calling C++. |
214 |
| - |
215 |
| - // TODO: arg is void*, which for MEMORY64 will be 64-bit. we need a way to |
216 |
| - // declare arg in the function signature here (like defineI64Param, |
217 |
| - // but that varies for wasm32/wasm64), and a way to do makeDynCall that |
218 |
| - // adds a 'p' signature type for pointer, or something like that |
219 |
| - // (however, dyncalls might also just work, given in MEMORY64 we assume |
220 |
| - // WASM_BIGINT so the pointer is just a single argument, just like in |
221 |
| - // wasm32). |
222 |
| - _wasmfs_jsimpl_async_alloc_file__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'], |
223 |
| - _wasmfs_jsimpl_async_alloc_file: async function(backend, file, fptr, arg) { |
224 |
| -#if ASSERTIONS |
225 |
| - assert(wasmFS$backends[backend]); |
226 |
| -#endif |
227 |
| - {{{ runtimeKeepalivePush() }}} |
228 |
| - await wasmFS$backends[backend].allocFile(file); |
229 |
| - {{{ runtimeKeepalivePop() }}} |
230 |
| - {{{ makeDynCall('vi', 'fptr') }}}(arg); |
231 |
| - }, |
232 |
| - |
233 |
| - _wasmfs_jsimpl_async_free_file__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'], |
234 |
| - _wasmfs_jsimpl_async_free_file: async function(backend, file, fptr, arg) { |
235 |
| -#if ASSERTIONS |
236 |
| - assert(wasmFS$backends[backend]); |
237 |
| -#endif |
238 |
| - {{{ runtimeKeepalivePush() }}} |
239 |
| - await wasmFS$backends[backend].freeFile(file); |
240 |
| - {{{ runtimeKeepalivePop() }}} |
241 |
| - {{{ makeDynCall('vi', 'fptr') }}}(arg); |
242 |
| - }, |
243 |
| - |
244 |
| - _wasmfs_jsimpl_async_write__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'], |
245 |
| - _wasmfs_jsimpl_async_write: async function(backend, file, buffer, length, {{{ defineI64Param('offset') }}}, fptr, arg) { |
246 |
| - {{{ receiveI64ParamAsDouble('offset') }}} |
247 |
| -#if ASSERTIONS |
248 |
| - assert(wasmFS$backends[backend]); |
249 |
| -#endif |
250 |
| - {{{ runtimeKeepalivePush() }}} |
251 |
| - var size = await wasmFS$backends[backend].write(file, buffer, length, offset); |
252 |
| - {{{ runtimeKeepalivePop() }}} |
253 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.result, '0', 'i32') }}}; |
254 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.offset, 'size', 'i64') }}}; |
255 |
| - {{{ makeDynCall('vi', 'fptr') }}}(arg); |
256 |
| - }, |
257 |
| - |
258 |
| - _wasmfs_jsimpl_async_read__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'], |
259 |
| - _wasmfs_jsimpl_async_read: async function(backend, file, buffer, length, {{{ defineI64Param('offset') }}}, fptr, arg) { |
260 |
| - {{{ receiveI64ParamAsDouble('offset') }}} |
261 |
| -#if ASSERTIONS |
262 |
| - assert(wasmFS$backends[backend]); |
263 |
| -#endif |
264 |
| - {{{ runtimeKeepalivePush() }}} |
265 |
| - var size = await wasmFS$backends[backend].read(file, buffer, length, offset); |
266 |
| - {{{ runtimeKeepalivePop() }}} |
267 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.result, '0', 'i32') }}}; |
268 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.offset, 'size', 'i64') }}}; |
269 |
| - {{{ makeDynCall('vi', 'fptr') }}}(arg); |
270 |
| - }, |
271 |
| - |
272 |
| - _wasmfs_jsimpl_async_get_size__deps: ['$runtimeKeepalivePush', '$runtimeKeepalivePop'], |
273 |
| - _wasmfs_jsimpl_async_get_size: async function(backend, file, fptr, arg) { |
274 |
| -#if ASSERTIONS |
275 |
| - assert(wasmFS$backends[backend]); |
276 |
| -#endif |
277 |
| - {{{ runtimeKeepalivePush() }}} |
278 |
| - var size = await wasmFS$backends[backend].getSize(file); |
279 |
| - {{{ runtimeKeepalivePop() }}} |
280 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.result, '0', 'i32') }}}; |
281 |
| - {{{ makeSetValue('arg', C_STRUCTS.CallbackState.offset, 'size', 'i64') }}}; |
282 |
| - {{{ makeDynCall('vi', 'fptr') }}}(arg); |
283 |
| - }, |
284 |
| -} |
285 |
| - |
286 |
| -mergeInto(LibraryManager.library, WasmFSLibrary); |
| 170 | + } |
| 171 | +}); |
287 | 172 |
|
288 | 173 | DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push('$FS');
|
0 commit comments