Browse Source

Use MicroCom instead of SharpGen (NOT TESTED YET)

pull/4971/head
Nikita Tsukanov 5 years ago
parent
commit
aeb08c7ae3
  1. 4
      src/Avalonia.MicroCom/IUnknown.cs
  2. 33
      src/Avalonia.MicroCom/MicroComProxyBase.cs
  3. 11
      src/Avalonia.MicroCom/MicroComRuntime.cs
  4. 2
      src/Avalonia.MicroCom/MicroComShadow.cs
  5. 1
      src/Avalonia.Native/.gitignore
  6. 27
      src/Avalonia.Native/Avalonia.Native.csproj
  7. 7
      src/Avalonia.Native/AvaloniaNativeMenuExporter.cs
  8. 12
      src/Avalonia.Native/AvaloniaNativePlatform.cs
  9. 4
      src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs
  10. 22
      src/Avalonia.Native/AvnString.cs
  11. 78
      src/Avalonia.Native/CallbackBase.cs
  12. 16
      src/Avalonia.Native/ClipboardImpl.cs
  13. 7
      src/Avalonia.Native/DeferredFramebuffer.cs
  14. 628
      src/Avalonia.Native/Generated/Enumerations.cs
  15. 5
      src/Avalonia.Native/Generated/Functions.cs
  16. 3092
      src/Avalonia.Native/Generated/Interfaces.cs
  17. 202
      src/Avalonia.Native/Generated/LocalInterop.cs
  18. 246
      src/Avalonia.Native/Generated/Structures.cs
  19. 2
      src/Avalonia.Native/Helpers.cs
  20. 45
      src/Avalonia.Native/IAvnMenu.cs
  21. 41
      src/Avalonia.Native/IAvnMenuItem.cs
  22. 4
      src/Avalonia.Native/NativeControlHostImpl.cs
  23. 5
      src/Avalonia.Native/PlatformThreadingInterface.cs
  24. 2
      src/Avalonia.Native/ScreenImpl.cs
  25. 8
      src/Avalonia.Native/SystemDialogs.cs
  26. 28
      src/Avalonia.Native/WindowImpl.cs
  27. 18
      src/Avalonia.Native/WindowImplBase.cs
  28. 42
      src/Avalonia.Native/avn.idl
  29. 175
      src/tools/MicroComGenerator/Ast.cs
  30. 17
      src/tools/MicroComGenerator/AstParser.cs
  31. 18
      src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs
  32. 25
      src/tools/MicroComGenerator/CSharpGen.Utils.cs
  33. 52
      src/tools/MicroComGenerator/CSharpGen.cs
  34. 7
      src/tools/MicroComGenerator/CppGen.cs
  35. 2
      src/tools/MicroComGenerator/MicroComGenerator.csproj

4
src/Avalonia.MicroCom/IUnknown.cs

@ -4,9 +4,5 @@ namespace Avalonia.MicroCom
{
public interface IUnknown : IDisposable
{
void AddRef();
void Release();
int QueryInterface(Guid guid, out IntPtr ppv);
T QueryInterface<T>() where T : IUnknown;
}
}

33
src/Avalonia.MicroCom/MicroComProxyBase.cs

@ -1,12 +1,15 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Threading;
namespace Avalonia.MicroCom
{
public unsafe class MicroComProxyBase : IUnknown
public unsafe class MicroComProxyBase : CriticalFinalizerObject, IUnknown
{
private IntPtr _nativePointer;
private bool _ownsHandle;
private SynchronizationContext _synchronizationContext;
public IntPtr NativePointer
{
@ -24,6 +27,9 @@ namespace Avalonia.MicroCom
{
_nativePointer = nativePointer;
_ownsHandle = ownsHandle;
_synchronizationContext = SynchronizationContext.Current;
if(!_ownsHandle)
GC.SuppressFinalize(this);
}
protected virtual int VTableSize => 3;
@ -56,13 +62,16 @@ namespace Avalonia.MicroCom
}
public bool IsDisposed => _nativePointer == IntPtr.Zero;
public void Dispose()
protected virtual void Dispose(bool disposing)
{
if (_ownsHandle)
Release();
_nativePointer = IntPtr.Zero;
GC.SuppressFinalize(this);
}
public void Dispose() => Dispose(true);
public bool OwnsHandle => _ownsHandle;
@ -70,9 +79,27 @@ namespace Avalonia.MicroCom
{
if (!_ownsHandle)
{
GC.ReRegisterForFinalize(true);
AddRef();
_ownsHandle = true;
}
}
private static readonly SendOrPostCallback _disposeDelegate = DisposeOnContext;
private static void DisposeOnContext(object state)
{
(state as MicroComProxyBase)?.Dispose(false);
}
~MicroComProxyBase()
{
if(!_ownsHandle)
return;
if (_synchronizationContext == null)
Dispose();
else
_synchronizationContext.Post(_disposeDelegate, this);
}
}
}

11
src/Avalonia.MicroCom/MicroComRuntime.cs

@ -34,9 +34,10 @@ namespace Avalonia.MicroCom
public static Guid GetGuidFor(Type type) => _guids[type];
public static T CreateProxyFor<T>(void* ppv, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(ppv), ownsHandle);
public static T CreateProxyFor<T>(void* pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(pObject), ownsHandle);
public static T CreateProxyFor<T>(IntPtr pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), pObject, ownsHandle);
public static object CreateProxyFor(Type type, IntPtr ppv, bool ownsHandle) => _factories[type](ppv, ownsHandle);
public static object CreateProxyFor(Type type, IntPtr pObject, bool ownsHandle) => _factories[type](pObject, ownsHandle);
public static void* GetNativePointer<T>(T obj, bool owned = false) where T : IUnknown
{
@ -84,5 +85,11 @@ namespace Avalonia.MicroCom
}
}
public static T CloneReference<T>(T iface) where T : IUnknown
{
var ownedPointer = GetNativePointer(iface, true);
return CreateProxyFor<T>(ownedPointer, true);
}
}
}

2
src/Avalonia.MicroCom/MicroComShadow.cs

