Recompile Mono, updating MonoPlatform.ts to work with the newer version
This commit is contained in:
parent
2978830a9f
commit
e3b995b933
|
|
@ -8,8 +8,13 @@
|
|||
window.Module = {
|
||||
print: function (line) { console.log(line); },
|
||||
printEr: function (line) { console.error(line); },
|
||||
wasmBinaryFile: '/_framework/wasm/mono.wasm',
|
||||
asmjsCodeFile: '/_framework/asmjs/mono.asm.js',
|
||||
locateFile: function (fileName) {
|
||||
switch (fileName) {
|
||||
case 'mono.wasm': return '/_framework/wasm/mono.wasm';
|
||||
case 'mono.asm.js': return '/_framework/asmjs/mono.asm.js';
|
||||
default: return fileName;
|
||||
}
|
||||
},
|
||||
preloadPlugins: [],
|
||||
preRun: [function () {
|
||||
preloadAssemblies(loadAssemblyUrls);
|
||||
|
|
@ -33,13 +38,13 @@
|
|||
var type = find_class(assembly, namespace, typeName);
|
||||
var method = find_method(type, methodName, -1);
|
||||
|
||||
var stack = Module.Runtime.stackSave();
|
||||
var stack = Module.stackSave();
|
||||
try {
|
||||
var resultPtr = callMethod(method, null, args);
|
||||
return dotnetStringToJavaScriptString(resultPtr);
|
||||
}
|
||||
finally {
|
||||
Module.Runtime.stackRestore(stack);
|
||||
Module.stackRestore(stack);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -94,16 +99,16 @@
|
|||
}
|
||||
|
||||
function callMethod(method, target, args) {
|
||||
var stack = Module.Runtime.stackSave();
|
||||
var stack = Module.stackSave();
|
||||
var invoke_method = Module.cwrap('mono_wasm_invoke_method', 'number', ['number', 'number', 'number']);
|
||||
|
||||
try {
|
||||
var argsBuffer = Module.Runtime.stackAlloc(args.length);
|
||||
var exceptionFlagManagedInt = Module.Runtime.stackAlloc(4);
|
||||
var argsBuffer = Module.stackAlloc(args.length);
|
||||
var exceptionFlagManagedInt = Module.stackAlloc(4);
|
||||
for (var i = 0; i < args.length; ++i) {
|
||||
var argVal = args[i];
|
||||
if (typeof argVal === 'number') {
|
||||
var managedInt = Module.Runtime.stackAlloc(4);
|
||||
var managedInt = Module.stackAlloc(4);
|
||||
Module.setValue(managedInt, argVal, 'i32');
|
||||
Module.setValue(argsBuffer + i * 4, managedInt, 'i32');
|
||||
} else if (typeof argVal === 'string') {
|
||||
|
|
@ -123,7 +128,7 @@
|
|||
|
||||
return res;
|
||||
} finally {
|
||||
Module.Runtime.stackRestore(stack);
|
||||
Module.stackRestore(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ export const monoPlatform: Platform = {
|
|||
throw new Error(`Currently, MonoPlatform supports passing a maximum of 4 arguments from JS to .NET. You tried to pass ${args.length}.`);
|
||||
}
|
||||
|
||||
const stack = Module.Runtime.stackSave();
|
||||
const stack = Module.stackSave();
|
||||
|
||||
try {
|
||||
const argsBuffer = Module.Runtime.stackAlloc(args.length);
|
||||
const exceptionFlagManagedInt = Module.Runtime.stackAlloc(4);
|
||||
const argsBuffer = Module.stackAlloc(args.length);
|
||||
const exceptionFlagManagedInt = Module.stackAlloc(4);
|
||||
for (var i = 0; i < args.length; ++i) {
|
||||
Module.setValue(argsBuffer + i * 4, args[i], 'i32');
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ export const monoPlatform: Platform = {
|
|||
|
||||
return res;
|
||||
} finally {
|
||||
Module.Runtime.stackRestore(stack);
|
||||
Module.stackRestore(stack);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -162,15 +162,23 @@ function addScriptTagsToDocument() {
|
|||
|
||||
function createEmscriptenModuleInstance(loadAssemblyUrls: string[], onReady: () => void, onError: (reason?: any) => void) {
|
||||
const module = {} as typeof Module;
|
||||
const wasmBinaryFile = '_framework/wasm/mono.wasm';
|
||||
const asmjsCodeFile = '_framework/asmjs/mono.asm.js';
|
||||
|
||||
module.print = line => console.log(`WASM: ${line}`);
|
||||
module.printErr = line => console.error(`WASM: ${line}`);
|
||||
module.wasmBinaryFile = '_framework/wasm/mono.wasm';
|
||||
module.asmjsCodeFile = '_framework/asmjs/mono.asm.js';
|
||||
module.preRun = [];
|
||||
module.postRun = [];
|
||||
module.preloadPlugins = [];
|
||||
|
||||
module.locateFile = fileName => {
|
||||
switch (fileName) {
|
||||
case 'mono.wasm': return wasmBinaryFile;
|
||||
case 'mono.asm.js': return asmjsCodeFile;
|
||||
default: return fileName;
|
||||
}
|
||||
};
|
||||
|
||||
module.preRun.push(() => {
|
||||
// By now, emscripten should be initialised enough that we can capture these methods for later use
|
||||
assembly_load = Module.cwrap('mono_wasm_assembly_load', 'number', ['string']);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,16 @@
|
|||
function UTF8ToString(utf8: Mono.Utf8Ptr): string;
|
||||
var preloadPlugins: any[];
|
||||
|
||||
function stackSave(): Mono.StackSaveHandle;
|
||||
function stackAlloc(length: number): number;
|
||||
function stackRestore(handle: Mono.StackSaveHandle): void;
|
||||
|
||||
// These should probably be in @types/emscripten
|
||||
var wasmBinaryFile: string;
|
||||
var asmjsCodeFile: string;
|
||||
function FS_createPath(parent, path, canRead, canWrite);
|
||||
function FS_createDataFile(parent, name, data, canRead, canWrite, canOwn);
|
||||
}
|
||||
|
||||
declare namespace Mono {
|
||||
interface Utf8Ptr { Utf8Ptr__DO_NOT_IMPLEMENT: any }
|
||||
interface StackSaveHandle { StackSaveHandle__DO_NOT_IMPLEMENT: any }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue