Skip to content

Commit

Permalink
chore: adjust for mono_bind_static_method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Sep 14, 2024
1 parent 0a7449b commit 405c1ea
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 84 deletions.
20 changes: 6 additions & 14 deletions src/SamplesApp/SamplesApp.Wasm/WasmScripts/TestRunner.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
class SampleRunner {

static init() {
static async init() {

if (!this._getAllTests) {
this._getAllTests = this.getMethod("[SamplesApp.Wasm] SamplesApp.App:GetAllTests");
this._runTest = this.getMethod("[SamplesApp.Wasm] SamplesApp.App:RunTest");
this._isTestDone = this.getMethod("[SamplesApp.Wasm] SamplesApp.App:IsTestDone");
this._getDisplayScreenScaling = this.getMethod("[SamplesApp.Wasm] SamplesApp.App:GetDisplayScreenScaling");
}
}
const sampleAppExports = await Module.getAssemblyExports("SamplesApp.Wasm");

static getMethod(methodName) {
var method = Module.mono_bind_static_method(methodName);

if (!method) {
throw new `Method ${methodName} does not exist`;
this._getAllTests = sampleAppExports.SamplesApp.App.GetAllTests;
this._runTest = sampleAppExports.SamplesApp.App.RunTest;
this._isTestDone = sampleAppExports.SamplesApp.App.IsTestDone;
this._getDisplayScreenScaling = sampleAppExports.SamplesApp.App.GetDisplayScreenScaling;
}

return method;
}

static IsTestDone(test) {
Expand Down
4 changes: 1 addition & 3 deletions src/Uno.UI/ts/Clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ namespace Uno.Utils {
if ((<any>globalThis).DotnetExports !== undefined) {
Clipboard.dispatchContentChanged = (<any>globalThis).DotnetExports.Uno.Windows.ApplicationModel.DataTransfer.Clipboard.DispatchContentChanged;
} else {
Clipboard.dispatchContentChanged =
(<any>Module).mono_bind_static_method(
"[Uno] Windows.ApplicationModel.DataTransfer.Clipboard:DispatchContentChanged");
throw `Unable to find dotnet exports`;
}
}
Clipboard.dispatchContentChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Interop/ManagedObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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");
throw `Unable to find dotnet exports`;
}
}

Expand Down
18 changes: 2 additions & 16 deletions src/Uno.UI/ts/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ namespace Uno.UI {
if ((<any>globalThis).DotnetExports !== undefined) {
WindowManager.setDependencyPropertyValueMethod = (<any>globalThis).DotnetExports.UnoUI.Uno.UI.Helpers.Automation.SetDependencyPropertyValue;
} else {
WindowManager.setDependencyPropertyValueMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Uno.UI.Helpers.Automation:SetDependencyPropertyValue");
throw `Unable to find dotnet exports`;
}
}

Expand Down Expand Up @@ -1438,21 +1438,7 @@ namespace Uno.UI {
WindowManager.focusInMethod = exports.Microsoft.UI.Xaml.Input.FocusManager.ReceiveFocusNative;
WindowManager.dispatchSuspendingMethod = exports.Microsoft.UI.Xaml.Application.DispatchSuspending;
} else {
if (!WindowManager.resizeMethod) {
WindowManager.resizeMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Window:Resize");
}

if (!WindowManager.dispatchEventMethod) {
WindowManager.dispatchEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.UIElement:DispatchEvent");
}

if (!WindowManager.focusInMethod) {
WindowManager.focusInMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Input.FocusManager:ReceiveFocusNative");
}

if (!WindowManager.dispatchSuspendingMethod) {
WindowManager.dispatchSuspendingMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Application:DispatchSuspending");
}
throw `Unable to find dotnet exports`;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
DragDropExtension._dispatchDropEventMethod = (<any>globalThis).DotnetExports.UnoUI.Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropExtension.OnNativeDropEvent;
} else {
DragDropExtension._dispatchDropEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropExtension:OnNativeDropEvent");
throw `Unable to find dotnet exports`;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
MidiDeviceConnectionWatcher.dispatchStateChanged = (<any>globalThis).DotnetExports.Uno.Uno.Devices.Enumeration.Internal.Providers.Midi.MidiDeviceConnectionWatcher.DispatchStateChanged;
} else {
MidiDeviceConnectionWatcher.dispatchStateChanged =
(<any>Module).mono_bind_static_method(
"[Uno] Uno.Devices.Enumeration.Internal.Providers.Midi.MidiDeviceConnectionWatcher:DispatchStateChanged");
throw `Unable to find dotnet exports`;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Uno.UI/ts/Windows/Devices/Geolocation/Geolocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
Geolocator.dispatchGeoposition = exports.DispatchGeoposition;
}
else {
Geolocator.dispatchAccessRequest = (<any>Module).mono_bind_static_method("[Uno] Uno.Devices.Geolocation.Geolocator:DispatchAccessRequest");
Geolocator.dispatchError = (<any>Module).mono_bind_static_method("[Uno] Uno.Devices.Geolocation.Geolocator:DispatchError");
Geolocator.dispatchGeoposition = (<any>Module).mono_bind_static_method("[Uno] Uno.Devices.Geolocation.Geolocator:DispatchGeoposition");
throw `Unable to find dotnet exports`;
}

Geolocator.interopInitialized = true;
Expand Down
3 changes: 1 addition & 2 deletions src/Uno.UI/ts/Windows/Devices/Midi/MidiInPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
MidiInPort.dispatchMessage = (<any>globalThis).DotnetExports.Uno.Windows.Devices.Midi.MidiInPort.DispatchMessage;
} else {
MidiInPort.dispatchMessage = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Devices.Midi.MidiInPort:DispatchMessage");
throw `Unable to find dotnet exports`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/Devices/Sensors/Accelerometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Windows.Devices.Sensors {
Accelerometer.dispatchReading = exports.DispatchReading;
}
else {
this.dispatchReading = (<any>Module).mono_bind_static_method("[Uno] Uno.Devices.Sensors.Accelerometer:DispatchReading");
throw `Unable to find dotnet exports`;
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/Devices/Sensors/Gyrometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Windows.Devices.Sensors {
if ((<any>globalThis).DotnetExports !== undefined) {
this.dispatchReading = (<any>globalThis).DotnetExports.Uno.Windows.Devices.Sensors.Gyrometer.DispatchReading;
} else {
this.dispatchReading = (<any>Module).mono_bind_static_method("[Uno] Windows.Devices.Sensors.Gyrometer:DispatchReading");
throw `Unable to find dotnet exports`;
}
let GyroscopeClass: any = window.Gyroscope;
this.gyroscope = new GyroscopeClass({ referenceFrame: "device" });
Expand Down
3 changes: 1 addition & 2 deletions src/Uno.UI/ts/Windows/Devices/Sensors/LightSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace Windows.Devices.Sensors {
if ((<any>globalThis).DotnetExports !== undefined) {
LightSensor.dispatchReading = (<any>globalThis).DotnetExports.Uno.Windows.Devices.Sensors.LightSensor.DispatchReading;
} else {
LightSensor.dispatchReading = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Devices.Sensors.LightSensor:DispatchReading");
throw `Unable to find dotnet exports`;
}
const AmbientLightSensorClass: any = window.AmbientLightSensor;
LightSensor.ambientLightSensor = new AmbientLightSensorClass();
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/Devices/Sensors/Magnetometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Windows.Devices.Sensors {
if ((<any>globalThis).DotnetExports !== undefined) {
this.dispatchReading = (<any>globalThis).DotnetExports.Uno.Windows.Devices.Sensors.Magnetometer.DispatchReading;
} else {
this.dispatchReading = (<any>Module).mono_bind_static_method("[Uno] Windows.Devices.Sensors.Magnetometer:DispatchReading");
throw `Unable to find dotnet exports`;
}
let MagnetometerClass: any = window.Magnetometer;
this.magnetometer = new MagnetometerClass({ referenceFrame: 'device' });
Expand Down
6 changes: 2 additions & 4 deletions src/Uno.UI/ts/Windows/Gaming/Input/Gamepad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
Gamepad.dispatchGamepadAdded = (<any>globalThis).DotnetExports.Uno.Windows.Gaming.Input.Gamepad.DispatchGamepadAdded;
} else {
Gamepad.dispatchGamepadAdded = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Gaming.Input.Gamepad:DispatchGamepadAdded");
throw `Unable to find dotnet exports`;
}
}
Gamepad.dispatchGamepadAdded(e.gamepad.index);
Expand All @@ -80,8 +79,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
Gamepad.dispatchGamepadRemoved = (<any>globalThis).DotnetExports.Uno.Windows.Gaming.Input.Gamepad.DispatchGamepadRemoved;
} else {
Gamepad.dispatchGamepadRemoved = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Gaming.Input.Gamepad:DispatchGamepadRemoved");
throw `Unable to find dotnet exports`;
}
}
Gamepad.dispatchGamepadRemoved(e.gamepad.index);
Expand Down
8 changes: 2 additions & 6 deletions src/Uno.UI/ts/Windows/Graphics/Display/DisplayInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
DisplayInformation.dispatchDpiChanged = (<any>globalThis).DotnetExports.Uno.Windows.Graphics.Display.DisplayInformation.DispatchDpiChanged;
} else {
DisplayInformation.dispatchDpiChanged =
(<any>Module).mono_bind_static_method(
"[Uno] Windows.Graphics.Display.DisplayInformation:DispatchDpiChanged");
throw `Unable to find dotnet exports`;
}
}
DisplayInformation.dispatchDpiChanged(currentDpi);
Expand All @@ -160,9 +158,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
DisplayInformation.dispatchOrientationChanged = (<any>globalThis).DotnetExports.Uno.Windows.Graphics.Display.DisplayInformation.DispatchOrientationChanged;
} else {
DisplayInformation.dispatchOrientationChanged =
(<any>Module).mono_bind_static_method(
"[Uno] Windows.Graphics.Display.DisplayInformation:DispatchOrientationChanged");
throw `Unable to find dotnet exports`;
}
}
DisplayInformation.dispatchOrientationChanged(window.screen.orientation.type);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/Helpers/Theming/SystemThemeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Uno.Helpers.Theming {
if ((<any>globalThis).DotnetExports !== undefined) {
SystemThemeHelper.dispatchThemeChange = (<any>globalThis).DotnetExports.Uno.Uno.Helpers.Theming.SystemThemeHelper.DispatchSystemThemeChange;
} else {
SystemThemeHelper.dispatchThemeChange = (<any>Module).mono_bind_static_method("[Uno] Uno.Helpers.Theming.SystemThemeHelper:DispatchSystemThemeChange");
throw `Unable to find dotnet exports`;
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/Uno.UI/ts/Windows/Media/SpeechRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ namespace Windows.Media {
if ((<any>globalThis).DotnetExports !== undefined) {
SpeechRecognizer.dispatchResult = (<any>globalThis).DotnetExports.Uno.Windows.Media.SpeechRecognition.SpeechRecognizer.DispatchResult;
} else {
SpeechRecognizer.dispatchResult = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Media.SpeechRecognition.SpeechRecognizer:DispatchResult");
throw `Unable to find dotnet exports`;
}
}
SpeechRecognizer.dispatchResult(this.managedId, event.results[0][0].transcript, event.results[0][0].confidence);
Expand All @@ -79,8 +78,7 @@ namespace Windows.Media {
if ((<any>globalThis).DotnetExports !== undefined) {
SpeechRecognizer.dispatchHypothesis = (<any>globalThis).DotnetExports.Uno.Windows.Media.SpeechRecognition.SpeechRecognizer.DispatchHypothesis;
} else {
SpeechRecognizer.dispatchHypothesis = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Media.SpeechRecognition.SpeechRecognizer:DispatchHypothesis");
throw `Unable to find dotnet exports`;
}
}
SpeechRecognizer.dispatchHypothesis(this.managedId, event.results[0][0].transcript);
Expand All @@ -92,8 +90,7 @@ namespace Windows.Media {
if ((<any>globalThis).DotnetExports !== undefined) {
SpeechRecognizer.dispatchStatus = (<any>globalThis).DotnetExports.Uno.Windows.Media.SpeechRecognition.SpeechRecognizer.DispatchStatus;
} else {
SpeechRecognizer.dispatchStatus = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Media.SpeechRecognition.SpeechRecognizer:DispatchStatus");
throw `Unable to find dotnet exports`;
}
}
SpeechRecognizer.dispatchStatus(this.managedId, "SpeechDetected")
Expand All @@ -104,8 +101,7 @@ namespace Windows.Media {
if ((<any>globalThis).DotnetExports !== undefined) {
SpeechRecognizer.dispatchError = (<any>globalThis).DotnetExports.Uno.Windows.Media.SpeechRecognition.SpeechRecognizer.DispatchError;
} else {
SpeechRecognizer.dispatchError = (<any>Module).mono_bind_static_method(
"[Uno] Windows.Media.SpeechRecognition.SpeechRecognizer:DispatchError");
throw `Unable to find dotnet exports`;
}
}
SpeechRecognizer.dispatchError(this.managedId, event.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
NetworkInformation.dispatchStatusChanged = (<any>globalThis).DotnetExports.Uno.Windows.Networking.Connectivity.NetworkInformation.DispatchStatusChanged;
} else {
NetworkInformation.dispatchStatusChanged =
(<any>Module).mono_bind_static_method(
"[Uno] Windows.Networking.Connectivity.NetworkInformation:DispatchStatusChanged");
throw `Unable to find dotnet exports`;
}
}
NetworkInformation.dispatchStatusChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/Storage/NativeStorageItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
NativeStorageItem.generateGuidBinding = (<any>globalThis).DotnetExports.Uno.Uno.Storage.NativeStorageItem.GenerateGuids;
} else {
NativeStorageItem.generateGuidBinding = (<any>Module).mono_bind_static_method("[Uno] Uno.Storage.NativeStorageItem:GenerateGuids");
throw `Unable to find dotnet exports`;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Uno.UI/ts/Windows/Storage/StorageFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ namespace Windows.Storage {
if ((<any>globalThis).DotnetExports !== undefined) {
StorageFolder.dispatchStorageInitialized = (<any>globalThis).DotnetExports.Uno.Windows.Storage.StorageFolder.DispatchStorageInitialized;
} else {
StorageFolder.dispatchStorageInitialized =
(<any>Module).mono_bind_static_method(
"[Uno] Windows.Storage.StorageFolder:DispatchStorageInitialized");
throw `Unable to find dotnet exports`;
}
}
StorageFolder.dispatchStorageInitialized();
Expand Down
4 changes: 1 addition & 3 deletions src/Uno.UI/ts/Windows/UI/Core/SystemNavigationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

constructor() {
var that = this;
var dispatchBackRequest = (<any>globalThis).DotnetExports !== undefined ?
(<any>globalThis).DotnetExports.Uno.Windows.UI.Core.SystemNavigationManager.DispatchBackRequest :
(<any>Module).mono_bind_static_method("[Uno] Windows.UI.Core.SystemNavigationManager:DispatchBackRequest");
var dispatchBackRequest = (<any>globalThis).DotnetExports.Uno.Windows.UI.Core.SystemNavigationManager.DispatchBackRequest;

Check warning on line 17 in src/Uno.UI/ts/Windows/UI/Core/SystemNavigationManager.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/ts/Windows/UI/Core/SystemNavigationManager.ts#L17

Exceeds maximum line length of 120

window.history.replaceState(0, document.title, null);
window.addEventListener("popstate", function (evt) {
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/ts/Windows/UI/Xaml/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
Application.dispatchVisibilityChange = (<any>globalThis).DotnetExports.UnoUI.Microsoft.UI.Xaml.Application.DispatchVisibilityChange;
} else {
Application.dispatchVisibilityChange = (<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Application:DispatchVisibilityChange");
throw `Unable to find dotnet exports`;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
FocusVisual.dispatchPositionChange = (<any>globalThis).DotnetExports.UnoUI.Uno.UI.Xaml.Controls.SystemFocusVisual.DispatchNativePositionChange;
} else {
FocusVisual.dispatchPositionChange = (<any>Module).mono_bind_static_method(
"[Uno.UI] Uno.UI.Xaml.Controls.SystemFocusVisual:DispatchNativePositionChange");
throw `Unable to find dotnet exports`;
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/Uno.UI/ts/Windows/UI/Xaml/Media/FontFamily.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
FontFamily.managedNotifyFontLoaded = (<any>globalThis).DotnetExports.UnoUI.Microsoft.UI.Xaml.Media.FontFamilyLoader.NotifyFontLoaded;
} else {
FontFamily.managedNotifyFontLoaded =
(<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Media.FontFamilyLoader:NotifyFontLoaded");
throw `Unable to find dotnet exports`;
}
}

Expand All @@ -66,8 +65,7 @@
if ((<any>globalThis).DotnetExports !== undefined) {
FontFamily.managedNotifyFontLoadFailed = (<any>globalThis).DotnetExports.UnoUI.Microsoft.UI.Xaml.Media.FontFamilyLoader.NotifyFontLoadFailed;
} else {
FontFamily.managedNotifyFontLoadFailed =
(<any>Module).mono_bind_static_method("[Uno.UI] Microsoft.UI.Xaml.Media.FontFamilyLoader:NotifyFontLoadFailed");
throw `Unable to find dotnet exports`;
}
}

Expand Down

0 comments on commit 405c1ea

Please sign in to comment.