-
Notifications
You must be signed in to change notification settings - Fork 0
Proposal 1 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Proposal 1 #2
Changes from 1 commit
b55907d
49dffa8
b9b1a34
61ba2b3
36ee3f8
2d58891
3940a4e
7023612
8b5acc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| // This file defines various types related with the interaction with Dotnet interop | ||
| // This file defines various types related with the interaction with Dotnet interop | ||
|
|
||
| // TODO find better types than the anys, however it will do for now | ||
|
|
||
| export interface BINDING { // Should BINDING be renamed? | ||
| call_static_method: (method: string, params: any[]) => void, | ||
| mono_bindings_init: (binding: string) => void, | ||
| mono_bind_method: (method: string, this_arg: number, args_marshal: string?, friendly_name: string) => any, | ||
| mono_method_invoke: (method: number, this_arg: number, args_marshal: string, args: any) => any, | ||
| mono_method_get_call_signature: (method: string, mono_obj: any[]) => any, | ||
| mono_method_resolve: (fqn: string) => any, | ||
| mono_bind_static_method: (fqn: string, signature: string?) => any, | ||
| mono_call_static_method: (fqn: string, args: any, signature: string) => any, | ||
| mono_bind_assembly_entry_point: (assembly: any, signature: string?) => any, | ||
| mono_call_assembly_entry_point: (assembly: any, args: any, signature: string?) => any, | ||
| mono_intern_string: (string: string) => any, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| import DotNet from "./dotnet.js"; // User can import DotNet so that there can even potentially be multiple instances in 1 app | ||
|
|
||
| // Called when the mono-config.js (soon to be mono-config.json via PR#53606) is loaded | ||
| function onConfigLoaded (config) { | ||
| // we can do some modification to config at runtime here | ||
|
|
@@ -35,32 +37,34 @@ DotNet.onMonoRuntimeInitialized = onMonoRuntimeInitialized; // required as it ac | |
|
|
||
|
|
||
| // FROM HTML SCRIPT TAG (all js code should be in js files) //////////////////////////////////////////////////////////////////////////// | ||
| var is_testing = false; | ||
| var onLoad = function() { | ||
| var url = new URL(decodeURI(window.location)); | ||
| // Only modification was to use newer syntax. | ||
|
|
||
| let is_testing = false; | ||
| function onLoad () { | ||
| const url = new URL(decodeURI(window.location)); | ||
| let args = url.searchParams.getAll('arg'); | ||
| is_testing = args !== undefined && (args.find(arg => arg == '--testing') !== undefined); | ||
| }; | ||
| onLoad(); | ||
|
|
||
| var test_exit = function(exit_code) { | ||
| function test_exit (exit_code) { | ||
| if (!is_testing) { | ||
| console.log(`test_exit: ${exit_code}`); | ||
| return; | ||
| } | ||
|
|
||
| /* Set result in a tests_done element, to be read by xharness */ | ||
| var tests_done_elem = document.createElement("label"); | ||
| let tests_done_elem = document.createElement("label"); | ||
| tests_done_elem.id = "tests_done"; | ||
| tests_done_elem.innerHTML = exit_code.toString(); | ||
| document.body.appendChild(tests_done_elem); | ||
|
|
||
| console.log(`WASM EXIT ${exit_code}`); | ||
| }; | ||
|
|
||
| var App = { | ||
| const App = { | ||
Daniel-Genkin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| init: function () { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to make clear this is user space, rename it to
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in C# you mean? yes |
||
| var ret = BINDING.call_static_method("[Wasm.Browser.Sample] Sample.Test:TestMeaning", []); | ||
| const ret = BINDING.call_static_method("[Wasm.Browser.Sample] Sample.Test:TestMeaning", []); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BINDING should become part of the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To not pollute global namespace |
||
| document.getElementById("out").innerHTML = ret; | ||
|
|
||
| if (is_testing) | ||
|
|
@@ -70,4 +74,4 @@ var App = { | |
| test_exit(exit_code); | ||
| } | ||
| }, | ||
| }; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and it should belong to DotNet namespace.
Also all the methods here should be renamed to camelCase as usual in JS.
Also I would like to understand if this is public contract or just internal API for Mono team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I also didn't yet add the library_mono.js exported functions nor those from dotnet_support.js. Perhaps I can ask this during the team meeting today.