提交 753f368a 编写于 作者: E Elie Bariche

perf: Add JSObject.Dispatch() export

上级 8a396433
......@@ -5,14 +5,21 @@ using System.Reflection;
using System.Runtime.InteropServices;
// using Uno.Logging;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.JavaScript;
#endif
namespace Uno.Foundation.Interop
{
[Obfuscation(Feature = "renaming", Exclude = true)]
public sealed class JSObject
public sealed partial class JSObject
{
/// <summary>
/// Used by javascript to dispatch a method call to the managed object at <paramref name="handlePtr"/>.
/// </summary>
#if NET7_0_OR_GREATER
[JSExport]
#endif
[Obfuscation(Feature = "renaming", Exclude = true)]
public static void Dispatch(IntPtr handlePtr, string method, string parameters)
{
......
......@@ -11,6 +11,7 @@
<PropertyGroup>
<NoWarn>$(NoWarn);NU1701</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);IS_UNO_FOUNDATION_RUNTIME_WEBASSEMBLY_PROJECT</DefineConstants>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
......
......@@ -9,7 +9,13 @@ namespace Uno.UI {
const unoExports = await (<any>Module).getAssemblyExports("Uno");
const unoUIExports = await (<any>Module).getAssemblyExports("Uno.UI");
(<any>globalThis).DotnetExports = { Uno: unoExports, UnoUI: unoUIExports };
const runtimeWasmExports = await (<any>Module).getAssemblyExports("Uno.Foundation.Runtime.WebAssembly");
(<any>globalThis).DotnetExports = {
Uno: unoExports,
UnoUI: unoUIExports,
UnoFoundationRuntimeWebAssembly: runtimeWasmExports
};
}
}
}
......
......@@ -4,7 +4,13 @@
private static dispatchMethod: (handle: number, method: string, parameters: string) => number;
private static init() {
ManagedObject.dispatchMethod = (<any>Module).mono_bind_static_method("[Uno.Foundation.Runtime.WebAssembly] Uno.Foundation.Interop.JSObject:Dispatch");
const exports = (<any>globalThis).DotnetExports?.UnoFoundationRuntimeWebAssembly?.Uno?.Foundation?.Interop?.JSObject;
if (exports !== undefined) {
ManagedObject.dispatchMethod = exports.Dispatch;
} else {
ManagedObject.dispatchMethod = (<any>Module).mono_bind_static_method("[Uno.Foundation.Runtime.WebAssembly] Uno.Foundation.Interop.JSObject:Dispatch");
}
}
public static dispatch(handle: number, method: string, parameters: string): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册