mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Refactor OS_JavaScript
This commit is contained in:
parent
c3c7391ebb
commit
b6ae2d8037
4 changed files with 748 additions and 804 deletions
|
@ -28,17 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "emscripten.h"
|
||||
#include "io/resource_loader.h"
|
||||
#include "main/main.h"
|
||||
#include "os_javascript.h"
|
||||
|
||||
OS_JavaScript *os = NULL;
|
||||
|
||||
static void main_loop() {
|
||||
|
||||
os->main_loop_iterate();
|
||||
}
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) {
|
||||
|
||||
|
@ -46,18 +40,18 @@ extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) {
|
|||
if (!idbfs_err.empty()) {
|
||||
print_line("IndexedDB not available: " + idbfs_err);
|
||||
}
|
||||
os->set_idbfs_available(idbfs_err.empty());
|
||||
// Ease up compatibility
|
||||
OS_JavaScript *os = OS_JavaScript::get_singleton();
|
||||
os->set_idb_available(idbfs_err.empty());
|
||||
// Ease up compatibility.
|
||||
ResourceLoader::set_abort_on_missing_resources(false);
|
||||
Main::start();
|
||||
os->main_loop_begin();
|
||||
emscripten_set_main_loop(main_loop, 0, false);
|
||||
os->run_async();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// sync from persistent state into memory and then
|
||||
// run the 'main_after_fs_sync' function
|
||||
// Sync from persistent state into memory and then
|
||||
// run the 'main_after_fs_sync' function.
|
||||
/* clang-format off */
|
||||
EM_ASM(
|
||||
FS.mkdir('/userfs');
|
||||
|
@ -68,9 +62,10 @@ int main(int argc, char *argv[]) {
|
|||
);
|
||||
/* clang-format on */
|
||||
|
||||
os = new OS_JavaScript(argv[0], NULL);
|
||||
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
||||
new OS_JavaScript(argc, argv);
|
||||
// TODO: Check error return value.
|
||||
Main::setup(argv[0], argc - 1, &argv[1]);
|
||||
|
||||
return 0;
|
||||
// continued async in main_after_fs_sync() from syncfs() callback
|
||||
// Continued async in main_after_fs_sync() from the syncfs() callback.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue