Browse Source

Renamed interop to native

flabbet 1 year ago
parent
commit
5aeec09cdf

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Api/Localization/LocalizedString.cs

@@ -39,7 +39,7 @@ public struct LocalizedString
             return localizationKey;
         }
         
-        string translated = Interop.translate_key(localizationKey);
+        string translated = Native.translate_key(localizationKey);
         if (translated == null)
         {
             return localizationKey;

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Api/Logging/Logger.cs

@@ -21,6 +21,6 @@ public class Logger : ILogger
 
     private void InvokeApiLog(string message)
     {
-        Interop.log_message(message);
+        Native.log_message(message);
     }
 }

+ 14 - 14
src/PixiEditor.Extensions.Wasm/Api/Window/PopupWindow.cs

@@ -14,49 +14,49 @@ public class PopupWindow : IPopupWindow
 
     public string Title
     {
-        get => Interop.get_window_title(windowHandle);
-        set => Interop.set_window_title(windowHandle, value);
+        get => Native.get_window_title(windowHandle);
+        set => Native.set_window_title(windowHandle, value);
     }
 
     public void Show()
     {
-        Interop.show_window(windowHandle);
+        Native.show_window(windowHandle);
     }
 
     public void Close()
     {
-        Interop.close_window(windowHandle);
+        Native.close_window(windowHandle);
     }
 
     public AsyncCall ShowDialog()
     {
-        int asyncHandle = Interop.show_window_async(windowHandle);
-        AsyncCall showDialogTask = Interop.AsyncHandleToTask<int>(asyncHandle);
+        int asyncHandle = Native.show_window_async(windowHandle);
+        AsyncCall showDialogTask = Native.AsyncHandleToTask<int>(asyncHandle);
         return showDialogTask;
     }
 
     public double Width
     {
-        get => Interop.get_window_width(windowHandle);
-        set => Interop.set_window_width(windowHandle, value);
+        get => Native.get_window_width(windowHandle);
+        set => Native.set_window_width(windowHandle, value);
     }
 
     public double Height
     {
-        get => Interop.get_window_height(windowHandle);
-        set => Interop.set_window_height(windowHandle, value);
+        get => Native.get_window_height(windowHandle);
+        set => Native.set_window_height(windowHandle, value);
     }
 
     public bool CanResize
     {
-        get => Interop.get_window_resizable(windowHandle);
-        set => Interop.set_window_resizable(windowHandle, value);
+        get => Native.get_window_resizable(windowHandle);
+        set => Native.set_window_resizable(windowHandle, value);
     }
 
     public bool CanMinimize
     {
-        get => Interop.get_window_minimizable(windowHandle);
-        set => Interop.set_window_minimizable(windowHandle, value);
+        get => Native.get_window_minimizable(windowHandle);
+        set => Native.set_window_minimizable(windowHandle, value);
     }
     
     Task<bool?> IPopupWindow.ShowDialog()

+ 3 - 3
src/PixiEditor.Extensions.Wasm/Api/Window/WindowProvider.cs

@@ -12,7 +12,7 @@ public class WindowProvider : IWindowProvider
         byte[] bytes = compiledControl.Serialize().ToArray();
         IntPtr ptr = Marshal.AllocHGlobal(bytes.Length);
         Marshal.Copy(bytes, 0, ptr, bytes.Length);
-        int handle = Interop.create_popup_window(title, ptr, bytes.Length);
+        int handle = Native.create_popup_window(title, ptr, bytes.Length);
         Marshal.FreeHGlobal(ptr);
         
         SubscribeToEvents(compiledControl);
@@ -24,7 +24,7 @@ public class WindowProvider : IWindowProvider
         byte[] bytes = newLayout.Serialize().ToArray();
         IntPtr ptr = Marshal.AllocHGlobal(bytes.Length);
         Marshal.Copy(bytes, 0, ptr, bytes.Length);
-        Interop.state_changed(uniqueId, ptr, bytes.Length);
+        Native.state_changed(uniqueId, ptr, bytes.Length);
         Marshal.FreeHGlobal(ptr);
 
         SubscribeToEvents(newLayout);
@@ -39,7 +39,7 @@ public class WindowProvider : IWindowProvider
 
         foreach (var queuedEvent in body.QueuedEvents)
         {
-            Interop.subscribe_to_event(body.UniqueId, queuedEvent);
+            Native.subscribe_to_event(body.UniqueId, queuedEvent);
         }
     }
 

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Interop.Async.cs → src/PixiEditor.Extensions.Wasm/Native.Async.cs

@@ -2,7 +2,7 @@
 
 namespace PixiEditor.Extensions.Wasm;
 
-internal partial class Interop
+internal partial class Native
 {
     private static Dictionary<int, AsyncCall> asyncCalls = new();
     

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Interop.Localization.cs → src/PixiEditor.Extensions.Wasm/Native.Localization.cs

@@ -2,7 +2,7 @@
 
 namespace PixiEditor.Extensions.Wasm;
 
-internal static partial class Interop
+internal static partial class Native
 {
     [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern string translate_key(string key);

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Interop.Windowing.cs → src/PixiEditor.Extensions.Wasm/Native.Windowing.cs

@@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
 
 namespace PixiEditor.Extensions.Wasm;
 
-internal static partial class Interop
+internal static partial class Native
 {
     [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern int create_popup_window(string title, IntPtr data, int length);

+ 1 - 1
src/PixiEditor.Extensions.Wasm/Interop.cs → src/PixiEditor.Extensions.Wasm/Native.cs

@@ -13,7 +13,7 @@ internal static class Program { internal static void Main() { } } // Required fo
 
 [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", 
     Justification = "Interop is a special case, it's injected to C code and follows C naming conventions.")]
-internal static partial class Interop
+internal static partial class Native
 {
     [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void log_message(string message);

+ 1 - 1
src/PixiEditor.Extensions.Wasm/native/interop.c

@@ -11,7 +11,7 @@ extern void _start(void);
 MonoMethod* lookup_interop_method(const char* method_name)
 {
     MonoMethod* method = NULL;
-    method = lookup_dotnet_method("PixiEditor.Extensions.Wasm.dll", "PixiEditor.Extensions.Wasm", "Interop", method_name, -1);
+    method = lookup_dotnet_method("PixiEditor.Extensions.Wasm.dll", "PixiEditor.Extensions.Wasm", "Native", method_name, -1);
     assert(method);
 
     return method;