Allow wasm to work without Ooui

This commit is contained in:
Frank A. Krueger 2018-03-13 16:44:06 -07:00
parent b615e7d6d7
commit 9a930deda9
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
1 changed files with 22 additions and 21 deletions

View File

@ -422,12 +422,13 @@ var WebAssemblyApp = {
runApp: function (a, b) { runApp: function (a, b) {
try { try {
var sessionId = "main"; var sessionId = "main";
var rres = MonoRuntime.call_method (this.main_method, null, [MonoRuntime.mono_string (a), MonoRuntime.mono_string (b)]); MonoRuntime.call_method (this.main_method, null, [MonoRuntime.mono_string (a), MonoRuntime.mono_string (b)]);
var res = MonoRuntime.conv_string (rres);
wasmSession = sessionId; wasmSession = sessionId;
if (!!ooui_StartWebAssemblySession_method) {
var initialSize = getSize (); var initialSize = getSize ();
MonoRuntime.call_method (this.ooui_StartWebAssemblySession_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string ("main"), MonoRuntime.mono_string (Math.round(initialSize.width) + " " + Math.round(initialSize.height))]); MonoRuntime.call_method (this.ooui_StartWebAssemblySession_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string ("main"), MonoRuntime.mono_string (Math.round(initialSize.width) + " " + Math.round(initialSize.height))]);
return res; }
return "ok";
} catch (e) { } catch (e) {
return e.msg; return e.msg;
} }
@ -438,9 +439,20 @@ var WebAssemblyApp = {
}, },
findMethods: function () { findMethods: function () {
this.main_module = MonoRuntime.assembly_load (Module.entryPoint.a);
if (!this.main_module)
throw "Could not find Main Module " + Module.entryPoint.a + ".dll";
this.main_class = MonoRuntime.find_class (this.main_module, Module.entryPoint.n, Module.entryPoint.t)
if (!this.main_class)
throw "Could not find Program class in main module";
this.main_method = MonoRuntime.find_method (this.main_class, Module.entryPoint.m, -1)
if (!this.main_method)
throw "Could not find Main method";
this.ooui_module = MonoRuntime.assembly_load ("Ooui"); this.ooui_module = MonoRuntime.assembly_load ("Ooui");
if (!this.ooui_module) if (!!this.ooui_module) {
throw "Could not find Ooui.dll";
this.ooui_class = MonoRuntime.find_class (this.ooui_module, "Ooui", "UI"); this.ooui_class = MonoRuntime.find_class (this.ooui_module, "Ooui", "UI");
if (!this.ooui_class) if (!this.ooui_class)
@ -453,18 +465,7 @@ var WebAssemblyApp = {
this.ooui_ReceiveWebAssemblySessionMessageJson_method = MonoRuntime.find_method (this.ooui_class, "ReceiveWebAssemblySessionMessageJson", -1); this.ooui_ReceiveWebAssemblySessionMessageJson_method = MonoRuntime.find_method (this.ooui_class, "ReceiveWebAssemblySessionMessageJson", -1);
if (!this.ooui_ReceiveWebAssemblySessionMessageJson_method) if (!this.ooui_ReceiveWebAssemblySessionMessageJson_method)
throw "Could not find ReceiveWebAssemblySessionMessageJson method"; throw "Could not find ReceiveWebAssemblySessionMessageJson method";
}
this.main_module = MonoRuntime.assembly_load (Module.entryPoint.a);
if (!this.main_module)
throw "Could not find Main Module " + Module.entryPoint.a + ".dll";
this.main_class = MonoRuntime.find_class (this.main_module, Module.entryPoint.n, Module.entryPoint.t)
if (!this.main_class)
throw "Could not find Program class in main module";
this.main_method = MonoRuntime.find_method (this.main_class, Module.entryPoint.m, -1)
if (!this.main_method)
throw "Could not find Main method";
}, },
}; };