@ -77,7 +77,7 @@ namespace Avalonia.MicroCom
{
try
{
Target.OnUnreferencedFromNative();
Target.OnReferencedFromNative();
}
catch (Exception e)
{

1
src/Avalonia.Native/.gitignore

@ -1 +1,2 @@
Generated/*.cs
*.Generated.cs

27
src/Avalonia.Native/Avalonia.Native.csproj

@ -21,11 +21,30 @@
</ItemGroup>
<ItemGroup>
<!--<SharpGenMapping Include="Mappings.xml" />-->
<PackageReference Include="SharpGenTools.Sdk" Version="1.2.1" PrivateAssets="all" />
<PackageReference Include="SharpGen.Runtime" Version="1.2.1" />
<PackageReference Include="SharpGen.Runtime.COM" Version="1.2.0" />
<ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj" />
<ProjectReference Include="..\Avalonia.Dialogs\Avalonia.Dialogs.csproj" />
</ItemGroup>
<!-- COM Interop generation -->
<ItemGroup>
<ProjectReference Include="..\tools\MicroComGenerator\MicroComGenerator.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<ExcludeAssets>all</ExcludeAssets>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
<Target Name="GenerateAvaloniaNativeComInterop" AfterTargets="BeforeBuild" Inputs="avn.idl" Outputs="Interop.Generated.cs">
<Message Importance="high" Text="Generating Interop.Generated.cs" />
<Exec Command="dotnet ../tools/MicroComGenerator/bin/$(Configuration)/netcoreapp3.1/MicroComGenerator.dll -i avn.idl --cs Interop.Generated.cs" LogStandardErrorAsError="true" />
<ItemGroup>
<!-- Remove and re-add generated file, this is needed for the clean build -->
<Compile Remove="Interop.Generated.cs"/>
<Compile Include="Interop.Generated.cs"/>
</ItemGroup>
</Target>
<PropertyGroup>
<_AvaloniaPatchComInterop>true</_AvaloniaPatchComInterop>
</PropertyGroup>
<Import Project="..\..\build\BuildTargets.targets" />
</Project>

7
src/Avalonia.Native/AvaloniaNativeMenuExporter.cs

@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Controls.Platform;
using Avalonia.Dialogs;
using Avalonia.Native.Interop;
using Avalonia.Native.Interop.Impl;
using Avalonia.Threading;
namespace Avalonia.Native
@ -15,7 +16,7 @@ namespace Avalonia.Native
private bool _exported = false;
private IAvnWindow _nativeWindow;
private NativeMenu _menu;
private IAvnMenu _nativeMenu;
private __MicroComIAvnMenuProxy _nativeMenu;
public AvaloniaNativeMenuExporter(IAvnWindow nativeWindow, IAvaloniaNativeFactory factory)
{
@ -135,7 +136,7 @@ namespace Avalonia.Native
if (_nativeMenu is null)
{
_nativeMenu = IAvnMenu.Create(_factory);
_nativeMenu = (__MicroComIAvnMenuProxy)__MicroComIAvnMenuProxy.Create(_factory);
_nativeMenu.Initialise(this, appMenuHolder, "");
@ -156,7 +157,7 @@ namespace Avalonia.Native
if (_nativeMenu is null)
{
_nativeMenu = IAvnMenu.Create(_factory);
_nativeMenu = __MicroComIAvnMenuProxy.Create(_factory);
_nativeMenu.Initialise(this, menu, "");

12
src/Avalonia.Native/AvaloniaNativePlatform.cs

@ -4,6 +4,7 @@ using System.Security.Cryptography;
using Avalonia.Controls.Platform;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.MicroCom;
using Avalonia.Native.Interop;
using Avalonia.OpenGL;
using Avalonia.Platform;
@ -29,7 +30,7 @@ namespace Avalonia.Native
public static AvaloniaNativePlatform Initialize(IntPtr factory, AvaloniaNativePlatformOptions options)
{
var result = new AvaloniaNativePlatform(new IAvaloniaNativeFactory(factory));
var result = new AvaloniaNativePlatform(MicroComRuntime.CreateProxyFor<IAvaloniaNativeFactory>(factory, true));
result.DoInitialize(options);
return result;
@ -65,10 +66,7 @@ namespace Avalonia.Native
{
if(!string.IsNullOrWhiteSpace(Application.Current.Name))
{
using (var buffer = new Utf8Buffer(Application.Current.Name))
{
_factory.MacOptions.SetApplicationTitle(buffer.DangerousGetHandle());
}
_factory.MacOptions.SetApplicationTitle(Application.Current.Name);
}
}
@ -93,7 +91,7 @@ namespace Avalonia.Native
{
var macOpts = AvaloniaLocator.Current.GetService<MacOSPlatformOptions>();
_factory.MacOptions.ShowInDock = macOpts?.ShowInDock != false ? 1 : 0;
_factory.MacOptions.SetShowInDock(macOpts?.ShowInDock != false ? 1 : 0);
}
AvaloniaLocator.CurrentMutable
@ -153,7 +151,7 @@ namespace Avalonia.Native
set
{
_showInDock = value;
_opts.ShowInDock = value ? 1 : 0;
_opts.SetShowInDock(value ? 1 : 0);
}
}
}

4
src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs

@ -150,12 +150,12 @@ namespace Avalonia.Native
{
get
{
var s = _session.GetPixelSize();
var s = _session.PixelSize;
return new PixelSize(s.Width, s.Height);
}
}
public double Scaling => _session.GetScaling();
public double Scaling => _session.Scaling;
public bool IsYFlipped => true;

22
src/Avalonia.Native/AvnString.cs

@ -1,8 +1,22 @@
using System;
using System.Runtime.InteropServices;
namespace Avalonia.Native.Interop
{
unsafe partial class IAvnString
partial interface IAvnString
{
public string String { get; }
public byte[] Bytes { get; }
}
partial interface IAvnStringArray
{
string[] ToStringArray();
}
}
namespace Avalonia.Native.Interop.Impl
{
unsafe partial class __MicroComIAvnStringProxy
{
private string _managed;
private byte[] _bytes;
@ -16,7 +30,7 @@ namespace Avalonia.Native.Interop
var ptr = Pointer();
if (ptr == null)
return null;
_managed = System.Text.Encoding.UTF8.GetString((byte*)ptr.ToPointer(), Length());
_managed = System.Text.Encoding.UTF8.GetString((byte*)ptr, Length());
}
return _managed;
@ -30,7 +44,7 @@ namespace Avalonia.Native.Interop
if (_bytes == null)
{
_bytes = new byte[Length()];
Marshal.Copy(Pointer(), _bytes, 0, _bytes.Length);
Marshal.Copy(new IntPtr(Pointer()), _bytes, 0, _bytes.Length);
}
return _bytes;
@ -40,7 +54,7 @@ namespace Avalonia.Native.Interop
public override string ToString() => String;
}
partial class IAvnStringArray
partial class __MicroComIAvnStringArrayProxy
{
public string[] ToStringArray()
{

78
src/Avalonia.Native/CallbackBase.cs

@ -1,44 +1,30 @@
using System;
using System.Runtime.ExceptionServices;
using SharpGen.Runtime;
using Avalonia.MicroCom;
using Avalonia.Platform;
namespace Avalonia.Native
{
public class CallbackBase : SharpGen.Runtime.IUnknown, IExceptionCallback
public class CallbackBase : IUnknown, IMicroComShadowContainer, IMicroComExceptionCallback
{
private uint _refCount;
private bool _disposed;
private readonly object _lock = new object();
private ShadowContainer _shadow;
private bool _referencedFromManaged = true;
private bool _referencedFromNative = false;
private bool _destroyed;
public CallbackBase()
{
_refCount = 1;
}
public ShadowContainer Shadow
protected virtual void Destroyed()
{
get => _shadow;
set
{
lock (_lock)
{
if (_disposed && value != null)
{
throw new ObjectDisposedException("CallbackBase");
}
_shadow = value;
}
}
}
public uint AddRef()
public void RaiseException(Exception e)
{
lock (_lock)
if (AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>() is PlatformThreadingInterface threadingInterface)
{
return ++_refCount;
threadingInterface.TerminateNativeApp();
threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e));
}
}
@ -46,43 +32,35 @@ namespace Avalonia.Native
{
lock (_lock)
{
if (!_disposed)
{
_disposed = true;
Release();
}
_referencedFromManaged = false;
DestroyIfNeeded();
}
}
public uint Release()
void DestroyIfNeeded()
{
lock (_lock)
if(_destroyed)
return;
if (_referencedFromManaged == false && _referencedFromNative == false)
{
_refCount--;
if (_refCount == 0)
{
Shadow?.Dispose();
Shadow = null;
Destroyed();
}
return _refCount;
_destroyed = true;
Destroyed();
}
}
protected virtual void Destroyed()
public MicroComShadow Shadow { get; set; }
public void OnReferencedFromNative()
{
lock (_lock)
_referencedFromNative = true;
}
public void RaiseException(Exception e)
public void OnUnreferencedFromNative()
{
if (AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>() is PlatformThreadingInterface threadingInterface)
lock (_lock)
{
threadingInterface.TerminateNativeApp();
threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e));
_referencedFromNative = false;
DestroyIfNeeded();
}
}
}

16
src/Avalonia.Native/ClipboardImpl.cs

@ -35,17 +35,12 @@ namespace Avalonia.Native
return Task.FromResult(text.String);
}
public Task SetTextAsync(string text)
public unsafe Task SetTextAsync(string text)
{
_native.Clear();
if (text != null)
{
using (var buffer = new Utf8Buffer(text))
{
_native.SetText(NSPasteboardTypeString, buffer.DangerousGetHandle());
}
}
if (text != null)
_native.SetText(NSPasteboardTypeString, text);
return Task.CompletedTask;
}
@ -90,11 +85,10 @@ namespace Avalonia.Native
{
var o = data.Get(fmt);
if(o is string s)
using (var b = new Utf8Buffer(s))
_native.SetText(fmt, b.DangerousGetHandle());
_native.SetText(fmt, s);
else if(o is byte[] bytes)
fixed (byte* pbytes = bytes)
_native.SetBytes(fmt, new IntPtr(pbytes), bytes.Length);
_native.SetBytes(fmt, pbytes, bytes.Length);
}
return Task.CompletedTask;
}

7
src/Avalonia.Native/DeferredFramebuffer.cs

@ -2,11 +2,10 @@
using System.Runtime.InteropServices;
using Avalonia.Native.Interop;
using Avalonia.Platform;
using SharpGen.Runtime;
namespace Avalonia.Native
{
public class DeferredFramebuffer : ILockedFramebuffer
internal unsafe class DeferredFramebuffer : ILockedFramebuffer
{
private readonly Func<Action<IAvnWindowBase>, bool> _lockWindow;
@ -56,7 +55,7 @@ namespace Avalonia.Native
{
var fb = new AvnFramebuffer
{
Data = Address,
Data = Address.ToPointer(),
Dpi = new AvnVector
{
X = Dpi.X,
@ -70,7 +69,7 @@ namespace Avalonia.Native
using (var d = new Disposer(Address))
{
win.ThreadSafeSetSwRenderedFrame(ref fb, d);
win.ThreadSafeSetSwRenderedFrame(&fb, d);
}
}))
{

628
src/Avalonia.Native/Generated/Enumerations.cs

@ -1,628 +0,0 @@
// <auto-generated/>
namespace Avalonia.Native.Interop
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnDragDropEffects</unmanaged>
/// <unmanaged-short>AvnDragDropEffects</unmanaged-short>
public enum AvnDragDropEffects : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>None</unmanaged>
/// <unmanaged-short>None</unmanaged-short>
None = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Copy</unmanaged>
/// <unmanaged-short>Copy</unmanaged-short>
Copy = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Move</unmanaged>
/// <unmanaged-short>Move</unmanaged-short>
Move = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Link</unmanaged>
/// <unmanaged-short>Link</unmanaged-short>
Link = unchecked ((System.Int32)(4))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnDragEventType</unmanaged>
/// <unmanaged-short>AvnDragEventType</unmanaged-short>
public enum AvnDragEventType : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Enter</unmanaged>
/// <unmanaged-short>Enter</unmanaged-short>
Enter = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Over</unmanaged>
/// <unmanaged-short>Over</unmanaged-short>
Over = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Leave</unmanaged>
/// <unmanaged-short>Leave</unmanaged-short>
Leave = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Drop</unmanaged>
/// <unmanaged-short>Drop</unmanaged-short>
Drop = unchecked ((System.Int32)(3))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnExtendClientAreaChromeHints</unmanaged>
/// <unmanaged-short>AvnExtendClientAreaChromeHints</unmanaged-short>
public enum AvnExtendClientAreaChromeHints : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnNoChrome</unmanaged>
/// <unmanaged-short>AvnNoChrome</unmanaged-short>
AvnNoChrome = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnSystemChrome</unmanaged>
/// <unmanaged-short>AvnSystemChrome</unmanaged-short>
AvnSystemChrome = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnPreferSystemChrome</unmanaged>
/// <unmanaged-short>AvnPreferSystemChrome</unmanaged-short>
AvnPreferSystemChrome = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnOSXThickTitleBar</unmanaged>
/// <unmanaged-short>AvnOSXThickTitleBar</unmanaged-short>
AvnOSXThickTitleBar = unchecked ((System.Int32)(8)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnDefaultChrome</unmanaged>
/// <unmanaged-short>AvnDefaultChrome</unmanaged-short>
AvnDefaultChrome = unchecked ((System.Int32)(1))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnInputModifiers</unmanaged>
/// <unmanaged-short>AvnInputModifiers</unmanaged-short>
public enum AvnInputModifiers : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnInputModifiersNone</unmanaged>
/// <unmanaged-short>AvnInputModifiersNone</unmanaged-short>
AvnInputModifiersNone = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Alt</unmanaged>
/// <unmanaged-short>Alt</unmanaged-short>
Alt = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Control</unmanaged>
/// <unmanaged-short>Control</unmanaged-short>
Control = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Shift</unmanaged>
/// <unmanaged-short>Shift</unmanaged-short>
Shift = unchecked ((System.Int32)(4)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Windows</unmanaged>
/// <unmanaged-short>Windows</unmanaged-short>
Windows = unchecked ((System.Int32)(8)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>LeftMouseButton</unmanaged>
/// <unmanaged-short>LeftMouseButton</unmanaged-short>
LeftMouseButton = unchecked ((System.Int32)(16)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>RightMouseButton</unmanaged>
/// <unmanaged-short>RightMouseButton</unmanaged-short>
RightMouseButton = unchecked ((System.Int32)(32)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>MiddleMouseButton</unmanaged>
/// <unmanaged-short>MiddleMouseButton</unmanaged-short>
MiddleMouseButton = unchecked ((System.Int32)(64)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton1MouseButton</unmanaged>
/// <unmanaged-short>XButton1MouseButton</unmanaged-short>
XButton1MouseButton = unchecked ((System.Int32)(128)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton2MouseButton</unmanaged>
/// <unmanaged-short>XButton2MouseButton</unmanaged-short>
XButton2MouseButton = unchecked ((System.Int32)(256))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnMenuItemToggleType</unmanaged>
/// <unmanaged-short>AvnMenuItemToggleType</unmanaged-short>
public enum AvnMenuItemToggleType : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>None</unmanaged>
/// <unmanaged-short>None</unmanaged-short>
None = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CheckMark</unmanaged>
/// <unmanaged-short>CheckMark</unmanaged-short>
CheckMark = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Radio</unmanaged>
/// <unmanaged-short>Radio</unmanaged-short>
Radio = unchecked ((System.Int32)(2))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnPixelFormat</unmanaged>
/// <unmanaged-short>AvnPixelFormat</unmanaged-short>
public enum AvnPixelFormat : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>kAvnRgb565</unmanaged>
/// <unmanaged-short>kAvnRgb565</unmanaged-short>
KAvnRgb565 = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>kAvnRgba8888</unmanaged>
/// <unmanaged-short>kAvnRgba8888</unmanaged-short>
KAvnRgba8888 = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>kAvnBgra8888</unmanaged>
/// <unmanaged-short>kAvnBgra8888</unmanaged-short>
KAvnBgra8888 = unchecked ((System.Int32)(2))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnRawKeyEventType</unmanaged>
/// <unmanaged-short>AvnRawKeyEventType</unmanaged-short>
public enum AvnRawKeyEventType : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>KeyDown</unmanaged>
/// <unmanaged-short>KeyDown</unmanaged-short>
KeyDown = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>KeyUp</unmanaged>
/// <unmanaged-short>KeyUp</unmanaged-short>
KeyUp = unchecked ((System.Int32)(1))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnRawMouseEventType</unmanaged>
/// <unmanaged-short>AvnRawMouseEventType</unmanaged-short>
public enum AvnRawMouseEventType : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>LeaveWindow</unmanaged>
/// <unmanaged-short>LeaveWindow</unmanaged-short>
LeaveWindow = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>LeftButtonDown</unmanaged>
/// <unmanaged-short>LeftButtonDown</unmanaged-short>
LeftButtonDown = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>LeftButtonUp</unmanaged>
/// <unmanaged-short>LeftButtonUp</unmanaged-short>
LeftButtonUp = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>RightButtonDown</unmanaged>
/// <unmanaged-short>RightButtonDown</unmanaged-short>
RightButtonDown = unchecked ((System.Int32)(3)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>RightButtonUp</unmanaged>
/// <unmanaged-short>RightButtonUp</unmanaged-short>
RightButtonUp = unchecked ((System.Int32)(4)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>MiddleButtonDown</unmanaged>
/// <unmanaged-short>MiddleButtonDown</unmanaged-short>
MiddleButtonDown = unchecked ((System.Int32)(5)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>MiddleButtonUp</unmanaged>
/// <unmanaged-short>MiddleButtonUp</unmanaged-short>
MiddleButtonUp = unchecked ((System.Int32)(6)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton1Down</unmanaged>
/// <unmanaged-short>XButton1Down</unmanaged-short>
XButton1Down = unchecked ((System.Int32)(7)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton1Up</unmanaged>
/// <unmanaged-short>XButton1Up</unmanaged-short>
XButton1Up = unchecked ((System.Int32)(8)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton2Down</unmanaged>
/// <unmanaged-short>XButton2Down</unmanaged-short>
XButton2Down = unchecked ((System.Int32)(9)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>XButton2Up</unmanaged>
/// <unmanaged-short>XButton2Up</unmanaged-short>
XButton2Up = unchecked ((System.Int32)(10)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Move</unmanaged>
/// <unmanaged-short>Move</unmanaged-short>
Move = unchecked ((System.Int32)(11)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Wheel</unmanaged>
/// <unmanaged-short>Wheel</unmanaged-short>
Wheel = unchecked ((System.Int32)(12)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>NonClientLeftButtonDown</unmanaged>
/// <unmanaged-short>NonClientLeftButtonDown</unmanaged-short>
NonClientLeftButtonDown = unchecked ((System.Int32)(13)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>TouchBegin</unmanaged>
/// <unmanaged-short>TouchBegin</unmanaged-short>
TouchBegin = unchecked ((System.Int32)(14)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>TouchUpdate</unmanaged>
/// <unmanaged-short>TouchUpdate</unmanaged-short>
TouchUpdate = unchecked ((System.Int32)(15)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>TouchEnd</unmanaged>
/// <unmanaged-short>TouchEnd</unmanaged-short>
TouchEnd = unchecked ((System.Int32)(16)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>TouchCancel</unmanaged>
/// <unmanaged-short>TouchCancel</unmanaged-short>
TouchCancel = unchecked ((System.Int32)(17))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnStandardCursorType</unmanaged>
/// <unmanaged-short>AvnStandardCursorType</unmanaged-short>
public enum AvnStandardCursorType : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorArrow</unmanaged>
/// <unmanaged-short>CursorArrow</unmanaged-short>
CursorArrow = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorIbeam</unmanaged>
/// <unmanaged-short>CursorIbeam</unmanaged-short>
CursorIbeam = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorWait</unmanaged>
/// <unmanaged-short>CursorWait</unmanaged-short>
CursorWait = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorCross</unmanaged>
/// <unmanaged-short>CursorCross</unmanaged-short>
CursorCross = unchecked ((System.Int32)(3)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorUpArrow</unmanaged>
/// <unmanaged-short>CursorUpArrow</unmanaged-short>
CursorUpArrow = unchecked ((System.Int32)(4)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorSizeWestEast</unmanaged>
/// <unmanaged-short>CursorSizeWestEast</unmanaged-short>
CursorSizeWestEast = unchecked ((System.Int32)(5)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorSizeNorthSouth</unmanaged>
/// <unmanaged-short>CursorSizeNorthSouth</unmanaged-short>
CursorSizeNorthSouth = unchecked ((System.Int32)(6)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorSizeAll</unmanaged>
/// <unmanaged-short>CursorSizeAll</unmanaged-short>
CursorSizeAll = unchecked ((System.Int32)(7)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorNo</unmanaged>
/// <unmanaged-short>CursorNo</unmanaged-short>
CursorNo = unchecked ((System.Int32)(8)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorHand</unmanaged>
/// <unmanaged-short>CursorHand</unmanaged-short>
CursorHand = unchecked ((System.Int32)(9)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorAppStarting</unmanaged>
/// <unmanaged-short>CursorAppStarting</unmanaged-short>
CursorAppStarting = unchecked ((System.Int32)(10)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorHelp</unmanaged>
/// <unmanaged-short>CursorHelp</unmanaged-short>
CursorHelp = unchecked ((System.Int32)(11)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorTopSide</unmanaged>
/// <unmanaged-short>CursorTopSide</unmanaged-short>
CursorTopSide = unchecked ((System.Int32)(12)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorBottomSize</unmanaged>
/// <unmanaged-short>CursorBottomSize</unmanaged-short>
CursorBottomSize = unchecked ((System.Int32)(13)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorLeftSide</unmanaged>
/// <unmanaged-short>CursorLeftSide</unmanaged-short>
CursorLeftSide = unchecked ((System.Int32)(14)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorRightSide</unmanaged>
/// <unmanaged-short>CursorRightSide</unmanaged-short>
CursorRightSide = unchecked ((System.Int32)(15)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorTopLeftCorner</unmanaged>
/// <unmanaged-short>CursorTopLeftCorner</unmanaged-short>
CursorTopLeftCorner = unchecked ((System.Int32)(16)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorTopRightCorner</unmanaged>
/// <unmanaged-short>CursorTopRightCorner</unmanaged-short>
CursorTopRightCorner = unchecked ((System.Int32)(17)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorBottomLeftCorner</unmanaged>
/// <unmanaged-short>CursorBottomLeftCorner</unmanaged-short>
CursorBottomLeftCorner = unchecked ((System.Int32)(18)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorBottomRightCorner</unmanaged>
/// <unmanaged-short>CursorBottomRightCorner</unmanaged-short>
CursorBottomRightCorner = unchecked ((System.Int32)(19)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorDragMove</unmanaged>
/// <unmanaged-short>CursorDragMove</unmanaged-short>
CursorDragMove = unchecked ((System.Int32)(20)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorDragCopy</unmanaged>
/// <unmanaged-short>CursorDragCopy</unmanaged-short>
CursorDragCopy = unchecked ((System.Int32)(21)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorDragLink</unmanaged>
/// <unmanaged-short>CursorDragLink</unmanaged-short>
CursorDragLink = unchecked ((System.Int32)(22)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>CursorNone</unmanaged>
/// <unmanaged-short>CursorNone</unmanaged-short>
CursorNone = unchecked ((System.Int32)(23))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnWindowEdge</unmanaged>
/// <unmanaged-short>AvnWindowEdge</unmanaged-short>
public enum AvnWindowEdge : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeNorthWest</unmanaged>
/// <unmanaged-short>WindowEdgeNorthWest</unmanaged-short>
WindowEdgeNorthWest = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeNorth</unmanaged>
/// <unmanaged-short>WindowEdgeNorth</unmanaged-short>
WindowEdgeNorth = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeNorthEast</unmanaged>
/// <unmanaged-short>WindowEdgeNorthEast</unmanaged-short>
WindowEdgeNorthEast = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeWest</unmanaged>
/// <unmanaged-short>WindowEdgeWest</unmanaged-short>
WindowEdgeWest = unchecked ((System.Int32)(3)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeEast</unmanaged>
/// <unmanaged-short>WindowEdgeEast</unmanaged-short>
WindowEdgeEast = unchecked ((System.Int32)(4)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeSouthWest</unmanaged>
/// <unmanaged-short>WindowEdgeSouthWest</unmanaged-short>
WindowEdgeSouthWest = unchecked ((System.Int32)(5)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeSouth</unmanaged>
/// <unmanaged-short>WindowEdgeSouth</unmanaged-short>
WindowEdgeSouth = unchecked ((System.Int32)(6)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WindowEdgeSouthEast</unmanaged>
/// <unmanaged-short>WindowEdgeSouthEast</unmanaged-short>
WindowEdgeSouthEast = unchecked ((System.Int32)(7))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnWindowState</unmanaged>
/// <unmanaged-short>AvnWindowState</unmanaged-short>
public enum AvnWindowState : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Normal</unmanaged>
/// <unmanaged-short>Normal</unmanaged-short>
Normal = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Minimized</unmanaged>
/// <unmanaged-short>Minimized</unmanaged-short>
Minimized = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Maximized</unmanaged>
/// <unmanaged-short>Maximized</unmanaged-short>
Maximized = unchecked ((System.Int32)(2)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>FullScreen</unmanaged>
/// <unmanaged-short>FullScreen</unmanaged-short>
FullScreen = unchecked ((System.Int32)(3))}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>SystemDecorations</unmanaged>
/// <unmanaged-short>SystemDecorations</unmanaged-short>
public enum SystemDecorations : System.Int32
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>SystemDecorationsNone</unmanaged>
/// <unmanaged-short>SystemDecorationsNone</unmanaged-short>
SystemDecorationsNone = unchecked ((System.Int32)(0)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>SystemDecorationsBorderOnly</unmanaged>
/// <unmanaged-short>SystemDecorationsBorderOnly</unmanaged-short>
SystemDecorationsBorderOnly = unchecked ((System.Int32)(1)),
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>SystemDecorationsFull</unmanaged>
/// <unmanaged-short>SystemDecorationsFull</unmanaged-short>
SystemDecorationsFull = unchecked ((System.Int32)(2))}
}

5
src/Avalonia.Native/Generated/Functions.cs

@ -1,5 +0,0 @@
// <auto-generated/>
namespace Avalonia.Native.Interop
{
}

3092
src/Avalonia.Native/Generated/Interfaces.cs

File diff suppressed because it is too large

202
src/Avalonia.Native/Generated/LocalInterop.cs

@ -1,202 +0,0 @@
// <auto-generated/>
namespace Avalonia.Native
{
internal static partial class LocalInterop
{
public static unsafe int CalliThisCallint(void *thisObject, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid0(void *thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4, void *methodPtr)
{
throw null;
}
public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3, void *methodPtr)
{
throw null;
}
public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, double param0, void *methodPtr)
{
throw null;
}
public static unsafe Avalonia.Native.Interop.AvnDragDropEffects CalliThisCallAvaloniaNativeInteropAvnDragDropEffects0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5, void *methodPtr)
{
throw null;
}
public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnSize param0, Avalonia.Native.Interop.AvnSize param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, double param0, double param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnRect param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, int param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, System.Byte param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, void *param2, void *param3, void *param4, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnColor param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, double param0, void *methodPtr)
{
throw null;
}
public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *methodPtr)
{
throw null;
}
public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, int param0, int param1, void *param2, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, System.Byte param2, void *param3, void *param4, void *param5, void *param6, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *param4, void *param5, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, int param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, int param2, void *methodPtr)
{
throw null;
}
public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *param0, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, void *param0, int param1, void *methodPtr)
{
throw null;
}
public static unsafe System.UInt32 CalliThisCallSystemUInt32(void *thisObject, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, float param2, float param3, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, void *methodPtr)
{
throw null;
}
public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *param2, void *methodPtr)
{
throw null;
}
public static unsafe void CalliThisCallvoid(void *thisObject, int param0, System.Byte param1, void *methodPtr)
{
throw null;
}
}
}

246
src/Avalonia.Native/Generated/Structures.cs

@ -1,246 +0,0 @@
// <auto-generated/>
namespace Avalonia.Native.Interop
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnColor</unmanaged>
/// <unmanaged-short>AvnColor</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnColor
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Alpha</unmanaged>
/// <unmanaged-short>Alpha</unmanaged-short>
public System.Byte Alpha;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Red</unmanaged>
/// <unmanaged-short>Red</unmanaged-short>
public System.Byte Red;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Green</unmanaged>
/// <unmanaged-short>Green</unmanaged-short>
public System.Byte Green;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Blue</unmanaged>
/// <unmanaged-short>Blue</unmanaged-short>
public System.Byte Blue;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnFramebuffer</unmanaged>
/// <unmanaged-short>AvnFramebuffer</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnFramebuffer
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Data</unmanaged>
/// <unmanaged-short>Data</unmanaged-short>
public System.IntPtr Data;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Width</unmanaged>
/// <unmanaged-short>Width</unmanaged-short>
public System.Int32 Width;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Height</unmanaged>
/// <unmanaged-short>Height</unmanaged-short>
public System.Int32 Height;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Stride</unmanaged>
/// <unmanaged-short>Stride</unmanaged-short>
public System.Int32 Stride;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Dpi</unmanaged>
/// <unmanaged-short>Dpi</unmanaged-short>
public Avalonia.Native.Interop.AvnVector Dpi;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>PixelFormat</unmanaged>
/// <unmanaged-short>PixelFormat</unmanaged-short>
public Avalonia.Native.Interop.AvnPixelFormat PixelFormat;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnPixelSize</unmanaged>
/// <unmanaged-short>AvnPixelSize</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnPixelSize
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Width</unmanaged>
/// <unmanaged-short>Width</unmanaged-short>
public System.Int32 Width;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Height</unmanaged>
/// <unmanaged-short>Height</unmanaged-short>
public System.Int32 Height;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnPoint</unmanaged>
/// <unmanaged-short>AvnPoint</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnPoint
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>X</unmanaged>
/// <unmanaged-short>X</unmanaged-short>
public System.Double X;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Y</unmanaged>
/// <unmanaged-short>Y</unmanaged-short>
public System.Double Y;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnRect</unmanaged>
/// <unmanaged-short>AvnRect</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnRect
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>X</unmanaged>
/// <unmanaged-short>X</unmanaged-short>
public System.Double X;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Y</unmanaged>
/// <unmanaged-short>Y</unmanaged-short>
public System.Double Y;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Width</unmanaged>
/// <unmanaged-short>Width</unmanaged-short>
public System.Double Width;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Height</unmanaged>
/// <unmanaged-short>Height</unmanaged-short>
public System.Double Height;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnScreen</unmanaged>
/// <unmanaged-short>AvnScreen</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnScreen
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Bounds</unmanaged>
/// <unmanaged-short>Bounds</unmanaged-short>
public Avalonia.Native.Interop.AvnRect Bounds;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>WorkingArea</unmanaged>
/// <unmanaged-short>WorkingArea</unmanaged-short>
public Avalonia.Native.Interop.AvnRect WorkingArea;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>PixelDensity</unmanaged>
/// <unmanaged-short>PixelDensity</unmanaged-short>
public System.Single PixelDensity;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Primary</unmanaged>
/// <unmanaged-short>Primary</unmanaged-short>
public bool Primary
{
get => 0 != _Primary;
set => _Primary = (System.Byte)(value ? 1 : 0);
}
internal System.Byte _Primary;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnSize</unmanaged>
/// <unmanaged-short>AvnSize</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnSize
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Width</unmanaged>
/// <unmanaged-short>Width</unmanaged-short>
public System.Double Width;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Height</unmanaged>
/// <unmanaged-short>Height</unmanaged-short>
public System.Double Height;
}
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>AvnVector</unmanaged>
/// <unmanaged-short>AvnVector</unmanaged-short>
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public partial struct AvnVector
{
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>X</unmanaged>
/// <unmanaged-short>X</unmanaged-short>
public System.Double X;
/// <summary>
/// No documentation.
/// </summary>
/// <unmanaged>Y</unmanaged>
/// <unmanaged-short>Y</unmanaged-short>
public System.Double Y;
}
}

2
src/Avalonia.Native/Helpers.cs

@ -2,7 +2,7 @@
namespace Avalonia.Native
{
public static class Helpers
internal static class Helpers
{
public static Point ToAvaloniaPoint (this AvnPoint pt)
{

45
src/Avalonia.Native/IAvnMenu.cs

@ -22,15 +22,23 @@ namespace Avalonia.Native.Interop
}
}
public partial class IAvnMenu
partial interface IAvnMenu
{
void RaiseNeedsUpdate();
void Deinitialise();
}
}
namespace Avalonia.Native.Interop.Impl
{
partial class __MicroComIAvnMenuProxy
{
private MenuEvents _events;
private AvaloniaNativeMenuExporter _exporter;
private List<IAvnMenuItem> _menuItems = new List<IAvnMenuItem>();
private Dictionary<NativeMenuItemBase, IAvnMenuItem> _menuItemLookup = new Dictionary<NativeMenuItemBase, IAvnMenuItem>();
private List<__MicroComIAvnMenuItemProxy> _menuItems = new List<__MicroComIAvnMenuItemProxy>();
private Dictionary<NativeMenuItemBase, __MicroComIAvnMenuItemProxy> _menuItemLookup = new Dictionary<NativeMenuItemBase, __MicroComIAvnMenuItemProxy>();
private CompositeDisposable _propertyDisposables = new CompositeDisposable();
internal void RaiseNeedsUpdate()
public void RaiseNeedsUpdate()
{
(ManagedMenu as INativeMenuExporterEventsImplBridge).RaiseNeedsUpdate();
@ -39,11 +47,11 @@ namespace Avalonia.Native.Interop
internal NativeMenu ManagedMenu { get; private set; }
public static IAvnMenu Create(IAvaloniaNativeFactory factory)
public static __MicroComIAvnMenuProxy Create(IAvaloniaNativeFactory factory)
{
var events = new MenuEvents();
var menu = factory.CreateMenu(events);
var menu = (__MicroComIAvnMenuProxy)factory.CreateMenu(events);
events.Initialise(menu);
@ -60,7 +68,7 @@ namespace Avalonia.Native.Interop
}
}
private void RemoveAndDispose(IAvnMenuItem item)
private void RemoveAndDispose(__MicroComIAvnMenuItemProxy item)
{
_menuItemLookup.Remove(item.ManagedMenuItem);
_menuItems.Remove(item);
@ -70,7 +78,7 @@ namespace Avalonia.Native.Interop
item.Dispose();
}
private void MoveExistingTo(int index, IAvnMenuItem item)
private void MoveExistingTo(int index, __MicroComIAvnMenuItemProxy item)
{
_menuItems.Remove(item);
_menuItems.Insert(index, item);
@ -79,7 +87,7 @@ namespace Avalonia.Native.Interop
InsertItem(index, item);
}
private IAvnMenuItem CreateNewAt(IAvaloniaNativeFactory factory, int index, NativeMenuItemBase item)
private __MicroComIAvnMenuItemProxy CreateNewAt(IAvaloniaNativeFactory factory, int index, NativeMenuItemBase item)
{
var result = CreateNew(factory, item);
@ -93,9 +101,11 @@ namespace Avalonia.Native.Interop
return result;
}
private IAvnMenuItem CreateNew(IAvaloniaNativeFactory factory, NativeMenuItemBase item)
private __MicroComIAvnMenuItemProxy CreateNew(IAvaloniaNativeFactory factory, NativeMenuItemBase item)
{
var nativeItem = item is NativeMenuItemSeperator ? factory.CreateMenuItemSeperator() : factory.CreateMenuItem();
var nativeItem = (__MicroComIAvnMenuItemProxy)(item is NativeMenuItemSeperator ?
factory.CreateMenuItemSeperator() :
factory.CreateMenuItem());
nativeItem.ManagedMenuItem = item;
return nativeItem;
@ -108,16 +118,11 @@ namespace Avalonia.Native.Interop
((INotifyCollectionChanged)ManagedMenu.Items).CollectionChanged += OnMenuItemsChanged;
if (!string.IsNullOrWhiteSpace(title))
{
using (var buffer = new Utf8Buffer(title))
{
Title = buffer.DangerousGetHandle();
}
}
if (!string.IsNullOrWhiteSpace(title))
SetTitle(title);
}
internal void Deinitialise()
public void Deinitialise()
{
((INotifyCollectionChanged)ManagedMenu.Items).CollectionChanged -= OnMenuItemsChanged;
@ -137,7 +142,7 @@ namespace Avalonia.Native.Interop
for (int i = 0; i < menu.Items.Count; i++)
{
IAvnMenuItem nativeItem;
__MicroComIAvnMenuItemProxy nativeItem;
if (i >= _menuItems.Count)
{

41
src/Avalonia.Native/IAvnMenuItem.cs

@ -7,37 +7,35 @@ using Avalonia.Platform.Interop;
namespace Avalonia.Native.Interop
{
public partial class IAvnMenuItem
partial interface IAvnMenuItem
{
private IAvnMenu _subMenu;
}
}
namespace Avalonia.Native.Interop.Impl
{
partial class __MicroComIAvnMenuItemProxy
{
private __MicroComIAvnMenuProxy _subMenu;
private CompositeDisposable _propertyDisposables = new CompositeDisposable();
private IDisposable _currentActionDisposable;
public NativeMenuItemBase ManagedMenuItem { get; set; }
private void UpdateTitle(string title)
{
using (var buffer = new Utf8Buffer(string.IsNullOrWhiteSpace(title) ? "" : title))
{
Title = buffer.DangerousGetHandle();
}
}
private void UpdateTitle(string title) => SetTitle(title ?? "");
private void UpdateIsChecked(bool isChecked)
{
IsChecked = isChecked;
}
private void UpdateIsChecked(bool isChecked) => SetIsChecked(isChecked);
private void UpdateToggleType(NativeMenuItemToggleType toggleType)
{
ToggleType = (AvnMenuItemToggleType)toggleType;
SetToggleType((AvnMenuItemToggleType)toggleType);
}
private unsafe void UpdateIcon (IBitmap icon)
{
if(icon is null)
{
SetIcon(IntPtr.Zero, 0);
SetIcon(null, IntPtr.Zero);
}
else
{
@ -49,7 +47,7 @@ namespace Avalonia.Native.Interop
fixed(void* ptr = imageData)
{
SetIcon(new IntPtr(ptr), imageData.Length);
SetIcon(ptr, new IntPtr(imageData.Length));
}
}
}
@ -57,12 +55,9 @@ namespace Avalonia.Native.Interop
private void UpdateGesture(Input.KeyGesture gesture)
{
// todo ensure backend can cope with setting null gesture.
using (var buffer = new Utf8Buffer(gesture == null ? "" : OsxUnicodeKeys.ConvertOSXSpecialKeyCodes(gesture.Key)))
{
var modifiers = gesture == null ? AvnInputModifiers.AvnInputModifiersNone : (AvnInputModifiers)gesture.KeyModifiers;
SetGesture(buffer.DangerousGetHandle(), modifiers);
}
var text = gesture == null ? "" : OsxUnicodeKeys.ConvertOSXSpecialKeyCodes(gesture.Key);
var modifiers = gesture == null ? AvnInputModifiers.AvnInputModifiersNone : (AvnInputModifiers)gesture.KeyModifiers;
SetGesture(text, modifiers);
}
private void UpdateAction(NativeMenuItem item)
@ -153,7 +148,7 @@ namespace Avalonia.Native.Interop
{
if (_subMenu == null)
{
_subMenu = IAvnMenu.Create(factory);
_subMenu = __MicroComIAvnMenuProxy.Create(factory);
_subMenu.Initialise(exporter, item.Menu, item.Header);

4
src/Avalonia.Native/NativeControlHostImpl.cs

@ -1,5 +1,6 @@
using System;
using Avalonia.Controls.Platform;
using Avalonia.MicroCom;
using Avalonia.Native.Interop;
using Avalonia.Platform;
using Avalonia.VisualTree;
@ -28,8 +29,7 @@ namespace Avalonia.Native
public DestroyableNSView(IAvnNativeControlHost impl)
{
_impl = new IAvnNativeControlHost(impl.NativePointer);
_impl.AddRef();
_impl = MicroComRuntime.CloneReference(impl);
_nsView = _impl.CreateDefaultChild(IntPtr.Zero);
}

5
src/Avalonia.Native/PlatformThreadingInterface.cs

@ -4,11 +4,10 @@ using System.Threading;
using Avalonia.Native.Interop;
using Avalonia.Platform;
using Avalonia.Threading;
using SharpGen.Runtime;
namespace Avalonia.Native
{
public class PlatformThreadingInterface : IPlatformThreadingInterface
internal class PlatformThreadingInterface : IPlatformThreadingInterface
{
class TimerCallback : CallbackBase, IAvnActionCallback
{
@ -48,7 +47,7 @@ namespace Avalonia.Native
{
_native = native;
using (var cb = new SignaledCallback(this))
_native.SignaledCallback = cb;
_native.SetSignaledCallback(cb);
}
public bool CurrentThreadIsLoopThread => _native.CurrentThreadIsLoopThread;

2
src/Avalonia.Native/ScreenImpl.cs

@ -14,7 +14,7 @@ namespace Avalonia.Native
_native = native;
}
public int ScreenCount => _native.GetScreenCount();
public int ScreenCount => _native.ScreenCount;
public IReadOnlyList<Screen> AllScreens
{

8
src/Avalonia.Native/SystemDialogs.cs

@ -8,7 +8,7 @@ using Avalonia.Native.Interop;
namespace Avalonia.Native
{
public class SystemDialogs : ISystemDialogImpl
internal class SystemDialogs : ISystemDialogImpl
{
IAvnSystemDialogs _native;
@ -62,7 +62,7 @@ namespace Avalonia.Native
}
}
public class SystemDialogEvents : CallbackBase, IAvnSystemDialogEvents
internal unsafe class SystemDialogEvents : CallbackBase, IAvnSystemDialogEvents
{
private TaskCompletionSource<string[]> _tcs;
@ -73,13 +73,13 @@ namespace Avalonia.Native
public Task<string[]> Task => _tcs.Task;
public void OnCompleted(int numResults, IntPtr trFirstResultRef)
public void OnCompleted(int numResults, void* trFirstResultRef)
{
string[] results = new string[numResults];
unsafe
{
var ptr = (IntPtr*)trFirstResultRef.ToPointer();
var ptr = (IntPtr*)trFirstResultRef;
for (int i = 0; i < numResults; i++)
{

28
src/Avalonia.Native/WindowImpl.cs

@ -10,7 +10,7 @@ using Avalonia.Platform.Interop;
namespace Avalonia.Native
{
public class WindowImpl : WindowBaseImpl, IWindowImpl, ITopLevelImplWithNativeMenuExporter
internal class WindowImpl : WindowBaseImpl, IWindowImpl, ITopLevelImplWithNativeMenuExporter
{
private readonly IAvaloniaNativeFactory _factory;
private readonly AvaloniaNativePlatformOptions _opts;
@ -69,12 +69,12 @@ namespace Avalonia.Native
public void CanResize(bool value)
{
_native.CanResize = value;
_native.SetCanResize(value);
}
public void SetSystemDecorations(Controls.SystemDecorations enabled)
{
_native.Decorations = (Interop.SystemDecorations)enabled;
_native.SetDecorations((Interop.SystemDecorations)enabled);
}
public void SetTitleBarColor(Avalonia.Media.Color color)
@ -82,24 +82,12 @@ namespace Avalonia.Native
_native.SetTitleBarColor(new AvnColor { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B });
}
public void SetTitle(string title)
{
using (var buffer = new Utf8Buffer(title))
{
_native.SetTitle(buffer.DangerousGetHandle());
}
}
public void SetTitle(string title) => _native.SetTitle(title);
public WindowState WindowState
{
get
{
return (WindowState)_native.GetWindowState();
}
set
{
_native.SetWindowState((AvnWindowState)value);
}
get => (WindowState)_native.WindowState;
set => _native.SetWindowState((AvnWindowState)value);
}
public Action<WindowState> WindowStateChanged { get; set; }
@ -146,7 +134,7 @@ namespace Avalonia.Native
}
else
{
ExtendedMargins = _isExtended ? new Thickness(0, _extendTitleBarHeight == -1 ? _native.GetExtendTitleBarHeight() : _extendTitleBarHeight, 0, 0) : new Thickness();
ExtendedMargins = _isExtended ? new Thickness(0, _extendTitleBarHeight == -1 ? _native.ExtendTitleBarHeight : _extendTitleBarHeight, 0, 0) : new Thickness();
}
ExtendClientAreaToDecorationsChanged?.Invoke(_isExtended);
@ -174,7 +162,7 @@ namespace Avalonia.Native
_extendTitleBarHeight = titleBarHeight;
_native.SetExtendTitleBarHeight(titleBarHeight);
ExtendedMargins = _isExtended ? new Thickness(0, titleBarHeight == -1 ? _native.GetExtendTitleBarHeight() : titleBarHeight, 0, 0) : new Thickness();
ExtendedMargins = _isExtended ? new Thickness(0, titleBarHeight == -1 ? _native.ExtendTitleBarHeight : titleBarHeight, 0, 0) : new Thickness();
ExtendClientAreaToDecorationsChanged?.Invoke(_isExtended);
}

18
src/Avalonia.Native/WindowImplBase.cs

@ -15,7 +15,7 @@ using Avalonia.Threading;
namespace Avalonia.Native
{
public class MacOSTopLevelWindowHandle : IPlatformHandle, IMacOSTopLevelPlatformHandle
internal class MacOSTopLevelWindowHandle : IPlatformHandle, IMacOSTopLevelPlatformHandle
{
IAvnWindowBase _native;
@ -43,7 +43,7 @@ namespace Avalonia.Native
}
}
public abstract class WindowBaseImpl : IWindowBaseImpl,
internal abstract class WindowBaseImpl : IWindowBaseImpl,
IFramebufferPlatformSurface, ITopLevelImplWithNativeControlHost
{
protected IInputRoot _inputRoot;
@ -96,7 +96,7 @@ namespace Avalonia.Native
{
if (_native != null)
{
var s = _native.GetClientSize();
var s = _native.ClientSize;
return new Size(s.Width, s.Height);
}
@ -137,7 +137,7 @@ namespace Avalonia.Native
public IMouseDevice MouseDevice => _mouse;
public abstract IPopupImpl CreatePopup();
protected class WindowBaseEvents : CallbackBase, IAvnWindowBaseEvents
protected unsafe class WindowBaseEvents : CallbackBase, IAvnWindowBaseEvents
{
private readonly WindowBaseImpl _parent;
@ -172,11 +172,11 @@ namespace Avalonia.Native
_parent.Paint?.Invoke(new Rect(0, 0, s.Width, s.Height));
}
void IAvnWindowBaseEvents.Resized(AvnSize size)
void IAvnWindowBaseEvents.Resized(AvnSize* size)
{
if (_parent._native != null)
{
var s = new Size(size.Width, size.Height);
var s = new Size(size->Width, size->Height);
_parent._savedLogicalSize = s;
_parent.Resized?.Invoke(s);
}
@ -359,7 +359,7 @@ namespace Avalonia.Native
public PixelPoint Position
{
get => _native.GetPosition().ToAvaloniaPixelPoint();
get => _native.Position.ToAvaloniaPixelPoint();
set => _native.SetPosition(value.ToAvnPoint());
}
@ -391,7 +391,7 @@ namespace Avalonia.Native
_native.SetTopMost(value);
}
public double RenderScaling => _native?.GetScaling() ?? 1;
public double RenderScaling => _native?.Scaling ?? 1;
public double DesktopScaling => 1;
@ -407,7 +407,7 @@ namespace Avalonia.Native
var newCursor = cursor as AvaloniaNativeCursor;
newCursor = newCursor ?? (_cursorFactory.GetCursor(StandardCursorType.Arrow) as AvaloniaNativeCursor);
_native.Cursor = newCursor.Cursor;
_native.SetCursor(newCursor.Cursor);
}
public Action<PixelPoint> PositionChanged { get; set; }

42
src/Avalonia.Native/avn.idl

@ -1,4 +1,4 @@
@clr-namespace Avalonia.Native.MicroCom
@clr-namespace Avalonia.Native.Interop
@clr-access internal
@cpp-preamble @@
#include "com.h"
@ -244,13 +244,13 @@ interface IAvnWindowBase : IUnknown
HRESULT SetCursor(IAvnCursor* cursor);
HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret);
HRESULT SetMainMenu(IAvnMenu* menu);
HRESULT ObtainNSWindowHandle(void** retOut);
HRESULT ObtainNSWindowHandleRetained(void** retOut);
HRESULT ObtainNSViewHandle(void** retOut);
HRESULT ObtainNSViewHandleRetained(void** retOut);
HRESULT ObtainNSWindowHandle([intptr]void** retOut);
HRESULT ObtainNSWindowHandleRetained([intptr]void** retOut);
HRESULT ObtainNSViewHandle([intptr]void** retOut);
HRESULT ObtainNSViewHandleRetained([intptr]void** retOut);
HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut);
HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point,
IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle);
IAvnClipboard* clipboard, IAvnDndResultCallback* cb, [intptr]void* sourceHandle);
HRESULT SetBlurEnabled(bool enable);
}
@ -267,7 +267,7 @@ interface IAvnWindow : IAvnWindowBase
HRESULT SetParent(IAvnWindow* parent);
HRESULT SetCanResize(bool value);
HRESULT SetDecorations(SystemDecorations value);
HRESULT SetTitle(void* utf8Title);
HRESULT SetTitle(char* utf8Title);
HRESULT SetTitleBarColor(AvnColor color);
HRESULT SetWindowState(AvnWindowState state);
HRESULT GetWindowState(AvnWindowState*ret);
@ -299,7 +299,7 @@ interface IAvnWindowBaseEvents : IUnknown
void LostFocus();
AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position,
AvnInputModifiers modifiers, AvnDragDropEffects effects,
IAvnClipboard* clipboard, void* dataObjectHandle);
IAvnClipboard* clipboard, [intptr]void* dataObjectHandle);
}
[uuid(1ae178ee-1fcc-447f-b6dd-b7bb727f934c)]
@ -321,7 +321,7 @@ interface IAvnWindowEvents : IAvnWindowBaseEvents
interface IAvnMacOptions : IUnknown
{
HRESULT SetShowInDock(int show);
HRESULT SetApplicationTitle(void* utf8string);
HRESULT SetApplicationTitle(char* utf8string);
}
[uuid(04c1b049-1f43-418a-9159-cae627ec1367)]
@ -395,7 +395,7 @@ interface IAvnScreens : IUnknown
interface IAvnClipboard : IUnknown
{
HRESULT GetText(char* type, IAvnString**ppv);
HRESULT SetText(char* type, void* utf8Text);
HRESULT SetText(char* type, char* utf8Text);
HRESULT ObtainFormats(IAvnStringArray**ppv);
HRESULT GetStrings(char* type, IAvnStringArray**ppv);
HRESULT SetBytes(char* type, void* utf8Text, int len);
@ -420,8 +420,8 @@ interface IAvnGlDisplay : IUnknown
{
HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv);
void LegacyClearCurrentContext();
HRESULT WrapContext(void* native, IAvnGlContext**ppv);
void* GetProcAddress(char* proc);
HRESULT WrapContext([intptr]void* native, IAvnGlContext**ppv);
[intptr]void* GetProcAddress(char* proc);
}
[uuid(78c5711e-2a98-40d2-bac4-0cc9a49dc4f3)]
@ -431,7 +431,7 @@ interface IAvnGlContext : IUnknown
HRESULT LegacyMakeCurrent();
int GetSampleCount();
int GetStencilSize();
void* GetNativeHandle();
[intptr]void* GetNativeHandle();
}
[uuid(931062d2-5bc8-4062-8588-83dd8deb99c2)]
@ -452,7 +452,7 @@ interface IAvnMenu : IUnknown
{
HRESULT InsertItem(int index, IAvnMenuItem* item);
HRESULT RemoveItem(IAvnMenuItem* item);
HRESULT SetTitle(void* utf8String);
HRESULT SetTitle(char* utf8String);
HRESULT Clear();
}
@ -466,8 +466,8 @@ interface IAvnPredicateCallback : IUnknown
interface IAvnMenuItem : IUnknown
{
HRESULT SetSubMenu(IAvnMenu* menu);
HRESULT SetTitle(void* utf8String);
HRESULT SetGesture(void* utf8String, AvnInputModifiers modifiers);
HRESULT SetTitle(char* utf8String);
HRESULT SetGesture(char* utf8String, AvnInputModifiers modifiers);
HRESULT SetAction(IAvnPredicateCallback* predicate, IAvnActionCallback* callback);
HRESULT SetIsChecked(bool isChecked);
HRESULT SetToggleType(AvnMenuItemToggleType toggleType);
@ -499,22 +499,22 @@ interface IAvnDndResultCallback : IUnknown
[uuid(f07c608e-52e9-422d-836e-c70f6e9b80f5)]
interface IAvnGCHandleDeallocatorCallback : IUnknown
{
void FreeGCHandle(void* handle);
void FreeGCHandle([intptr]void* handle);
}
[uuid(91c7f677-f26b-4ff3-93cc-cf15aa966ffa)]
interface IAvnNativeControlHost : IUnknown
{
HRESULT CreateDefaultChild(void* parent, void** retOut);
HRESULT CreateDefaultChild([intptr]void* parent, [intptr]void** retOut);
IAvnNativeControlHostTopLevelAttachment* CreateAttachment();
void DestroyDefaultChild(void* child);
void DestroyDefaultChild([intptr]void* child);
}
[uuid(14a9e164-1aae-4271-bb78-7b5230999b52)]
interface IAvnNativeControlHostTopLevelAttachment : IUnknown
{
void* GetParentHandle();
HRESULT InitializeWithChildHandle(void* child);
[intptr]void* GetParentHandle();
HRESULT InitializeWithChildHandle([intptr]void* child);
HRESULT AttachTo(IAvnNativeControlHost* host);
void ShowInBounds(float x, float y, float width, float height);
void HideWithSize(float width, float height);

175
src/tools/MicroComGenerator/Ast.cs

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace MicroComGenerator.Ast
{
@ -14,13 +16,38 @@ namespace MicroComGenerator.Ast
}
public override string ToString() => $"{Name} = {Value}";
public AstAttributeNode Clone() => new AstAttributeNode(Name, Value);
}
public class AstEnumNode : List<AstEnumMemberNode>
public class AstAttributes : List<AstAttributeNode>
{
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public bool HasAttribute(string a) => this.Any(x => x.Name == a);
public AstAttributes Clone()
{
var rv= new AstAttributes();
rv.AddRange(this.Select(x => x.Clone()));
return rv;
}
}
public interface IAstNodeWithAttributes
{
public AstAttributes Attributes { get; set; }
}
public class AstEnumNode : List<AstEnumMemberNode>, IAstNodeWithAttributes
{
public AstAttributes Attributes { get; set; } = new AstAttributes();
public string Name { get; set; }
public override string ToString() => Name;
public override string ToString() => "Enum " + Name;
public AstEnumNode Clone()
{
var rv = new AstEnumNode { Name = Name, Attributes = Attributes.Clone() };
rv.AddRange(this.Select(x => x.Clone()));
return rv;
}
}
public class AstEnumMemberNode
@ -34,14 +61,22 @@ namespace MicroComGenerator.Ast
Value = value;
}
public override string ToString() => $"{Name} = {Value}";
public override string ToString() => $"Enum member {Name} = {Value}";
public AstEnumMemberNode Clone() => new AstEnumMemberNode(Name, Value);
}
public class AstStructNode : List<AstStructMemberNode>
public class AstStructNode : List<AstStructMemberNode>, IAstNodeWithAttributes
{
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public AstAttributes Attributes { get; set; } = new AstAttributes();
public string Name { get; set; }
public override string ToString() => Name;
public override string ToString() => "Struct " + Name;
public AstStructNode Clone()
{
var rv = new AstStructNode { Name = Name, Attributes = Attributes.Clone() };
rv.AddRange(this.Select(x => x.Clone()));
return rv;
}
}
public class AstTypeNode
@ -49,20 +84,24 @@ namespace MicroComGenerator.Ast
public string Name { get; set; }
public int PointerLevel { get; set; }
public override string ToString() => Name + new string('*', PointerLevel);
public string Format() => Name + new string('*', PointerLevel);
public override string ToString() => Format();
public AstTypeNode Clone() => new AstTypeNode() { Name = Name, PointerLevel = PointerLevel };
}
public class AstStructMemberNode
public class AstStructMemberNode : IAstNodeWithAttributes
{
public string Name { get; set; }
public AstTypeNode Type { get; set; }
public override string ToString() => $"{Type} {Name}";
public override string ToString() => $"Struct member {Type.Format()} {Name}";
public AstStructMemberNode Clone() => new AstStructMemberNode() { Name = Name, Type = Type.Clone() };
public AstAttributes Attributes { get; set; } = new AstAttributes();
}
public class AstInterfaceNode : List<AstInterfaceMemberNode>
public class AstInterfaceNode : List<AstInterfaceMemberNode>, IAstNodeWithAttributes
{
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public AstAttributes Attributes { get; set; } = new AstAttributes();
public string Name { get; set; }
public string Inherits { get; set; }
@ -70,33 +109,127 @@ namespace MicroComGenerator.Ast
{
if (Inherits == null)
return Name;
return $"{Name} : {Inherits}";
return $"Interface {Name} : {Inherits}";
}
public AstInterfaceNode Clone()
{
var rv = new AstInterfaceNode { Name = Name, Inherits = Inherits, Attributes = Attributes.Clone() };
rv.AddRange(this.Select(x => x.Clone()));
return rv;
}
}
public class AstInterfaceMemberNode : List<AstInterfaceMemberArgumentNode>
public class AstInterfaceMemberNode : List<AstInterfaceMemberArgumentNode>, IAstNodeWithAttributes
{
public string Name { get; set; }
public AstTypeNode ReturnType { get; set; }
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public AstAttributes Attributes { get; set; } = new AstAttributes();
public override string ToString() => $"{ReturnType} {Name} ({string.Join(", ", this)})";
public AstInterfaceMemberNode Clone()
{
var rv = new AstInterfaceMemberNode()
{
Name = Name, Attributes = Attributes.Clone(), ReturnType = ReturnType
};
rv.AddRange(this.Select(x => x.Clone()));
return rv;
}
public override string ToString() =>
$"Interface member {ReturnType.Format()} {Name} ({string.Join(", ", this.Select(x => x.Format()))})";
}
public class AstInterfaceMemberArgumentNode
public class AstInterfaceMemberArgumentNode : IAstNodeWithAttributes
{
public string Name { get; set; }
public AstTypeNode Type { get; set; }
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public AstAttributes Attributes { get; set; } = new AstAttributes();
public string Format() => $"{Type.Format()} {Name}";
public override string ToString() => "Argument " + Format();
public override string ToString() => $"{Type} {Name}";
public AstInterfaceMemberArgumentNode Clone() => new AstInterfaceMemberArgumentNode
{
Name = Name, Type = Type.Clone(), Attributes = Attributes.Clone()
};
}
public class AstIdlNode
public static class AstExtensions
{
public List<AstAttributeNode> Attributes { get; set; } = new List<AstAttributeNode>();
public static bool HasAttribute(this IAstNodeWithAttributes node, string s) => node.Attributes.HasAttribute(s);
public static string GetAttribute(this IAstNodeWithAttributes node, string s)
{
var value = node.Attributes.FirstOrDefault(a => a.Name == s)?.Value;
if (value == null)
throw new CodeGenException("Expected attribute " + s + " for node " + node);
return value;
}
public static string GetAttributeOrDefault(this IAstNodeWithAttributes node, string s)
=> node.Attributes.FirstOrDefault(a => a.Name == s)?.Value;
}
class AstVisitor
{
protected virtual void VisitType(AstTypeNode type)
{
}
protected virtual void VisitArgument(AstInterfaceMemberArgumentNode argument)
{
VisitType(argument.Type);
}
protected virtual void VisitInterfaceMember(AstInterfaceMemberNode member)
{
foreach(var a in member)
VisitArgument(a);
VisitType(member.ReturnType);
}
protected virtual void VisitInterface(AstInterfaceNode iface)
{
foreach(var m in iface)
VisitInterfaceMember(m);
}
protected virtual void VisitStructMember(AstStructMemberNode member)
{
VisitType(member.Type);
}
protected virtual void VisitStruct(AstStructNode node)
{
foreach(var m in node)
VisitStructMember(m);
}
public virtual void VisitAst(AstIdlNode ast)
{
foreach(var iface in ast.Interfaces)
VisitInterface(iface);
foreach (var s in ast.Structs)
VisitStruct(s);
}
}
public class AstIdlNode : IAstNodeWithAttributes
{
public AstAttributes Attributes { get; set; } = new AstAttributes();
public List<AstEnumNode> Enums { get; set; } = new List<AstEnumNode>();
public List<AstStructNode> Structs { get; set; } = new List<AstStructNode>();
public List<AstInterfaceNode> Interfaces { get; set; } = new List<AstInterfaceNode>();
public AstIdlNode Clone() => new AstIdlNode()
{
Attributes = Attributes.Clone(),
Enums = Enums.Select(x => x.Clone()).ToList(),
Structs = Structs.Select(x => x.Clone()).ToList(),
Interfaces = Interfaces.Select(x => x.Clone()).ToList()
};
}
}

17
src/tools/MicroComGenerator/AstParser.cs

@ -27,9 +27,9 @@ namespace MicroComGenerator
return idl;
}
static List<AstAttributeNode> ParseGlobalAttributes(ref TokenParser parser)
static AstAttributes ParseGlobalAttributes(ref TokenParser parser)
{
var rv = new List<AstAttributeNode>();
var rv = new AstAttributes();
while (!parser.Eof)
{
parser.SkipWhitespace();
@ -61,9 +61,9 @@ namespace MicroComGenerator
return rv;
}
static List<AstAttributeNode> ParseLocalAttributes(ref TokenParser parser)
static AstAttributes ParseLocalAttributes(ref TokenParser parser)
{
var rv = new List<AstAttributeNode>();
var rv = new AstAttributes();
if (parser.TryConsume("["))
{
while (!parser.TryConsume("]") && !parser.Eof)
@ -107,7 +107,7 @@ namespace MicroComGenerator
throw new ParseException("{ expected", ref parser);
}
static AstEnumNode ParseEnum(List<AstAttributeNode> attrs, ref TokenParser parser)
static AstEnumNode ParseEnum(AstAttributes attrs, ref TokenParser parser)
{
var name = parser.ParseIdentifier();
EnsureOpenBracket(ref parser);
@ -149,13 +149,14 @@ namespace MicroComGenerator
return t;
}
static AstStructNode ParseStruct(List<AstAttributeNode> attrs, ref TokenParser parser)
static AstStructNode ParseStruct(AstAttributes attrs, ref TokenParser parser)
{
var name = parser.ParseIdentifier();
EnsureOpenBracket(ref parser);
var rv = new AstStructNode { Name = name, Attributes = attrs };
while (!parser.TryConsume('}') && !parser.Eof)
{
var memberAttrs = ParseLocalAttributes(ref parser);
var t = ParseType(ref parser);
bool parsedAtLeastOneMember = false;
while (!parser.TryConsume(';'))
@ -165,7 +166,7 @@ namespace MicroComGenerator
var ident = parser.ParseIdentifier();
parsedAtLeastOneMember = true;
rv.Add(new AstStructMemberNode { Name = ident, Type = t });
rv.Add(new AstStructMemberNode { Name = ident, Type = t, Attributes = memberAttrs});
}
if (!parsedAtLeastOneMember)
@ -175,7 +176,7 @@ namespace MicroComGenerator
return rv;
}
static AstInterfaceNode ParseInterface(List<AstAttributeNode> interfaceAttrs, ref TokenParser parser)
static AstInterfaceNode ParseInterface(AstAttributes interfaceAttrs, ref TokenParser parser)
{
var interfaceName = parser.ParseIdentifier();
string inheritsFrom = null;

18
src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs

@ -167,12 +167,12 @@ namespace MicroComGenerator
if (type.PointerLevel == 2)
{
if (type.Name.StartsWith("I"))
if (IsInterface(type))
return new InterfaceReturnArg { Name = name, InterfaceType = type.Name, NativeType = "void**" };
}
else if (type.PointerLevel == 1)
{
if (type.Name.StartsWith("I"))
if (IsInterface(type))
return new InterfaceArg { Name = name, InterfaceType = type.Name, NativeType = "void*" };
if (type.Name == "char")
return new StringArg { Name = name, NativeType = "byte*" };
@ -197,8 +197,7 @@ namespace MicroComGenerator
&& args.Count > 0
&& (args.Last().Name == "ppv" || args.Last().Name == "retOut" || args.Last().Name == "ret")
&& ((member.Last().Type.PointerLevel > 0
&& !member.Last().Type.Name
.StartsWith("I"))
&& !IsInterface(member.Last().Type))
|| member.Last().Type.PointerLevel == 2);
bool isVoidReturn = member.ReturnType.Name == "void" && member.ReturnType.PointerLevel == 0;
@ -390,21 +389,20 @@ namespace MicroComGenerator
void GenerateInterface(ref NamespaceDeclarationSyntax ns, ref NamespaceDeclarationSyntax implNs,
AstInterfaceNode iface)
{
var guidString = iface.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value;
if (guidString == null)
throw new CodeGenException("Missing GUID for " + iface.Name);
var guidString = iface.GetAttribute("uuid");
var inheritsUnknown = iface.Inherits == null || iface.Inherits == "IUnknown";
var ifaceDec = InterfaceDeclaration(iface.Name)
.WithBaseType(inheritsUnknown ? "Avalonia.MicroCom.IUnknown" : iface.Inherits)
.AddModifiers(Token(_visibility), Token(SyntaxKind.UnsafeKeyword));
.AddModifiers(Token(_visibility), Token(SyntaxKind.UnsafeKeyword), Token(SyntaxKind.PartialKeyword));
var proxyClassName = "__MicroCom" + iface.Name + "Proxy";
var proxy = ClassDeclaration(proxyClassName)
.AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility))
.AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility), Token(SyntaxKind.PartialKeyword))
.WithBaseType(inheritsUnknown ?
"Avalonia.MicroCom.MicroComProxyBase" :
("__MicroCom" + iface.Inherits + "Proxy"));
("__MicroCom" + iface.Inherits + "Proxy"))
.AddBaseListTypes(SimpleBaseType(ParseTypeName(iface.Name)));
// Generate vtable

25
src/tools/MicroComGenerator/CSharpGen.Utils.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MicroComGenerator.Ast;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Formatting;
@ -23,13 +24,16 @@ namespace MicroComGenerator
string Format(CompilationUnitSyntax unit)
{
var cw = new AdhocWorkspace();
return Microsoft.CodeAnalysis.Formatting.Formatter.Format(unit.NormalizeWhitespace(), cw, cw.Options
.WithChangedOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, true)
.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, true)
.WithChangedOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, true)
.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true)
return
"#pragma warning disable 108\n" +
Microsoft.CodeAnalysis.Formatting.Formatter.Format(unit.NormalizeWhitespace(), cw, cw.Options
.WithChangedOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, true)
.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers,
true)
.WithChangedOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, true)
.WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true)
).ToFullString();
).ToFullString();
}
@ -93,5 +97,14 @@ namespace MicroComGenerator
return decl.ReplaceNodes(replace.Keys, (m, m2) => replace[m]);
}
bool IsInterface(string name)
{
if (name == "IUnknown")
return true;
return _idl.Interfaces.Any(i => i.Name == name);
}
private bool IsInterface(AstTypeNode type) => IsInterface(type.Name);
}
}

52
src/tools/MicroComGenerator/CSharpGen.cs

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
@ -20,14 +21,12 @@ namespace MicroComGenerator
public CSharpGen(AstIdlNode idl)
{
_idl = idl;
_idl = idl.Clone();
new AstRewriter().VisitAst(_idl);
_extraUsings = _idl.Attributes.Where(u => u.Name == "clr-using").Select(u => u.Value).ToList();
_namespace = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-namespace")?.Value;
if (_namespace == null)
throw new CodeGenException("Missing clr-namespace attribute");
var visibilityString = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-access")?.Value;
if (visibilityString == null)
throw new CodeGenException("Missing clr-visibility attribute");
_namespace = _idl.GetAttribute("clr-namespace");
var visibilityString = _idl.GetAttribute("clr-access");
if (visibilityString == "internal")
_visibility = SyntaxKind.InternalKeyword;
else if (visibilityString == "public")
@ -36,6 +35,45 @@ namespace MicroComGenerator
throw new CodeGenException("Invalid clr-access attribute");
}
class AstRewriter : AstVisitor
{
void ConvertIntPtr(AstTypeNode type)
{
if (type.Name == "void" && type.PointerLevel > 0)
{
type.Name = "IntPtr";
type.PointerLevel--;
}
}
protected override void VisitStructMember(AstStructMemberNode member)
{
if (member.HasAttribute("intptr"))
ConvertIntPtr(member.Type);
base.VisitStructMember(member);
}
protected override void VisitArgument(AstInterfaceMemberArgumentNode argument)
{
if (argument.HasAttribute("intptr"))
{
if(argument.Name == "retOut")
Console.WriteLine();
ConvertIntPtr(argument.Type);
}
base.VisitArgument(argument);
}
protected override void VisitInterfaceMember(AstInterfaceMemberNode member)
{
if (member.HasAttribute("intptr"))
ConvertIntPtr(member.ReturnType);
base.VisitInterfaceMember(member);
}
}
public string Generate()
{
var ns = NamespaceDeclaration(ParseName(_namespace));

7
src/tools/MicroComGenerator/CppGen.cs

@ -20,7 +20,7 @@ namespace MicroComGenerator
public static string GenerateCpp(AstIdlNode idl)
{
var sb = new StringBuilder();
var preamble = idl.Attributes.FirstOrDefault(x => x.Name == "cpp-preamble")?.Value;
var preamble = idl.GetAttributeOrDefault("cpp-preamble");
if (preamble != null)
sb.AppendLine(preamble);
@ -60,10 +60,7 @@ namespace MicroComGenerator
foreach (var i in idl.Interfaces)
{
var guidString = i.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value;
if (guidString == null)
throw new CodeGenException("Missing uuid for " + i.Name);
var guidString = i.GetAttribute("uuid");
var guid = Guid.Parse(guidString).ToString().Replace("-", "");

2
src/tools/MicroComGenerator/MicroComGenerator.csproj

@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
@ -8,5 +7,4 @@
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0" />
</ItemGroup>
</Project>

Loading…
Cancel
Save