Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sdks
diff options
context:
space:
mode:
authorKenneth Pouncey <kjpou@pt.lu>2019-10-23 13:43:16 +0300
committerGitHub <noreply@github.com>2019-10-23 13:43:16 +0300
commitcdf8b839aef8068f601bdbed5b3fd7ec4acc462f (patch)
treea39bade87b480d1e98b3e0ce5aef25116377b139 /sdks
parent479d2dff365a688cc0045b3c76aa7aba79d4784e (diff)
[wasm][binding] Add bindings for calling the entry point of an '.exe' (#17510)
- Add `mono_bind_assembly_entry_point` - Add `mono_call_assembly_entry_point` - Module.mono_call_assembly_entry_point("WasmHttpStreamSync", []); Example: ``` Module.mono_call_assembly_entry_point("WasmHttpStreamSync", []); ``` ``` var main = Module.mono_bind_assembly_entry_point("WasmHttpStreamSync", []); main(); ```
Diffstat (limited to 'sdks')
-rw-r--r--sdks/wasm/src/binding_support.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/sdks/wasm/src/binding_support.js b/sdks/wasm/src/binding_support.js
index 98bdcfe2a5a..80c51c15828 100644
--- a/sdks/wasm/src/binding_support.js
+++ b/sdks/wasm/src/binding_support.js
@@ -18,6 +18,8 @@ var BindingSupportLib = {
module ["mono_method_resolve"] = BINDING.resolve_method_fqn.bind(BINDING);
module ["mono_bind_static_method"] = BINDING.bind_static_method.bind(BINDING);
module ["mono_call_static_method"] = BINDING.call_static_method.bind(BINDING);
+ module ["mono_bind_assembly_entry_point"] = BINDING.bind_assembly_entry_point.bind(BINDING);
+ module ["mono_call_assembly_entry_point"] = BINDING.call_assembly_entry_point.bind(BINDING);
},
bindings_lazy_init: function () {
@@ -38,6 +40,7 @@ var BindingSupportLib = {
this.mono_obj_array_new = Module.cwrap ('mono_wasm_obj_array_new', 'number', ['number']);
this.mono_obj_array_set = Module.cwrap ('mono_wasm_obj_array_set', 'void', ['number', 'number', 'number']);
this.mono_unbox_enum = Module.cwrap ('mono_wasm_unbox_enum', 'number', ['number']);
+ this.assembly_get_entry_point = Module.cwrap ('mono_wasm_assembly_get_entry_point', 'number', ['number']);
// receives a byteoffset into allocated Heap with a size.
this.mono_typed_array_new = Module.cwrap ('mono_wasm_typed_array_new', 'number', ['number','number','number','number']);
@@ -737,6 +740,40 @@ var BindingSupportLib = {
return BINDING.call_method (method, null, signature, arguments);
};
},
+ bind_assembly_entry_point: function (assembly) {
+ this.bindings_lazy_init ();
+
+ var asm = this.assembly_load (assembly);
+ if (!asm)
+ throw new Error ("Could not find assembly: " + assembly);
+
+ var method = this.assembly_get_entry_point(asm);
+ if (!method)
+ throw new Error ("Could not find entry point for assembly: " + assembly);
+
+ if (typeof signature === "undefined")
+ signature = Module.mono_method_get_call_signature (method);
+
+ return function() {
+ return BINDING.call_method (method, null, signature, arguments);
+ };
+ },
+ call_assembly_entry_point: function (assembly, args, signature) {
+ this.bindings_lazy_init ();
+
+ var asm = this.assembly_load (assembly);
+ if (!asm)
+ throw new Error ("Could not find assembly: " + assembly);
+
+ var method = this.assembly_get_entry_point(asm);
+ if (!method)
+ throw new Error ("Could not find entry point for assembly: " + assembly);
+
+ if (typeof signature === "undefined")
+ signature = Module.mono_method_get_call_signature (method);
+
+ return this.call_method (method, null, signature, args);
+ },
wasm_get_core_type: function (obj)
{
return this.call_method (this.get_core_type, null, "so", [ "WebAssembly.Core."+obj.constructor.name ]);