Browse Source

Finished glue

flabbet 1 year ago
parent
commit
dd831926c2

+ 3 - 2
src/CGlueTestLib/Imports.cs

@@ -1,9 +1,10 @@
-using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 
 namespace CGlueTestLib;
 
 internal static class Imports
 {
-    [DllImport("pixieditor")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void test();
 }

BIN
src/PixiEditor.Api.CGlueMSBuild.Tests/TestAssets/CGlueTestLib.dll


BIN
src/PixiEditor.Api.CGlueMSBuild.Tests/TestAssets/PixiEditor.Extensions.Wasm.dll


+ 5 - 5
src/PixiEditor.Api.CGlueMSBuild/CApiGenerator.cs

@@ -53,7 +53,7 @@ public class CApiGenerator
     {
         var importedMethods = types
             .SelectMany(t => t.Methods)
-            .Where(m => m.IsStatic && m.HasPInvokeInfo)
+            .Where(m => m.IsStatic && m.ImplAttributes == MethodImplAttributes.InternalCall)
             .ToArray();
         return importedMethods;
     }
@@ -139,7 +139,7 @@ public class CApiGenerator
 
     private string BuildImportFunction(MethodDefinition method)
     {
-        string functionName = string.IsNullOrEmpty(method.PInvokeInfo.EntryPoint) ? method.Name : method.PInvokeInfo.EntryPoint;
+        string functionName = method.Name;
         var returnType = method.ReturnType;
         var parameters = method.Parameters;
 
@@ -176,7 +176,7 @@ public class CApiGenerator
     private string BuildAttachedFunction(MethodDefinition method)
     {
         StringBuilder sb = new StringBuilder();
-        string functionName = string.IsNullOrEmpty(method.PInvokeInfo.EntryPoint) ? method.Name : method.PInvokeInfo.EntryPoint;
+        string functionName = method.Name;
         var returnType = method.ReturnType;
         var parameters = method.Parameters;
 
@@ -267,7 +267,7 @@ public class CApiGenerator
 
     private static void BuildInvokeImport(MethodDefinition method, StringBuilder sb, string[] paramsToPass)
     {
-        string functionName = string.IsNullOrEmpty(method.PInvokeInfo.EntryPoint) ? method.Name : method.PInvokeInfo.EntryPoint;
+        string functionName = method.Name;
         if (method.ReturnType.FullName != "System.Void")
         {
             sb.Append("return ");
@@ -280,7 +280,7 @@ public class CApiGenerator
     private string GenerateAttachImportedFunction(MethodDefinition method)
     {
         StringBuilder sb = new StringBuilder();
-        string functionName = string.IsNullOrEmpty(method.PInvokeInfo.EntryPoint) ? method.Name : method.PInvokeInfo.EntryPoint;
+        string functionName = method.Name;
         string funcNamespace = method.DeclaringType.FullName;
         sb.Append($"mono_add_internal_call(\"{funcNamespace}::{functionName}\", internal_{functionName});");
         return sb.ToString();

+ 0 - 3
src/PixiEditor.AvaloniaUI/PixiEditor.AvaloniaUI.csproj

@@ -96,9 +96,6 @@
     </ItemGroup>
   
     <ItemGroup>
-      <Reference Include="Microsoft.Xaml.Behaviors">
-        <HintPath>..\..\..\..\Users\flubb\.nuget\packages\microsoft.xaml.behaviors.wpf\1.1.31\lib\net5.0-windows7.0\Microsoft.Xaml.Behaviors.dll</HintPath>
-      </Reference>
       <Reference Include="PixiDocks.Avalonia">
         <HintPath>..\..\..\PixiDocks\src\PixiDocks.Avalonia\bin\Debug\net8.0\PixiDocks.Avalonia.dll</HintPath>
       </Reference>

+ 5 - 5
src/PixiEditor.Extensions.Wasm/Interop.Windowing.cs

@@ -5,18 +5,18 @@ namespace PixiEditor.Extensions.Wasm;
 
 internal static partial class Interop
 {
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern int create_popup_window(string title, IntPtr data, int length);
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void set_window_title(int windowHandle, string title);
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern string get_window_title(int windowHandle);
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void show_window(int windowHandle);
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void close_window(int windowHandle);
 }

+ 3 - 3
src/PixiEditor.Extensions.Wasm/Interop.cs

@@ -17,14 +17,14 @@ internal static class Program
 
 internal static partial class Interop
 {
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void log_message(string message);
 
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern unsafe void subscribe_to_event(int internalControlId, string eventName);
 
-    [DllImport("interop")]
+    [MethodImpl(MethodImplOptions.InternalCall)]
     internal static extern void state_changed(int uniqueId, IntPtr data, int length);
 
 

BIN
src/PixiEditor.Extensions.Wasm/build/PixiEditor.Api.CGlueMSBuild.dll