From 7fa2c8495690b0af1699b87ed62cd273fbd91e59 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 31 Jul 2020 20:28:04 +0300 Subject: [PATCH 01/35] Add handling mouse events in webapp --- .../webapp/src/FramePresenter.tsx | 25 ++++++++++++- .../src/Models/Input/InputEventMessageBase.ts | 11 ++++++ .../webapp/src/Models/Input/InputModifiers.ts | 9 +++++ .../webapp/src/Models/Input/MouseButton.ts | 6 +++ .../src/Models/Input/MouseEventHelpers.ts | 37 +++++++++++++++++++ .../Models/Input/PointerEventMessageBase.ts | 13 +++++++ .../Models/Input/PointerMovedEventMessage.ts | 12 ++++++ .../Input/PointerPressedEventMessage.ts | 17 +++++++++ .../Input/PointerReleasedEventMessage.ts | 17 +++++++++ 9 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index 0059cfe683..ce43822dd8 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -1,5 +1,8 @@ -import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConnection"; import * as React from "react"; +import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConnection"; +import {PointerPressedEventMessage} from "src/Models/Input/PointerPressedEventMessage"; +import {PointerReleasedEventMessage} from "src/Models/Input/PointerReleasedEventMessage"; +import {PointerMovedEventMessage} from "src/Models/Input/PointerMovedEventMessage"; interface PreviewerPresenterProps { conn: PreviewerServerConnection; @@ -51,7 +54,25 @@ export class PreviewerPresenter extends React.Component } } + handleMouseDown(e: React.MouseEvent) { + const pointerPressedEventMessage = new PointerPressedEventMessage(e); + // TODO: Send message to server + } + + handleMouseUp(e: React.MouseEvent) { + const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); + // TODO: Send message to server + } + + handleMouseMove(e: React.MouseEvent) { + const pointerMovedEventMessage = new PointerMovedEventMessage(e); + // TODO: Send message to server + } + render() { - return + return } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts new file mode 100644 index 0000000000..2da7424e2a --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts @@ -0,0 +1,11 @@ +import * as React from "react"; +import {InputModifiers} from "src/Models/Input/InputModifiers"; +import {getModifiers} from "src/Models/Input/MouseEventHelpers"; + +export abstract class InputEventMessageBase { + public readonly modifiers : Array; + + protected constructor(e: React.MouseEvent) { + this.modifiers = getModifiers(e); + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts new file mode 100644 index 0000000000..483b4c02d0 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts @@ -0,0 +1,9 @@ +export enum InputModifiers { + Alt, + Control, + Shift, + Windows, + LeftMouseButton, + RightMouseButton, + MiddleMouseButton, +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts new file mode 100644 index 0000000000..880f8fb5ce --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts @@ -0,0 +1,6 @@ +export enum MouseButton { + None, + Left, + Right, + Middle, +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts new file mode 100644 index 0000000000..783bacad38 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -0,0 +1,37 @@ +import * as React from "react"; +import {InputModifiers} from "src/Models/Input/InputModifiers"; +import {MouseButton} from "src/Models/Input/MouseButton"; + +export function getModifiers(e: React.MouseEvent): Array { + + let modifiers : Array = []; + + if (e.altKey) + modifiers.push(InputModifiers.Alt); + if (e.ctrlKey) + modifiers.push(InputModifiers.Control); + if (e.shiftKey) + modifiers.push(InputModifiers.Shift); + if (e.metaKey) + modifiers.push(InputModifiers.Windows); + if ((e.buttons & 1) != 0) + modifiers.push(InputModifiers.LeftMouseButton); + if ((e.buttons & 2) != 0) + modifiers.push(InputModifiers.RightMouseButton); + if ((e.buttons & 4) != 0) + modifiers.push(InputModifiers.MiddleMouseButton); + + return modifiers; +} + +export function getMouseButton(e: React.MouseEvent) : MouseButton { + if (e.button == 1) { + return MouseButton.Left; + } else if (e.button == 2) { + return MouseButton.Right; + } else if (e.button == 4) { + return MouseButton.Middle + } else { + return MouseButton.None; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts new file mode 100644 index 0000000000..e43362ac1c --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -0,0 +1,13 @@ +import * as React from "react"; +import {InputEventMessageBase} from "src/Models/Input/InputEventMessageBase"; + +export abstract class PointerEventMessageBase extends InputEventMessageBase { + public readonly x: number; + public readonly y: number; + + protected constructor(e: React.MouseEvent) { + super(e) + this.x = e.clientX; + this.y = e.clientY; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts new file mode 100644 index 0000000000..3ca8e91b8d --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -0,0 +1,12 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; + +export class PointerMovedEventMessage extends PointerEventMessageBase { + constructor(e: React.MouseEvent) { + super(e) + } + + public toString = () : string => { + return `pointer-moved:${this.modifiers}:${this.x}:${this.y}`; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts new file mode 100644 index 0000000000..712ec64a14 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {MouseButton} from "src/Models/Input/MouseButton"; +import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; + +export class PointerPressedEventMessage extends PointerEventMessageBase { + public readonly button: MouseButton + + constructor(e: React.MouseEvent) { + super(e) + this.button = getMouseButton(e); + } + + public toString = () : string => { + return `pointer-pressed:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts new file mode 100644 index 0000000000..46234263db --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {MouseButton} from "src/Models/Input/MouseButton"; +import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; + +export class PointerReleasedEventMessage extends PointerEventMessageBase { + public readonly button: MouseButton + + constructor(e: React.MouseEvent) { + super(e) + this.button = getMouseButton(e); + } + + public toString = () : string => { + return `pointer-released:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + } +} From 23d29d445c316df9718d598f5439951d2fb993c7 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sun, 9 Aug 2020 19:54:13 +0300 Subject: [PATCH 02/35] Add message sending and server processing --- .../Remote/HtmlTransport/HtmlTransport.cs | 71 +++++++++++++++++-- .../webapp/src/FramePresenter.tsx | 10 ++- .../webapp/src/PreviewerServerConnection.ts | 6 ++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 55e2df8890..eb64f83d35 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Viewport; +using InputProtocol = Avalonia.Remote.Protocol.Input; namespace Avalonia.DesignerSupport.Remote.HtmlTransport { @@ -117,10 +118,55 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport return; if (msg.IsText) { - var s = Encoding.UTF8.GetString(msg.Data); - var parts = s.Split(':'); - if (parts[0] == "frame-received") - _onMessage?.Invoke(this, new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + var parts = msg.AsString().Split(':'); + switch (parts[0]) + { + case "frame-received": + { + _onMessage?.Invoke( + this, + new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + break; + } + case "pointer-released": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + Button = ParseMouseButton(parts[2]), + X = double.Parse(parts[3]), + Y = double.Parse(parts[4]), + }); + break; + } + case "pointer-pressed": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + Button = ParseMouseButton(parts[2]), + X = double.Parse(parts[3]), + Y = double.Parse(parts[4]), + }); + break; + } + case "pointer-moved": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + }); + break; + } + } } } } @@ -262,5 +308,22 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport _onException?.Invoke(this, ex); } #endregion + + private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) + { + var enumTexts = modifiersText.Split(','); + if (string.IsNullOrEmpty(enumTexts[0])) + return new InputProtocol.InputModifiers[0]; + return enumTexts + .Select(x => (InputProtocol.InputModifiers)Enum.Parse( + typeof(InputProtocol.InputModifiers), x)) + .ToArray(); + } + + private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => + string.IsNullOrEmpty(buttonText) + ? InputProtocol.MouseButton.None + : (InputProtocol.MouseButton)Enum.Parse( + typeof(InputProtocol.MouseButton), buttonText); } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index ce43822dd8..b35e611c95 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -18,6 +18,10 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); + + this.handleMouseDown = this.handleMouseDown.bind(this); + this.handleMouseUp = this.handleMouseUp.bind(this); + this.handleMouseMove = this.handleMouseMove.bind(this); } componentDidMount(): void { @@ -56,17 +60,17 @@ export class PreviewerPresenter extends React.Component handleMouseDown(e: React.MouseEvent) { const pointerPressedEventMessage = new PointerPressedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerPressedEventMessage); } handleMouseUp(e: React.MouseEvent) { const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerReleasedEventMessage); } handleMouseMove(e: React.MouseEvent) { const pointerMovedEventMessage = new PointerMovedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerMovedEventMessage); } render() { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts index 891c5094e7..7f1ab84f99 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts @@ -1,3 +1,5 @@ +import { InputEventMessageBase } from "src/Models/Input/InputEventMessageBase"; + export interface PreviewerFrame { data: ImageData; dpiX: number; @@ -28,6 +30,10 @@ export class PreviewerServerConnection { this.handlers.delete(listener); } + public sendMouseEvent(message: InputEventMessageBase) { + this.conn.send(message.toString()); + } + constructor(uri: string) { this.currentFrame = null; var conn = this.conn = new WebSocket(uri); From 851c03fa70d53675edc2693ed23299ca8c407bef Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Mon, 10 Aug 2020 17:08:53 +0300 Subject: [PATCH 03/35] Add handling wheel --- .../Remote/HtmlTransport/HtmlTransport.cs | 26 ++++++++++++++----- .../webapp/src/FramePresenter.tsx | 11 +++++++- .../Models/Input/PointerEventMessageBase.ts | 2 +- .../Models/Input/PointerMovedEventMessage.ts | 2 +- .../Input/PointerPressedEventMessage.ts | 4 +-- .../Input/PointerReleasedEventMessage.ts | 4 +-- .../src/Models/Input/ScrollEventMessage.ts | 17 ++++++++++++ 7 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index eb64f83d35..c32aefe308 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -135,9 +135,9 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerReleasedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - Button = ParseMouseButton(parts[2]), - X = double.Parse(parts[3]), - Y = double.Parse(parts[4]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), }); break; } @@ -148,9 +148,9 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerPressedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - Button = ParseMouseButton(parts[2]), - X = double.Parse(parts[3]), - Y = double.Parse(parts[4]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), }); break; } @@ -166,6 +166,20 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport }); break; } + case "scroll": + { + _onMessage?.Invoke( + this, + new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + DeltaX = double.Parse(parts[4]), + DeltaY = double.Parse(parts[5]), + }); + break; + } } } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index b35e611c95..5182a087e7 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -3,6 +3,7 @@ import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConn import {PointerPressedEventMessage} from "src/Models/Input/PointerPressedEventMessage"; import {PointerReleasedEventMessage} from "src/Models/Input/PointerReleasedEventMessage"; import {PointerMovedEventMessage} from "src/Models/Input/PointerMovedEventMessage"; +import {ScrollEventMessage} from "src/Models/Input/ScrollEventMessage"; interface PreviewerPresenterProps { conn: PreviewerServerConnection; @@ -22,6 +23,7 @@ export class PreviewerPresenter extends React.Component this.handleMouseDown = this.handleMouseDown.bind(this); this.handleMouseUp = this.handleMouseUp.bind(this); this.handleMouseMove = this.handleMouseMove.bind(this); + this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -73,10 +75,17 @@ export class PreviewerPresenter extends React.Component this.props.conn.sendMouseEvent(pointerMovedEventMessage); } + handleWheel(e: React.WheelEvent) { + e.preventDefault(); + const scrollEventMessage = new ScrollEventMessage(e); + this.props.conn.sendMouseEvent(scrollEventMessage); + } + render() { return + onMouseMove={this.handleMouseMove} + onWheel={this.handleWheel} /> } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts index e43362ac1c..fc304c2965 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -6,7 +6,7 @@ export abstract class PointerEventMessageBase extends InputEventMessageBase { public readonly y: number; protected constructor(e: React.MouseEvent) { - super(e) + super(e); this.x = e.clientX; this.y = e.clientY; } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts index 3ca8e91b8d..cd135dfa39 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -3,7 +3,7 @@ import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase" export class PointerMovedEventMessage extends PointerEventMessageBase { constructor(e: React.MouseEvent) { - super(e) + super(e); } public toString = () : string => { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts index 712ec64a14..e75551e0b3 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -7,11 +7,11 @@ export class PointerPressedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton constructor(e: React.MouseEvent) { - super(e) + super(e); this.button = getMouseButton(e); } public toString = () : string => { - return `pointer-pressed:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + return `pointer-pressed:${this.modifiers}:${this.x}:${this.y}:${this.button}`; } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts index 46234263db..c2bc368323 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -7,11 +7,11 @@ export class PointerReleasedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton constructor(e: React.MouseEvent) { - super(e) + super(e); this.button = getMouseButton(e); } public toString = () : string => { - return `pointer-released:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + return `pointer-released:${this.modifiers}:${this.x}:${this.y}:${this.button}`; } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts new file mode 100644 index 0000000000..427ccc5e5e --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; + +export class ScrollEventMessage extends PointerEventMessageBase { + public readonly deltaX: number; + public readonly deltaY: number; + + constructor(e: React.WheelEvent) { + super(e); + this.deltaX = -e.deltaX; + this.deltaY = -e.deltaY; + } + + public toString = () : string => { + return `scroll:${this.modifiers}:${this.x}:${this.y}:${this.deltaX}:${this.deltaY}`; + } +} From 27f289e2bffb3ad0ecbc00eb0b327e41c14d520c Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Mon, 10 Aug 2020 23:21:59 +0300 Subject: [PATCH 04/35] Refactor --- .../Remote/HtmlTransport/HtmlTransport.cs | 141 +++++++++--------- .../webapp/src/FramePresenter.tsx | 13 +- 2 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index c32aefe308..51d266f11a 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -118,69 +118,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport return; if (msg.IsText) { - var parts = msg.AsString().Split(':'); - switch (parts[0]) - { - case "frame-received": - { - _onMessage?.Invoke( - this, - new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); - break; - } - case "pointer-released": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; - } - case "pointer-pressed": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; - } - case "pointer-moved": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - }); - break; - } - case "scroll": - { - _onMessage?.Invoke( - this, - new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - DeltaX = double.Parse(parts[4]), - DeltaY = double.Parse(parts[5]), - }); - break; - } - } + ProcessingReceiveMessage(msg.AsString()); } } } @@ -323,16 +261,81 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } #endregion - private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) + private void ProcessingReceiveMessage(string message) { - var enumTexts = modifiersText.Split(','); - if (string.IsNullOrEmpty(enumTexts[0])) - return new InputProtocol.InputModifiers[0]; - return enumTexts + var parts = message.Split(':'); + switch (parts[0]) + { + case "frame-received": + { + _onMessage?.Invoke( + this, + new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + break; + } + case "pointer-released": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), + }); + break; + } + case "pointer-pressed": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), + }); + break; + } + case "pointer-moved": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + }); + break; + } + case "scroll": + { + _onMessage?.Invoke( + this, + new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + DeltaX = double.Parse(parts[4]), + DeltaY = double.Parse(parts[5]), + }); + break; + } + } + } + + private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => + string.IsNullOrEmpty(modifiersText) + ? new InputProtocol.InputModifiers[0] + : modifiersText + .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( typeof(InputProtocol.InputModifiers), x)) .ToArray(); - } private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => string.IsNullOrEmpty(buttonText) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index 5182a087e7..ec8a1bab68 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -19,11 +19,6 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); - - this.handleMouseDown = this.handleMouseDown.bind(this); - this.handleMouseUp = this.handleMouseUp.bind(this); - this.handleMouseMove = this.handleMouseMove.bind(this); - this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -83,9 +78,9 @@ export class PreviewerPresenter extends React.Component render() { return + onMouseDown={this.handleMouseDown.bind(this)} + onMouseUp={this.handleMouseUp.bind(this)} + onMouseMove={this.handleMouseMove.bind(this)} + onWheel={this.handleWheel.bind(this)} /> } } From 162d6f8cedf4f06e49846bd6f182e86af5d5f27e Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 00:29:33 +0300 Subject: [PATCH 05/35] Return null instead of empty array --- .../Remote/HtmlTransport/HtmlTransport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 51d266f11a..361d35c0b7 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -330,7 +330,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => string.IsNullOrEmpty(modifiersText) - ? new InputProtocol.InputModifiers[0] + ? null : modifiersText .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( From f3718a5d034ab710e8416f9b76883f4f154c2a1b Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 01:52:33 +0300 Subject: [PATCH 06/35] revert bind and preventdefault --- .../HtmlTransport/webapp/src/FramePresenter.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index ec8a1bab68..96d2f45fdc 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -19,6 +19,11 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); + + this.handleMouseDown = this.handleMouseDown.bind(this); + this.handleMouseUp = this.handleMouseUp.bind(this); + this.handleMouseMove = this.handleMouseMove.bind(this); + this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -56,16 +61,19 @@ export class PreviewerPresenter extends React.Component } handleMouseDown(e: React.MouseEvent) { + e.preventDefault(); const pointerPressedEventMessage = new PointerPressedEventMessage(e); this.props.conn.sendMouseEvent(pointerPressedEventMessage); } handleMouseUp(e: React.MouseEvent) { + e.preventDefault(); const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); this.props.conn.sendMouseEvent(pointerReleasedEventMessage); } handleMouseMove(e: React.MouseEvent) { + e.preventDefault(); const pointerMovedEventMessage = new PointerMovedEventMessage(e); this.props.conn.sendMouseEvent(pointerMovedEventMessage); } @@ -78,9 +86,9 @@ export class PreviewerPresenter extends React.Component render() { return + onMouseDown={this.handleMouseDown} + onMouseUp={this.handleMouseUp} + onMouseMove={this.handleMouseMove} + onWheel={this.handleWheel} /> } } From 1cfa116cc325461c041c2ed2c17a367a2f759795 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 14:46:54 +0300 Subject: [PATCH 07/35] Fix typo in detect mouse button --- .../webapp/src/Models/Input/MouseEventHelpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts index 783bacad38..3f85959d6f 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -25,12 +25,12 @@ export function getModifiers(e: React.MouseEvent): Array { } export function getMouseButton(e: React.MouseEvent) : MouseButton { - if (e.button == 1) { + if (e.button == 0) { return MouseButton.Left; + } else if (e.button == 1) { + return MouseButton.Middle; } else if (e.button == 2) { return MouseButton.Right; - } else if (e.button == 4) { - return MouseButton.Middle } else { return MouseButton.None; } From 138404de4e0706b9e3dc4ba50b5ce296540745b3 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 29 Aug 2020 14:21:32 +0300 Subject: [PATCH 08/35] Fix double parse with InvariantCulture --- .../Remote/HtmlTransport/HtmlTransport.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 361d35c0b7..5946e2681c 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; @@ -280,8 +281,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerReleasedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), Button = ParseMouseButton(parts[4]), }); break; @@ -293,8 +294,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerPressedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), Button = ParseMouseButton(parts[4]), }); break; @@ -306,8 +307,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerMovedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), }); break; } @@ -318,10 +319,10 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.ScrollEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - DeltaX = double.Parse(parts[4]), - DeltaY = double.Parse(parts[5]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), }); break; } @@ -334,13 +335,16 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport : modifiersText .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( - typeof(InputProtocol.InputModifiers), x)) + typeof(InputProtocol.InputModifiers), x, true)) .ToArray(); private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => string.IsNullOrEmpty(buttonText) ? InputProtocol.MouseButton.None : (InputProtocol.MouseButton)Enum.Parse( - typeof(InputProtocol.MouseButton), buttonText); + typeof(InputProtocol.MouseButton), buttonText, true); + + private static double ParseDouble(string text) => + double.Parse(text, CultureInfo.InvariantCulture); } } From 26ae25d28dee5bd278da14c3a51800b8628d6037 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 29 Aug 2020 14:35:05 +0300 Subject: [PATCH 09/35] Refactor parsing message --- .../Remote/HtmlTransport/HtmlTransport.cs | 88 ++++++++----------- 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 5946e2681c..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -115,11 +115,11 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport while (true) { var msg = await socket.ReceiveMessage().ConfigureAwait(false); - if(msg == null) - return; - if (msg.IsText) + if(msg != null && msg.IsText) { - ProcessingReceiveMessage(msg.AsString()); + var message = ParseMessage(msg.AsString()); + if (message != null) + _onMessage?.Invoke(this, message); } } } @@ -178,7 +178,6 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport _pendingSocket?.Dispose(); _simpleServer.Dispose(); } - public Task Send(object data) { @@ -262,70 +261,57 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } #endregion - private void ProcessingReceiveMessage(string message) + private static object ParseMessage(string message) { var parts = message.Split(':'); switch (parts[0]) { case "frame-received": { - _onMessage?.Invoke( - this, - new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); - break; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } case "pointer-released": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; } case "pointer-pressed": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; } case "pointer-moved": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }); - break; + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; } case "scroll": { - _onMessage?.Invoke( - this, - new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }); - break; + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; } + default: + return null; } } @@ -345,6 +331,6 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport typeof(InputProtocol.MouseButton), buttonText, true); private static double ParseDouble(string text) => - double.Parse(text, CultureInfo.InvariantCulture); + double.Parse(text, NumberStyles.Float, CultureInfo.InvariantCulture); } } From cf42bc3bd0899545149d947127a1fa0bef8c97d9 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:12:44 +0300 Subject: [PATCH 10/35] Fix comparing strings with InvariantCultureIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..1d7fd91756 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,55 +264,53 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0]; + if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) { - case "frame-received": - { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - case "pointer-released": - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-pressed": - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-moved": - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - case "scroll": - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; - } - default: - return null; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } + else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + + return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From 4df6d86e0321f712177937ed5f7d82224f91c685 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:24:23 +0300 Subject: [PATCH 11/35] Revert "Fix comparing strings with InvariantCultureIgnoreCase" This reverts commit cf42bc3bd0899545149d947127a1fa0bef8c97d9. --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 1d7fd91756..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,53 +264,55 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - var key = parts[0]; - if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) + switch (parts[0]) { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; + case "frame-received": + { + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; + } + case "pointer-released": + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + case "pointer-pressed": + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + case "pointer-moved": + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + case "scroll": + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + default: + return null; } - - return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From c019f3a3f9ca84850aa24de75d111da7d87acf5a Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:27:30 +0300 Subject: [PATCH 12/35] Fix API key to lower invariant --- .../Remote/HtmlTransport/HtmlTransport.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..920f155cfd 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,7 +264,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0].ToLowerInvariant(); + switch (key) { case "frame-received": { From fe1a847847df1179201709db1a11d35e09abc54a Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:42:50 +0300 Subject: [PATCH 13/35] Revert "Fix API key to lower invariant" This reverts commit c019f3a3f9ca84850aa24de75d111da7d87acf5a. --- .../Remote/HtmlTransport/HtmlTransport.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 920f155cfd..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,8 +264,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - var key = parts[0].ToLowerInvariant(); - switch (key) + switch (parts[0]) { case "frame-received": { From 5f4f52f78d4075731f878526632a30ffbd664c68 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:43:43 +0300 Subject: [PATCH 14/35] Fix comparing strings with InvariantCultureIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..1d7fd91756 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,55 +264,53 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0]; + if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) { - case "frame-received": - { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - case "pointer-released": - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-pressed": - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-moved": - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - case "scroll": - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; - } - default: - return null; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } + else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + + return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From 1025b1240247793e19415e797100882952dc4043 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 00:27:05 +0500 Subject: [PATCH 15/35] Add tests --- .editorconfig | 3 + .../src/Models/Input/InputEventMessageBase.ts | 4 +- .../src/Models/Input/MouseEventHelpers.ts | 18 +- .../Models/Input/PointerEventMessageBase.ts | 2 +- .../Models/Input/PointerMovedEventMessage.ts | 2 +- .../Input/PointerPressedEventMessage.ts | 6 +- .../Input/PointerReleasedEventMessage.ts | 6 +- .../src/Models/Input/ScrollEventMessage.ts | 2 +- .../Remote/HtmlTransport/webapp/.gitignore | 2 + .../webapp/Models/InputEventTests.ts | 73 + .../HtmlTransport/webapp/package-lock.json | 2414 +++++++++++++++++ .../Remote/HtmlTransport/webapp/package.json | 26 + .../Remote/HtmlTransport/webapp/tsconfig.json | 12 + 13 files changed, 2551 insertions(+), 19 deletions(-) create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json diff --git a/.editorconfig b/.editorconfig index f6bce9cb76..c7a381b730 100644 --- a/.editorconfig +++ b/.editorconfig @@ -156,6 +156,9 @@ indent_size = 2 [*.{props,targets,config,nuspec}] indent_size = 2 +[*.json] +indent_size = 2 + # Shell scripts [*.sh] end_of_line = lf diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts index 2da7424e2a..bfe5aad093 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts @@ -1,6 +1,6 @@ import * as React from "react"; -import {InputModifiers} from "src/Models/Input/InputModifiers"; -import {getModifiers} from "src/Models/Input/MouseEventHelpers"; +import {InputModifiers} from "./InputModifiers"; +import {getModifiers} from "./MouseEventHelpers"; export abstract class InputEventMessageBase { public readonly modifiers : Array; diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts index 3f85959d6f..f2cd1f4d46 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -1,6 +1,6 @@ import * as React from "react"; -import {InputModifiers} from "src/Models/Input/InputModifiers"; -import {MouseButton} from "src/Models/Input/MouseButton"; +import {InputModifiers} from "./InputModifiers"; +import {MouseButton} from "./MouseButton"; export function getModifiers(e: React.MouseEvent): Array { @@ -14,12 +14,14 @@ export function getModifiers(e: React.MouseEvent): Array { modifiers.push(InputModifiers.Shift); if (e.metaKey) modifiers.push(InputModifiers.Windows); - if ((e.buttons & 1) != 0) - modifiers.push(InputModifiers.LeftMouseButton); - if ((e.buttons & 2) != 0) - modifiers.push(InputModifiers.RightMouseButton); - if ((e.buttons & 4) != 0) - modifiers.push(InputModifiers.MiddleMouseButton); + if (e.buttons != 0) { + if ((e.buttons & 1) != 0) + modifiers.push(InputModifiers.LeftMouseButton); + if ((e.buttons & 2) != 0) + modifiers.push(InputModifiers.RightMouseButton); + if ((e.buttons & 4) != 0) + modifiers.push(InputModifiers.MiddleMouseButton); + } return modifiers; } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts index fc304c2965..c9de132ff4 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {InputEventMessageBase} from "src/Models/Input/InputEventMessageBase"; +import {InputEventMessageBase} from "./InputEventMessageBase"; export abstract class PointerEventMessageBase extends InputEventMessageBase { public readonly x: number; diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts index cd135dfa39..3f782d1d46 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; export class PointerMovedEventMessage extends PointerEventMessageBase { constructor(e: React.MouseEvent) { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts index e75551e0b3..0ae06cc064 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -1,7 +1,7 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; -import {MouseButton} from "src/Models/Input/MouseButton"; -import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; +import {MouseButton} from "./MouseButton"; +import {getMouseButton} from "./MouseEventHelpers"; export class PointerPressedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts index c2bc368323..fb1477b554 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -1,7 +1,7 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; -import {MouseButton} from "src/Models/Input/MouseButton"; -import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; +import {MouseButton} from "./MouseButton"; +import {getMouseButton} from "./MouseEventHelpers"; export class PointerReleasedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts index 427ccc5e5e..b11be19d82 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; export class ScrollEventMessage extends PointerEventMessageBase { public readonly deltaX: number; diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore new file mode 100644 index 0000000000..e3fbd98336 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore @@ -0,0 +1,2 @@ +build +node_modules diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts new file mode 100644 index 0000000000..061bb74be7 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts @@ -0,0 +1,73 @@ +import {describe} from 'mocha'; +import {expect} from 'chai'; +import {Mock} from "moq.ts"; +import {MouseEvent, WheelEvent} from "react"; +import {InputModifiers} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; +import {MouseButton} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; +import {PointerMovedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; +import {PointerPressedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; +import {PointerReleasedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; +import {ScrollEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; + +const x = .3 +const y = .42 +const modifiers = [ + InputModifiers.Alt, + InputModifiers.Control, + InputModifiers.Shift, + InputModifiers.Windows, + InputModifiers.LeftMouseButton, + InputModifiers.RightMouseButton, + InputModifiers.MiddleMouseButton +] + +const button = MouseButton.Left + +const deltaX = -3. +const deltaY = -3. + +const mouseEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.button).returns(0) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .object() + +const wheelEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .setup(x => x.deltaX).returns(-deltaX) + .setup(x => x.deltaY).returns(-deltaY) + .object() + +describe("Input event tests", () => { + it("PointerMovedEventMessage", () => { + const message = new PointerMovedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-moved:${modifiers}:${x}:${y}`) + }) + it("PointerPressedEventMessage", () => { + const message = new PointerPressedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) + }) + it("PointerReleasedEventMessage", () => { + const message = new PointerReleasedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) + }) + it("ScrollEventMessage", () => { + const message = new ScrollEventMessage(wheelEvent) + expect(message.toString()) + .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + }) +}) diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json new file mode 100644 index 0000000000..eb707cb73f --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json @@ -0,0 +1,2414 @@ +{ + "name": "simple-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, + "@babel/core": { + "version": "7.11.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.6.tgz", + "integrity": "sha512-Wpcv03AGnmkgm6uS6k8iwhIwTrcP0m17TL1n1sy7qD0qelDu4XNeW0dN0mHfa+Gei211yDaLoEe/VlbXQzM4Bg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.11.6", + "@babel/helper-module-transforms": "^7.11.0", + "@babel/helpers": "^7.10.4", + "@babel/parser": "^7.11.5", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.11.5", + "@babel/types": "^7.11.5", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", + "json5": "^2.1.2", + "lodash": "^4.17.19", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.11.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.6.tgz", + "integrity": "sha512-DWtQ1PV3r+cLbySoHrwn9RWEgKMBLLma4OBQloPRyDYvc5msJM9kvTLo1YnlJd1P/ZuKbdli3ijr5q3FvAF3uA==", + "dev": true, + "requires": { + "@babel/types": "^7.11.5", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz", + "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz", + "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.11.0.tgz", + "integrity": "sha512-JbFlKHFntRV5qKw3YC0CvQnDZ4XMwgzzBbld7Ly4Mj4cbFy3KywcR8NtNctRToMWJOVvLINJv525Gd6wwVEx/Q==", + "dev": true, + "requires": { + "@babel/types": "^7.11.0" + } + }, + "@babel/helper-module-imports": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz", + "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-module-transforms": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.11.0.tgz", + "integrity": "sha512-02EVu8COMuTRO1TAzdMtpBPbe6aQ1w/8fePD2YgQmxZU4gpNWaL9gK3Jp7dxlkUlUCJOTaSeA+Hrm1BRQwqIhg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-simple-access": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.11.0", + "@babel/template": "^7.10.4", + "@babel/types": "^7.11.0", + "lodash": "^4.17.19" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", + "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-replace-supers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz", + "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-simple-access": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz", + "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz", + "integrity": "sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg==", + "dev": true, + "requires": { + "@babel/types": "^7.11.0" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", + "dev": true + }, + "@babel/helpers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz", + "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/highlight": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@babel/parser": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.5.tgz", + "integrity": "sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==", + "dev": true + }, + "@babel/template": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz", + "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/traverse": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.11.5.tgz", + "integrity": "sha512-EjiPXt+r7LiCZXEfRpSJd+jUMnBd4/9OUv7Nx3+0u9+eimMwJmG0Q98lw4/289JCoxSE8OolDMNZaaF/JZ69WQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.11.5", + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.11.0", + "@babel/parser": "^7.11.5", + "@babel/types": "^7.11.5", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.19" + } + }, + "@babel/types": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.11.5.tgz", + "integrity": "sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "lodash": "^4.17.19", + "to-fast-properties": "^2.0.0" + } + }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", + "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", + "dev": true + }, + "@types/chai": { + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.12.tgz", + "integrity": "sha512-aN5IAC8QNtSUdQzxu7lGBgYAOuU1tmRU4c9dIq5OKGf/SBVjXo+ffM2wEjudAWbgpOhy60nLoAGH1xm8fpCKFQ==", + "dev": true + }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, + "@types/mocha": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.3.tgz", + "integrity": "sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg==", + "dev": true + }, + "@types/prop-types": { + "version": "15.7.3", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", + "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==", + "dev": true + }, + "@types/react": { + "version": "16.9.49", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.49.tgz", + "integrity": "sha512-DtLFjSj0OYAdVLBbyjhuV9CdGVHCkHn2R+xr3XkBvK2rS1Y1tkc14XSGjYgm5Fjjr90AxH9tiSzc1pCFMGO06g==", + "dev": true, + "requires": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, + "aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "requires": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "requires": { + "default-require-extensions": "^3.0.0" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "array.prototype.map": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array.prototype.map/-/array.prototype.map-1.0.2.tgz", + "integrity": "sha512-Az3OYxgsa1g7xDYp86l0nnN4bcmuEITGe1rbdEBVkrqkzMgDcbdQ2R7r41pNzti+4NMces3H8gMmuioZUilLgw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "es-array-method-boxes-properly": "^1.0.0", + "is-string": "^1.0.4" + } + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "binary-extensions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", + "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "requires": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "chokidar": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz", + "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.4.0" + } + }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "csstype": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.3.tgz", + "integrity": "sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "default-require-extensions": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", + "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", + "dev": true, + "requires": { + "strip-bom": "^4.0.0" + } + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-array-method-boxes-properly": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", + "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", + "dev": true + }, + "es-get-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz", + "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==", + "dev": true, + "requires": { + "es-abstract": "^1.17.4", + "has-symbols": "^1.0.1", + "is-arguments": "^1.0.4", + "is-map": "^2.0.1", + "is-set": "^2.0.1", + "is-string": "^1.0.5", + "isarray": "^2.0.5" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-cache-dir": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, + "foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + } + }, + "fromentries": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.2.1.tgz", + "integrity": "sha512-Xu2Qh8yqYuDhQGOhD5iJGninErSfI9A3FrriD3tjUgV5VbJFeH8vfgZ9HnC6jWN80QDVNQK5vmxRAmEAp7Mevw==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gensync": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", + "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "hasha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.0.tgz", + "integrity": "sha512-2W+jKdQbAdSIrggA8Q35Br8qKadTrqCTC8+XZvBWepKDK6m9XkX6Iz1a2yh2KP01kzAR/dpuMeUnocoLYDcskw==", + "dev": true, + "requires": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true + }, + "is-callable": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz", + "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==", + "dev": true + }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz", + "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-set": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz", + "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==", + "dev": true + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "requires": { + "append-transform": "^2.0.0" + } + }, + "istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + } + }, + "istanbul-lib-processinfo": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", + "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.0", + "istanbul-lib-coverage": "^3.0.0-alpha.1", + "make-dir": "^3.0.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^3.3.3" + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", + "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "iterate-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.1.tgz", + "integrity": "sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw==", + "dev": true + }, + "iterate-value": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/iterate-value/-/iterate-value-1.0.2.tgz", + "integrity": "sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==", + "dev": true, + "requires": { + "es-get-iterator": "^1.0.2", + "iterate-iterator": "^1.0.1" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "dev": true + }, + "log-symbols": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "dev": true, + "requires": { + "chalk": "^4.0.0" + } + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mocha": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.1.3.tgz", + "integrity": "sha512-ZbaYib4hT4PpF4bdSO2DohooKXIn4lDeiYqB+vTmCdr6l2woW0b6H3pf5x4sM5nwQMru9RvjjHYWVGltR50ZBw==", + "dev": true, + "requires": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.4.2", + "debug": "4.1.1", + "diff": "4.0.2", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.6", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.14.0", + "log-symbols": "4.0.0", + "minimatch": "3.0.4", + "ms": "2.1.2", + "object.assign": "4.1.0", + "promise.allsettled": "1.0.2", + "serialize-javascript": "4.0.0", + "strip-json-comments": "3.0.1", + "supports-color": "7.1.0", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.0.0", + "yargs": "13.3.2", + "yargs-parser": "13.1.2", + "yargs-unparser": "1.6.1" + } + }, + "moq.ts": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/moq.ts/-/moq.ts-6.4.0.tgz", + "integrity": "sha512-g9siyKOvYGVhfDCl9mpLptch93egRC3yXIbPLssxukOROl368XBB+6M7YjLTkjVRHbKbpJBD6P7od+Ky/0xWIw==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "requires": { + "process-on-spawn": "^1.0.0" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "nyc": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", + "integrity": "sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==", + "dev": true, + "requires": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^2.0.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^4.0.0", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-inspect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz", + "integrity": "sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } + } + }, + "process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dev": true, + "requires": { + "fromentries": "^1.2.0" + } + }, + "promise.allsettled": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", + "integrity": "sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg==", + "dev": true, + "requires": { + "array.prototype.map": "^1.0.1", + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "iterate-value": "^1.0.0" + } + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "react": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", + "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2" + } + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "readdirp": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", + "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "dev": true, + "requires": { + "es6-error": "^4.0.1" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "requires": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "ts-node": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz", + "integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", + "dev": true + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "typescript": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz", + "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==", + "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "workerpool": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz", + "integrity": "sha512-fU2OcNA/GVAJLLyKUoHkAgIhKb0JoCpSjLC/G2vYKxUjVmQwGbRVeoPJ1a8U4pnVofz4AQV5Y/NEw8oKqxEBtA==", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.1.tgz", + "integrity": "sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "decamelize": "^1.2.0", + "flat": "^4.1.0", + "is-plain-obj": "^1.1.0", + "yargs": "^14.2.3" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "yargs": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz", + "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.1" + } + }, + "yargs-parser": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz", + "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json new file mode 100644 index 0000000000..dbb12e192a --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json @@ -0,0 +1,26 @@ +{ + "name": "simple-test", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "mocha -r ts-node/register ./**/*Tests.ts", + "coverage": "nyc -r text -e .ts -x \"./*Tests.ts\" npm run test" + }, + "type": "module", + "keywords": [], + "author": "", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "@types/chai": "4.2.12", + "@types/mocha": "8.0.3", + "@types/react": "^16.3.14", + "chai": "^4.2.0", + "mocha": "^8.1.3", + "moq.ts": "^6.4.0", + "nyc": "^15.1.0", + "react": "^16.3.2", + "ts-node": "^9.0.0", + "typescript": "^4.0.2" + } +} diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json new file mode 100644 index 0000000000..fdb82879fc --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "sourceMap": true, + "strict": true, + "esModuleInterop": true + }, + "exclude": [ + "node_modules" + ] +} From a52464ebb9b31c1e03e89b0c39705f5c942e61d7 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 20:19:58 +0500 Subject: [PATCH 16/35] Add html previewer tests to nuke --- build.ps1 | 4 ++-- nukebuild/Build.cs | 16 ++++++++++++++++ nukebuild/BuildParameters.cs | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 57e2f80075..98a9c9afee 100644 --- a/build.ps1 +++ b/build.ps1 @@ -43,7 +43,7 @@ if (Test-Path $DotNetGlobalFile) { } # If dotnet is installed locally, and expected version is not set or installation matches the expected version -if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and ` +if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { $env:DOTNET_EXE = (Get-Command "dotnet").Path } @@ -53,7 +53,7 @@ else { # Download install script $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - md -force $TempDirectory > $null + mkdir -force $TempDirectory > $null (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) # Install by channel or version diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index 24398accbb..c56703f9cc 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -223,6 +223,21 @@ partial class Build : NukeBuild } } + Target RunHtmlPreviewerTests => _ => _ + .DependsOn(CompileHtmlPreviewer) + .OnlyWhenStatic(() => !(Parameters.SkipPreviewer || Parameters.SkipTests)) + .Executes(() => + { + var webappTestDir = RootDirectory / "tests" / "Avalonia.DesignerSupport.Tests" / "Remote" / "HtmlTransport" / "webapp"; + + NpmTasks.NpmInstall(c => c + .SetWorkingDirectory(webappTestDir) + .SetArgumentConfigurator(a => a.Add("--silent"))); + NpmTasks.NpmRun(c => c + .SetWorkingDirectory(webappTestDir) + .SetCommand("test")); + }); + Target RunCoreLibsTests => _ => _ .OnlyWhenStatic(() => !Parameters.SkipTests) .DependsOn(Compile) @@ -323,6 +338,7 @@ partial class Build : NukeBuild .DependsOn(RunCoreLibsTests) .DependsOn(RunRenderTests) .DependsOn(RunDesignerTests) + .DependsOn(RunHtmlPreviewerTests) .DependsOn(RunLeakTests); Target Package => _ => _ diff --git a/nukebuild/BuildParameters.cs b/nukebuild/BuildParameters.cs index a167e9d892..c76019d9eb 100644 --- a/nukebuild/BuildParameters.cs +++ b/nukebuild/BuildParameters.cs @@ -62,7 +62,7 @@ public partial class Build public AbsolutePath ZipTargetControlCatalogDesktopDir { get; } - public BuildParameters(Build b) + public BuildParameters(Build b) { // ARGUMENTS Configuration = b.Configuration ?? "Release"; From 8fd50dd15aa569b2f41583a64c690d0233d3d237 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 20:49:27 +0500 Subject: [PATCH 17/35] Add some tests --- .../Remote/HtmlTransport/webapp/.gitignore | 1 + .../webapp/Models/InputEventTests.ts | 151 ++++++++++-------- 2 files changed, 87 insertions(+), 65 deletions(-) diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore index e3fbd98336..dc33b94747 100644 --- a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore @@ -1,2 +1,3 @@ build node_modules +.nyc_output \ No newline at end of file diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts index 061bb74be7..e96c4d4731 100644 --- a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts @@ -1,73 +1,94 @@ -import {describe} from 'mocha'; -import {expect} from 'chai'; -import {Mock} from "moq.ts"; -import {MouseEvent, WheelEvent} from "react"; -import {InputModifiers} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; -import {MouseButton} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; -import {PointerMovedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; -import {PointerPressedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; -import {PointerReleasedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; -import {ScrollEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; +import { describe } from 'mocha'; +import { expect } from 'chai'; +import { Mock } from "moq.ts"; +import { MouseEvent, WheelEvent } from "react"; +import { InputModifiers } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; +import { MouseButton } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; +import { PointerMovedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; +import { PointerPressedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; +import { PointerReleasedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; +import { ScrollEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; +import { getModifiers, getMouseButton } from '../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers'; -const x = .3 -const y = .42 -const modifiers = [ - InputModifiers.Alt, - InputModifiers.Control, - InputModifiers.Shift, - InputModifiers.Windows, - InputModifiers.LeftMouseButton, - InputModifiers.RightMouseButton, - InputModifiers.MiddleMouseButton -] +describe("Input event tests", () => { + describe("Helpers", () => { + it("getModifiers", () => { + const event = new Mock() + .setup(x => x.altKey).returns(false) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(false) + .setup(x => x.metaKey).returns(false) + .setup(x => x.buttons).returns(1) + .object() + var actual = getModifiers(event) -const button = MouseButton.Left + expect(actual) + .eql([InputModifiers.Control, InputModifiers.LeftMouseButton]) + }) + it("getMouseButton", () => { + const event = new Mock() + .setup(x => x.button).returns(1) + .object() + var actual = getMouseButton(event) -const deltaX = -3. -const deltaY = -3. + expect(actual) + .equal(MouseButton.Middle) + }) + }) -const mouseEvent = new Mock() - .setup(x => x.altKey).returns(true) - .setup(x => x.ctrlKey).returns(true) - .setup(x => x.shiftKey).returns(true) - .setup(x => x.metaKey).returns(true) - .setup(x => x.buttons).returns(7) - .setup(x => x.button).returns(0) - .setup(x => x.clientX).returns(x) - .setup(x => x.clientY).returns(y) - .object() + describe("Messages", () => { + const x = .3 + const y = .42 + const modifiers = "0,1,2,3,4,5,6" -const wheelEvent = new Mock() - .setup(x => x.altKey).returns(true) - .setup(x => x.ctrlKey).returns(true) - .setup(x => x.shiftKey).returns(true) - .setup(x => x.metaKey).returns(true) - .setup(x => x.buttons).returns(7) - .setup(x => x.clientX).returns(x) - .setup(x => x.clientY).returns(y) - .setup(x => x.deltaX).returns(-deltaX) - .setup(x => x.deltaY).returns(-deltaY) - .object() + const button = "1" -describe("Input event tests", () => { - it("PointerMovedEventMessage", () => { - const message = new PointerMovedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-moved:${modifiers}:${x}:${y}`) - }) - it("PointerPressedEventMessage", () => { - const message = new PointerPressedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) - }) - it("PointerReleasedEventMessage", () => { - const message = new PointerReleasedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) - }) - it("ScrollEventMessage", () => { - const message = new ScrollEventMessage(wheelEvent) - expect(message.toString()) - .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + const deltaX = -3. + const deltaY = -3. + + const mouseEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.button).returns(0) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .object() + + it("PointerMovedEventMessage", () => { + const message = new PointerMovedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-moved:${modifiers}:${x}:${y}`) + }) + it("PointerPressedEventMessage", () => { + const message = new PointerPressedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) + }) + it("PointerReleasedEventMessage", () => { + const message = new PointerReleasedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) + }) + + it("ScrollEventMessage", () => { + const wheelEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .setup(x => x.deltaX).returns(-deltaX) + .setup(x => x.deltaY).returns(-deltaY) + .object() + const message = new ScrollEventMessage(wheelEvent) + + expect(message.toString()) + .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + }) }) }) From 79a53846c8bb7dbb789a3d08fe8179e8ada37b72 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 18 Sep 2020 22:35:59 +0500 Subject: [PATCH 18/35] InvariantCultureIgnoreCase -> OrdinalIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index de7da4985c..0996431b1f 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -267,11 +267,11 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport { var parts = message.Split(':'); var key = parts[0]; - if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) + if (key.Equals("frame-received", StringComparison.OrdinalIgnoreCase)) { return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } - else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-released", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerReleasedEventMessage { @@ -281,7 +281,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Button = ParseMouseButton(parts[4]), }; } - else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-pressed", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerPressedEventMessage { @@ -291,7 +291,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Button = ParseMouseButton(parts[4]), }; } - else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-moved", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerMovedEventMessage { @@ -300,7 +300,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Y = ParseDouble(parts[3]), }; } - else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("scroll", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.ScrollEventMessage { @@ -316,7 +316,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => - string.IsNullOrEmpty(modifiersText) + string.IsNullOrWhiteSpace(modifiersText) ? null : modifiersText .Split(',') From 9ce5a98277e7c33f8ec3e298a1669dd27485e1fd Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 18 Sep 2020 22:39:22 +0500 Subject: [PATCH 19/35] IsNullOrEmpty -> IsNullOrWhiteSpace --- .../Remote/HtmlTransport/HtmlTransport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 0996431b1f..804bb09510 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -325,7 +325,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport .ToArray(); private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => - string.IsNullOrEmpty(buttonText) + string.IsNullOrWhiteSpace(buttonText) ? InputProtocol.MouseButton.None : (InputProtocol.MouseButton)Enum.Parse( typeof(InputProtocol.MouseButton), buttonText, true); From de8edba8ad12b7952805b86e72814e52625d1f67 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 26 Oct 2020 02:11:24 +0300 Subject: [PATCH 20/35] [WIP] IDL-based codegen --- Avalonia.sln | 53 ++ packages/Avalonia/Avalonia.csproj | 7 +- packages/Avalonia/AvaloniaBuildTasks.targets | 2 + src/Avalonia.Build.Tasks/ComInteropHelper.cs | 130 +++++ .../CompileAvaloniaXamlTask.cs | 6 +- src/Avalonia.Build.Tasks/Program.cs | 3 +- .../XamlCompilerTaskExecutor.cs | 8 +- .../Avalonia.MicroCom.csproj | 8 + .../IMicroComExceptionCallback.cs | 9 + .../IMicroComShadowContainer.cs | 9 + src/Avalonia.MicroCom/IUnknown.cs | 12 + src/Avalonia.MicroCom/LocalInterop.cs | 17 + src/Avalonia.MicroCom/MicroComProxyBase.cs | 78 +++ src/Avalonia.MicroCom/MicroComRuntime.cs | 88 +++ src/Avalonia.MicroCom/MicroComShadow.cs | 171 ++++++ src/Avalonia.MicroCom/MicroComVtblBase.cs | 41 ++ src/Avalonia.Native/avn.idl | 522 ++++++++++++++++++ src/tools/MicroComGenerator/Ast.cs | 102 ++++ src/tools/MicroComGenerator/AstParser.cs | 228 ++++++++ .../CSharpGen.InterfaceGen.cs | 453 +++++++++++++++ .../MicroComGenerator/CSharpGen.Utils.cs | 97 ++++ src/tools/MicroComGenerator/CSharpGen.cs | 89 +++ src/tools/MicroComGenerator/CppGen.cs | 108 ++++ src/tools/MicroComGenerator/Extensions.cs | 90 +++ .../MicroComGenerator.csproj | 12 + src/tools/MicroComGenerator/ParseException.cs | 27 + src/tools/MicroComGenerator/Program.cs | 44 ++ src/tools/MicroComGenerator/TokenParser.cs | 417 ++++++++++++++ 28 files changed, 2821 insertions(+), 10 deletions(-) create mode 100644 src/Avalonia.Build.Tasks/ComInteropHelper.cs create mode 100644 src/Avalonia.MicroCom/Avalonia.MicroCom.csproj create mode 100644 src/Avalonia.MicroCom/IMicroComExceptionCallback.cs create mode 100644 src/Avalonia.MicroCom/IMicroComShadowContainer.cs create mode 100644 src/Avalonia.MicroCom/IUnknown.cs create mode 100644 src/Avalonia.MicroCom/LocalInterop.cs create mode 100644 src/Avalonia.MicroCom/MicroComProxyBase.cs create mode 100644 src/Avalonia.MicroCom/MicroComRuntime.cs create mode 100644 src/Avalonia.MicroCom/MicroComShadow.cs create mode 100644 src/Avalonia.MicroCom/MicroComVtblBase.cs create mode 100644 src/Avalonia.Native/avn.idl create mode 100644 src/tools/MicroComGenerator/Ast.cs create mode 100644 src/tools/MicroComGenerator/AstParser.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.Utils.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.cs create mode 100644 src/tools/MicroComGenerator/CppGen.cs create mode 100644 src/tools/MicroComGenerator/Extensions.cs create mode 100644 src/tools/MicroComGenerator/MicroComGenerator.csproj create mode 100644 src/tools/MicroComGenerator/ParseException.cs create mode 100644 src/tools/MicroComGenerator/Program.cs create mode 100644 src/tools/MicroComGenerator/TokenParser.cs diff --git a/Avalonia.sln b/Avalonia.sln index 34ad19b41d..74a2dbb94b 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -226,6 +226,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI.Events" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox", "samples\Sandbox\Sandbox.csproj", "{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroComGenerator", "src\tools\MicroComGenerator\MicroComGenerator.csproj", "{AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.MicroCom", "src\Avalonia.MicroCom\Avalonia.MicroCom.csproj", "{FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 @@ -2064,6 +2068,54 @@ Global {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhone.Build.0 = Release|Any CPU {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|Any CPU.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhone.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhone.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|Any CPU.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhone.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhone.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2123,6 +2175,7 @@ Global {3C84E04B-36CF-4D0D-B965-C26DD649D1F3} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9} {909A8CBD-7D0E-42FD-B841-022AD8925820} = {8B6A8209-894F-4BA1-B880-965FD453982C} {11BE52AF-E2DD-4CF0-B19A-05285ACAF571} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj index cd3ce9adcd..90c1c67956 100644 --- a/packages/Avalonia/Avalonia.csproj +++ b/packages/Avalonia/Avalonia.csproj @@ -5,8 +5,9 @@ - + + @@ -15,9 +16,7 @@ - + <_PackageFiles Include="$(DesignerHostAppPath)/Avalonia.Designer.HostApp/bin/$(Configuration)/netcoreapp2.0/Avalonia.Designer.HostApp.dll"> diff --git a/packages/Avalonia/AvaloniaBuildTasks.targets b/packages/Avalonia/AvaloniaBuildTasks.targets index 612c368633..57b4cb04e3 100644 --- a/packages/Avalonia/AvaloniaBuildTasks.targets +++ b/packages/Avalonia/AvaloniaBuildTasks.targets @@ -3,6 +3,7 @@ <_AvaloniaUseExternalMSBuild>$(AvaloniaUseExternalMSBuild) <_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false low + <_AvaloniaPatchComInterop Condition="'$(_AvaloniaPatchComInterop)' == ''">false @@ -90,6 +91,7 @@ AssemblyOriginatorKeyFile="$(AssemblyOriginatorKeyFile)" SignAssembly="$(SignAssembly)" DelaySign="$(DelaySign)" + EnableComInteropPatching="$(_AvaloniaPatchComInterop)" /> (); + var initializers = new List(); + foreach (var type in asm.MainModule.Types) + { + var i = type.Methods.FirstOrDefault(m => m.Name == "__MicroComModuleInit"); + if (i != null) + initializers.Add(i); + + PatchType(type, classToRemoveList); + } + + // Remove All Interop classes + foreach (var type in classToRemoveList) + asm.MainModule.Types.Remove(type); + + + // Patch automatic registrations + if (initializers.Count != 0) + { + var moduleType = asm.MainModule.Types.First(x => x.Name == ""); + + // Needed for compatibility with upcoming .NET 5 feature, look for existing initializer first + var staticCtor = moduleType.Methods.FirstOrDefault(m => m.Name == ".cctor"); + if (staticCtor == null) + { + // Create a new static ctor if none exists + staticCtor = new MethodDefinition(".cctor", + MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | + MethodAttributes.Static | MethodAttributes.Private, + asm.MainModule.TypeSystem.Void); + staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); + moduleType.Methods.Add(staticCtor); + } + + foreach (var i in initializers) + staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Call, i)); + } + + } + + + + static void PatchMethod(MethodDefinition method) + { + if (method.HasBody) + { + var ilProcessor = method.Body.GetILProcessor(); + + var instructions = method.Body.Instructions; + for (int i = 0; i < instructions.Count; i++) + { + Instruction instruction = instructions[i]; + + if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference) + { + var methodDescription = (MethodReference)instruction.Operand; + + if (methodDescription.Name.StartsWith("Calli") && methodDescription.DeclaringType.Name == "LocalInterop") + { + var callSite = new CallSite(methodDescription.ReturnType) { CallingConvention = MethodCallingConvention.StdCall }; + + if (methodDescription.Name.StartsWith("CalliCdecl")) + { + callSite.CallingConvention = MethodCallingConvention.C; + } + else if(methodDescription.Name.StartsWith("CalliThisCall")) + { + callSite.CallingConvention = MethodCallingConvention.ThisCall; + } + else if(methodDescription.Name.StartsWith("CalliStdCall")) + { + callSite.CallingConvention = MethodCallingConvention.StdCall; + } + else if(methodDescription.Name.StartsWith("CalliFastCall")) + { + callSite.CallingConvention = MethodCallingConvention.FastCall; + } + + // Last parameter is the function ptr, so we don't add it as a parameter for calli + // as it is already an implicit parameter for calli + for (int j = 0; j < methodDescription.Parameters.Count - 1; j++) + { + var parameterDefinition = methodDescription.Parameters[j]; + callSite.Parameters.Add(parameterDefinition); + } + + // Create calli Instruction + var callIInstruction = ilProcessor.Create(OpCodes.Calli, callSite); + + // Replace instruction + ilProcessor.Replace(instruction, callIInstruction); + } + } + } + } + } + + /// + /// Patches the type. + /// + /// The type. + static void PatchType(TypeDefinition type, List classToRemoveList) + { + // Patch methods + foreach (var method in type.Methods) + PatchMethod(method); + + if (type.Name == "LocalInterop") + classToRemoveList.Add(type); + + // Patch nested types + foreach (var typeDefinition in type.NestedTypes) + PatchType(typeDefinition, classToRemoveList); + } + } +} diff --git a/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs b/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs index 8e1f6c257d..f44e90b25e 100644 --- a/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs +++ b/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs @@ -40,8 +40,8 @@ namespace Avalonia.Build.Tasks var res = XamlCompilerTaskExecutor.Compile(BuildEngine, input, File.ReadAllLines(ReferencesFilePath).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray(), ProjectDirectory, OutputPath, VerifyIl, outputImportance, - (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null - ); + (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null, + EnableComInteropPatching); if (!res.Success) return false; if (!res.WrittenFile) @@ -76,6 +76,8 @@ namespace Avalonia.Build.Tasks public bool VerifyIl { get; set; } + public bool EnableComInteropPatching { get; set; } + public string AssemblyOriginatorKeyFile { get; set; } public bool SignAssembly { get; set; } public bool DelaySign { get; set; } diff --git a/src/Avalonia.Build.Tasks/Program.cs b/src/Avalonia.Build.Tasks/Program.cs index 1909c4c6ec..b18c19cd63 100644 --- a/src/Avalonia.Build.Tasks/Program.cs +++ b/src/Avalonia.Build.Tasks/Program.cs @@ -29,7 +29,8 @@ namespace Avalonia.Build.Tasks OutputPath = args[2], BuildEngine = new ConsoleBuildEngine(), ProjectDirectory = Directory.GetCurrentDirectory(), - VerifyIl = true + VerifyIl = true, + EnableComInteropPatching = true }.Execute() ? 0 : 2; diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 6b01af2ede..938732cfe1 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -42,13 +42,13 @@ namespace Avalonia.Build.Tasks } public static CompileResult Compile(IBuildEngine engine, string input, string[] references, string projectDirectory, - string output, bool verifyIl, MessageImportance logImportance, string strongNameKey) + string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom) { var typeSystem = new CecilTypeSystem(references.Concat(new[] {input}), input); var asm = typeSystem.TargetAssemblyDefinition; var emres = new EmbeddedResources(asm); var avares = new AvaloniaResources(asm, projectDirectory); - if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0) + if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0 && !patchCom) // Nothing to do return new CompileResult(true); @@ -374,7 +374,9 @@ namespace Avalonia.Build.Tasks loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldnull)); loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); - + + if (patchCom) + ComInteropHelper.PatchAssembly(asm, typeSystem); var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; if (!string.IsNullOrWhiteSpace(strongNameKey)) diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj new file mode 100644 index 0000000000..aaf54ed80e --- /dev/null +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -0,0 +1,8 @@ + + + + netstandard2.0 + true + + + diff --git a/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs b/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs new file mode 100644 index 0000000000..08f20339ec --- /dev/null +++ b/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs @@ -0,0 +1,9 @@ +using System; + +namespace Avalonia.MicroCom +{ + public interface IMicroComExceptionCallback + { + void RaiseException(Exception e); + } +} diff --git a/src/Avalonia.MicroCom/IMicroComShadowContainer.cs b/src/Avalonia.MicroCom/IMicroComShadowContainer.cs new file mode 100644 index 0000000000..a33d3a9811 --- /dev/null +++ b/src/Avalonia.MicroCom/IMicroComShadowContainer.cs @@ -0,0 +1,9 @@ +namespace Avalonia.MicroCom +{ + public interface IMicroComShadowContainer + { + MicroComShadow Shadow { get; set; } + void OnReferencedFromNative(); + void OnUnreferencedFromNative(); + } +} diff --git a/src/Avalonia.MicroCom/IUnknown.cs b/src/Avalonia.MicroCom/IUnknown.cs new file mode 100644 index 0000000000..a46953ced9 --- /dev/null +++ b/src/Avalonia.MicroCom/IUnknown.cs @@ -0,0 +1,12 @@ +using System; + +namespace Avalonia.MicroCom +{ + public interface IUnknown : IDisposable + { + void AddRef(); + void Release(); + int QueryInterface(Guid guid, out IntPtr ppv); + T QueryInterface() where T : IUnknown; + } +} diff --git a/src/Avalonia.MicroCom/LocalInterop.cs b/src/Avalonia.MicroCom/LocalInterop.cs new file mode 100644 index 0000000000..785f4e03a5 --- /dev/null +++ b/src/Avalonia.MicroCom/LocalInterop.cs @@ -0,0 +1,17 @@ +using System; + +namespace Avalonia.MicroCom +{ + unsafe class LocalInterop + { + public static unsafe void CalliStdCallvoid(void* thisObject, void* methodPtr) + { + throw null; + } + + public static unsafe int CalliStdCallint(void* thisObject, Guid* guid, IntPtr* ppv, void* methodPtr) + { + throw null; + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs new file mode 100644 index 0000000000..56b80c2632 --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -0,0 +1,78 @@ +using System; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComProxyBase : IUnknown + { + private IntPtr _nativePointer; + private bool _ownsHandle; + + public IntPtr NativePointer + { + get + { + if (_nativePointer == IntPtr.Zero) + throw new ObjectDisposedException(this.GetType().FullName); + return _nativePointer; + } + } + + public void*** PPV => (void***)NativePointer; + + public MicroComProxyBase(IntPtr nativePointer, bool ownsHandle) + { + _nativePointer = nativePointer; + _ownsHandle = ownsHandle; + } + + protected virtual int VTableSize => 3; + + public void AddRef() + { + LocalInterop.CalliStdCallvoid(PPV, (*PPV)[1]); + } + + public void Release() + { + LocalInterop.CalliStdCallvoid(PPV, (*PPV)[2]); + } + + public int QueryInterface(Guid guid, out IntPtr ppv) + { + IntPtr r = default; + var rv = LocalInterop.CalliStdCallint(PPV, &guid, &r, (*PPV)[0]); + ppv = r; + return rv; + } + + public T QueryInterface() where T : IUnknown + { + var guid = MicroComRuntime.GetGuidFor(typeof(T)); + var rv = QueryInterface(guid, out var ppv); + if (rv != 0) + return (T)MicroComRuntime.CreateProxyFor(typeof(T), ppv, true); + throw new COMException("QueryInterface failed", rv); + } + + public bool IsDisposed => _nativePointer == IntPtr.Zero; + + public void Dispose() + { + if (_ownsHandle) + Release(); + _nativePointer = IntPtr.Zero; + } + + public bool OwnsHandle => _ownsHandle; + + public void EnsureOwned() + { + if (!_ownsHandle) + { + AddRef(); + _ownsHandle = true; + } + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs new file mode 100644 index 0000000000..eccf24b496 --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Concurrent; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public static unsafe class MicroComRuntime + { + private static ConcurrentDictionary _vtables = new ConcurrentDictionary(); + + private static ConcurrentDictionary> _factories = + new ConcurrentDictionary>(); + private static ConcurrentDictionary _guids = new ConcurrentDictionary(); + private static ConcurrentDictionary _guidsToTypes = new ConcurrentDictionary(); + + static MicroComRuntime() + { + Register(typeof(IUnknown), new Guid("00000000-0000-0000-C000-000000000046"), + (ppv, owns) => new MicroComProxyBase(ppv, owns)); + RegisterVTable(typeof(IUnknown), MicroComVtblBase.Vtable); + } + + public static void RegisterVTable(Type t, IntPtr vtable) + { + _vtables[t] = vtable; + } + + public static void Register(Type t, Guid guid, Func proxyFactory) + { + _factories[t] = proxyFactory; + _guids[t] = guid; + _guidsToTypes[guid] = t; + } + + public static Guid GetGuidFor(Type type) => _guids[type]; + + public static T CreateProxyFor(void* ppv, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(ppv), ownsHandle); + + public static object CreateProxyFor(Type type, IntPtr ppv, bool ownsHandle) => _factories[type](ppv, ownsHandle); + + public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown + { + if (obj is MicroComProxyBase proxy) + return (void*)proxy.NativePointer; + if (obj is IMicroComShadowContainer container) + { + container.Shadow ??= new MicroComShadow(container); + void* ptr = null; + var res = container.Shadow.GetOrCreateNativePointer(typeof(T), &ptr); + if (res != 0) + throw new COMException( + "Unable to create native callable wrapper for type " + typeof(T) + " for instance of type " + + obj.GetType(), + res); + if (owned) + container.Shadow.AddRef((Ccw*)ptr); + } + throw new ArgumentException("Unable to get a native pointer for " + obj); + } + + public static object GetObjectFromCcw(IntPtr ccw) + { + var ptr = (Ccw*)ccw; + var shadow = (MicroComShadow)GCHandle.FromIntPtr(ptr->GcShadowHandle).Target; + return shadow.Target; + } + + public static bool TryGetTypeForGuid(Guid guid, out Type t) => _guidsToTypes.TryGetValue(guid, out t); + + public static bool GetVtableFor(Type type, out IntPtr ptr) => _vtables.TryGetValue(type, out ptr); + + public static void UnhandledException(object target, Exception e) + { + if (target is IMicroComExceptionCallback cb) + { + try + { + cb.RaiseException(e); + } + catch + { + // We've tried + } + } + + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComShadow.cs b/src/Avalonia.MicroCom/MicroComShadow.cs new file mode 100644 index 0000000000..c9411a089e --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComShadow.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComShadow : IDisposable + { + private readonly object _lock = new object(); + private readonly Dictionary _shadows = new Dictionary(); + private readonly Dictionary _backShadows = new Dictionary(); + private GCHandle? _handle; + private volatile int _refCount; + internal IMicroComShadowContainer Target { get; } + internal MicroComShadow(IMicroComShadowContainer target) + { + Target = target; + Target.Shadow = this; + } + + internal int QueryInterface(Ccw* ccw, Guid* guid, void** ppv) + { + if (MicroComRuntime.TryGetTypeForGuid(*guid, out var type)) + return QueryInterface(type, ppv); + else + return unchecked((int)0x80004002u); + } + + internal int QueryInterface(Type type, void** ppv) + { + if (!type.IsInstanceOfType(Target)) + return unchecked((int)0x80004002u); + + var rv = GetOrCreateNativePointer(type, ppv); + if (rv == 0) + AddRef((Ccw*)*ppv); + return rv; + } + + internal int GetOrCreateNativePointer(Type type, void** ppv) + { + if (!MicroComRuntime.GetVtableFor(type, out var vtable)) + return unchecked((int)0x80004002u); + lock (_lock) + { + + if (_shadows.TryGetValue(type, out var shadow)) + { + var targetCcw = (Ccw*)shadow; + AddRef(targetCcw); + *ppv = targetCcw; + return 0; + } + else + { + var intPtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + var targetCcw = (Ccw*)intPtr; + *targetCcw = default; + targetCcw->RefCount = 0; + targetCcw->VTable = vtable; + if (_handle == null) + _handle = GCHandle.Alloc(this); + targetCcw->GcShadowHandle = GCHandle.ToIntPtr(_handle.Value); + _shadows[type] = intPtr; + _backShadows[intPtr] = type; + *ppv = targetCcw; + + return 0; + } + } + } + + internal int AddRef(Ccw* ccw) + { + if (Interlocked.Increment(ref _refCount) == 1) + { + try + { + Target.OnUnreferencedFromNative(); + } + catch (Exception e) + { + MicroComRuntime.UnhandledException(Target, e); + } + } + + return Interlocked.Increment(ref ccw->RefCount); + } + + internal int Release(Ccw* ccw) + { + Interlocked.Decrement(ref _refCount); + var cnt = Interlocked.Decrement(ref ccw->RefCount); + if (cnt == 0) + return FreeCcw(ccw); + + return cnt; + } + + int FreeCcw(Ccw* ccw) + { + lock (_lock) + { + // Shadow got resurrected by a call to QueryInterface from another thread + if (ccw->RefCount != 0) + return ccw->RefCount; + + var intPtr = new IntPtr(ccw); + var type = _backShadows[intPtr]; + _backShadows.Remove(intPtr); + _shadows.Remove(type); + Marshal.FreeHGlobal(intPtr); + if (_shadows.Count == 0) + { + _handle?.Free(); + _handle = null; + try + { + Target.OnUnreferencedFromNative(); + } + catch(Exception e) + { + MicroComRuntime.UnhandledException(Target, e); + } + } + } + + return 0; + } + + /* + Needs to be called to support the following scenario: + 1) Object created + 2) Object passed to native code, shadow is created, CCW is created + 3) Native side has never called AddRef + + In that case the GC handle to the shadow object is still alive + */ + + public void Dispose() + { + lock (_lock) + { + List toRemove = null; + foreach (var kv in _backShadows) + { + var ccw = (Ccw*)kv.Key; + if (ccw->RefCount == 0) + { + toRemove ??= new List(); + toRemove.Add(kv.Key); + } + } + + if(toRemove != null) + foreach (var intPtr in toRemove) + FreeCcw((Ccw*)intPtr); + } + } + } + + [StructLayout(LayoutKind.Sequential)] + struct Ccw + { + public IntPtr VTable; + public IntPtr GcShadowHandle; + public volatile int RefCount; + public MicroComShadow GetShadow() => (MicroComShadow)GCHandle.FromIntPtr(GcShadowHandle).Target; + } +} diff --git a/src/Avalonia.MicroCom/MicroComVtblBase.cs b/src/Avalonia.MicroCom/MicroComVtblBase.cs new file mode 100644 index 0000000000..4cd419cdaf --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComVtblBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComVtblBase + { + private List _methods = new List(); + [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + private delegate int AddRefDelegate(Ccw* ccw); + + [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + private delegate int QueryInterfaceDelegate(Ccw* ccw, Guid* guid, void** ppv); + + public static IntPtr Vtable { get; } = new MicroComVtblBase().CreateVTable(); + public MicroComVtblBase() + { + AddMethod((QueryInterfaceDelegate)QueryInterface); + AddMethod((AddRefDelegate)AddRef); + } + + protected void AddMethod(Delegate d) + { + GCHandle.Alloc(d); + _methods.Add(Marshal.GetFunctionPointerForDelegate(d)); + } + + protected unsafe IntPtr CreateVTable() + { + var ptr = (IntPtr*)Marshal.AllocHGlobal((IntPtr.Size + 1) * _methods.Count); + for (var c = 0; c < _methods.Count; c++) + ptr[c] = _methods[c]; + return new IntPtr(ptr); + } + + static int QueryInterface(Ccw* ccw, Guid* guid, void** ppv) => ccw->GetShadow().QueryInterface(ccw, guid, ppv); + static int AddRef(Ccw* ccw) => ccw->GetShadow().AddRef(ccw); + static int Release(Ccw* ccw) => ccw->GetShadow().Release(ccw); + } +} diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl new file mode 100644 index 0000000000..c763007826 --- /dev/null +++ b/src/Avalonia.Native/avn.idl @@ -0,0 +1,522 @@ +@clr-namespace Avalonia.Native.MicroCom +@clr-access internal +@cpp-preamble @@ +#include "com.h" +#include "key.h" +#include "stddef.h" +@@ + +enum SystemDecorations { + SystemDecorationsNone = 0, + SystemDecorationsBorderOnly = 1, + SystemDecorationsFull = 2, +} + +struct AvnSize +{ + double Width, Height; +} + +struct AvnPixelSize +{ + int Width, Height; +} + +struct AvnRect +{ + double X, Y, Width, Height; +} + +struct AvnVector +{ + double X, Y; +} + +struct AvnPoint +{ + double X, Y; +} + +struct AvnScreen +{ + AvnRect Bounds; + AvnRect WorkingArea; + float PixelDensity; + bool Primary; +} + +enum AvnPixelFormat +{ + kAvnRgb565, + kAvnRgba8888, + kAvnBgra8888 +} + +struct AvnFramebuffer +{ + void* Data; + int Width; + int Height; + int Stride; + AvnVector Dpi; + AvnPixelFormat PixelFormat; +} + +struct AvnColor +{ + byte Alpha; + byte Red; + byte Green; + byte Blue; +} + +enum AvnRawMouseEventType +{ + LeaveWindow, + LeftButtonDown, + LeftButtonUp, + RightButtonDown, + RightButtonUp, + MiddleButtonDown, + MiddleButtonUp, + XButton1Down, + XButton1Up, + XButton2Down, + XButton2Up, + Move, + Wheel, + NonClientLeftButtonDown, + TouchBegin, + TouchUpdate, + TouchEnd, + TouchCancel +} + +enum AvnRawKeyEventType +{ + KeyDown, + KeyUp +} + +enum AvnInputModifiers +{ + AvnInputModifiersNone = 0, + Alt = 1, + Control = 2, + Shift = 4, + Windows = 8, + LeftMouseButton = 16, + RightMouseButton = 32, + MiddleMouseButton = 64, + XButton1MouseButton = 128, + XButton2MouseButton = 256 +} + +[class-enum] +enum AvnDragDropEffects +{ + None = 0, + Copy = 1, + Move = 2, + Link = 4, +} + +[class-enum] +enum AvnDragEventType +{ + Enter, + Over, + Leave, + Drop +} + +enum AvnWindowState +{ + Normal, + Minimized, + Maximized, + FullScreen, +} + +enum AvnStandardCursorType +{ + CursorArrow, + CursorIbeam, + CursorWait, + CursorCross, + CursorUpArrow, + CursorSizeWestEast, + CursorSizeNorthSouth, + CursorSizeAll, + CursorNo, + CursorHand, + CursorAppStarting, + CursorHelp, + CursorTopSide, + CursorBottomSize, + CursorLeftSide, + CursorRightSide, + CursorTopLeftCorner, + CursorTopRightCorner, + CursorBottomLeftCorner, + CursorBottomRightCorner, + CursorDragMove, + CursorDragCopy, + CursorDragLink, + CursorNone +} + +enum AvnWindowEdge +{ + WindowEdgeNorthWest, + WindowEdgeNorth, + WindowEdgeNorthEast, + WindowEdgeWest, + WindowEdgeEast, + WindowEdgeSouthWest, + WindowEdgeSouth, + WindowEdgeSouthEast +} + +enum AvnMenuItemToggleType +{ + None, + CheckMark, + Radio +} + +enum AvnExtendClientAreaChromeHints +{ + AvnNoChrome = 0, + AvnSystemChrome = 0x01, + AvnPreferSystemChrome = 0x02, + AvnOSXThickTitleBar = 0x08, + AvnDefaultChrome = AvnSystemChrome, +} + +[uuid(809c652e-7396-11d2-9771-00a0c9b4d50c)] +interface IAvaloniaNativeFactory : IUnknown +{ + HRESULT Initialize(IAvnGCHandleDeallocatorCallback* deallocator); + IAvnMacOptions* GetMacOptions(); + HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnWindow** ppv); + HRESULT CreatePopup(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnPopup** ppv); + HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv); + HRESULT CreateSystemDialogs(IAvnSystemDialogs** ppv); + HRESULT CreateScreens(IAvnScreens** ppv); + HRESULT CreateClipboard(IAvnClipboard** ppv); + HRESULT CreateDndClipboard(IAvnClipboard** ppv); + HRESULT CreateCursorFactory(IAvnCursorFactory** ppv); + HRESULT ObtainGlDisplay(IAvnGlDisplay** ppv); + HRESULT SetAppMenu(IAvnMenu* menu); + HRESULT CreateMenu(IAvnMenuEvents* cb, IAvnMenu** ppv); + HRESULT CreateMenuItem(IAvnMenuItem** ppv); + HRESULT CreateMenuItemSeperator(IAvnMenuItem** ppv); +} + +[uuid(233e094f-9b9f-44a3-9a6e-6948bbdd9fb1)] +interface IAvnString : IUnknown +{ + HRESULT Pointer(void**retOut); + HRESULT Length(int*ret); +} + +[uuid(e5aca675-02b7-4129-aa79-d6e417210bda)] +interface IAvnWindowBase : IUnknown +{ + HRESULT Show(); + HRESULT Hide(); + HRESULT Close(); + HRESULT Activate(); + HRESULT GetClientSize(AvnSize*ret); + HRESULT GetScaling(double*ret); + HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize); + HRESULT Resize(double width, double height); + HRESULT Invalidate(AvnRect rect); + HRESULT BeginMoveDrag(); + HRESULT BeginResizeDrag(AvnWindowEdge edge); + HRESULT GetPosition(AvnPoint*ret); + HRESULT SetPosition(AvnPoint point); + HRESULT PointToClient(AvnPoint point, AvnPoint*ret); + HRESULT PointToScreen(AvnPoint point, AvnPoint*ret); + HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose); + HRESULT SetTopMost(bool value); + 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 CreateNativeControlHost(IAvnNativeControlHost** retOut); + HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, + IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle); + HRESULT SetBlurEnabled(bool enable); +} + +[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91)] +interface IAvnPopup : IAvnWindowBase +{ + +} + +[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d)] +interface IAvnWindow : IAvnWindowBase +{ + HRESULT SetEnabled(bool enable); + HRESULT SetParent(IAvnWindow* parent); + HRESULT SetCanResize(bool value); + HRESULT SetDecorations(SystemDecorations value); + HRESULT SetTitle(void* utf8Title); + HRESULT SetTitleBarColor(AvnColor color); + HRESULT SetWindowState(AvnWindowState state); + HRESULT GetWindowState(AvnWindowState*ret); + HRESULT TakeFocusFromChildren(); + HRESULT SetExtendClientArea(bool enable); + HRESULT SetExtendClientAreaHints(AvnExtendClientAreaChromeHints hints); + HRESULT GetExtendTitleBarHeight(double*ret); + HRESULT SetExtendTitleBarHeight(double value); +} + +[uuid(939b6599-40a8-4710-a4c8-5d72d8f174fb)] +interface IAvnWindowBaseEvents : IUnknown +{ + HRESULT Paint(); + void Closed(); + void Activated(); + void Deactivated(); + void Resized([const] AvnSize* size); + void PositionChanged(AvnPoint position); + void RawMouseEvent(AvnRawMouseEventType type, + uint timeStamp, + AvnInputModifiers modifiers, + AvnPoint point, + AvnVector delta); + bool RawKeyEvent(AvnRawKeyEventType type, uint timeStamp, AvnInputModifiers modifiers, uint key); + bool RawTextInputEvent(uint timeStamp, [const] char* text); + void ScalingChanged(double scaling); + void RunRenderPriorityJobs(); + void LostFocus(); + AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position, + AvnInputModifiers modifiers, AvnDragDropEffects effects, + IAvnClipboard* clipboard, void* dataObjectHandle); +} + +[uuid(1ae178ee-1fcc-447f-b6dd-b7bb727f934c)] +interface IAvnWindowEvents : IAvnWindowBaseEvents +{ + /** + * Closing Event + * Called when the user presses the OS window close button. + * return true to allow the close, return false to prevent close. + */ + bool Closing(); + + void WindowStateChanged(AvnWindowState state); + + void GotInputWhenDisabled(); +} + +[uuid(e34ae0f8-18b4-48a3-b09d-2e6b19a3cf5e)] +interface IAvnMacOptions : IUnknown +{ + HRESULT SetShowInDock(int show); + HRESULT SetApplicationTitle(void* utf8string); +} + +[uuid(04c1b049-1f43-418a-9159-cae627ec1367)] +interface IAvnActionCallback : IUnknown +{ + void Run(); +} + +[uuid(6df4d2db-0b80-4f59-ad88-0baa5e21eb14)] +interface IAvnSignaledCallback : IUnknown +{ + void Signaled(int priority, bool priorityContainsMeaningfulValue); +} + +[uuid(97330f88-c22b-4a8e-a130-201520091b01)] +interface IAvnLoopCancellation : IUnknown +{ + void Cancel(); +} + +[uuid(fbc06f3d-7860-42df-83fd-53c4b02dd9c3)] +interface IAvnPlatformThreadingInterface : IUnknown +{ + bool GetCurrentThreadIsLoopThread(); + void SetSignaledCallback(IAvnSignaledCallback* cb); + IAvnLoopCancellation* CreateLoopCancellation(); + HRESULT RunLoop(IAvnLoopCancellation* cancel); + // Can't pass int* to sharpgentools for some reason + void Signal(int priority); + IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback); +} + +[uuid(6c621a6e-e4c1-4ae3-9749-83eeeffa09b6)] +interface IAvnSystemDialogEvents : IUnknown +{ + void OnCompleted(int numResults, void* ptrFirstResult); +} + +[uuid(4d7a47db-a944-4061-abe7-62cb6aa0ffd5)] +interface IAvnSystemDialogs : IUnknown +{ + void SelectFolderDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + [const] char* title, + [const] char* initialPath); + + void OpenFileDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + bool allowMultiple, + [const] char* title, + [const] char* initialDirectory, + [const] char* initialFile, + [const] char* filters); + + void SaveFileDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + [const] char* title, + [const] char* initialDirectory, + [const] char* initialFile, + [const] char* filters); +} + +[uuid(9a52bc7a-d8c7-4230-8d34-704a0b70a933)] +interface IAvnScreens : IUnknown +{ + HRESULT GetScreenCount(int* ret); + HRESULT GetScreen(int index, AvnScreen* ret); +} + +[uuid(792b1bd4-76cc-46ea-bfd0-9d642154b1b3)] +interface IAvnClipboard : IUnknown +{ + HRESULT GetText(char* type, IAvnString**ppv); + HRESULT SetText(char* type, void* utf8Text); + HRESULT ObtainFormats(IAvnStringArray**ppv); + HRESULT GetStrings(char* type, IAvnStringArray**ppv); + HRESULT SetBytes(char* type, void* utf8Text, int len); + HRESULT GetBytes(char* type, IAvnString**ppv); + + HRESULT Clear(); +} + +[uuid(3f998545-f027-4d4d-bd2a-1a80926d984e)] +interface IAvnCursor : IUnknown +{ +} + +[uuid(51ecfb12-c427-4757-a2c9-1596bfce53ef)] +interface IAvnCursorFactory : IUnknown +{ + HRESULT GetCursor(AvnStandardCursorType cursorType, IAvnCursor** retOut); +} + +[uuid(60452465-8616-40af-bc00-042e69828ce7)] +interface IAvnGlDisplay : IUnknown +{ + HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv); + void LegacyClearCurrentContext(); + HRESULT WrapContext(void* native, IAvnGlContext**ppv); + void* GetProcAddress(char* proc); +} + +[uuid(78c5711e-2a98-40d2-bac4-0cc9a49dc4f3)] +interface IAvnGlContext : IUnknown +{ + HRESULT MakeCurrent(IUnknown** ppv); + HRESULT LegacyMakeCurrent(); + int GetSampleCount(); + int GetStencilSize(); + void* GetNativeHandle(); +} + +[uuid(931062d2-5bc8-4062-8588-83dd8deb99c2)] +interface IAvnGlSurfaceRenderTarget : IUnknown +{ + HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret); +} + +[uuid(e625b406-f04c-484e-946a-4abd2c6015ad)] +interface IAvnGlSurfaceRenderingSession : IUnknown +{ + HRESULT GetPixelSize(AvnPixelSize* ret); + HRESULT GetScaling(double* ret); +} + +[uuid(a7724dc1-cf6b-4fa8-9d23-228bf2593edc)] +interface IAvnMenu : IUnknown +{ + HRESULT InsertItem(int index, IAvnMenuItem* item); + HRESULT RemoveItem(IAvnMenuItem* item); + HRESULT SetTitle(void* utf8String); + HRESULT Clear(); +} + +[uuid(59e0586d-bd1c-4b85-9882-80d448b0fed9)] +interface IAvnPredicateCallback : IUnknown +{ + bool Evaluate(); +} + +[uuid(f890219a-1720-4cd5-9a26-cd95fccbf53c)] +interface IAvnMenuItem : IUnknown +{ + HRESULT SetSubMenu(IAvnMenu* menu); + HRESULT SetTitle(void* utf8String); + HRESULT SetGesture(void* utf8String, AvnInputModifiers modifiers); + HRESULT SetAction(IAvnPredicateCallback* predicate, IAvnActionCallback* callback); + HRESULT SetIsChecked(bool isChecked); + HRESULT SetToggleType(AvnMenuItemToggleType toggleType); + HRESULT SetIcon(void* data, size_t length); +} + +[uuid(0af7df53-7632-42f4-a650-0992c361b477)] +interface IAvnMenuEvents : IUnknown +{ + /** + * NeedsUpdate + */ + void NeedsUpdate(); +} + +[uuid(5142bb41-66ab-49e7-bb37-cd079c000f27)] +interface IAvnStringArray : IUnknown +{ + uint GetCount(); + HRESULT Get(uint index, IAvnString**ppv); +} + +[uuid(a13d2382-3b3a-4d1c-9b27-8f34653d3f01)] +interface IAvnDndResultCallback : IUnknown +{ + void OnDragAndDropComplete(AvnDragDropEffects effecct); +} + +[uuid(f07c608e-52e9-422d-836e-c70f6e9b80f5)] +interface IAvnGCHandleDeallocatorCallback : IUnknown +{ + void FreeGCHandle(void* handle); +} + +[uuid(91c7f677-f26b-4ff3-93cc-cf15aa966ffa)] +interface IAvnNativeControlHost : IUnknown +{ + HRESULT CreateDefaultChild(void* parent, void** retOut); + IAvnNativeControlHostTopLevelAttachment* CreateAttachment(); + void DestroyDefaultChild(void* child); +} + +[uuid(14a9e164-1aae-4271-bb78-7b5230999b52)] +interface IAvnNativeControlHostTopLevelAttachment : IUnknown +{ + void* GetParentHandle(); + HRESULT InitializeWithChildHandle(void* child); + HRESULT AttachTo(IAvnNativeControlHost* host); + void ShowInBounds(float x, float y, float width, float height); + void HideWithSize(float width, float height); + void ReleaseChild(); +} diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs new file mode 100644 index 0000000000..8613cbba88 --- /dev/null +++ b/src/tools/MicroComGenerator/Ast.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; + +namespace MicroComGenerator.Ast +{ + public class AstAttributeNode + { + public string Name { get; set; } + public string Value { get; set; } + + public AstAttributeNode(string name, string value) + { + Name = name; + Value = value; + } + + public override string ToString() => $"{Name} = {Value}"; + } + + public class AstEnumNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public override string ToString() => Name; + } + + public class AstEnumMemberNode + { + public string Name { get; set; } + public string Value { get; set; } + + public AstEnumMemberNode(string name, string value) + { + Name = name; + Value = value; + } + + public override string ToString() => $"{Name} = {Value}"; + } + + public class AstStructNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public override string ToString() => Name; + } + + public class AstTypeNode + { + public string Name { get; set; } + public int PointerLevel { get; set; } + + public override string ToString() => Name + new string('*', PointerLevel); + } + + public class AstStructMemberNode + { + public string Name { get; set; } + public AstTypeNode Type { get; set; } + + public override string ToString() => $"{Type} {Name}"; + } + + public class AstInterfaceNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public string Inherits { get; set; } + + public override string ToString() + { + if (Inherits == null) + return Name; + return $"{Name} : {Inherits}"; + } + } + + public class AstInterfaceMemberNode : List + { + public string Name { get; set; } + public AstTypeNode ReturnType { get; set; } + public List Attributes { get; set; } = new List(); + + public override string ToString() => $"{ReturnType} {Name} ({string.Join(", ", this)})"; + } + + public class AstInterfaceMemberArgumentNode + { + public string Name { get; set; } + public AstTypeNode Type { get; set; } + public List Attributes { get; set; } = new List(); + + public override string ToString() => $"{Type} {Name}"; + } + + public class AstIdlNode + { + public List Attributes { get; set; } = new List(); + public List Enums { get; set; } = new List(); + public List Structs { get; set; } = new List(); + public List Interfaces { get; set; } = new List(); + } +} diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs new file mode 100644 index 0000000000..46404da3d7 --- /dev/null +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -0,0 +1,228 @@ +using System.Collections.Generic; +using MicroComGenerator.Ast; + +namespace MicroComGenerator +{ + public class AstParser + { + public static AstIdlNode Parse(string source) + { + var parser = new TokenParser(source); + var idl = new AstIdlNode { Attributes = ParseGlobalAttributes(ref parser) }; + + while (!parser.Eof) + { + var attrs = ParseLocalAttributes(ref parser); + + if (parser.TryParseKeyword("enum")) + idl.Enums.Add(ParseEnum(attrs, ref parser)); + else if (parser.TryParseKeyword("struct")) + idl.Structs.Add(ParseStruct(attrs, ref parser)); + else if (parser.TryParseKeyword("interface")) + idl.Interfaces.Add(ParseInterface(attrs, ref parser)); + else + throw new ParseException("Unexpected character", ref parser); + } + + return idl; + } + + static List ParseGlobalAttributes(ref TokenParser parser) + { + var rv = new List(); + while (!parser.Eof) + { + parser.SkipWhitespace(); + if (parser.TryConsume('@')) + { + var ident = parser.ParseIdentifier("-"); + var value = parser.ReadToEol().Trim(); + if (value == "@@") + { + parser.Advance(1); + value = ""; + while (true) + { + var l = parser.ReadToEol(); + if (l == "@@") + break; + else + value = value.Length == 0 ? l : (value + "\n" + l); + parser.Advance(1); + } + + } + rv.Add(new AstAttributeNode(ident, value)); + } + else + return rv; + } + + return rv; + } + + static List ParseLocalAttributes(ref TokenParser parser) + { + var rv = new List(); + if (parser.TryConsume("[")) + { + while (!parser.TryConsume("]") && !parser.Eof) + { + if (parser.TryConsume(',')) + continue; + + // Get identifier + var ident = parser.ParseIdentifier("-"); + + // No value, end of attribute list + if (parser.TryConsume(']')) + { + rv.Add(new AstAttributeNode(ident, null)); + return rv; + } + // No value, next attribute + else if (parser.TryConsume(',')) + rv.Add(new AstAttributeNode(ident, null)); + // Has value + else if (parser.TryConsume('(')) + { + var value = parser.ReadTo(')'); + parser.Consume(')'); + rv.Add(new AstAttributeNode(ident, value)); + } + else + throw new ParseException("Unexpected character", ref parser); + } + + if (parser.Eof) + throw new ParseException("Unexpected EOF", ref parser); + } + + return rv; + } + + static void EnsureOpenBracket(ref TokenParser parser) + { + if (!parser.TryConsume('{')) + throw new ParseException("{ expected", ref parser); + } + + static AstEnumNode ParseEnum(List attrs, ref TokenParser parser) + { + var name = parser.ParseIdentifier(); + EnsureOpenBracket(ref parser); + var rv = new AstEnumNode { Name = name, Attributes = attrs }; + while (!parser.TryConsume('}') && !parser.Eof) + { + if (parser.TryConsume(',')) + continue; + + var ident = parser.ParseIdentifier(); + + // Automatic value + if (parser.TryConsume(',') || parser.Peek == '}') + { + rv.Add(new AstEnumMemberNode(ident, null)); + continue; + } + + if (!parser.TryConsume('=')) + throw new ParseException("Unexpected character", ref parser); + + var value = parser.ReadToAny(",}").Trim(); + rv.Add(new AstEnumMemberNode(ident, value)); + + if (parser.Eof) + throw new ParseException("Unexpected EOF", ref parser); + } + + + return rv; + } + + static AstTypeNode ParseType(ref TokenParser parser) + { + var ident = parser.ParseIdentifier(); + var t = new AstTypeNode { Name = ident }; + while (parser.TryConsume('*')) + t.PointerLevel++; + return t; + } + + static AstStructNode ParseStruct(List 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 t = ParseType(ref parser); + bool parsedAtLeastOneMember = false; + while (!parser.TryConsume(';')) + { + // Skip any , + while (parser.TryConsume(',')) { } + + var ident = parser.ParseIdentifier(); + parsedAtLeastOneMember = true; + rv.Add(new AstStructMemberNode { Name = ident, Type = t }); + } + + if (!parsedAtLeastOneMember) + throw new ParseException("Expected at least one enum member with declared type " + t, ref parser); + } + + return rv; + } + + static AstInterfaceNode ParseInterface(List interfaceAttrs, ref TokenParser parser) + { + var interfaceName = parser.ParseIdentifier(); + string inheritsFrom = null; + if (parser.TryConsume(":")) + inheritsFrom = parser.ParseIdentifier(); + + EnsureOpenBracket(ref parser); + var rv = new AstInterfaceNode + { + Name = interfaceName, Attributes = interfaceAttrs, Inherits = inheritsFrom + }; + while (!parser.TryConsume('}') && !parser.Eof) + { + var memberAttrs = ParseLocalAttributes(ref parser); + var returnType = ParseType(ref parser); + var name = parser.ParseIdentifier(); + var member = new AstInterfaceMemberNode + { + Name = name, ReturnType = returnType, Attributes = memberAttrs + }; + rv.Add(member); + + parser.Consume('('); + while (true) + { + if (parser.TryConsume(')')) + break; + + var argumentAttrs = ParseLocalAttributes(ref parser); + var type = ParseType(ref parser); + var argName = parser.ParseIdentifier(); + member.Add(new AstInterfaceMemberArgumentNode + { + Name = argName, Type = type, Attributes = argumentAttrs + }); + + if (parser.TryConsume(')')) + break; + if (parser.TryConsume(',')) + continue; + throw new ParseException("Unexpected character", ref parser); + } + + parser.Consume(';'); + } + + return rv; + } + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs new file mode 100644 index 0000000000..2fcf1b404b --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -0,0 +1,453 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using MicroComGenerator.Ast; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +// ReSharper disable CoVariantArrayConversion + +// HERE BE DRAGONS + +namespace MicroComGenerator +{ + public partial class CSharpGen + { + abstract class Arg + { + public string Name; + public string NativeType; + + public virtual StatementSyntax CreateFixed(StatementSyntax inner) => inner; + + public virtual void PreMarshal(List body) + { + } + + public virtual void PreMarshalForReturn(List body) => + throw new InvalidOperationException("Don't know how to use " + NativeType + " as HRESULT-return"); + + public virtual ExpressionSyntax Value(bool isHresultReturn) => ParseExpression(Name); + public abstract string ManagedType { get; } + public virtual string ReturnManagedType => ManagedType; + + public virtual StatementSyntax[] ReturnMarshalResult() => new[] { ParseStatement("return " + Name + ";") }; + + + public virtual void BackPreMarshal(List body) + { + } + + public virtual ExpressionSyntax BackMarshalValue() => ParseExpression(Name); + public virtual ExpressionSyntax BackMarshalReturn(string resultVar) => ParseExpression(resultVar); + + } + + class InterfaceReturnArg : Arg + { + public string InterfaceType; + public override ExpressionSyntax Value(bool isHresultReturn) => ParseExpression("&" + PName); + public override string ManagedType => InterfaceType; + + private string PName => "__marshal_" + Name; + + public override void PreMarshalForReturn(List body) + { + body.Add(ParseStatement("void* " + PName + " = null;")); + } + + public override StatementSyntax[] ReturnMarshalResult() => new[] + { + ParseStatement("return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + PName + ", true);") + }; + + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression("INVALID"); + } + + public override ExpressionSyntax BackMarshalReturn(string resultVar) + { + return ParseExpression($"Avalonia.MicroCom.MicroComRuntime.GetNativePointer({resultVar}, true)"); + } + } + + class InterfaceArg : Arg + { + public string InterfaceType; + + public override ExpressionSyntax Value(bool isHresultReturn) => + ParseExpression("Avalonia.MicroCom.MicroComRuntime.GetNativePointer(" + Name + ")"); + + public override string ManagedType => InterfaceType; + + public override StatementSyntax[] ReturnMarshalResult() => new[] + { + ParseStatement("return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + Name + ", true);") + }; + + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression("Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + Name + ", false)"); + } + + public override ExpressionSyntax BackMarshalReturn(string resultVar) + { + return ParseExpression($"Avalonia.MicroCom.MicroComRuntime.GetNativePointer({resultVar}, true)"); + } + } + + class BypassArg : Arg + { + public string Type { get; set; } + public int PointerLevel; + public override string ManagedType => Type + new string('*', PointerLevel); + public override string ReturnManagedType => Type + new string('*', PointerLevel - 1); + + public override ExpressionSyntax Value(bool isHresultReturn) + { + if (isHresultReturn) + return ParseExpression("&" + Name); + return base.Value(false); + } + + public override void PreMarshalForReturn(List body) + { + if (PointerLevel == 0) + base.PreMarshalForReturn(body); + else + body.Add(ParseStatement(Type + new string('*', PointerLevel - 1) + " " + Name + "=default;")); + } + } + + class StringArg : Arg + { + private string BName => "__bytemarshal_" + Name; + private string FName => "__fixedmarshal_" + Name; + + public override void PreMarshal(List body) + { + body.Add(ParseStatement($"var {BName} = new byte[System.Text.Encoding.UTF8.GetByteCount({Name})+1];")); + body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name.Length}, {BName}, 0);")); + } + + public override StatementSyntax CreateFixed(StatementSyntax inner) + { + return FixedStatement(DeclareVar("byte*", FName, ParseExpression(BName)), inner); + } + + public override ExpressionSyntax Value(bool isHresultReturn) => ParseExpression(FName); + public override string ManagedType => "string"; + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression( + $"({Name} == null ? null : System.Runtime.InteropServices.Marshal.PtrToStringAnsi(new IntPtr(" + Name + ")))"); + } + } + + string ConvertNativeType(string type) + { + if (type == "size_t") + return "System.IntPtr"; + if (type == "HRESULT") + return "int"; + return type; + } + + Arg ConvertArg(string name, AstTypeNode type) + { + type = new AstTypeNode { Name = ConvertNativeType(type.Name), PointerLevel = type.PointerLevel }; + + if (type.PointerLevel == 2) + { + if (type.Name.StartsWith("I")) + return new InterfaceReturnArg { Name = name, InterfaceType = type.Name, NativeType = "void**" }; + } + else if (type.PointerLevel == 1) + { + if (type.Name.StartsWith("I")) + return new InterfaceArg { Name = name, InterfaceType = type.Name, NativeType = "void*" }; + if (type.Name == "char") + return new StringArg { Name = name, NativeType = "byte*" }; + } + + return new BypassArg + { + Name = name, Type = type.Name, PointerLevel = type.PointerLevel, NativeType = type.ToString() + }; + } + + + void GenerateInterfaceMember(AstInterfaceMemberNode member, ref InterfaceDeclarationSyntax iface, + ref ClassDeclarationSyntax proxy, ref ClassDeclarationSyntax vtbl, + List vtblCtor, int num) + { + // Prepare method information + var args = member.Select(a => ConvertArg(a.Name, a.Type)).ToList(); + var returnArg = ConvertArg("__result", member.ReturnType); + bool isHresult = member.ReturnType.Name == "HRESULT"; + bool isHresultLastArgumentReturn = isHresult + && 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")) + || member.Last().Type.PointerLevel == 2); + + bool isVoidReturn = member.ReturnType.Name == "void" && member.ReturnType.PointerLevel == 0; + + + // Generate method signature + MethodDeclarationSyntax GenerateManagedSig(string returnType, string name, + IEnumerable<(string n, string t)> args) + => MethodDeclaration(ParseTypeName(returnType), name).WithParameterList( + ParameterList( + SeparatedList(args.Select(x => Parameter(Identifier(x.n)).WithType(ParseTypeName(x.t)))))); + + var managedSig = + isHresult ? + GenerateManagedSig(isHresultLastArgumentReturn ? args.Last().ReturnManagedType : "void", + member.Name, + (isHresultLastArgumentReturn ? args.SkipLast(1) : args).Select(a => (a.Name, a.ManagedType))) : + GenerateManagedSig(returnArg.ManagedType, member.Name, args.Select(a => (a.Name, a.ManagedType))); + + iface = iface.AddMembers(managedSig.WithSemicolonToken(Semicolon())); + + // Prepare args for marshaling + var preMarshal = new List(); + if (!isVoidReturn) + preMarshal.Add(ParseStatement(returnArg.NativeType + " __result;")); + + for (var idx = 0; idx < args.Count; idx++) + { + if (isHresultLastArgumentReturn && idx == args.Count - 1) + args[idx].PreMarshalForReturn(preMarshal); + else + args[idx].PreMarshal(preMarshal); + } + + // Generate call expression + ExpressionSyntax callExpr = InvocationExpression(_localInterop.GetCaller(returnArg.NativeType, + args.Select(x => x.NativeType).ToList())) + .AddArgumentListArguments(Argument(ParseExpression("PPV"))) + .AddArgumentListArguments(args + .Select((a, i) => Argument(a.Value(isHresultLastArgumentReturn && i == args.Count - 1))).ToArray()) + .AddArgumentListArguments(Argument(ParseExpression("PPV[base.VTableSize + " + num + "]"))); + + // Save call result if needed + if (!isVoidReturn) + callExpr = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, ParseExpression("__result"), + callExpr); + + + // Wrap call into fixed() blocks + StatementSyntax callStatement = ExpressionStatement(callExpr); + foreach (var arg in args) + callStatement = arg.CreateFixed(callStatement); + + // Build proxy body + var proxyBody = Block() + .AddStatements(preMarshal.ToArray()) + .AddStatements(callStatement); + + // Process return value + if (!isVoidReturn) + { + if (isHresult) + { + proxyBody = proxyBody.AddStatements( + ParseStatement( + $"if(__result != 0) throw new System.Runtime.InteropServices.COMException(\"{member.Name} failed\", __result);")); + + if (isHresultLastArgumentReturn) + proxyBody = proxyBody.AddStatements(args.Last().ReturnMarshalResult()); + } + else + proxyBody = proxyBody.AddStatements(returnArg.ReturnMarshalResult()); + } + + // Add the proxy method + proxy = proxy.AddMembers(managedSig.AddModifiers(SyntaxKind.PublicKeyword) + .WithBody(proxyBody)); + + + // Generate VTable method + + var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name+"Delegate") + .AddParameterListParameters(Parameter(Identifier("@this")).WithType(ParseTypeName("IntPtr"))) + .AddParameterListParameters(args.Select(x => + Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()); + + var shadowMethod = MethodDeclaration(shadowDelegate.ReturnType, member.Name) + .WithParameterList(shadowDelegate.ParameterList) + .AddModifiers(Token(SyntaxKind.StaticKeyword)); + + var backPreMarshal = new List(); + foreach (var arg in args) + arg.BackPreMarshal(backPreMarshal); + + backPreMarshal.Add( + ParseStatement($"__target = ({iface.Identifier.Text})Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this);")); + + var isBackVoidReturn = isVoidReturn || (isHresult && !isHresultLastArgumentReturn); + + StatementSyntax backCallStatement; + + var backCallExpr = + IsPropertyRewriteCandidate(managedSig) ? + ParseExpression("__target." + member.Name.Substring(3)) : + InvocationExpression(ParseExpression("__target." + member.Name)) + .WithArgumentList(ArgumentList(SeparatedList( + (isHresultLastArgumentReturn ? args.SkipLast(1) : args) + .Select(a => + Argument(a.BackMarshalValue()))))); + + if (isBackVoidReturn) + backCallStatement = ExpressionStatement(backCallExpr); + else + { + backCallStatement = LocalDeclarationStatement(DeclareVar("var", "__result", backCallExpr)); + if (isHresultLastArgumentReturn) + { + backCallStatement = Block(backCallStatement, + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + ParseExpression("*" + args.Last().Name), + args.Last().BackMarshalReturn("__result") + ))); + + } + else + backCallStatement = Block(backCallStatement, + ReturnStatement(returnArg.BackMarshalReturn("__result"))); + } + + BlockSyntax backBodyBlock = Block().AddStatements(backPreMarshal.ToArray()).AddStatements(backCallStatement); + + + backBodyBlock = Block( + TryStatement( + SingletonList(CatchClause( + CatchDeclaration(ParseTypeName("System.Exception"), Identifier("__exception__")), null, + Block( + ParseStatement( + "Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__);"), + isHresult ? ParseStatement("return unchecked((int)0x80004005u);") + : isVoidReturn ? EmptyStatement() : ParseStatement("return default;") + )))) + .WithBlock(Block(backBodyBlock)) + ); + if (isHresult) + backBodyBlock = backBodyBlock.AddStatements(ParseStatement("return 0;")); + + + backBodyBlock = Block() + .AddStatements(ParseStatement($"{iface.Identifier.Text} __target = null;")) + .AddStatements(backBodyBlock.Statements.ToArray()); + + shadowMethod = shadowMethod.WithBody(backBodyBlock); + + vtbl = vtbl.AddMembers(shadowDelegate).AddMembers(shadowMethod); + vtblCtor.Add(ParseStatement("base.AddMethod((" + shadowDelegate.Identifier.Text + ")" + + shadowMethod.Identifier.Text + ");")); + + + + + } + + class LocalInteropHelper + { + public ClassDeclarationSyntax Class { get; private set; } = ClassDeclaration("LocalInterop"); + private HashSet _existing = new HashSet(); + + public ExpressionSyntax GetCaller(string returnType, List args) + { + var name = "CalliStdCall" + returnType.Replace("*", "_ptr"); + var signature = returnType + "::" + name + "::" + string.Join("::", args); + if (_existing.Add(signature)) + { + Class = Class.AddMembers(MethodDeclaration(ParseTypeName(returnType), name) + .AddModifiers(SyntaxKind.StaticKeyword, SyntaxKind.UnsafeKeyword, SyntaxKind.PublicKeyword) + .AddParameterListParameters(Parameter(Identifier("thisObj")).WithType(ParseTypeName("void*"))) + .AddParameterListParameters(args.Select((x, i) => + Parameter(Identifier("arg" + i)).WithType(ParseTypeName(x))).ToArray()) + .AddParameterListParameters(Parameter(Identifier("methodPtr")).WithType(ParseTypeName("void*"))) + .WithBody(Block(ExpressionStatement(ThrowExpression(ParseExpression("null")))))); + } + + return ParseExpression("LocalInterop." + name); + } + } + + + 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 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)); + + var proxyClassName = "__MicroCom" + iface.Name + "Proxy"; + var proxy = ClassDeclaration(proxyClassName) + .AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility)) + .WithBaseType(inheritsUnknown ? + "Avalonia.MicroCom.MicroComProxyBase" : + ("__MicroCom" + iface.Inherits + "Proxy")); + + + // Generate vtable + var vtbl = ClassDeclaration("__MicroCom" + iface.Name + "VTable") + .AddModifiers(Token(SyntaxKind.UnsafeKeyword)); + + vtbl = vtbl.WithBaseType(inheritsUnknown ? + "Avalonia.MicroCom.MicroComVtblBase" : + "__MicroCom" + iface.Inherits + "VTable"); + + var vtblCtor = new List(); + for (var idx = 0; idx < iface.Count; idx++) + GenerateInterfaceMember(iface[idx], ref ifaceDec, ref proxy, ref vtbl, vtblCtor, idx); + + vtbl = vtbl.AddMembers( + ConstructorDeclaration(vtbl.Identifier.Text) + .AddModifiers(Token(SyntaxKind.PublicKeyword)) + .WithBody(Block(vtblCtor)) + ) + .AddMembers(MethodDeclaration(ParseTypeName("void"), "__MicroComModuleInit") + .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) + .WithExpressionBody(ArrowExpressionClause( + ParseExpression("Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(" + + proxyClassName + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) + .WithSemicolonToken(Semicolon())); + + + // Finalize proxy code + proxy = proxy.AddMembers( + MethodDeclaration(ParseTypeName("void"), "__MicroComModuleInit") + .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) + .WithBody(Block( + ParseStatement("Avalonia.MicroCom.MicroComRuntime.Register(typeof(" + + proxyClassName + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + + proxyClassName + "(p, owns));") + ))) + .AddMembers(ParseMemberDeclaration("public " + proxyClassName + + "(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) {}")) + .AddMembers(ParseMemberDeclaration("protected override int VTableSize => base.VTableSize + " + + iface.Count + ";")); + + ns = ns.AddMembers(RewriteMethodsToProperties(ifaceDec)); + implNs = implNs.AddMembers(RewriteMethodsToProperties(proxy), RewriteMethodsToProperties(vtbl)); + } + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.Utils.cs b/src/tools/MicroComGenerator/CSharpGen.Utils.cs new file mode 100644 index 0000000000..ed2bcdd6d8 --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.Utils.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Formatting; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +namespace MicroComGenerator +{ + public partial class CSharpGen + { + + CompilationUnitSyntax Unit() + => CompilationUnit().WithUsings(List(new[] + { + "System", "System.Text", "System.Collections", "System.Collections.Generic", "Avalonia.MicroCom" + } + .Concat(_extraUsings).Select(u => UsingDirective(IdentifierName(u))))); + + 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) + + ).ToFullString(); + } + + + SyntaxToken Semicolon() => Token(SyntaxKind.SemicolonToken); + + static VariableDeclarationSyntax DeclareVar(string type, string name, + ExpressionSyntax? initializer = null) + => VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList(VariableDeclarator(name) + .WithInitializer(initializer == null ? null : EqualsValueClause(initializer)))); + + FieldDeclarationSyntax DeclareConstant(string type, string name, LiteralExpressionSyntax value) + => FieldDeclaration( + VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList( + VariableDeclarator(name).WithInitializer(EqualsValueClause(value)) + )) + ).WithSemicolonToken(Semicolon()) + .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ConstKeyword))); + + FieldDeclarationSyntax DeclareField(string type, string name, params SyntaxKind[] modifiers) => + DeclareField(type, name, null, modifiers); + + FieldDeclarationSyntax DeclareField(string type, string name, EqualsValueClauseSyntax initializer, + params SyntaxKind[] modifiers) => + FieldDeclaration( + VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList( + VariableDeclarator(name).WithInitializer(initializer)))) + .WithSemicolonToken(Semicolon()) + .WithModifiers(TokenList(modifiers.Select(x => Token(x)))); + + bool IsPropertyRewriteCandidate(MethodDeclarationSyntax method) + { + if(method.Identifier.Text.Contains("GetScaling")) + Console.WriteLine(); + return (method.Identifier.Text.StartsWith("Get") && + method.ParameterList.Parameters.Count == 0); + } + + TypeDeclarationSyntax RewriteMethodsToProperties(T decl) where T : TypeDeclarationSyntax + { + var replace = new Dictionary(); + foreach (var method in decl.Members.OfType().ToList()) + { + if (IsPropertyRewriteCandidate(method)) + { + var getter = AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); + if (method.Body != null) + getter = getter.WithBody(method.Body); + else + getter = getter.WithSemicolonToken(Semicolon()); + + replace[method] = PropertyDeclaration(method.ReturnType, + method.Identifier.Text.Substring(3)) + .WithModifiers(method.Modifiers).AddAccessorListAccessors(getter); + + } + } + + return decl.ReplaceNodes(replace.Keys, (m, m2) => replace[m]); + } + + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs new file mode 100644 index 0000000000..49e4f7a09e --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using MicroComGenerator.Ast; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +// ReSharper disable CoVariantArrayConversion + +namespace MicroComGenerator +{ + public partial class CSharpGen + { + private readonly AstIdlNode _idl; + private List _extraUsings; + private string _namespace; + private SyntaxKind _visibility; + private LocalInteropHelper _localInterop = new LocalInteropHelper(); + + public CSharpGen(AstIdlNode idl) + { + _idl = 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"); + if (visibilityString == "internal") + _visibility = SyntaxKind.InternalKeyword; + else if (visibilityString == "public") + _visibility = SyntaxKind.PublicKeyword; + else + throw new CodeGenException("Invalid clr-access attribute"); + } + + public string Generate() + { + var ns = NamespaceDeclaration(ParseName(_namespace)); + var implNs = NamespaceDeclaration(ParseName(_namespace + ".Impl")); + ns = GenerateEnums(ns); + ns = GenerateStructs(ns); + foreach (var i in _idl.Interfaces) + GenerateInterface(ref ns, ref implNs, i); + + implNs = implNs.AddMembers(_localInterop.Class); + var unit = Unit().AddMembers(ns, implNs); + + return Format(unit); + } + + NamespaceDeclarationSyntax GenerateEnums(NamespaceDeclarationSyntax ns) + { + return ns.AddMembers(_idl.Enums.Select(e => + EnumDeclaration(e.Name) + .WithModifiers(TokenList(Token(_visibility))) + .WithMembers(SeparatedList(e.Select(m => + { + var member = EnumMemberDeclaration(m.Name); + if (m.Value != null) + return member.WithEqualsValue(EqualsValueClause(ParseExpression(m.Value))); + return member; + }))) + ).ToArray()); + } + + NamespaceDeclarationSyntax GenerateStructs(NamespaceDeclarationSyntax ns) + { + return ns.AddMembers(_idl.Structs.Select(e => + StructDeclaration(e.Name) + .WithModifiers(TokenList(Token(_visibility))) + .AddModifiers(Token(SyntaxKind.UnsafeKeyword)) + .AddAttributeLists(AttributeList(SingletonSeparatedList( + Attribute(ParseName("System.Runtime.InteropServices.StructLayout"), + AttributeArgumentList(SingletonSeparatedList( + AttributeArgument( + ParseExpression("System.Runtime.InteropServices.LayoutKind.Sequential")))) + )))) + .WithMembers(new SyntaxList(SeparatedList(e.Select(m => + DeclareField(m.Type.ToString(), m.Name, SyntaxKind.PublicKeyword))))) + ).ToArray()); + } + + + + } +} diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs new file mode 100644 index 0000000000..133902f764 --- /dev/null +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -0,0 +1,108 @@ +using System; +using System.Linq; +using System.Text; +using MicroComGenerator.Ast; + +namespace MicroComGenerator +{ + public class CppGen + { + static string ConvertType(AstTypeNode type) + { + var name = type.Name; + if (name == "byte") + name = "unsigned char"; + else if(name == "uint") + name = "unsigned int"; + return name + new string('*', type.PointerLevel); + } + + public static string GenerateCpp(AstIdlNode idl) + { + var sb = new StringBuilder(); + var preamble = idl.Attributes.FirstOrDefault(x => x.Name == "cpp-preamble")?.Value; + if (preamble != null) + sb.AppendLine(preamble); + + foreach (var s in idl.Structs) + sb.AppendLine("struct " + s.Name + ";"); + + foreach (var s in idl.Interfaces) + sb.AppendLine("struct " + s.Name + ";"); + + foreach (var en in idl.Enums) + { + sb.Append("enum "); + if (en.Attributes.Any(a => a.Name == "class-enum")) + sb.Append("class "); + sb.Append(en.Name).Append(" "); + sb.AppendLine(en.Name).AppendLine("{"); + + foreach (var m in en) + { + sb.Append(" ").Append(m.Name); + if (m.Value != null) + sb.Append(" = ").Append(m.Value); + sb.AppendLine(","); + } + + sb.AppendLine("};"); + } + + foreach (var s in idl.Structs) + { + sb.Append("struct ").AppendLine(s.Name).AppendLine("{"); + foreach (var m in s) + sb.Append(" ").Append(ConvertType(m.Type)).Append(" ").Append(m.Name).AppendLine(";"); + + sb.AppendLine("};"); + } + + 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 guid = Guid.Parse(guidString).ToString().Replace("-", ""); + + + sb.Append("COMINTERFACE(").Append(i.Name).Append(", ") + .Append(guid.Substring(0, 8)).Append(", ") + .Append(guid.Substring(8, 4)).Append(", ") + .Append(guid.Substring(12, 4)); + for (var c = 0; c < 8; c++) + { + sb.Append(", ").Append(guid.Substring(16 + c * 2, 2)); + } + + sb.Append(") : ") + .AppendLine(i.Inherits ?? "IUnknown") + .AppendLine("{"); + + foreach (var m in i) + { + sb.Append(" ").Append(ConvertType(m.ReturnType)).Append(" ").Append(m.Name).AppendLine(" ("); + for (var c = 0; c < m.Count; c++) + { + var arg = m[c]; + sb.Append(" "); + if (arg.Attributes.Any(a => a.Name == "const")) + sb.Append("const "); + sb.Append(ConvertType(arg.Type)) + .Append(" ") + .Append(arg.Name); + if (c != m.Count - 1) + sb.Append(", "); + sb.AppendLine(); + sb.AppendLine(" );"); + } + } + + sb.AppendLine("}"); + } + + return sb.ToString(); + } + } +} diff --git a/src/tools/MicroComGenerator/Extensions.cs b/src/tools/MicroComGenerator/Extensions.cs new file mode 100644 index 0000000000..4942442d1b --- /dev/null +++ b/src/tools/MicroComGenerator/Extensions.cs @@ -0,0 +1,90 @@ + +using System; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +namespace MicroComGenerator +{ + public static class Extensions + { + public static ClassDeclarationSyntax AddModifiers(this ClassDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static MethodDeclarationSyntax AddModifiers(this MethodDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static PropertyDeclarationSyntax AddModifiers(this PropertyDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static ConstructorDeclarationSyntax AddModifiers(this ConstructorDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static AccessorDeclarationSyntax AddModifiers(this AccessorDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static string WithLowerFirst(this string s) + { + if (string.IsNullOrEmpty(s)) + return s; + return char.ToLowerInvariant(s[0]) + s.Substring(1); + } + + public static ExpressionSyntax MemberAccess(params string[] identifiers) + { + if (identifiers == null || identifiers.Length == 0) + throw new ArgumentException(); + var expr = (ExpressionSyntax)IdentifierName(identifiers[0]); + for (var c = 1; c < identifiers.Length; c++) + expr = MemberAccess(expr, identifiers[c]); + return expr; + } + + public static ExpressionSyntax MemberAccess(ExpressionSyntax expr, params string[] identifiers) + { + foreach (var i in identifiers) + expr = MemberAccess(expr, i); + return expr; + } + + public static MemberAccessExpressionSyntax MemberAccess(ExpressionSyntax expr, string identifier) => + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, IdentifierName(identifier)); + + public static ClassDeclarationSyntax WithBaseType(this ClassDeclarationSyntax cl, string bt) + { + return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); + } + + public static InterfaceDeclarationSyntax WithBaseType(this InterfaceDeclarationSyntax cl, string bt) + { + return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); + } + + public static string StripPrefix(this string s, string prefix) => string.IsNullOrEmpty(s) + ? s + : s.StartsWith(prefix) + ? s.Substring(prefix.Length) + : s; + } +} diff --git a/src/tools/MicroComGenerator/MicroComGenerator.csproj b/src/tools/MicroComGenerator/MicroComGenerator.csproj new file mode 100644 index 0000000000..193bb9a100 --- /dev/null +++ b/src/tools/MicroComGenerator/MicroComGenerator.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/src/tools/MicroComGenerator/ParseException.cs b/src/tools/MicroComGenerator/ParseException.cs new file mode 100644 index 0000000000..dfa8dcfe54 --- /dev/null +++ b/src/tools/MicroComGenerator/ParseException.cs @@ -0,0 +1,27 @@ +using System; + +namespace MicroComGenerator +{ + class ParseException : Exception + { + public int Line { get; } + public int Position { get; } + + public ParseException(string message, int line, int position) : base(message) + { + Line = line; + Position = position; + } + + public ParseException(string message, ref TokenParser parser) : this(message, parser.Line, parser.Position) + { + } + } + + class CodeGenException : Exception + { + public CodeGenException(string message) : base(message) + { + } + } +} diff --git a/src/tools/MicroComGenerator/Program.cs b/src/tools/MicroComGenerator/Program.cs new file mode 100644 index 0000000000..578ba1465d --- /dev/null +++ b/src/tools/MicroComGenerator/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using System.Linq; +using CommandLine; + +namespace MicroComGenerator +{ + class Program + { + public class Options + { + [Option('i', "input", Required = true, HelpText = "Input IDL file")] + public string Input { get; set; } + + [Option("cpp", Required = false, HelpText = "C++ output file")] + public string CppOutput { get; set; } + + [Option("cs", Required = false, HelpText = "C# output file")] + public string CSharpOutput { get; set; } + + } + + static int Main(string[] args) + { + var p = Parser.Default.ParseArguments(args); + if (p is NotParsed) + { + return 1; + } + + var opts = ((Parsed)p).Value; + + var text = File.ReadAllText(opts.Input); + var ast = AstParser.Parse(text); + + if (opts.CppOutput != null) + File.WriteAllText(opts.CppOutput, CppGen.GenerateCpp(ast)); + if (opts.CSharpOutput != null) + File.WriteAllText(opts.CSharpOutput, new CSharpGen(ast).Generate()); + + return 0; + } + } +} diff --git a/src/tools/MicroComGenerator/TokenParser.cs b/src/tools/MicroComGenerator/TokenParser.cs new file mode 100644 index 0000000000..ea8850b8e4 --- /dev/null +++ b/src/tools/MicroComGenerator/TokenParser.cs @@ -0,0 +1,417 @@ +using System; +using System.Globalization; +using System.IO; + +namespace MicroComGenerator +{ + internal ref struct TokenParser + { + private ReadOnlySpan _s; + public int Position { get; private set; } + public int Line { get; private set; } + public TokenParser(ReadOnlySpan s) + { + _s = s; + Position = 0; + Line = 0; + } + + public void SkipWhitespace() + { + while (true) + { + if(_s.Length == 0) + return; + if (char.IsWhiteSpace(_s[0])) + Advance(1); + else if (_s[0] == '/' && _s.Length>1) + { + if (_s[1] == '/') + SkipOneLineComment(); + else if (_s[1] == '*') + SkipMultiLineComment(); + else + return; + } + else + return; + } + } + + void SkipOneLineComment() + { + while (true) + { + if (_s.Length > 0 && _s[0] != '\n' && _s[0] != '\r') + Advance(1); + else + return; + } + } + + void SkipMultiLineComment() + { + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("No matched */ found for /*", l, p); + + if (_s[0] == '*' && _s.Length > 1 && _s[1] == '/') + { + Advance(2); + return; + } + + Advance(1); + } + } + + static bool IsAlphaNumeric(char ch) => (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || + (ch >= 'A' && ch <= 'Z'); + + public void Consume(char c) + { + if (!TryConsume(c)) + throw new ParseException("Expected " + c, Line, Position); + } + public bool TryConsume(char c) + { + SkipWhitespace(); + if (_s.Length == 0 || _s[0] != c) + return false; + + Advance(1); + return true; + } + + public bool TryConsume(string s) + { + SkipWhitespace(); + if (_s.Length < s.Length) + return false; + for (var c = 0; c < s.Length; c++) + { + if (_s[c] != s[c]) + return false; + } + + Advance(s.Length); + return true; + } + + public bool TryConsumeAny(ReadOnlySpan chars, out char token) + { + SkipWhitespace(); + token = default; + if (_s.Length == 0) + return false; + + foreach (var c in chars) + { + if (c == _s[0]) + { + token = c; + Advance(1); + return true; + } + } + + return false; + } + + + public bool TryParseKeyword(string keyword) + { + SkipWhitespace(); + if (keyword.Length > _s.Length) + return false; + for(var c=0; c keyword.Length && IsAlphaNumeric(_s[keyword.Length])) + return false; + + Advance(keyword.Length); + return true; + } + + public bool TryParseKeywordLowerCase(string keywordInLowerCase) + { + SkipWhitespace(); + if (keywordInLowerCase.Length > _s.Length) + return false; + for(var c=0; c keywordInLowerCase.Length && IsAlphaNumeric(_s[keywordInLowerCase.Length])) + return false; + + Advance(keywordInLowerCase.Length); + return true; + } + + public void Advance(int c) + { + while (c > 0) + { + if (_s[0] == '\n') + { + Line++; + Position = 0; + } + else + Position++; + + _s = _s.Slice(1); + c--; + } + } + + public int Length => _s.Length; + public bool Eof + { + get + { + SkipWhitespace(); + return Length == 0; + } + } + + public char Peek + { + get + { + if (_s.Length == 0) + throw new ParseException("Unexpected EOF", Line, Position); + return _s[0]; + } + } + + public string ParseIdentifier(ReadOnlySpan extraValidChars) + { + if (!TryParseIdentifier(extraValidChars, out var ident)) + throw new ParseException("Identifier expected", Line, Position); + return ident.ToString(); + } + + public string ParseIdentifier() + { + if (!TryParseIdentifier(out var ident)) + throw new ParseException("Identifier expected", Line, Position); + return ident.ToString(); + } + + public bool TryParseIdentifier(ReadOnlySpan extraValidChars, out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_')) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if (IsAlphaNumeric(ch) || ch == '_') + len++; + else + { + var found = false; + foreach(var vc in extraValidChars) + if (vc == ch) + { + found = true; + break; + } + + if (found) + len++; + else + break; + } + } + + res = _s.Slice(0, len); + Advance(len); + return true; + } + + public bool TryParseIdentifier(out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_')) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if (IsAlphaNumeric(ch) || ch == '_') + len++; + else + break; + } + + res = _s.Slice(0, len); + Advance(len); + return true; + } + + public string ReadToEol() + { + var initial = _s; + var len = 0; + while (true) + { + if (_s.Length > 0 && _s[0] != '\n' && _s[0] != '\r') + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public string ReadTo(char c) + { + var initial = _s; + var len = 0; + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("Expected " + c + " before EOF", l, p); + + if (_s[0] != c) + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public string ReadToAny(ReadOnlySpan chars) + { + var initial = _s; + var len = 0; + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("Expected any of '" + chars.ToString() + "' before EOF", l, p); + + var foundTerminator = false; + foreach (var term in chars) + { + if (_s[0] == term) + { + foundTerminator = true; + break; + } + } + + if (!foundTerminator) + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public bool TryParseCall(out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z'))) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch<= 'Z') || ch == '.') + len++; + else + break; + } + + res = _s.Slice(0, len); + + // Find '(' + for (var c = len; c < _s.Length; c++) + { + if(char.IsWhiteSpace(_s[c])) + continue; + if(_s[c]=='(') + { + Advance(c + 1); + return true; + } + + return false; + + } + + return false; + + } + + + public bool TryParseFloat(out float res) + { + res = 0; + SkipWhitespace(); + if (_s.Length == 0) + return false; + + var len = 0; + var dotCount = 0; + for (var c = 0; c < _s.Length; c++) + { + var ch = _s[c]; + if (ch >= '0' && ch <= '9') + len = c + 1; + else if (ch == '.' && dotCount == 0) + { + len = c + 1; + dotCount++; + } + else + break; + } + + var span = _s.Slice(0, len); + +#if NETSTANDARD2_0 + if (!float.TryParse(span.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out res)) + return false; +#else + if (!float.TryParse(span, NumberStyles.Number, CultureInfo.InvariantCulture, out res)) + return false; +#endif + Advance(len); + return true; + } + + public override string ToString() => _s.ToString(); + + } +} From aeb08c7ae3b3ad800ec2cc70ec73088a04152c10 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 16:56:26 +0300 Subject: [PATCH 21/35] Use MicroCom instead of SharpGen (NOT TESTED YET) --- src/Avalonia.MicroCom/IUnknown.cs | 4 - src/Avalonia.MicroCom/MicroComProxyBase.cs | 33 +- src/Avalonia.MicroCom/MicroComRuntime.cs | 11 +- src/Avalonia.MicroCom/MicroComShadow.cs | 2 +- src/Avalonia.Native/.gitignore | 1 + src/Avalonia.Native/Avalonia.Native.csproj | 27 +- .../AvaloniaNativeMenuExporter.cs | 7 +- src/Avalonia.Native/AvaloniaNativePlatform.cs | 12 +- .../AvaloniaNativePlatformOpenGlInterface.cs | 4 +- src/Avalonia.Native/AvnString.cs | 22 +- src/Avalonia.Native/CallbackBase.cs | 78 +- src/Avalonia.Native/ClipboardImpl.cs | 16 +- src/Avalonia.Native/DeferredFramebuffer.cs | 7 +- src/Avalonia.Native/Generated/Enumerations.cs | 628 ---- src/Avalonia.Native/Generated/Functions.cs | 5 - src/Avalonia.Native/Generated/Interfaces.cs | 3092 ----------------- src/Avalonia.Native/Generated/LocalInterop.cs | 202 -- src/Avalonia.Native/Generated/Structures.cs | 246 -- src/Avalonia.Native/Helpers.cs | 2 +- src/Avalonia.Native/IAvnMenu.cs | 45 +- src/Avalonia.Native/IAvnMenuItem.cs | 41 +- src/Avalonia.Native/NativeControlHostImpl.cs | 4 +- .../PlatformThreadingInterface.cs | 5 +- src/Avalonia.Native/ScreenImpl.cs | 2 +- src/Avalonia.Native/SystemDialogs.cs | 8 +- src/Avalonia.Native/WindowImpl.cs | 28 +- src/Avalonia.Native/WindowImplBase.cs | 18 +- src/Avalonia.Native/avn.idl | 42 +- src/tools/MicroComGenerator/Ast.cs | 175 +- src/tools/MicroComGenerator/AstParser.cs | 17 +- .../CSharpGen.InterfaceGen.cs | 18 +- .../MicroComGenerator/CSharpGen.Utils.cs | 25 +- src/tools/MicroComGenerator/CSharpGen.cs | 52 +- src/tools/MicroComGenerator/CppGen.cs | 7 +- .../MicroComGenerator.csproj | 2 - 35 files changed, 457 insertions(+), 4431 deletions(-) delete mode 100644 src/Avalonia.Native/Generated/Enumerations.cs delete mode 100644 src/Avalonia.Native/Generated/Functions.cs delete mode 100644 src/Avalonia.Native/Generated/Interfaces.cs delete mode 100644 src/Avalonia.Native/Generated/LocalInterop.cs delete mode 100644 src/Avalonia.Native/Generated/Structures.cs diff --git a/src/Avalonia.MicroCom/IUnknown.cs b/src/Avalonia.MicroCom/IUnknown.cs index a46953ced9..0dc4106423 100644 --- a/src/Avalonia.MicroCom/IUnknown.cs +++ b/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() where T : IUnknown; } } diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs index 56b80c2632..6a13fb10c4 100644 --- a/src/Avalonia.MicroCom/MicroComProxyBase.cs +++ b/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); + } } } diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs index eccf24b496..d43568631a 100644 --- a/src/Avalonia.MicroCom/MicroComRuntime.cs +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -34,9 +34,10 @@ namespace Avalonia.MicroCom public static Guid GetGuidFor(Type type) => _guids[type]; - public static T CreateProxyFor(void* ppv, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(ppv), ownsHandle); + public static T CreateProxyFor(void* pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(pObject), ownsHandle); + public static T CreateProxyFor(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 obj, bool owned = false) where T : IUnknown { @@ -84,5 +85,11 @@ namespace Avalonia.MicroCom } } + + public static T CloneReference(T iface) where T : IUnknown + { + var ownedPointer = GetNativePointer(iface, true); + return CreateProxyFor(ownedPointer, true); + } } } diff --git a/src/Avalonia.MicroCom/MicroComShadow.cs b/src/Avalonia.MicroCom/MicroComShadow.cs index c9411a089e..a6a0fd519e 100644 --- a/src/Avalonia.MicroCom/MicroComShadow.cs +++ b/src/Avalonia.MicroCom/MicroComShadow.cs @@ -77,7 +77,7 @@ namespace Avalonia.MicroCom { try { - Target.OnUnreferencedFromNative(); + Target.OnReferencedFromNative(); } catch (Exception e) { diff --git a/src/Avalonia.Native/.gitignore b/src/Avalonia.Native/.gitignore index b1153e777c..b270c05962 100644 --- a/src/Avalonia.Native/.gitignore +++ b/src/Avalonia.Native/.gitignore @@ -1 +1,2 @@ Generated/*.cs +*.Generated.cs diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index 49bd578290..a3e99595c2 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -21,11 +21,30 @@ - - - - + + + + + false + all + true + + + + + + + + + + + + + + <_AvaloniaPatchComInterop>true + + \ No newline at end of file diff --git a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs index 6d1b95b997..b192de95de 100644 --- a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs +++ b/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, ""); diff --git a/src/Avalonia.Native/AvaloniaNativePlatform.cs b/src/Avalonia.Native/AvaloniaNativePlatform.cs index e8b2f065c7..6ce55e17b3 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatform.cs +++ b/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(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(); - _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); } } } diff --git a/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs b/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs index dbe968b82f..3b3d8836fd 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs +++ b/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; diff --git a/src/Avalonia.Native/AvnString.cs b/src/Avalonia.Native/AvnString.cs index 11b1a33276..dcd473bae3 100644 --- a/src/Avalonia.Native/AvnString.cs +++ b/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() { diff --git a/src/Avalonia.Native/CallbackBase.cs b/src/Avalonia.Native/CallbackBase.cs index 4cda358d0a..455ed4b159 100644 --- a/src/Avalonia.Native/CallbackBase.cs +++ b/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() 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() is PlatformThreadingInterface threadingInterface) + lock (_lock) { - threadingInterface.TerminateNativeApp(); - - threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e)); + _referencedFromNative = false; + DestroyIfNeeded(); } } } diff --git a/src/Avalonia.Native/ClipboardImpl.cs b/src/Avalonia.Native/ClipboardImpl.cs index 554e7a497a..4ee590516b 100644 --- a/src/Avalonia.Native/ClipboardImpl.cs +++ b/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; } diff --git a/src/Avalonia.Native/DeferredFramebuffer.cs b/src/Avalonia.Native/DeferredFramebuffer.cs index 8ea7b20b8c..950b6a3197 100644 --- a/src/Avalonia.Native/DeferredFramebuffer.cs +++ b/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, 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); } })) { diff --git a/src/Avalonia.Native/Generated/Enumerations.cs b/src/Avalonia.Native/Generated/Enumerations.cs deleted file mode 100644 index 0b30ce50c0..0000000000 --- a/src/Avalonia.Native/Generated/Enumerations.cs +++ /dev/null @@ -1,628 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - /// - /// No documentation. - /// - /// AvnDragDropEffects - /// AvnDragDropEffects - public enum AvnDragDropEffects : System.Int32 - { - /// - /// No documentation. - /// - /// None - /// None - None = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Copy - /// Copy - Copy = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Move - /// Move - Move = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Link - /// Link - Link = unchecked ((System.Int32)(4))} - - /// - /// No documentation. - /// - /// AvnDragEventType - /// AvnDragEventType - public enum AvnDragEventType : System.Int32 - { - /// - /// No documentation. - /// - /// Enter - /// Enter - Enter = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Over - /// Over - Over = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Leave - /// Leave - Leave = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Drop - /// Drop - Drop = unchecked ((System.Int32)(3))} - - /// - /// No documentation. - /// - /// AvnExtendClientAreaChromeHints - /// AvnExtendClientAreaChromeHints - public enum AvnExtendClientAreaChromeHints : System.Int32 - { - /// - /// No documentation. - /// - /// AvnNoChrome - /// AvnNoChrome - AvnNoChrome = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// AvnSystemChrome - /// AvnSystemChrome - AvnSystemChrome = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// AvnPreferSystemChrome - /// AvnPreferSystemChrome - AvnPreferSystemChrome = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// AvnOSXThickTitleBar - /// AvnOSXThickTitleBar - AvnOSXThickTitleBar = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// AvnDefaultChrome - /// AvnDefaultChrome - AvnDefaultChrome = unchecked ((System.Int32)(1))} - - /// - /// No documentation. - /// - /// AvnInputModifiers - /// AvnInputModifiers - public enum AvnInputModifiers : System.Int32 - { - /// - /// No documentation. - /// - /// AvnInputModifiersNone - /// AvnInputModifiersNone - AvnInputModifiersNone = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Alt - /// Alt - Alt = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Control - /// Control - Control = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Shift - /// Shift - Shift = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// Windows - /// Windows - Windows = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// LeftMouseButton - /// LeftMouseButton - LeftMouseButton = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// RightMouseButton - /// RightMouseButton - RightMouseButton = unchecked ((System.Int32)(32)), - /// - /// No documentation. - /// - /// MiddleMouseButton - /// MiddleMouseButton - MiddleMouseButton = unchecked ((System.Int32)(64)), - /// - /// No documentation. - /// - /// XButton1MouseButton - /// XButton1MouseButton - XButton1MouseButton = unchecked ((System.Int32)(128)), - /// - /// No documentation. - /// - /// XButton2MouseButton - /// XButton2MouseButton - XButton2MouseButton = unchecked ((System.Int32)(256))} - - /// - /// No documentation. - /// - /// AvnMenuItemToggleType - /// AvnMenuItemToggleType - public enum AvnMenuItemToggleType : System.Int32 - { - /// - /// No documentation. - /// - /// None - /// None - None = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// CheckMark - /// CheckMark - CheckMark = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Radio - /// Radio - Radio = unchecked ((System.Int32)(2))} - - /// - /// No documentation. - /// - /// AvnPixelFormat - /// AvnPixelFormat - public enum AvnPixelFormat : System.Int32 - { - /// - /// No documentation. - /// - /// kAvnRgb565 - /// kAvnRgb565 - KAvnRgb565 = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// kAvnRgba8888 - /// kAvnRgba8888 - KAvnRgba8888 = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// kAvnBgra8888 - /// kAvnBgra8888 - KAvnBgra8888 = unchecked ((System.Int32)(2))} - - /// - /// No documentation. - /// - /// AvnRawKeyEventType - /// AvnRawKeyEventType - public enum AvnRawKeyEventType : System.Int32 - { - /// - /// No documentation. - /// - /// KeyDown - /// KeyDown - KeyDown = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// KeyUp - /// KeyUp - KeyUp = unchecked ((System.Int32)(1))} - - /// - /// No documentation. - /// - /// AvnRawMouseEventType - /// AvnRawMouseEventType - public enum AvnRawMouseEventType : System.Int32 - { - /// - /// No documentation. - /// - /// LeaveWindow - /// LeaveWindow - LeaveWindow = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// LeftButtonDown - /// LeftButtonDown - LeftButtonDown = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// LeftButtonUp - /// LeftButtonUp - LeftButtonUp = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// RightButtonDown - /// RightButtonDown - RightButtonDown = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// RightButtonUp - /// RightButtonUp - RightButtonUp = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// MiddleButtonDown - /// MiddleButtonDown - MiddleButtonDown = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// MiddleButtonUp - /// MiddleButtonUp - MiddleButtonUp = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// XButton1Down - /// XButton1Down - XButton1Down = unchecked ((System.Int32)(7)), - /// - /// No documentation. - /// - /// XButton1Up - /// XButton1Up - XButton1Up = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// XButton2Down - /// XButton2Down - XButton2Down = unchecked ((System.Int32)(9)), - /// - /// No documentation. - /// - /// XButton2Up - /// XButton2Up - XButton2Up = unchecked ((System.Int32)(10)), - /// - /// No documentation. - /// - /// Move - /// Move - Move = unchecked ((System.Int32)(11)), - /// - /// No documentation. - /// - /// Wheel - /// Wheel - Wheel = unchecked ((System.Int32)(12)), - /// - /// No documentation. - /// - /// NonClientLeftButtonDown - /// NonClientLeftButtonDown - NonClientLeftButtonDown = unchecked ((System.Int32)(13)), - /// - /// No documentation. - /// - /// TouchBegin - /// TouchBegin - TouchBegin = unchecked ((System.Int32)(14)), - /// - /// No documentation. - /// - /// TouchUpdate - /// TouchUpdate - TouchUpdate = unchecked ((System.Int32)(15)), - /// - /// No documentation. - /// - /// TouchEnd - /// TouchEnd - TouchEnd = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// TouchCancel - /// TouchCancel - TouchCancel = unchecked ((System.Int32)(17))} - - /// - /// No documentation. - /// - /// AvnStandardCursorType - /// AvnStandardCursorType - public enum AvnStandardCursorType : System.Int32 - { - /// - /// No documentation. - /// - /// CursorArrow - /// CursorArrow - CursorArrow = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// CursorIbeam - /// CursorIbeam - CursorIbeam = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// CursorWait - /// CursorWait - CursorWait = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// CursorCross - /// CursorCross - CursorCross = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// CursorUpArrow - /// CursorUpArrow - CursorUpArrow = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// CursorSizeWestEast - /// CursorSizeWestEast - CursorSizeWestEast = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// CursorSizeNorthSouth - /// CursorSizeNorthSouth - CursorSizeNorthSouth = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// CursorSizeAll - /// CursorSizeAll - CursorSizeAll = unchecked ((System.Int32)(7)), - /// - /// No documentation. - /// - /// CursorNo - /// CursorNo - CursorNo = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// CursorHand - /// CursorHand - CursorHand = unchecked ((System.Int32)(9)), - /// - /// No documentation. - /// - /// CursorAppStarting - /// CursorAppStarting - CursorAppStarting = unchecked ((System.Int32)(10)), - /// - /// No documentation. - /// - /// CursorHelp - /// CursorHelp - CursorHelp = unchecked ((System.Int32)(11)), - /// - /// No documentation. - /// - /// CursorTopSide - /// CursorTopSide - CursorTopSide = unchecked ((System.Int32)(12)), - /// - /// No documentation. - /// - /// CursorBottomSize - /// CursorBottomSize - CursorBottomSize = unchecked ((System.Int32)(13)), - /// - /// No documentation. - /// - /// CursorLeftSide - /// CursorLeftSide - CursorLeftSide = unchecked ((System.Int32)(14)), - /// - /// No documentation. - /// - /// CursorRightSide - /// CursorRightSide - CursorRightSide = unchecked ((System.Int32)(15)), - /// - /// No documentation. - /// - /// CursorTopLeftCorner - /// CursorTopLeftCorner - CursorTopLeftCorner = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// CursorTopRightCorner - /// CursorTopRightCorner - CursorTopRightCorner = unchecked ((System.Int32)(17)), - /// - /// No documentation. - /// - /// CursorBottomLeftCorner - /// CursorBottomLeftCorner - CursorBottomLeftCorner = unchecked ((System.Int32)(18)), - /// - /// No documentation. - /// - /// CursorBottomRightCorner - /// CursorBottomRightCorner - CursorBottomRightCorner = unchecked ((System.Int32)(19)), - /// - /// No documentation. - /// - /// CursorDragMove - /// CursorDragMove - CursorDragMove = unchecked ((System.Int32)(20)), - /// - /// No documentation. - /// - /// CursorDragCopy - /// CursorDragCopy - CursorDragCopy = unchecked ((System.Int32)(21)), - /// - /// No documentation. - /// - /// CursorDragLink - /// CursorDragLink - CursorDragLink = unchecked ((System.Int32)(22)), - /// - /// No documentation. - /// - /// CursorNone - /// CursorNone - CursorNone = unchecked ((System.Int32)(23))} - - /// - /// No documentation. - /// - /// AvnWindowEdge - /// AvnWindowEdge - public enum AvnWindowEdge : System.Int32 - { - /// - /// No documentation. - /// - /// WindowEdgeNorthWest - /// WindowEdgeNorthWest - WindowEdgeNorthWest = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// WindowEdgeNorth - /// WindowEdgeNorth - WindowEdgeNorth = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// WindowEdgeNorthEast - /// WindowEdgeNorthEast - WindowEdgeNorthEast = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// WindowEdgeWest - /// WindowEdgeWest - WindowEdgeWest = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// WindowEdgeEast - /// WindowEdgeEast - WindowEdgeEast = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// WindowEdgeSouthWest - /// WindowEdgeSouthWest - WindowEdgeSouthWest = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// WindowEdgeSouth - /// WindowEdgeSouth - WindowEdgeSouth = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// WindowEdgeSouthEast - /// WindowEdgeSouthEast - WindowEdgeSouthEast = unchecked ((System.Int32)(7))} - - /// - /// No documentation. - /// - /// AvnWindowState - /// AvnWindowState - public enum AvnWindowState : System.Int32 - { - /// - /// No documentation. - /// - /// Normal - /// Normal - Normal = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Minimized - /// Minimized - Minimized = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Maximized - /// Maximized - Maximized = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// FullScreen - /// FullScreen - FullScreen = unchecked ((System.Int32)(3))} - - /// - /// No documentation. - /// - /// SystemDecorations - /// SystemDecorations - public enum SystemDecorations : System.Int32 - { - /// - /// No documentation. - /// - /// SystemDecorationsNone - /// SystemDecorationsNone - SystemDecorationsNone = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// SystemDecorationsBorderOnly - /// SystemDecorationsBorderOnly - SystemDecorationsBorderOnly = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// SystemDecorationsFull - /// SystemDecorationsFull - SystemDecorationsFull = unchecked ((System.Int32)(2))} -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Functions.cs b/src/Avalonia.Native/Generated/Functions.cs deleted file mode 100644 index 6ab648dc50..0000000000 --- a/src/Avalonia.Native/Generated/Functions.cs +++ /dev/null @@ -1,5 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Interfaces.cs b/src/Avalonia.Native/Generated/Interfaces.cs deleted file mode 100644 index 161ada1e50..0000000000 --- a/src/Avalonia.Native/Generated/Interfaces.cs +++ /dev/null @@ -1,3092 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f01")] - public partial class IAvaloniaNativeFactory : SharpGen.Runtime.ComObject - { - public IAvaloniaNativeFactory(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvaloniaNativeFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvaloniaNativeFactory(nativePtr); - /// - /// No documentation. - /// - /// GetMacOptions - /// GetMacOptions - public Avalonia.Native.Interop.IAvnMacOptions MacOptions - { - get => GetMacOptions(); - } - - /// - /// No documentation. - /// - /// SetAppMenu - /// SetAppMenu - public Avalonia.Native.Interop.IAvnMenu AppMenu - { - set => SetAppMenu(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::Initialize([In] IAvnGCHandleDeallocatorCallback* deallocator) - /// IAvaloniaNativeFactory::Initialize - public unsafe void Initialize(Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallback deallocator) - { - System.IntPtr deallocator_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - deallocator_ = SharpGen.Runtime.CppObject.ToCallbackPtr(deallocator); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)deallocator_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(deallocator); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnMacOptions* IAvaloniaNativeFactory::GetMacOptions() - /// IAvaloniaNativeFactory::GetMacOptions - internal unsafe Avalonia.Native.Interop.IAvnMacOptions GetMacOptions() - { - Avalonia.Native.Interop.IAvnMacOptions __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnMacOptions(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateWindow([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnWindow** ppv) - /// IAvaloniaNativeFactory::CreateWindow - public unsafe Avalonia.Native.Interop.IAvnWindow CreateWindow(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) - { - System.IntPtr cb_ = System.IntPtr.Zero; - System.IntPtr gl_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnWindow vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnWindow(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - System.GC.KeepAlive(gl); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreatePopup([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnPopup** ppv) - /// IAvaloniaNativeFactory::CreatePopup - public unsafe Avalonia.Native.Interop.IAvnPopup CreatePopup(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) - { - System.IntPtr cb_ = System.IntPtr.Zero; - System.IntPtr gl_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnPopup vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[6]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnPopup(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - System.GC.KeepAlive(gl); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreatePlatformThreadingInterface([In] IAvnPlatformThreadingInterface** ppv) - /// IAvaloniaNativeFactory::CreatePlatformThreadingInterface - public unsafe Avalonia.Native.Interop.IAvnPlatformThreadingInterface CreatePlatformThreadingInterface() - { - Avalonia.Native.Interop.IAvnPlatformThreadingInterface vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[7]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnPlatformThreadingInterface(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateSystemDialogs([In] IAvnSystemDialogs** ppv) - /// IAvaloniaNativeFactory::CreateSystemDialogs - public unsafe Avalonia.Native.Interop.IAvnSystemDialogs CreateSystemDialogs() - { - Avalonia.Native.Interop.IAvnSystemDialogs vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[8]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnSystemDialogs(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateScreens([In] IAvnScreens** ppv) - /// IAvaloniaNativeFactory::CreateScreens - public unsafe Avalonia.Native.Interop.IAvnScreens CreateScreens() - { - Avalonia.Native.Interop.IAvnScreens vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[9]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnScreens(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateClipboard([In] IAvnClipboard** ppv) - /// IAvaloniaNativeFactory::CreateClipboard - public unsafe Avalonia.Native.Interop.IAvnClipboard CreateClipboard() - { - Avalonia.Native.Interop.IAvnClipboard vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[10]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateDndClipboard([In] IAvnClipboard** ppv) - /// IAvaloniaNativeFactory::CreateDndClipboard - public unsafe Avalonia.Native.Interop.IAvnClipboard CreateDndClipboard() - { - Avalonia.Native.Interop.IAvnClipboard vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[11]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateCursorFactory([In] IAvnCursorFactory** ppv) - /// IAvaloniaNativeFactory::CreateCursorFactory - public unsafe Avalonia.Native.Interop.IAvnCursorFactory CreateCursorFactory() - { - Avalonia.Native.Interop.IAvnCursorFactory vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[12]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnCursorFactory(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::ObtainGlDisplay([In] IAvnGlDisplay** ppv) - /// IAvaloniaNativeFactory::ObtainGlDisplay - public unsafe Avalonia.Native.Interop.IAvnGlDisplay ObtainGlDisplay() - { - Avalonia.Native.Interop.IAvnGlDisplay vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[13]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlDisplay(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::SetAppMenu([In] IAvnMenu* menu) - /// IAvaloniaNativeFactory::SetAppMenu - internal unsafe void SetAppMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[14]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenu([In] IAvnMenuEvents* cb,[In] IAvnMenu** ppv) - /// IAvaloniaNativeFactory::CreateMenu - public unsafe Avalonia.Native.Interop.IAvnMenu CreateMenu(Avalonia.Native.Interop.IAvnMenuEvents cb) - { - System.IntPtr cb_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnMenu vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, &vOut_, (*(void ***)this._nativePointer)[15]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenu(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenuItem([In] IAvnMenuItem** ppv) - /// IAvaloniaNativeFactory::CreateMenuItem - public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItem() - { - Avalonia.Native.Interop.IAvnMenuItem vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[16]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenuItemSeperator([In] IAvnMenuItem** ppv) - /// IAvaloniaNativeFactory::CreateMenuItemSeperator - public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItemSeperator() - { - Avalonia.Native.Interop.IAvnMenuItem vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[17]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - } - - class IAvnActionCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnActionCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnActionCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new RunDelegate(Run)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RunDelegate(System.IntPtr thisObject); - private static unsafe void Run(System.IntPtr thisObject) - { - try - { - IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; - @this.Run(); - } - catch (System.Exception __exception__) - { - IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnActionCallbackShadow.IAvnActionCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f08"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnActionCallbackShadow))] - public partial interface IAvnActionCallback : SharpGen.Runtime.IUnknown - { - void Run(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0f")] - public partial class IAvnClipboard : SharpGen.Runtime.ComObject - { - public IAvnClipboard(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnClipboard(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnClipboard(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetText([In] char* type,[In] IAvnString** ppv) - /// IAvnClipboard::GetText - public unsafe Avalonia.Native.Interop.IAvnString GetText(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::SetText([In] char* type,[In] void* utf8Text) - /// IAvnClipboard::SetText - public unsafe void SetText(System.String type, System.IntPtr utf8Text) - { - System.IntPtr type_; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, (*(void ***)this._nativePointer)[4]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnClipboard::ObtainFormats([In] IAvnStringArray** ppv) - /// IAvnClipboard::ObtainFormats - public unsafe Avalonia.Native.Interop.IAvnStringArray ObtainFormats() - { - Avalonia.Native.Interop.IAvnStringArray vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetStrings([In] char* type,[In] IAvnStringArray** ppv) - /// IAvnClipboard::GetStrings - public unsafe Avalonia.Native.Interop.IAvnStringArray GetStrings(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnStringArray vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[6]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::SetBytes([In] char* type,[In] void* utf8Text,[In] int len) - /// IAvnClipboard::SetBytes - public unsafe void SetBytes(System.String type, System.IntPtr utf8Text, System.Int32 len) - { - System.IntPtr type_; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, len, (*(void ***)this._nativePointer)[7]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetBytes([In] char* type,[In] IAvnString** ppv) - /// IAvnClipboard::GetBytes - public unsafe Avalonia.Native.Interop.IAvnString GetBytes(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[8]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnClipboard::Clear() - /// IAvnClipboard::Clear - public unsafe void Clear() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f10")] - public partial class IAvnCursor : SharpGen.Runtime.ComObject - { - public IAvnCursor(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnCursor(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursor(nativePtr); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f11")] - public partial class IAvnCursorFactory : SharpGen.Runtime.ComObject - { - public IAvnCursorFactory(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnCursorFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursorFactory(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnCursorFactory::GetCursor([In] AvnStandardCursorType cursorType,[Out] IAvnCursor** retOut) - /// IAvnCursorFactory::GetCursor - public unsafe Avalonia.Native.Interop.IAvnCursor GetCursor(Avalonia.Native.Interop.AvnStandardCursorType cursorType) - { - Avalonia.Native.Interop.IAvnCursor retOut; - System.IntPtr retOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)cursorType), &retOut_, (*(void ***)this._nativePointer)[3]); - if (retOut_ != System.IntPtr.Zero) - retOut = new Avalonia.Native.Interop.IAvnCursor(retOut_); - else - retOut = null; - __result__.CheckError(); - return retOut; - } - } - - class IAvnDndResultCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnDndResultCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnDndResultCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new OnDragAndDropCompleteDelegate(OnDragAndDropComplete)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void OnDragAndDropCompleteDelegate(System.IntPtr thisObject, int arg0); - private static unsafe void OnDragAndDropComplete(System.IntPtr thisObject, int param0) - { - try - { - Avalonia.Native.Interop.AvnDragDropEffects effecct = default (Avalonia.Native.Interop.AvnDragDropEffects); - effecct = (Avalonia.Native.Interop.AvnDragDropEffects)param0; - IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; - @this.OnDragAndDropComplete(effecct); - } - catch (System.Exception __exception__) - { - IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnDndResultCallbackShadow.IAvnDndResultCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnDndResultCallbackShadow))] - public partial interface IAvnDndResultCallback : SharpGen.Runtime.IUnknown - { - void OnDragAndDropComplete(Avalonia.Native.Interop.AvnDragDropEffects effecct); - } - - class IAvnGCHandleDeallocatorCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnGCHandleDeallocatorCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnGCHandleDeallocatorCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new FreeGCHandleDelegate(FreeGCHandle)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void FreeGCHandleDelegate(System.IntPtr thisObject, void *arg0); - private static unsafe void FreeGCHandle(System.IntPtr thisObject, void *param0) - { - try - { - System.IntPtr handle = default (System.IntPtr); - handle = (System.IntPtr)param0; - IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; - @this.FreeGCHandle(handle); - } - catch (System.Exception __exception__) - { - IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow.IAvnGCHandleDeallocatorCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f22"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow))] - public partial interface IAvnGCHandleDeallocatorCallback : SharpGen.Runtime.IUnknown - { - void FreeGCHandle(System.IntPtr handle); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f14")] - public partial class IAvnGlContext : SharpGen.Runtime.ComObject - { - public IAvnGlContext(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlContext(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlContext(nativePtr); - /// - /// No documentation. - /// - /// GetSampleCount - /// GetSampleCount - public System.Int32 SampleCount - { - get => GetSampleCount(); - } - - /// - /// No documentation. - /// - /// GetStencilSize - /// GetStencilSize - public System.Int32 StencilSize - { - get => GetStencilSize(); - } - - /// - /// No documentation. - /// - /// GetNativeHandle - /// GetNativeHandle - public System.IntPtr NativeHandle - { - get => GetNativeHandle(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlContext::MakeCurrent([In] IUnknown** ppv) - /// IAvnGlContext::MakeCurrent - public unsafe SharpGen.Runtime.IUnknown MakeCurrent() - { - SharpGen.Runtime.IUnknown vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new SharpGen.Runtime.ComObject(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlContext::LegacyMakeCurrent() - /// IAvnGlContext::LegacyMakeCurrent - public unsafe void LegacyMakeCurrent() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// int IAvnGlContext::GetSampleCount() - /// IAvnGlContext::GetSampleCount - internal unsafe System.Int32 GetSampleCount() - { - System.Int32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// int IAvnGlContext::GetStencilSize() - /// IAvnGlContext::GetStencilSize - internal unsafe System.Int32 GetStencilSize() - { - System.Int32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void* IAvnGlContext::GetNativeHandle() - /// IAvnGlContext::GetNativeHandle - internal unsafe System.IntPtr GetNativeHandle() - { - System.IntPtr __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[7]); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f13")] - public partial class IAvnGlDisplay : SharpGen.Runtime.ComObject - { - public IAvnGlDisplay(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlDisplay(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlDisplay(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnGlDisplay::CreateContext([In] IAvnGlContext* share,[In] IAvnGlContext** ppv) - /// IAvnGlDisplay::CreateContext - public unsafe Avalonia.Native.Interop.IAvnGlContext CreateContext(Avalonia.Native.Interop.IAvnGlContext share) - { - System.IntPtr share_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnGlContext vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - share_ = SharpGen.Runtime.CppObject.ToCallbackPtr(share); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)share_, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); - else - vOut = null; - System.GC.KeepAlive(share); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// void IAvnGlDisplay::LegacyClearCurrentContext() - /// IAvnGlDisplay::LegacyClearCurrentContext - public unsafe void LegacyClearCurrentContext() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[4]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnGlDisplay::WrapContext([In] void* native,[In] IAvnGlContext** ppv) - /// IAvnGlDisplay::WrapContext - public unsafe Avalonia.Native.Interop.IAvnGlContext WrapContext(System.IntPtr native) - { - Avalonia.Native.Interop.IAvnGlContext vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)native, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// void* IAvnGlDisplay::GetProcAddress([In] char* proc) - /// IAvnGlDisplay::GetProcAddress - public unsafe System.IntPtr GetProcAddress(System.String rocRef) - { - System.IntPtr rocRef_; - System.IntPtr __result__; - rocRef_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(rocRef); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (void *)rocRef_, (*(void ***)this._nativePointer)[6]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(rocRef_); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f16")] - public partial class IAvnGlSurfaceRenderingSession : SharpGen.Runtime.ComObject - { - public IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderingSession(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderingSession::GetPixelSize([In] AvnPixelSize* ret) - /// IAvnGlSurfaceRenderingSession::GetPixelSize - public unsafe Avalonia.Native.Interop.AvnPixelSize GetPixelSize() - { - Avalonia.Native.Interop.AvnPixelSize ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderingSession::GetScaling([In] double* ret) - /// IAvnGlSurfaceRenderingSession::GetScaling - public unsafe System.Double GetScaling() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f15")] - public partial class IAvnGlSurfaceRenderTarget : SharpGen.Runtime.ComObject - { - public IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderTarget(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderTarget::BeginDrawing([In] IAvnGlSurfaceRenderingSession** ret) - /// IAvnGlSurfaceRenderTarget::BeginDrawing - public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession BeginDrawing() - { - Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession ret; - System.IntPtr ret_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[3]); - if (ret_ != System.IntPtr.Zero) - ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession(ret_); - else - ret = null; - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0a")] - public partial class IAvnLoopCancellation : SharpGen.Runtime.ComObject - { - public IAvnLoopCancellation(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnLoopCancellation(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnLoopCancellation(nativePtr); - /// - /// No documentation. - /// - /// void IAvnLoopCancellation::Cancel() - /// IAvnLoopCancellation::Cancel - public unsafe void Cancel() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[3]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f07")] - public partial class IAvnMacOptions : SharpGen.Runtime.ComObject - { - public IAvnMacOptions(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMacOptions(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMacOptions(nativePtr); - /// - /// No documentation. - /// - /// SetShowInDock - /// SetShowInDock - public System.Int32 ShowInDock - { - set => SetShowInDock(value); - } - - /// - /// No documentation. - /// - /// SetApplicationTitle - /// SetApplicationTitle - public System.IntPtr ApplicationTitle - { - set => SetApplicationTitle(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMacOptions::SetShowInDock([In] int show) - /// IAvnMacOptions::SetShowInDock - internal unsafe void SetShowInDock(System.Int32 show) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, show, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMacOptions::SetApplicationTitle([In] void* utf8string) - /// IAvnMacOptions::SetApplicationTitle - internal unsafe void SetApplicationTitle(System.IntPtr utf8string) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8string, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] - public partial class IAvnMenu : SharpGen.Runtime.ComObject - { - public IAvnMenu(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMenu(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenu(nativePtr); - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::InsertItem([In] int index,[In] IAvnMenuItem* item) - /// IAvnMenu::InsertItem - public unsafe void InsertItem(System.Int32 index, Avalonia.Native.Interop.IAvnMenuItem item) - { - System.IntPtr item_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, (void *)item_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(item); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::RemoveItem([In] IAvnMenuItem* item) - /// IAvnMenu::RemoveItem - public unsafe void RemoveItem(Avalonia.Native.Interop.IAvnMenuItem item) - { - System.IntPtr item_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)item_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(item); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::SetTitle([In] void* utf8String) - /// IAvnMenu::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8String) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnMenu::Clear() - /// IAvnMenu::Clear - public unsafe void Clear() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - __result__.CheckError(); - } - } - - class IAvnMenuEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnMenuEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnMenuEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new NeedsUpdateDelegate(NeedsUpdate)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void NeedsUpdateDelegate(System.IntPtr thisObject); - private static unsafe void NeedsUpdate(System.IntPtr thisObject) - { - try - { - IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; - @this.NeedsUpdate(); - } - catch (System.Exception __exception__) - { - IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnMenuEventsShadow.IAvnMenuEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f1A"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnMenuEventsShadow))] - public partial interface IAvnMenuEvents : SharpGen.Runtime.IUnknown - { - void NeedsUpdate(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f19")] - public partial class IAvnMenuItem : SharpGen.Runtime.ComObject - { - public IAvnMenuItem(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMenuItem(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenuItem(nativePtr); - /// - /// No documentation. - /// - /// SetSubMenu - /// SetSubMenu - public Avalonia.Native.Interop.IAvnMenu SubMenu - { - set => SetSubMenu(value); - } - - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// SetIsChecked - /// SetIsChecked - public System.Boolean IsChecked - { - set => SetIsChecked(value); - } - - /// - /// No documentation. - /// - /// SetToggleType - /// SetToggleType - public Avalonia.Native.Interop.AvnMenuItemToggleType ToggleType - { - set => SetToggleType(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetSubMenu([In] IAvnMenu* menu) - /// IAvnMenuItem::SetSubMenu - internal unsafe void SetSubMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetTitle([In] void* utf8String) - /// IAvnMenuItem::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8String) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetGesture([In] void* utf8String,[In] AvnInputModifiers modifiers) - /// IAvnMenuItem::SetGesture - public unsafe void SetGesture(System.IntPtr utf8String, Avalonia.Native.Interop.AvnInputModifiers modifiers) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, unchecked ((System.Int32)modifiers), (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetAction([In] IAvnPredicateCallback* predicate,[In] IAvnActionCallback* callback) - /// IAvnMenuItem::SetAction - public unsafe void SetAction(Avalonia.Native.Interop.IAvnPredicateCallback redicateRef, Avalonia.Native.Interop.IAvnActionCallback callback) - { - System.IntPtr redicateRef_ = System.IntPtr.Zero; - System.IntPtr callback_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - redicateRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(redicateRef); - callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)redicateRef_, (void *)callback_, (*(void ***)this._nativePointer)[6]); - System.GC.KeepAlive(redicateRef); - System.GC.KeepAlive(callback); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetIsChecked([In] bool isChecked) - /// IAvnMenuItem::SetIsChecked - internal unsafe void SetIsChecked(System.Boolean isChecked) - { - System.Byte isChecked_; - SharpGen.Runtime.Result __result__; - isChecked_ = (System.Byte)(isChecked ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, isChecked_, (*(void ***)this._nativePointer)[7]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetToggleType([In] AvnMenuItemToggleType toggleType) - /// IAvnMenuItem::SetToggleType - internal unsafe void SetToggleType(Avalonia.Native.Interop.AvnMenuItemToggleType toggleType) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)toggleType), (*(void ***)this._nativePointer)[8]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetIcon([In] void* data,[In] size_t length) - /// IAvnMenuItem::SetIcon - public unsafe void SetIcon(System.IntPtr data, SharpGen.Runtime.PointerSize length) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)data, (void *)length, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] - public partial class IAvnNativeControlHost : SharpGen.Runtime.ComObject - { - public IAvnNativeControlHost(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnNativeControlHost(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHost(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHost::CreateDefaultChild([In] void* parent,[Out] void** retOut) - /// IAvnNativeControlHost::CreateDefaultChild - public unsafe System.IntPtr CreateDefaultChild(System.IntPtr arentRef) - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef, &retOut, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnNativeControlHostTopLevelAttachment* IAvnNativeControlHost::CreateAttachment() - /// IAvnNativeControlHost::CreateAttachment - public unsafe Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment CreateAttachment() - { - Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnNativeControlHost::DestroyDefaultChild([In] void* child) - /// IAvnNativeControlHost::DestroyDefaultChild - public unsafe void DestroyDefaultChild(System.IntPtr child) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[5]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21")] - public partial class IAvnNativeControlHostTopLevelAttachment : SharpGen.Runtime.ComObject - { - public IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHostTopLevelAttachment(nativePtr); - /// - /// No documentation. - /// - /// GetParentHandle - /// GetParentHandle - public System.IntPtr ParentHandle - { - get => GetParentHandle(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// void* IAvnNativeControlHostTopLevelAttachment::GetParentHandle() - /// IAvnNativeControlHostTopLevelAttachment::GetParentHandle - internal unsafe System.IntPtr GetParentHandle() - { - System.IntPtr __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[3]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle([In] void* child) - /// IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle - public unsafe void InitializeWithChildHandle(System.IntPtr child) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHostTopLevelAttachment::AttachTo([In] IAvnNativeControlHost* host) - /// IAvnNativeControlHostTopLevelAttachment::AttachTo - public unsafe void AttachTo(Avalonia.Native.Interop.IAvnNativeControlHost host) - { - System.IntPtr host_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - host_ = SharpGen.Runtime.CppObject.ToCallbackPtr(host); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)host_, (*(void ***)this._nativePointer)[5]); - System.GC.KeepAlive(host); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnNativeControlHostTopLevelAttachment::ShowInBounds([In] float x,[In] float y,[In] float width,[In] float height) - /// IAvnNativeControlHostTopLevelAttachment::ShowInBounds - public unsafe void ShowInBounds(System.Single x, System.Single y, System.Single width, System.Single height) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, x, y, width, height, (*(void ***)this._nativePointer)[6]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// void IAvnNativeControlHostTopLevelAttachment::HideWithSize([In] float width,[In] float height) - /// IAvnNativeControlHostTopLevelAttachment::HideWithSize - public unsafe void HideWithSize(System.Single width, System.Single height) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, width, height, (*(void ***)this._nativePointer)[7]); - } - - /// - /// No documentation. - /// - /// void IAvnNativeControlHostTopLevelAttachment::ReleaseChild() - /// IAvnNativeControlHostTopLevelAttachment::ReleaseChild - public unsafe void ReleaseChild() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[8]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0b")] - public partial class IAvnPlatformThreadingInterface : SharpGen.Runtime.ComObject - { - public IAvnPlatformThreadingInterface(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnPlatformThreadingInterface(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPlatformThreadingInterface(nativePtr); - /// - /// No documentation. - /// - /// GetCurrentThreadIsLoopThread - /// GetCurrentThreadIsLoopThread - public System.Boolean CurrentThreadIsLoopThread - { - get => GetCurrentThreadIsLoopThread(); - } - - /// - /// No documentation. - /// - /// SetSignaledCallback - /// SetSignaledCallback - public Avalonia.Native.Interop.IAvnSignaledCallback SignaledCallback - { - set => SetSignaledCallback(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// bool IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread() - /// IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread - internal unsafe System.Boolean GetCurrentThreadIsLoopThread() - { - System.Boolean __result__; - System.Byte __result__native; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemByte(this._nativePointer, (*(void ***)this._nativePointer)[3]); - __result__ = __result__native != 0; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnPlatformThreadingInterface::SetSignaledCallback([In] IAvnSignaledCallback* cb) - /// IAvnPlatformThreadingInterface::SetSignaledCallback - internal unsafe void SetSignaledCallback(Avalonia.Native.Interop.IAvnSignaledCallback cb) - { - System.IntPtr cb_ = System.IntPtr.Zero; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)cb_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(cb); - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnLoopCancellation* IAvnPlatformThreadingInterface::CreateLoopCancellation() - /// IAvnPlatformThreadingInterface::CreateLoopCancellation - public unsafe Avalonia.Native.Interop.IAvnLoopCancellation CreateLoopCancellation() - { - Avalonia.Native.Interop.IAvnLoopCancellation __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[5]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnLoopCancellation(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnPlatformThreadingInterface::RunLoop([In] IAvnLoopCancellation* cancel) - /// IAvnPlatformThreadingInterface::RunLoop - public unsafe void RunLoop(Avalonia.Native.Interop.IAvnLoopCancellation cancel) - { - System.IntPtr cancel_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cancel_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cancel); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cancel_, (*(void ***)this._nativePointer)[6]); - System.GC.KeepAlive(cancel); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnPlatformThreadingInterface::Signal([In] int priority) - /// IAvnPlatformThreadingInterface::Signal - public unsafe void Signal(System.Int32 priority) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, priority, (*(void ***)this._nativePointer)[7]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// IUnknown* IAvnPlatformThreadingInterface::StartTimer([In] int priority,[In] int ms,[In] IAvnActionCallback* callback) - /// IAvnPlatformThreadingInterface::StartTimer - public unsafe SharpGen.Runtime.ComObject StartTimer(System.Int32 priority, System.Int32 ms, Avalonia.Native.Interop.IAvnActionCallback callback) - { - System.IntPtr callback_ = System.IntPtr.Zero; - SharpGen.Runtime.ComObject __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, priority, ms, (void *)callback_, (*(void ***)this._nativePointer)[8]); - if (__result__native != System.IntPtr.Zero) - __result__ = new SharpGen.Runtime.ComObject(__result__native); - else - __result__ = null; - System.GC.KeepAlive(callback); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f03")] - public partial class IAvnPopup : Avalonia.Native.Interop.IAvnWindowBase - { - public IAvnPopup(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnPopup(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPopup(nativePtr); - } - - class IAvnPredicateCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnPredicateCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnPredicateCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new EvaluateDelegate(Evaluate)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte EvaluateDelegate(System.IntPtr thisObject); - private static unsafe System.Byte Evaluate(System.IntPtr thisObject) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; - __result__ = @this.Evaluate(); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnPredicateCallbackShadow.IAvnPredicateCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f18"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnPredicateCallbackShadow))] - public partial interface IAvnPredicateCallback : SharpGen.Runtime.IUnknown - { - System.Boolean Evaluate(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0e")] - public partial class IAvnScreens : SharpGen.Runtime.ComObject - { - public IAvnScreens(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnScreens(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnScreens(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnScreens::GetScreenCount([In] int* ret) - /// IAvnScreens::GetScreenCount - public unsafe System.Int32 GetScreenCount() - { - System.Int32 ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnScreens::GetScreen([In] int index,[In] AvnScreen* ret) - /// IAvnScreens::GetScreen - public unsafe Avalonia.Native.Interop.AvnScreen GetScreen(System.Int32 index) - { - Avalonia.Native.Interop.AvnScreen ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - class IAvnSignaledCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnSignaledCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnSignaledCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new SignaledDelegate(Signaled)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void SignaledDelegate(System.IntPtr thisObject, int arg0, System.Byte arg1); - private static unsafe void Signaled(System.IntPtr thisObject, int param0, System.Byte param1) - { - try - { - System.Int32 priority = default (System.Int32); - priority = (System.Int32)param0; - System.Boolean priorityContainsMeaningfulValue = default (System.Boolean); - System.Byte priorityContainsMeaningfulValue_ = (System.Byte)param1; - IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; - priorityContainsMeaningfulValue = priorityContainsMeaningfulValue_ != 0; - @this.Signaled(priority, priorityContainsMeaningfulValue); - } - catch (System.Exception __exception__) - { - IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnSignaledCallbackShadow.IAvnSignaledCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f09"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSignaledCallbackShadow))] - public partial interface IAvnSignaledCallback : SharpGen.Runtime.IUnknown - { - void Signaled(System.Int32 priority, System.Boolean priorityContainsMeaningfulValue); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] - public partial class IAvnString : SharpGen.Runtime.ComObject - { - public IAvnString(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnString(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnString(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnString::Pointer([Out] void** retOut) - /// IAvnString::Pointer - public unsafe System.IntPtr Pointer() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnString::Length([In] int* ret) - /// IAvnString::Length - public unsafe System.Int32 Length() - { - System.Int32 ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] - public partial class IAvnStringArray : SharpGen.Runtime.ComObject - { - public IAvnStringArray(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnStringArray(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnStringArray(nativePtr); - /// - /// No documentation. - /// - /// GetCount - /// GetCount - public System.UInt32 Count - { - get => GetCount(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// unsigned int IAvnStringArray::GetCount() - /// IAvnStringArray::GetCount - internal unsafe System.UInt32 GetCount() - { - System.UInt32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemUInt32(this._nativePointer, (*(void ***)this._nativePointer)[3]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnStringArray::Get([In] unsigned int index,[In] IAvnString** ppv) - /// IAvnStringArray::Get - public unsafe Avalonia.Native.Interop.IAvnString Get(System.UInt32 index) - { - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &vOut_, (*(void ***)this._nativePointer)[4]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - } - - class IAvnSystemDialogEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnSystemDialogEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnSystemDialogEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new OnCompletedDelegate(OnCompleted)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void OnCompletedDelegate(System.IntPtr thisObject, int arg0, void *arg1); - private static unsafe void OnCompleted(System.IntPtr thisObject, int param0, void *param1) - { - try - { - System.Int32 numResults = default (System.Int32); - numResults = (System.Int32)param0; - System.IntPtr trFirstResultRef = default (System.IntPtr); - trFirstResultRef = (System.IntPtr)param1; - IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; - @this.OnCompleted(numResults, trFirstResultRef); - } - catch (System.Exception __exception__) - { - IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnSystemDialogEventsShadow.IAvnSystemDialogEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0c"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSystemDialogEventsShadow))] - public partial interface IAvnSystemDialogEvents : SharpGen.Runtime.IUnknown - { - void OnCompleted(System.Int32 numResults, System.IntPtr trFirstResultRef); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0d")] - public partial class IAvnSystemDialogs : SharpGen.Runtime.ComObject - { - public IAvnSystemDialogs(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnSystemDialogs(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnSystemDialogs(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::SelectFolderDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialPath) - /// IAvnSystemDialogs::SelectFolderDialog - public unsafe void SelectFolderDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialPath) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.IntPtr title_; - System.IntPtr initialPath_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialPath_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialPath); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialPath_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialPath_); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::OpenFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] bool allowMultiple,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) - /// IAvnSystemDialogs::OpenFileDialog - public unsafe void OpenFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.Boolean allowMultiple, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.Byte allowMultiple_; - System.IntPtr title_; - System.IntPtr initialDirectory_; - System.IntPtr initialFile_; - System.IntPtr filters_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - allowMultiple_ = (System.Byte)(allowMultiple ? 1 : 0); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); - initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); - filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, allowMultiple_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::SaveFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) - /// IAvnSystemDialogs::SaveFileDialog - public unsafe void SaveFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.IntPtr title_; - System.IntPtr initialDirectory_; - System.IntPtr initialFile_; - System.IntPtr filters_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); - initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); - filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[5]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f04")] - public partial class IAvnWindow : Avalonia.Native.Interop.IAvnWindowBase - { - public IAvnWindow(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnWindow(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindow(nativePtr); - /// - /// No documentation. - /// - /// SetEnabled - /// SetEnabled - public System.Boolean Enabled - { - set => SetEnabled(value); - } - - /// - /// No documentation. - /// - /// SetParent - /// SetParent - public Avalonia.Native.Interop.IAvnWindow Parent - { - set => SetParent(value); - } - - /// - /// No documentation. - /// - /// SetCanResize - /// SetCanResize - public System.Boolean CanResize - { - set => SetCanResize(value); - } - - /// - /// No documentation. - /// - /// SetDecorations - /// SetDecorations - public Avalonia.Native.Interop.SystemDecorations Decorations - { - set => SetDecorations(value); - } - - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// SetTitleBarColor - /// SetTitleBarColor - public Avalonia.Native.Interop.AvnColor TitleBarColor - { - set => SetTitleBarColor(value); - } - - /// - /// No documentation. - /// - /// SetExtendClientArea - /// SetExtendClientArea - public System.Boolean ExtendClientArea - { - set => SetExtendClientArea(value); - } - - /// - /// No documentation. - /// - /// SetExtendClientAreaHints - /// SetExtendClientAreaHints - public Avalonia.Native.Interop.AvnExtendClientAreaChromeHints ExtendClientAreaHints - { - set => SetExtendClientAreaHints(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetEnabled([In] bool enable) - /// IAvnWindow::SetEnabled - internal unsafe void SetEnabled(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[30]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetParent([In] IAvnWindow* parent) - /// IAvnWindow::SetParent - internal unsafe void SetParent(Avalonia.Native.Interop.IAvnWindow arentRef) - { - System.IntPtr arentRef_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - arentRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentRef); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef_, (*(void ***)this._nativePointer)[31]); - System.GC.KeepAlive(arentRef); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetCanResize([In] bool value) - /// IAvnWindow::SetCanResize - internal unsafe void SetCanResize(System.Boolean value) - { - System.Byte value_; - SharpGen.Runtime.Result __result__; - value_ = (System.Byte)(value ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[32]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetDecorations([In] SystemDecorations value) - /// IAvnWindow::SetDecorations - internal unsafe void SetDecorations(Avalonia.Native.Interop.SystemDecorations value) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)value), (*(void ***)this._nativePointer)[33]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetTitle([In] void* utf8Title) - /// IAvnWindow::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8Title) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8Title, (*(void ***)this._nativePointer)[34]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetTitleBarColor([In] AvnColor color) - /// IAvnWindow::SetTitleBarColor - internal unsafe void SetTitleBarColor(Avalonia.Native.Interop.AvnColor color) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, color, (*(void ***)this._nativePointer)[35]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetWindowState([In] AvnWindowState state) - /// IAvnWindow::SetWindowState - public unsafe void SetWindowState(Avalonia.Native.Interop.AvnWindowState state) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)state), (*(void ***)this._nativePointer)[36]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::GetWindowState([In] AvnWindowState* ret) - /// IAvnWindow::GetWindowState - public unsafe Avalonia.Native.Interop.AvnWindowState GetWindowState() - { - Avalonia.Native.Interop.AvnWindowState ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[37]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::TakeFocusFromChildren() - /// IAvnWindow::TakeFocusFromChildren - public unsafe void TakeFocusFromChildren() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[38]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendClientArea([In] bool enable) - /// IAvnWindow::SetExtendClientArea - internal unsafe void SetExtendClientArea(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[39]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendClientAreaHints([In] AvnExtendClientAreaChromeHints hints) - /// IAvnWindow::SetExtendClientAreaHints - internal unsafe void SetExtendClientAreaHints(Avalonia.Native.Interop.AvnExtendClientAreaChromeHints hints) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)hints), (*(void ***)this._nativePointer)[40]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::GetExtendTitleBarHeight([In] double* ret) - /// IAvnWindow::GetExtendTitleBarHeight - public unsafe System.Double GetExtendTitleBarHeight() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[41]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendTitleBarHeight([In] double value) - /// IAvnWindow::SetExtendTitleBarHeight - public unsafe void SetExtendTitleBarHeight(System.Double value) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value, (*(void ***)this._nativePointer)[42]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f02")] - public partial class IAvnWindowBase : SharpGen.Runtime.ComObject - { - public IAvnWindowBase(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnWindowBase(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindowBase(nativePtr); - /// - /// No documentation. - /// - /// SetTopMost - /// SetTopMost - public System.Boolean TopMost - { - set => SetTopMost(value); - } - - /// - /// No documentation. - /// - /// SetCursor - /// SetCursor - public Avalonia.Native.Interop.IAvnCursor Cursor - { - set => SetCursor(value); - } - - /// - /// No documentation. - /// - /// SetMainMenu - /// SetMainMenu - public Avalonia.Native.Interop.IAvnMenu MainMenu - { - set => SetMainMenu(value); - } - - /// - /// No documentation. - /// - /// SetBlurEnabled - /// SetBlurEnabled - public System.Boolean BlurEnabled - { - set => SetBlurEnabled(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Show() - /// IAvnWindowBase::Show - public unsafe void Show() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Hide() - /// IAvnWindowBase::Hide - public unsafe void Hide() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Close() - /// IAvnWindowBase::Close - public unsafe void Close() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Activate() - /// IAvnWindowBase::Activate - public unsafe void Activate() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetClientSize([In] AvnSize* ret) - /// IAvnWindowBase::GetClientSize - public unsafe Avalonia.Native.Interop.AvnSize GetClientSize() - { - Avalonia.Native.Interop.AvnSize ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[7]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetScaling([In] double* ret) - /// IAvnWindowBase::GetScaling - public unsafe System.Double GetScaling() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[8]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetMinMaxSize([In] AvnSize minSize,[In] AvnSize maxSize) - /// IAvnWindowBase::SetMinMaxSize - public unsafe void SetMinMaxSize(Avalonia.Native.Interop.AvnSize minSize, Avalonia.Native.Interop.AvnSize maxSize) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, minSize, maxSize, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::Resize([In] double width,[In] double height) - /// IAvnWindowBase::Resize - public unsafe void Resize(System.Double width, System.Double height) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, width, height, (*(void ***)this._nativePointer)[10]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::Invalidate([In] AvnRect rect) - /// IAvnWindowBase::Invalidate - public unsafe void Invalidate(Avalonia.Native.Interop.AvnRect rect) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, rect, (*(void ***)this._nativePointer)[11]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::BeginMoveDrag() - /// IAvnWindowBase::BeginMoveDrag - public unsafe void BeginMoveDrag() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[12]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::BeginResizeDrag([In] AvnWindowEdge edge) - /// IAvnWindowBase::BeginResizeDrag - public unsafe void BeginResizeDrag(Avalonia.Native.Interop.AvnWindowEdge edge) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)edge), (*(void ***)this._nativePointer)[13]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetPosition([In] AvnPoint* ret) - /// IAvnWindowBase::GetPosition - public unsafe Avalonia.Native.Interop.AvnPoint GetPosition() - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[14]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetPosition([In] AvnPoint point) - /// IAvnWindowBase::SetPosition - public unsafe void SetPosition(Avalonia.Native.Interop.AvnPoint point) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, (*(void ***)this._nativePointer)[15]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::PointToClient([In] AvnPoint point,[In] AvnPoint* ret) - /// IAvnWindowBase::PointToClient - public unsafe Avalonia.Native.Interop.AvnPoint PointToClient(Avalonia.Native.Interop.AvnPoint point) - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[16]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::PointToScreen([In] AvnPoint point,[In] AvnPoint* ret) - /// IAvnWindowBase::PointToScreen - public unsafe Avalonia.Native.Interop.AvnPoint PointToScreen(Avalonia.Native.Interop.AvnPoint point) - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[17]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::ThreadSafeSetSwRenderedFrame([In] AvnFramebuffer* fb,[In] IUnknown* dispose) - /// IAvnWindowBase::ThreadSafeSetSwRenderedFrame - public unsafe void ThreadSafeSetSwRenderedFrame(ref Avalonia.Native.Interop.AvnFramebuffer fb, SharpGen.Runtime.IUnknown dispose) - { - System.IntPtr dispose_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - dispose_ = SharpGen.Runtime.CppObject.ToCallbackPtr(dispose); - fixed (void *fb_ = &fb) - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, fb_, (void *)dispose_, (*(void ***)this._nativePointer)[18]); - System.GC.KeepAlive(dispose); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetTopMost([In] bool value) - /// IAvnWindowBase::SetTopMost - internal unsafe void SetTopMost(System.Boolean value) - { - System.Byte value_; - SharpGen.Runtime.Result __result__; - value_ = (System.Byte)(value ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[19]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetCursor([In] IAvnCursor* cursor) - /// IAvnWindowBase::SetCursor - internal unsafe void SetCursor(Avalonia.Native.Interop.IAvnCursor cursor) - { - System.IntPtr cursor_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cursor_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cursor); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cursor_, (*(void ***)this._nativePointer)[20]); - System.GC.KeepAlive(cursor); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::CreateGlRenderTarget([In] IAvnGlSurfaceRenderTarget** ret) - /// IAvnWindowBase::CreateGlRenderTarget - public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget CreateGlRenderTarget() - { - Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget ret; - System.IntPtr ret_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[21]); - if (ret_ != System.IntPtr.Zero) - ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget(ret_); - else - ret = null; - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetMainMenu([In] IAvnMenu* menu) - /// IAvnWindowBase::SetMainMenu - internal unsafe void SetMainMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[22]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSWindowHandle([Out] void** retOut) - /// IAvnWindowBase::ObtainNSWindowHandle - public unsafe System.IntPtr ObtainNSWindowHandle() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[23]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSWindowHandleRetained([Out] void** retOut) - /// IAvnWindowBase::ObtainNSWindowHandleRetained - public unsafe System.IntPtr ObtainNSWindowHandleRetained() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[24]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSViewHandle([Out] void** retOut) - /// IAvnWindowBase::ObtainNSViewHandle - public unsafe System.IntPtr ObtainNSViewHandle() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[25]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSViewHandleRetained([Out] void** retOut) - /// IAvnWindowBase::ObtainNSViewHandleRetained - public unsafe System.IntPtr ObtainNSViewHandleRetained() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[26]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::CreateNativeControlHost([Out] IAvnNativeControlHost** retOut) - /// IAvnWindowBase::CreateNativeControlHost - public unsafe Avalonia.Native.Interop.IAvnNativeControlHost CreateNativeControlHost() - { - Avalonia.Native.Interop.IAvnNativeControlHost retOut; - System.IntPtr retOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut_, (*(void ***)this._nativePointer)[27]); - if (retOut_ != System.IntPtr.Zero) - retOut = new Avalonia.Native.Interop.IAvnNativeControlHost(retOut_); - else - retOut = null; - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::BeginDragAndDropOperation([In] AvnDragDropEffects effects,[In] AvnPoint point,[In] IAvnClipboard* clipboard,[In] IAvnDndResultCallback* cb,[In] void* sourceHandle) - /// IAvnWindowBase::BeginDragAndDropOperation - public unsafe void BeginDragAndDropOperation(Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.IAvnClipboard clipboard, Avalonia.Native.Interop.IAvnDndResultCallback cb, System.IntPtr sourceHandle) - { - System.IntPtr clipboard_ = System.IntPtr.Zero; - System.IntPtr cb_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - clipboard_ = SharpGen.Runtime.CppObject.ToCallbackPtr(clipboard); - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, unchecked ((System.Int32)effects), point, (void *)clipboard_, (void *)cb_, (void *)sourceHandle, (*(void ***)this._nativePointer)[28]); - System.GC.KeepAlive(clipboard); - System.GC.KeepAlive(cb); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetBlurEnabled([In] bool enable) - /// IAvnWindowBase::SetBlurEnabled - internal unsafe void SetBlurEnabled(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[29]); - __result__.CheckError(); - } - } - - class IAvnWindowBaseEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnWindowBaseEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnWindowBaseEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 13) - { - AddMethod(new PaintDelegate(Paint)); - AddMethod(new ClosedDelegate(Closed)); - AddMethod(new ActivatedDelegate(Activated)); - AddMethod(new DeactivatedDelegate(Deactivated)); - AddMethod(new ResizedDelegate(Resized)); - AddMethod(new PositionChangedDelegate(PositionChanged)); - AddMethod(new RawMouseEventDelegate(RawMouseEvent)); - AddMethod(new RawKeyEventDelegate(RawKeyEvent)); - AddMethod(new RawTextInputEventDelegate(RawTextInputEvent)); - AddMethod(new ScalingChangedDelegate(ScalingChanged)); - AddMethod(new RunRenderPriorityJobsDelegate(RunRenderPriorityJobs)); - AddMethod(new LostFocusDelegate(LostFocus)); - AddMethod(new DragEventDelegate(DragEvent)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate int PaintDelegate(System.IntPtr thisObject); - private static unsafe int Paint(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Paint(); - return SharpGen.Runtime.Result.Ok.Code; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return SharpGen.Runtime.Result.GetResultFromException(__exception__).Code; - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ClosedDelegate(System.IntPtr thisObject); - private static unsafe void Closed(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Closed(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ActivatedDelegate(System.IntPtr thisObject); - private static unsafe void Activated(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Activated(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void DeactivatedDelegate(System.IntPtr thisObject); - private static unsafe void Deactivated(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Deactivated(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ResizedDelegate(System.IntPtr thisObject, void *arg0); - private static unsafe void Resized(System.IntPtr thisObject, void *param0) - { - try - { - Avalonia.Native.Interop.AvnSize size = System.Runtime.CompilerServices.Unsafe.AsRef(param0); - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Resized(size); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void PositionChangedDelegate(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint arg0); - private static unsafe void PositionChanged(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint param0) - { - try - { - Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); - position = (Avalonia.Native.Interop.AvnPoint)param0; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.PositionChanged(position); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RawMouseEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, Avalonia.Native.Interop.AvnPoint arg3, Avalonia.Native.Interop.AvnVector arg4); - private static unsafe void RawMouseEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4) - { - try - { - Avalonia.Native.Interop.AvnRawMouseEventType type = default (Avalonia.Native.Interop.AvnRawMouseEventType); - type = (Avalonia.Native.Interop.AvnRawMouseEventType)param0; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - Avalonia.Native.Interop.AvnPoint point = default (Avalonia.Native.Interop.AvnPoint); - point = (Avalonia.Native.Interop.AvnPoint)param3; - Avalonia.Native.Interop.AvnVector delta = default (Avalonia.Native.Interop.AvnVector); - delta = (Avalonia.Native.Interop.AvnVector)param4; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.RawMouseEvent(type, timeStamp, modifiers, point, delta); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte RawKeyEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, System.UInt32 arg3); - private static unsafe System.Byte RawKeyEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - Avalonia.Native.Interop.AvnRawKeyEventType type = default (Avalonia.Native.Interop.AvnRawKeyEventType); - type = (Avalonia.Native.Interop.AvnRawKeyEventType)param0; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - System.UInt32 key = default (System.UInt32); - key = (System.UInt32)param3; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - __result__ = @this.RawKeyEvent(type, timeStamp, modifiers, key); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte RawTextInputEventDelegate(System.IntPtr thisObject, System.UInt32 arg0, void *arg1); - private static unsafe System.Byte RawTextInputEvent(System.IntPtr thisObject, System.UInt32 param0, void *param1) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param0; - System.String text = default (System.String); - System.IntPtr text_ = (System.IntPtr)param1; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(text_); - __result__ = @this.RawTextInputEvent(timeStamp, text); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ScalingChangedDelegate(System.IntPtr thisObject, double arg0); - private static unsafe void ScalingChanged(System.IntPtr thisObject, double param0) - { - try - { - System.Double scaling = default (System.Double); - scaling = (System.Double)param0; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.ScalingChanged(scaling); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RunRenderPriorityJobsDelegate(System.IntPtr thisObject); - private static unsafe void RunRenderPriorityJobs(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.RunRenderPriorityJobs(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void LostFocusDelegate(System.IntPtr thisObject); - private static unsafe void LostFocus(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.LostFocus(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate Avalonia.Native.Interop.AvnDragDropEffects DragEventDelegate(System.IntPtr thisObject, int arg0, Avalonia.Native.Interop.AvnPoint arg1, int arg2, int arg3, void *arg4, void *arg5); - private static unsafe Avalonia.Native.Interop.AvnDragDropEffects DragEvent(System.IntPtr thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5) - { - try - { - Avalonia.Native.Interop.AvnDragDropEffects __result__ = default (Avalonia.Native.Interop.AvnDragDropEffects); - Avalonia.Native.Interop.AvnDragEventType type = default (Avalonia.Native.Interop.AvnDragEventType); - type = (Avalonia.Native.Interop.AvnDragEventType)param0; - Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); - position = (Avalonia.Native.Interop.AvnPoint)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - Avalonia.Native.Interop.AvnDragDropEffects effects = default (Avalonia.Native.Interop.AvnDragDropEffects); - effects = (Avalonia.Native.Interop.AvnDragDropEffects)param3; - Avalonia.Native.Interop.IAvnClipboard clipboard = default (Avalonia.Native.Interop.IAvnClipboard); - System.IntPtr clipboard_ = (System.IntPtr)param4; - System.IntPtr dataObjectHandle = default (System.IntPtr); - dataObjectHandle = (System.IntPtr)param5; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - if (clipboard_ != System.IntPtr.Zero) - clipboard = new Avalonia.Native.Interop.IAvnClipboard(clipboard_); - else - clipboard = null; - __result__ = @this.DragEvent(type, position, modifiers, effects, clipboard, dataObjectHandle); - return __result__; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (Avalonia.Native.Interop.AvnDragDropEffects); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f05"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowBaseEventsShadow))] - public partial interface IAvnWindowBaseEvents : SharpGen.Runtime.IUnknown - { - void Paint(); - void Closed(); - void Activated(); - void Deactivated(); - void Resized(Avalonia.Native.Interop.AvnSize size); - void PositionChanged(Avalonia.Native.Interop.AvnPoint position); - void RawMouseEvent(Avalonia.Native.Interop.AvnRawMouseEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.AvnVector delta); - System.Boolean RawKeyEvent(Avalonia.Native.Interop.AvnRawKeyEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, System.UInt32 key); - System.Boolean RawTextInputEvent(System.UInt32 timeStamp, System.String text); - void ScalingChanged(System.Double scaling); - void RunRenderPriorityJobs(); - void LostFocus(); - Avalonia.Native.Interop.AvnDragDropEffects DragEvent(Avalonia.Native.Interop.AvnDragEventType type, Avalonia.Native.Interop.AvnPoint position, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.IAvnClipboard clipboard, System.IntPtr dataObjectHandle); - } - - class IAvnWindowEventsShadow : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow - { - protected unsafe class IAvnWindowEventsVtbl : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl - { - public IAvnWindowEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 3) - { - AddMethod(new ClosingDelegate(Closing)); - AddMethod(new WindowStateChangedDelegate(WindowStateChanged)); - AddMethod(new GotInputWhenDisabledDelegate(GotInputWhenDisabled)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte ClosingDelegate(System.IntPtr thisObject); - private static unsafe System.Byte Closing(System.IntPtr thisObject) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - __result__ = @this.Closing(); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void WindowStateChangedDelegate(System.IntPtr thisObject, int arg0); - private static unsafe void WindowStateChanged(System.IntPtr thisObject, int param0) - { - try - { - Avalonia.Native.Interop.AvnWindowState state = default (Avalonia.Native.Interop.AvnWindowState); - state = (Avalonia.Native.Interop.AvnWindowState)param0; - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - @this.WindowStateChanged(state); - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void GotInputWhenDisabledDelegate(System.IntPtr thisObject); - private static unsafe void GotInputWhenDisabled(System.IntPtr thisObject) - { - try - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - @this.GotInputWhenDisabled(); - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnWindowEventsShadow.IAvnWindowEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f06"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowEventsShadow))] - public partial interface IAvnWindowEvents : Avalonia.Native.Interop.IAvnWindowBaseEvents - { - System.Boolean Closing(); - void WindowStateChanged(Avalonia.Native.Interop.AvnWindowState state); - void GotInputWhenDisabled(); - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/LocalInterop.cs b/src/Avalonia.Native/Generated/LocalInterop.cs deleted file mode 100644 index 41e69a6bdc..0000000000 --- a/src/Avalonia.Native/Generated/LocalInterop.cs +++ /dev/null @@ -1,202 +0,0 @@ -// - -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; - } - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Structures.cs b/src/Avalonia.Native/Generated/Structures.cs deleted file mode 100644 index fc871a2516..0000000000 --- a/src/Avalonia.Native/Generated/Structures.cs +++ /dev/null @@ -1,246 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - /// - /// No documentation. - /// - /// AvnColor - /// AvnColor - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnColor - { - /// - /// No documentation. - /// - /// Alpha - /// Alpha - public System.Byte Alpha; - /// - /// No documentation. - /// - /// Red - /// Red - public System.Byte Red; - /// - /// No documentation. - /// - /// Green - /// Green - public System.Byte Green; - /// - /// No documentation. - /// - /// Blue - /// Blue - public System.Byte Blue; - } - - /// - /// No documentation. - /// - /// AvnFramebuffer - /// AvnFramebuffer - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnFramebuffer - { - /// - /// No documentation. - /// - /// Data - /// Data - public System.IntPtr Data; - /// - /// No documentation. - /// - /// Width - /// Width - public System.Int32 Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Int32 Height; - /// - /// No documentation. - /// - /// Stride - /// Stride - public System.Int32 Stride; - /// - /// No documentation. - /// - /// Dpi - /// Dpi - public Avalonia.Native.Interop.AvnVector Dpi; - /// - /// No documentation. - /// - /// PixelFormat - /// PixelFormat - public Avalonia.Native.Interop.AvnPixelFormat PixelFormat; - } - - /// - /// No documentation. - /// - /// AvnPixelSize - /// AvnPixelSize - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnPixelSize - { - /// - /// No documentation. - /// - /// Width - /// Width - public System.Int32 Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Int32 Height; - } - - /// - /// No documentation. - /// - /// AvnPoint - /// AvnPoint - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnPoint - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - } - - /// - /// No documentation. - /// - /// AvnRect - /// AvnRect - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnRect - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - /// - /// No documentation. - /// - /// Width - /// Width - public System.Double Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Double Height; - } - - /// - /// No documentation. - /// - /// AvnScreen - /// AvnScreen - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnScreen - { - /// - /// No documentation. - /// - /// Bounds - /// Bounds - public Avalonia.Native.Interop.AvnRect Bounds; - /// - /// No documentation. - /// - /// WorkingArea - /// WorkingArea - public Avalonia.Native.Interop.AvnRect WorkingArea; - /// - /// No documentation. - /// - /// PixelDensity - /// PixelDensity - public System.Single PixelDensity; - /// - /// No documentation. - /// - /// Primary - /// Primary - public bool Primary - { - get => 0 != _Primary; - set => _Primary = (System.Byte)(value ? 1 : 0); - } - - internal System.Byte _Primary; - } - - /// - /// No documentation. - /// - /// AvnSize - /// AvnSize - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnSize - { - /// - /// No documentation. - /// - /// Width - /// Width - public System.Double Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Double Height; - } - - /// - /// No documentation. - /// - /// AvnVector - /// AvnVector - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnVector - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Helpers.cs b/src/Avalonia.Native/Helpers.cs index 25e8250232..564434a04c 100644 --- a/src/Avalonia.Native/Helpers.cs +++ b/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) { diff --git a/src/Avalonia.Native/IAvnMenu.cs b/src/Avalonia.Native/IAvnMenu.cs index 8a49559a02..dd9464284f 100644 --- a/src/Avalonia.Native/IAvnMenu.cs +++ b/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 _menuItems = new List(); - private Dictionary _menuItemLookup = new Dictionary(); + private List<__MicroComIAvnMenuItemProxy> _menuItems = new List<__MicroComIAvnMenuItemProxy>(); + private Dictionary _menuItemLookup = new Dictionary(); 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) { diff --git a/src/Avalonia.Native/IAvnMenuItem.cs b/src/Avalonia.Native/IAvnMenuItem.cs index c8819d1994..e2feffaa33 100644 --- a/src/Avalonia.Native/IAvnMenuItem.cs +++ b/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); diff --git a/src/Avalonia.Native/NativeControlHostImpl.cs b/src/Avalonia.Native/NativeControlHostImpl.cs index a46528dc48..2c9c1728d3 100644 --- a/src/Avalonia.Native/NativeControlHostImpl.cs +++ b/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); } diff --git a/src/Avalonia.Native/PlatformThreadingInterface.cs b/src/Avalonia.Native/PlatformThreadingInterface.cs index 5a81f6a3bf..df69f2eafb 100644 --- a/src/Avalonia.Native/PlatformThreadingInterface.cs +++ b/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; diff --git a/src/Avalonia.Native/ScreenImpl.cs b/src/Avalonia.Native/ScreenImpl.cs index f28be52dd5..ae6da01388 100644 --- a/src/Avalonia.Native/ScreenImpl.cs +++ b/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 AllScreens { diff --git a/src/Avalonia.Native/SystemDialogs.cs b/src/Avalonia.Native/SystemDialogs.cs index 98e3e383dc..0239fc680d 100644 --- a/src/Avalonia.Native/SystemDialogs.cs +++ b/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 _tcs; @@ -73,13 +73,13 @@ namespace Avalonia.Native public Task 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++) { diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index 11a0ebce61..b42831854d 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/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 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); } diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 824f62aee5..bc0916c8da 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/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 PositionChanged { get; set; } diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index c763007826..dc139cf8e3 100644 --- a/src/Avalonia.Native/avn.idl +++ b/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); diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs index 8613cbba88..2c366b143d 100644 --- a/src/tools/MicroComGenerator/Ast.cs +++ b/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 + public class AstAttributes : List { - public List Attributes { get; set; } = new List(); + 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, 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 + public class AstStructNode : List, IAstNodeWithAttributes { - public List Attributes { get; set; } = new List(); + 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 + public class AstInterfaceNode : List, IAstNodeWithAttributes { - public List Attributes { get; set; } = new List(); + 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 + public class AstInterfaceMemberNode : List, IAstNodeWithAttributes { public string Name { get; set; } public AstTypeNode ReturnType { get; set; } - public List Attributes { get; set; } = new List(); + 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 Attributes { get; set; } = new List(); + 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 Attributes { get; set; } = new List(); + 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 Enums { get; set; } = new List(); public List Structs { get; set; } = new List(); public List Interfaces { get; set; } = new List(); + + 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() + }; } } diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs index 46404da3d7..a003fb3096 100644 --- a/src/tools/MicroComGenerator/AstParser.cs +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -27,9 +27,9 @@ namespace MicroComGenerator return idl; } - static List ParseGlobalAttributes(ref TokenParser parser) + static AstAttributes ParseGlobalAttributes(ref TokenParser parser) { - var rv = new List(); + var rv = new AstAttributes(); while (!parser.Eof) { parser.SkipWhitespace(); @@ -61,9 +61,9 @@ namespace MicroComGenerator return rv; } - static List ParseLocalAttributes(ref TokenParser parser) + static AstAttributes ParseLocalAttributes(ref TokenParser parser) { - var rv = new List(); + 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 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 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 interfaceAttrs, ref TokenParser parser) + static AstInterfaceNode ParseInterface(AstAttributes interfaceAttrs, ref TokenParser parser) { var interfaceName = parser.ParseIdentifier(); string inheritsFrom = null; diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index 2fcf1b404b..d6848dc48e 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/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 diff --git a/src/tools/MicroComGenerator/CSharpGen.Utils.cs b/src/tools/MicroComGenerator/CSharpGen.Utils.cs index ed2bcdd6d8..3a62220d12 100644 --- a/src/tools/MicroComGenerator/CSharpGen.Utils.cs +++ b/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); + } } diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 49e4f7a09e..93fce16dfc 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/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)); diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs index 133902f764..f2b748787f 100644 --- a/src/tools/MicroComGenerator/CppGen.cs +++ b/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("-", ""); diff --git a/src/tools/MicroComGenerator/MicroComGenerator.csproj b/src/tools/MicroComGenerator/MicroComGenerator.csproj index 193bb9a100..5ae431b4b9 100644 --- a/src/tools/MicroComGenerator/MicroComGenerator.csproj +++ b/src/tools/MicroComGenerator/MicroComGenerator.csproj @@ -1,5 +1,4 @@ - Exe netcoreapp3.1 @@ -8,5 +7,4 @@ - From a8c871963960b8ecf56edc6d8e992984605ecbea Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 17:19:59 +0300 Subject: [PATCH 22/35] Module initializer hooks should be called before ret --- src/Avalonia.Build.Tasks/ComInteropHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Build.Tasks/ComInteropHelper.cs b/src/Avalonia.Build.Tasks/ComInteropHelper.cs index 2f92ddc116..007231417d 100644 --- a/src/Avalonia.Build.Tasks/ComInteropHelper.cs +++ b/src/Avalonia.Build.Tasks/ComInteropHelper.cs @@ -47,7 +47,7 @@ namespace Avalonia.Build.Tasks } foreach (var i in initializers) - staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Call, i)); + staticCtor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, i)); } } From 96eaa26d1dd87e9015b440e68a4cbd12e6832e72 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 19:54:30 +0300 Subject: [PATCH 23/35] Add System.Runtime.InteropServices.UnmanagedFunctionPointer --- src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs | 7 ++++--- src/tools/MicroComGenerator/CSharpGen.cs | 7 +------ src/tools/MicroComGenerator/Extensions.cs | 7 +++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index d6848dc48e..b4a0770e73 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -278,11 +278,12 @@ namespace MicroComGenerator // Generate VTable method - - var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name+"Delegate") + var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name + "Delegate") .AddParameterListParameters(Parameter(Identifier("@this")).WithType(ParseTypeName("IntPtr"))) .AddParameterListParameters(args.Select(x => - Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()); + Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()) + .AddAttribute("System.Runtime.InteropServices.UnmanagedFunctionPointer", + "System.Runtime.InteropServices.CallingConvention.StdCall"); var shadowMethod = MethodDeclaration(shadowDelegate.ReturnType, member.Name) .WithParameterList(shadowDelegate.ParameterList) diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 93fce16dfc..8806531b19 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -109,13 +109,8 @@ namespace MicroComGenerator return ns.AddMembers(_idl.Structs.Select(e => StructDeclaration(e.Name) .WithModifiers(TokenList(Token(_visibility))) + .AddAttribute("System.Runtime.InteropServices.StructLayout", "System.Runtime.InteropServices.LayoutKind.Sequential") .AddModifiers(Token(SyntaxKind.UnsafeKeyword)) - .AddAttributeLists(AttributeList(SingletonSeparatedList( - Attribute(ParseName("System.Runtime.InteropServices.StructLayout"), - AttributeArgumentList(SingletonSeparatedList( - AttributeArgument( - ParseExpression("System.Runtime.InteropServices.LayoutKind.Sequential")))) - )))) .WithMembers(new SyntaxList(SeparatedList(e.Select(m => DeclareField(m.Type.ToString(), m.Name, SyntaxKind.PublicKeyword))))) ).ToArray()); diff --git a/src/tools/MicroComGenerator/Extensions.cs b/src/tools/MicroComGenerator/Extensions.cs index 4942442d1b..c8a4c8f45c 100644 --- a/src/tools/MicroComGenerator/Extensions.cs +++ b/src/tools/MicroComGenerator/Extensions.cs @@ -81,6 +81,13 @@ namespace MicroComGenerator return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); } + public static T AddAttribute(this T member, string attribute, params string[] args) where T : MemberDeclarationSyntax + { + return (T)member.AddAttributeLists(AttributeList(SingletonSeparatedList( + Attribute(ParseName(attribute), AttributeArgumentList( + SeparatedList(args.Select(a => AttributeArgument(ParseExpression(a))))))))); + } + public static string StripPrefix(this string s, string prefix) => string.IsNullOrEmpty(s) ? s : s.StartsWith(prefix) From c404dcf1c70357d07c5529212b4e8f492be6f491 Mon Sep 17 00:00:00 2001 From: artyom Date: Wed, 28 Oct 2020 22:36:56 +0300 Subject: [PATCH 24/35] Use GetObservable and AvaProperty.UnSet --- .../ReactiveUserControl.cs | 27 +++++-- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 27 +++++-- .../ReactiveUserControlTest.cs | 71 +++++++++++++++++++ 3 files changed, 117 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 31f4691c90..416f0a2165 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -29,10 +29,29 @@ namespace Avalonia.ReactiveUI // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.ObservableForProperty(x => x.ViewModel, false, true) - .Subscribe(args => DataContext = args.Value); - this.ObservableForProperty(x => x.DataContext, false, true) - .Subscribe(args => ViewModel = args.Value as TViewModel); + this.GetObservable(DataContextProperty).Subscribe(value => + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + }); + + this.GetObservable(ViewModelProperty).Subscribe(value => + { + if (value == null) + { + DataContext = AvaloniaProperty.UnsetValue; + } + else + { + DataContext = value; + } + }); } /// diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index 1204266b63..fcef0a019f 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -29,10 +29,29 @@ namespace Avalonia.ReactiveUI // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.ObservableForProperty(x => x.ViewModel, false, true) - .Subscribe(args => DataContext = args.Value); - this.ObservableForProperty(x => x.DataContext, false, true) - .Subscribe(args => ViewModel = args.Value as TViewModel); + this.GetObservable(DataContextProperty).Subscribe(value => + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + }); + + this.GetObservable(ViewModelProperty).Subscribe(value => + { + if (value == null) + { + DataContext = AvaloniaProperty.UnsetValue; + } + else + { + DataContext = value; + } + }); } /// diff --git a/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs index 5d257f75f2..4dd60e21c5 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs @@ -1,4 +1,5 @@ using System.Reactive.Disposables; +using Avalonia.Controls; using Avalonia.UnitTests; using ReactiveUI; using Splat; @@ -100,5 +101,75 @@ namespace Avalonia.ReactiveUI.UnitTests Assert.NotNull(view.DataContext); Assert.False(view.ViewModel.IsActive); } + + [Fact] + public void Should_Inherit_DataContext() + { + var vm1 = new ExampleViewModel(); + var vm2 = new ExampleViewModel(); + var view = new ExampleView(); + var root = new TestRoot(view); + + Assert.Null(view.DataContext); + Assert.Null(view.ViewModel); + + root.DataContext = vm1; + + Assert.Same(vm1, view.DataContext); + Assert.Same(vm1, view.ViewModel); + + root.DataContext = null; + + Assert.Null(view.DataContext); + Assert.Null(view.ViewModel); + + root.DataContext = vm2; + + Assert.Same(vm2, view.DataContext); + Assert.Same(vm2, view.ViewModel); + } + + [Fact] + public void Should_Not_Overlap_Change_Notifications() + { + var vm1 = new ExampleViewModel(); + var vm2 = new ExampleViewModel(); + + var view1 = new ExampleView(); + var view2 = new ExampleView(); + + Assert.Null(view1.DataContext); + Assert.Null(view2.DataContext); + Assert.Null(view1.ViewModel); + Assert.Null(view2.ViewModel); + + view1.DataContext = vm1; + + Assert.Same(vm1, view1.DataContext); + Assert.Same(vm1, view1.ViewModel); + Assert.Null(view2.DataContext); + Assert.Null(view2.ViewModel); + + view2.DataContext = vm2; + + Assert.Same(vm1, view1.DataContext); + Assert.Same(vm1, view1.ViewModel); + Assert.Same(vm2, view2.DataContext); + Assert.Same(vm2, view2.ViewModel); + + view1.ViewModel = null; + + Assert.Null(view1.DataContext); + Assert.Null(view1.ViewModel); + Assert.Same(vm2, view2.DataContext); + Assert.Same(vm2, view2.ViewModel); + + view2.ViewModel = null; + + Assert.Null(view1.DataContext); + Assert.Null(view2.DataContext); + Assert.Null(view1.ViewModel); + Assert.Null(view2.ViewModel); + } } } From a6d83bb7ce306388d18bee75c338f2d7f535ea3b Mon Sep 17 00:00:00 2001 From: artyom Date: Wed, 28 Oct 2020 23:11:10 +0300 Subject: [PATCH 25/35] Correct change notification listeners --- .../ReactiveUserControl.cs | 50 ++++++++++--------- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 50 ++++++++++--------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 416f0a2165..40d9666c3e 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -28,30 +28,8 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - - this.GetObservable(DataContextProperty).Subscribe(value => - { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } - }); - - this.GetObservable(ViewModelProperty).Subscribe(value => - { - if (value == null) - { - DataContext = AvaloniaProperty.UnsetValue; - } - else - { - DataContext = value; - } - }); + this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); + this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } /// @@ -68,5 +46,29 @@ namespace Avalonia.ReactiveUI get => ViewModel; set => ViewModel = (TViewModel)value; } + + private void OnDataContextChanged(object value) + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + } + + private void OnViewModelChanged(object value) + { + if (value == null) + { + ClearValue(DataContextProperty); + } + else if (DataContext != value) + { + DataContext = value; + } + } } } diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index fcef0a019f..758a807bfc 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -28,30 +28,8 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - - this.GetObservable(DataContextProperty).Subscribe(value => - { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } - }); - - this.GetObservable(ViewModelProperty).Subscribe(value => - { - if (value == null) - { - DataContext = AvaloniaProperty.UnsetValue; - } - else - { - DataContext = value; - } - }); + this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); + this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } /// @@ -68,5 +46,29 @@ namespace Avalonia.ReactiveUI get => ViewModel; set => ViewModel = (TViewModel)value; } + + private void OnDataContextChanged(object value) + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + } + + private void OnViewModelChanged(object value) + { + if (value == null) + { + ClearValue(DataContextProperty); + } + else if (DataContext != value) + { + DataContext = value; + } + } } } From f8d5ae59cccb58f95f00e1c032627066f653f141 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 15:22:46 +0300 Subject: [PATCH 26/35] Fix microcom target? --- build/CoreLibraries.props | 1 + packages/Avalonia/Avalonia.csproj | 2 -- src/Avalonia.Native/Avalonia.Native.csproj | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build/CoreLibraries.props b/build/CoreLibraries.props index d17eec0135..fff00041c3 100644 --- a/build/CoreLibraries.props +++ b/build/CoreLibraries.props @@ -15,6 +15,7 @@ + diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj index 90c1c67956..75ee4a05cb 100644 --- a/packages/Avalonia/Avalonia.csproj +++ b/packages/Avalonia/Avalonia.csproj @@ -7,8 +7,6 @@ - - diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index a3e99595c2..ecd245966e 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -34,7 +34,11 @@ - + From 334f5f0a8645f9ef4fe0ed2ef573576a2d4377e4 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 15:22:54 +0300 Subject: [PATCH 27/35] Fix microcom registration --- src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index b4a0770e73..10c44bea21 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -437,7 +437,7 @@ namespace MicroComGenerator .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) .WithBody(Block( ParseStatement("Avalonia.MicroCom.MicroComRuntime.Register(typeof(" + - proxyClassName + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + + iface.Name + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + proxyClassName + "(p, owns));") ))) .AddMembers(ParseMemberDeclaration("public " + proxyClassName + From 8de6823e5ddd6a189bc3a8dff94573a6cceb1c0a Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 16:52:47 +0300 Subject: [PATCH 28/35] IT'S ALIVE --- packages/Avalonia/AvaloniaBuildTasks.targets | 2 + .../CompileAvaloniaXamlTask.cs | 3 +- .../XamlCompilerTaskExecutor.cs | 57 +++++++++++++------ .../Avalonia.MicroCom.csproj | 14 +++-- src/Avalonia.MicroCom/MicroComRuntime.cs | 3 + src/Avalonia.MicroCom/MicroComVtblBase.cs | 1 + src/Avalonia.Native/Avalonia.Native.csproj | 8 ++- .../CSharpGen.InterfaceGen.cs | 13 ++++- 8 files changed, 71 insertions(+), 30 deletions(-) diff --git a/packages/Avalonia/AvaloniaBuildTasks.targets b/packages/Avalonia/AvaloniaBuildTasks.targets index 57b4cb04e3..45a7f1aa44 100644 --- a/packages/Avalonia/AvaloniaBuildTasks.targets +++ b/packages/Avalonia/AvaloniaBuildTasks.targets @@ -4,6 +4,7 @@ <_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false low <_AvaloniaPatchComInterop Condition="'$(_AvaloniaPatchComInterop)' == ''">false + <_AvaloniaSkipXamlCompilation Condition="'$(_AvaloniaSkipXamlCompilation)' == ''">false @@ -92,6 +93,7 @@ SignAssembly="$(SignAssembly)" DelaySign="$(DelaySign)" EnableComInteropPatching="$(_AvaloniaPatchComInterop)" + SkipXamlCompilation="$(_AvaloniaSkipXamlCompilation)" /> !string.IsNullOrWhiteSpace(l)).ToArray(), ProjectDirectory, OutputPath, VerifyIl, outputImportance, (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null, - EnableComInteropPatching); + EnableComInteropPatching, SkipXamlCompilation); if (!res.Success) return false; if (!res.WrittenFile) @@ -77,6 +77,7 @@ namespace Avalonia.Build.Tasks public bool VerifyIl { get; set; } public bool EnableComInteropPatching { get; set; } + public bool SkipXamlCompilation { get; set; } public string AssemblyOriginatorKeyFile { get; set; } public bool SignAssembly { get; set; } diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 938732cfe1..0b9b50e771 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -40,17 +40,48 @@ namespace Avalonia.Build.Tasks WrittenFile = writtenFile; } } + + public static CompileResult Compile(IBuildEngine engine, string input, string[] references, + string projectDirectory, + string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom, + bool skipXamlCompilation) + { + var typeSystem = new CecilTypeSystem(references.Concat(new[] { input }), input); + + var asm = typeSystem.TargetAssemblyDefinition; + + if (!skipXamlCompilation) + { + var compileRes = CompileCore(engine, typeSystem, projectDirectory, verifyIl, logImportance); + if (compileRes == null && !patchCom) + return new CompileResult(true); + if (compileRes == false) + return new CompileResult(false); + } + + if (patchCom) + ComInteropHelper.PatchAssembly(asm, typeSystem); + + var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; + if (!string.IsNullOrWhiteSpace(strongNameKey)) + writerParameters.StrongNameKeyBlob = File.ReadAllBytes(strongNameKey); + + asm.Write(output, writerParameters); + + return new CompileResult(true, true); + + } - public static CompileResult Compile(IBuildEngine engine, string input, string[] references, string projectDirectory, - string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom) + static bool? CompileCore(IBuildEngine engine, CecilTypeSystem typeSystem, + string projectDirectory, bool verifyIl, + MessageImportance logImportance) { - var typeSystem = new CecilTypeSystem(references.Concat(new[] {input}), input); var asm = typeSystem.TargetAssemblyDefinition; var emres = new EmbeddedResources(asm); var avares = new AvaloniaResources(asm, projectDirectory); - if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0 && !patchCom) + if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0) // Nothing to do - return new CompileResult(true); + return null; var clrPropertiesDef = new TypeDefinition("CompiledAvaloniaXaml", "XamlIlHelpers", TypeAttributes.Class, asm.MainModule.TypeSystem.Object); @@ -364,27 +395,17 @@ namespace Avalonia.Build.Tasks if (emres.Resources.Count(CheckXamlName) != 0) if (!CompileGroup(emres)) - return new CompileResult(false); + return false; if (avares.Resources.Count(CheckXamlName) != 0) { if (!CompileGroup(avares)) - return new CompileResult(false); + return false; avares.Save(); } loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldnull)); loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); - - if (patchCom) - ComInteropHelper.PatchAssembly(asm, typeSystem); - - var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; - if (!string.IsNullOrWhiteSpace(strongNameKey)) - writerParameters.StrongNameKeyBlob = File.ReadAllBytes(strongNameKey); - - asm.Write(output, writerParameters); - - return new CompileResult(true, true); + return true; } } diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj index aaf54ed80e..7994a74f76 100644 --- a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -1,8 +1,10 @@ - - - netstandard2.0 - true - - + + netstandard2.0 + true + + + <_AvaloniaPatchComInterop>true + + diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs index d43568631a..9d2c23f40a 100644 --- a/src/Avalonia.MicroCom/MicroComRuntime.cs +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -41,6 +41,8 @@ namespace Avalonia.MicroCom public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown { + if (obj == null) + return null; if (obj is MicroComProxyBase proxy) return (void*)proxy.NativePointer; if (obj is IMicroComShadowContainer container) @@ -55,6 +57,7 @@ namespace Avalonia.MicroCom res); if (owned) container.Shadow.AddRef((Ccw*)ptr); + return ptr; } throw new ArgumentException("Unable to get a native pointer for " + obj); } diff --git a/src/Avalonia.MicroCom/MicroComVtblBase.cs b/src/Avalonia.MicroCom/MicroComVtblBase.cs index 4cd419cdaf..e06e2d4934 100644 --- a/src/Avalonia.MicroCom/MicroComVtblBase.cs +++ b/src/Avalonia.MicroCom/MicroComVtblBase.cs @@ -18,6 +18,7 @@ namespace Avalonia.MicroCom { AddMethod((QueryInterfaceDelegate)QueryInterface); AddMethod((AddRefDelegate)AddRef); + AddMethod((AddRefDelegate)Release); } protected void AddMethod(Delegate d) diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index ecd245966e..f0c747504b 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -37,7 +37,7 @@ @@ -47,8 +47,12 @@ + + + + <_AvaloniaPatchComInterop>true - \ No newline at end of file + diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index 10c44bea21..91ece81bd0 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -135,7 +135,7 @@ namespace MicroComGenerator public override void PreMarshal(List body) { body.Add(ParseStatement($"var {BName} = new byte[System.Text.Encoding.UTF8.GetByteCount({Name})+1];")); - body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name.Length}, {BName}, 0);")); + body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name}.Length, {BName}, 0);")); } public override StatementSyntax CreateFixed(StatementSyntax inner) @@ -238,8 +238,11 @@ namespace MicroComGenerator .AddArgumentListArguments(Argument(ParseExpression("PPV"))) .AddArgumentListArguments(args .Select((a, i) => Argument(a.Value(isHresultLastArgumentReturn && i == args.Count - 1))).ToArray()) - .AddArgumentListArguments(Argument(ParseExpression("PPV[base.VTableSize + " + num + "]"))); + .AddArgumentListArguments(Argument(ParseExpression("(*PPV)[base.VTableSize + " + num + "]"))); + if (!isVoidReturn) + callExpr = CastExpression(ParseTypeName(returnArg.NativeType), callExpr); + // Save call result if needed if (!isVoidReturn) callExpr = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, ParseExpression("__result"), @@ -369,6 +372,10 @@ namespace MicroComGenerator public ExpressionSyntax GetCaller(string returnType, List args) { + string ConvertType(string t) => t.EndsWith("*") ? "void*" : t; + returnType = ConvertType(returnType); + args = args.Select(ConvertType).ToList(); + var name = "CalliStdCall" + returnType.Replace("*", "_ptr"); var signature = returnType + "::" + name + "::" + string.Join("::", args); if (_existing.Add(signature)) @@ -427,7 +434,7 @@ namespace MicroComGenerator .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) .WithExpressionBody(ArrowExpressionClause( ParseExpression("Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(" + - proxyClassName + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) + iface.Name + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) .WithSemicolonToken(Semicolon())); From 7460c429feef2a2b9e5cc15701c6515c084b3764 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 16:55:05 +0300 Subject: [PATCH 29/35] Calling Dispose multiple times should be valid --- src/Avalonia.MicroCom/MicroComProxyBase.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs index 6a13fb10c4..681e278104 100644 --- a/src/Avalonia.MicroCom/MicroComProxyBase.cs +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -65,8 +65,13 @@ namespace Avalonia.MicroCom protected virtual void Dispose(bool disposing) { + if(_nativePointer == null) + return; if (_ownsHandle) + { Release(); + _ownsHandle = false; + } _nativePointer = IntPtr.Zero; GC.SuppressFinalize(this); } From addcc6674d5a341f5a821a00f1deacdf9c7fa6f3 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 17:40:44 +0300 Subject: [PATCH 30/35] Generate avalonia-native.h from avn.idl --- azure-pipelines.yml | 6 + native/Avalonia.Native/inc/.gitignore | 1 + native/Avalonia.Native/inc/avalonia-native.h | 516 ------------------- native/Avalonia.Native/src/OSX/clipboard.mm | 2 +- native/Avalonia.Native/src/OSX/main.mm | 4 +- native/Avalonia.Native/src/OSX/menu.h | 6 +- native/Avalonia.Native/src/OSX/menu.mm | 6 +- native/Avalonia.Native/src/OSX/window.mm | 2 +- nukebuild/MicroComGen.cs | 14 + nukebuild/_build.csproj | 4 + src/Avalonia.Native/avn.idl | 6 +- src/tools/MicroComGenerator/Ast.cs | 10 +- src/tools/MicroComGenerator/AstParser.cs | 2 + src/tools/MicroComGenerator/CSharpGen.cs | 11 + src/tools/MicroComGenerator/CppGen.cs | 43 +- 15 files changed, 86 insertions(+), 547 deletions(-) create mode 100644 native/Avalonia.Native/inc/.gitignore delete mode 100644 native/Avalonia.Native/inc/avalonia-native.h create mode 100644 nukebuild/MicroComGen.cs diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e67fa14c57..5d6c561bc6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -48,6 +48,12 @@ jobs: curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg sudo installer -verbose -pkg ./mono.pkg -target / + - task: CmdLine@2 + displayName: 'Generate avalonia-native' + inputs: + script: | + cd src/tools/MicroComGenerator; dotnet run -i ../../Avalonia.Native/avn.idl --cpp ../../../native/Avalonia.Native/inc/avalonia-native.h + - task: Xcode@5 inputs: actions: 'build' diff --git a/native/Avalonia.Native/inc/.gitignore b/native/Avalonia.Native/inc/.gitignore new file mode 100644 index 0000000000..e7aa7fc6a5 --- /dev/null +++ b/native/Avalonia.Native/inc/.gitignore @@ -0,0 +1 @@ +avalonia-native.h diff --git a/native/Avalonia.Native/inc/avalonia-native.h b/native/Avalonia.Native/inc/avalonia-native.h deleted file mode 100644 index 9ff6130e5f..0000000000 --- a/native/Avalonia.Native/inc/avalonia-native.h +++ /dev/null @@ -1,516 +0,0 @@ -#include "com.h" -#include "key.h" -#include "stddef.h" - -#define AVNCOM(name, id) COMINTERFACE(name, 2e2cda0a, 9ae5, 4f1b, 8e, 20, 08, 1a, 04, 27, 9f, id) - -struct IAvnWindowEvents; -struct IAvnWindow; -struct IAvnPopup; -struct IAvnMacOptions; -struct IAvnPlatformThreadingInterface; -struct IAvnSystemDialogEvents; -struct IAvnSystemDialogs; -struct IAvnScreens; -struct IAvnClipboard; -struct IAvnCursor; -struct IAvnCursorFactory; -struct IAvnGlFeature; -struct IAvnGlContext; -struct IAvnGlDisplay; -struct IAvnGlSurfaceRenderTarget; -struct IAvnGlSurfaceRenderingSession; -struct IAvnMenu; -struct IAvnMenuItem; -struct IAvnStringArray; -struct IAvnDndResultCallback; -struct IAvnGCHandleDeallocatorCallback; -struct IAvnMenuEvents; -struct IAvnNativeControlHost; -struct IAvnNativeControlHostTopLevelAttachment; -enum SystemDecorations { - SystemDecorationsNone = 0, - SystemDecorationsBorderOnly = 1, - SystemDecorationsFull = 2, -}; - -struct AvnSize -{ - double Width, Height; -}; - -struct AvnPixelSize -{ - int Width, Height; -}; - -struct AvnRect -{ - double X, Y, Width, Height; -}; - -struct AvnVector -{ - double X, Y; -}; - -struct AvnPoint -{ - double X, Y; -}; - -struct AvnScreen -{ - AvnRect Bounds; - AvnRect WorkingArea; - float PixelDensity; - bool Primary; -}; - -enum AvnPixelFormat -{ - kAvnRgb565, - kAvnRgba8888, - kAvnBgra8888 -}; - -struct AvnFramebuffer -{ - void* Data; - int Width; - int Height; - int Stride; - AvnVector Dpi; - AvnPixelFormat PixelFormat; -}; - -struct AvnColor -{ - unsigned char Alpha; - unsigned char Red; - unsigned char Green; - unsigned char Blue; -}; - -enum AvnRawMouseEventType -{ - LeaveWindow, - LeftButtonDown, - LeftButtonUp, - RightButtonDown, - RightButtonUp, - MiddleButtonDown, - MiddleButtonUp, - XButton1Down, - XButton1Up, - XButton2Down, - XButton2Up, - Move, - Wheel, - NonClientLeftButtonDown, - TouchBegin, - TouchUpdate, - TouchEnd, - TouchCancel -}; - -enum AvnRawKeyEventType -{ - KeyDown, - KeyUp -}; - -enum AvnInputModifiers -{ - AvnInputModifiersNone = 0, - Alt = 1, - Control = 2, - Shift = 4, - Windows = 8, - LeftMouseButton = 16, - RightMouseButton = 32, - MiddleMouseButton = 64, - XButton1MouseButton = 128, - XButton2MouseButton = 256 -}; - -enum class AvnDragDropEffects -{ - None = 0, - Copy = 1, - Move = 2, - Link = 4, -}; - -enum class AvnDragEventType -{ - Enter, - Over, - Leave, - Drop -}; - -enum AvnWindowState -{ - Normal, - Minimized, - Maximized, - FullScreen, -}; - -enum AvnStandardCursorType -{ - CursorArrow, - CursorIbeam, - CursorWait, - CursorCross, - CursorUpArrow, - CursorSizeWestEast, - CursorSizeNorthSouth, - CursorSizeAll, - CursorNo, - CursorHand, - CursorAppStarting, - CursorHelp, - CursorTopSide, - CursorBottomSize, - CursorLeftSide, - CursorRightSide, - CursorTopLeftCorner, - CursorTopRightCorner, - CursorBottomLeftCorner, - CursorBottomRightCorner, - CursorDragMove, - CursorDragCopy, - CursorDragLink, - CursorNone -}; - -enum AvnWindowEdge -{ - WindowEdgeNorthWest, - WindowEdgeNorth, - WindowEdgeNorthEast, - WindowEdgeWest, - WindowEdgeEast, - WindowEdgeSouthWest, - WindowEdgeSouth, - WindowEdgeSouthEast -}; - -enum AvnMenuItemToggleType -{ - None, - CheckMark, - Radio -}; - -enum AvnExtendClientAreaChromeHints -{ - AvnNoChrome = 0, - AvnSystemChrome = 0x01, - AvnPreferSystemChrome = 0x02, - AvnOSXThickTitleBar = 0x08, - AvnDefaultChrome = AvnSystemChrome, -}; - -AVNCOM(IAvaloniaNativeFactory, 01) : IUnknown -{ -public: - virtual HRESULT Initialize(IAvnGCHandleDeallocatorCallback* deallocator) = 0; - virtual IAvnMacOptions* GetMacOptions() = 0; - virtual HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnWindow** ppv) = 0; - virtual HRESULT CreatePopup (IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnPopup** ppv) = 0; - virtual HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv) = 0; - virtual HRESULT CreateSystemDialogs (IAvnSystemDialogs** ppv) = 0; - virtual HRESULT CreateScreens (IAvnScreens** ppv) = 0; - virtual HRESULT CreateClipboard(IAvnClipboard** ppv) = 0; - virtual HRESULT CreateDndClipboard(IAvnClipboard** ppv) = 0; - virtual HRESULT CreateCursorFactory(IAvnCursorFactory** ppv) = 0; - virtual HRESULT ObtainGlDisplay(IAvnGlDisplay** ppv) = 0; - virtual HRESULT SetAppMenu(IAvnMenu* menu) = 0; - virtual HRESULT CreateMenu (IAvnMenuEvents* cb, IAvnMenu** ppv) = 0; - virtual HRESULT CreateMenuItem (IAvnMenuItem** ppv) = 0; - virtual HRESULT CreateMenuItemSeperator (IAvnMenuItem** ppv) = 0; -}; - -AVNCOM(IAvnString, 17) : IUnknown -{ - virtual HRESULT Pointer(void**retOut) = 0; - virtual HRESULT Length(int*ret) = 0; -}; - -AVNCOM(IAvnWindowBase, 02) : IUnknown -{ - virtual HRESULT Show() = 0; - virtual HRESULT Hide () = 0; - virtual HRESULT Close() = 0; - virtual HRESULT Activate () = 0; - virtual HRESULT GetClientSize(AvnSize*ret) = 0; - virtual HRESULT GetScaling(double*ret)=0; - virtual HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize) = 0; - virtual HRESULT Resize(double width, double height) = 0; - virtual HRESULT Invalidate (AvnRect rect) = 0; - virtual HRESULT BeginMoveDrag () = 0; - virtual HRESULT BeginResizeDrag (AvnWindowEdge edge) = 0; - virtual HRESULT GetPosition (AvnPoint*ret) = 0; - virtual HRESULT SetPosition (AvnPoint point) = 0; - virtual HRESULT PointToClient (AvnPoint point, AvnPoint*ret) = 0; - virtual HRESULT PointToScreen (AvnPoint point, AvnPoint*ret) = 0; - virtual HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose) = 0; - virtual HRESULT SetTopMost (bool value) = 0; - virtual HRESULT SetCursor(IAvnCursor* cursor) = 0; - virtual HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret) = 0; - virtual HRESULT SetMainMenu(IAvnMenu* menu) = 0; - virtual HRESULT ObtainNSWindowHandle(void** retOut) = 0; - virtual HRESULT ObtainNSWindowHandleRetained(void** retOut) = 0; - virtual HRESULT ObtainNSViewHandle(void** retOut) = 0; - virtual HRESULT ObtainNSViewHandleRetained(void** retOut) = 0; - virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut) = 0; - virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, - IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle) = 0; - virtual HRESULT SetBlurEnabled (bool enable) = 0; -}; - -AVNCOM(IAvnPopup, 03) : virtual IAvnWindowBase -{ - -}; - -AVNCOM(IAvnWindow, 04) : virtual IAvnWindowBase -{ - virtual HRESULT SetEnabled (bool enable) = 0; - virtual HRESULT SetParent (IAvnWindow* parent) = 0; - virtual HRESULT SetCanResize(bool value) = 0; - virtual HRESULT SetDecorations(SystemDecorations value) = 0; - virtual HRESULT SetTitle (void* utf8Title) = 0; - virtual HRESULT SetTitleBarColor (AvnColor color) = 0; - virtual HRESULT SetWindowState(AvnWindowState state) = 0; - virtual HRESULT GetWindowState(AvnWindowState*ret) = 0; - virtual HRESULT TakeFocusFromChildren() = 0; - virtual HRESULT SetExtendClientArea (bool enable) = 0; - virtual HRESULT SetExtendClientAreaHints (AvnExtendClientAreaChromeHints hints) = 0; - virtual HRESULT GetExtendTitleBarHeight (double*ret) = 0; - virtual HRESULT SetExtendTitleBarHeight (double value) = 0; -}; - -AVNCOM(IAvnWindowBaseEvents, 05) : IUnknown -{ - virtual HRESULT Paint() = 0; - virtual void Closed() = 0; - virtual void Activated() = 0; - virtual void Deactivated() = 0; - virtual void Resized(const AvnSize& size) = 0; - virtual void PositionChanged (AvnPoint position) = 0; - virtual void RawMouseEvent (AvnRawMouseEventType type, - unsigned int timeStamp, - AvnInputModifiers modifiers, - AvnPoint point, - AvnVector delta) = 0; - virtual bool RawKeyEvent (AvnRawKeyEventType type, unsigned int timeStamp, AvnInputModifiers modifiers, unsigned int key) = 0; - virtual bool RawTextInputEvent (unsigned int timeStamp, const char* text) = 0; - virtual void ScalingChanged(double scaling) = 0; - virtual void RunRenderPriorityJobs() = 0; - virtual void LostFocus() = 0; - virtual AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position, - AvnInputModifiers modifiers, AvnDragDropEffects effects, - IAvnClipboard* clipboard, void* dataObjectHandle) = 0; -}; - - -AVNCOM(IAvnWindowEvents, 06) : IAvnWindowBaseEvents -{ - /** - * Closing Event - * Called when the user presses the OS window close button. - * return true to allow the close, return false to prevent close. - */ - virtual bool Closing () = 0; - - virtual void WindowStateChanged (AvnWindowState state) = 0; - - virtual void GotInputWhenDisabled () = 0; -}; - -AVNCOM(IAvnMacOptions, 07) : IUnknown -{ - virtual HRESULT SetShowInDock(int show) = 0; - virtual HRESULT SetApplicationTitle (void* utf8string) = 0; -}; - -AVNCOM(IAvnActionCallback, 08) : IUnknown -{ - virtual void Run() = 0; -}; - -AVNCOM(IAvnSignaledCallback, 09) : IUnknown -{ - virtual void Signaled(int priority, bool priorityContainsMeaningfulValue) = 0; -}; - -AVNCOM(IAvnLoopCancellation, 0a) : IUnknown -{ - virtual void Cancel() = 0; -}; - -AVNCOM(IAvnPlatformThreadingInterface, 0b) : IUnknown -{ - virtual bool GetCurrentThreadIsLoopThread() = 0; - virtual void SetSignaledCallback(IAvnSignaledCallback* cb) = 0; - virtual IAvnLoopCancellation* CreateLoopCancellation() = 0; - virtual HRESULT RunLoop(IAvnLoopCancellation* cancel) = 0; - // Can't pass int* to sharpgentools for some reason - virtual void Signal(int priority) = 0; - virtual IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback) = 0; -}; - -AVNCOM(IAvnSystemDialogEvents, 0c) : IUnknown -{ - virtual void OnCompleted (int numResults, void* ptrFirstResult) = 0; -}; - -AVNCOM(IAvnSystemDialogs, 0d) : IUnknown -{ - virtual void SelectFolderDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - const char* title, - const char* initialPath) = 0; - - virtual void OpenFileDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - bool allowMultiple, - const char* title, - const char* initialDirectory, - const char* initialFile, - const char* filters) = 0; - - virtual void SaveFileDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - const char* title, - const char* initialDirectory, - const char* initialFile, - const char* filters) = 0; -}; - -AVNCOM(IAvnScreens, 0e) : IUnknown -{ - virtual HRESULT GetScreenCount (int* ret) = 0; - virtual HRESULT GetScreen (int index, AvnScreen* ret) = 0; -}; - -AVNCOM(IAvnClipboard, 0f) : IUnknown -{ - virtual HRESULT GetText (char* type, IAvnString**ppv) = 0; - virtual HRESULT SetText (char* type, void* utf8Text) = 0; - virtual HRESULT ObtainFormats(IAvnStringArray**ppv) = 0; - virtual HRESULT GetStrings(char* type, IAvnStringArray**ppv) = 0; - virtual HRESULT SetBytes(char* type, void* utf8Text, int len) = 0; - virtual HRESULT GetBytes(char* type, IAvnString**ppv) = 0; - - virtual HRESULT Clear() = 0; -}; - -AVNCOM(IAvnCursor, 10) : IUnknown -{ -}; - -AVNCOM(IAvnCursorFactory, 11) : IUnknown -{ - virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) = 0; -}; - -AVNCOM(IAvnGlDisplay, 13) : IUnknown -{ - virtual HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv) = 0; - virtual void LegacyClearCurrentContext() = 0; - virtual HRESULT WrapContext(void* native, IAvnGlContext**ppv) = 0; - virtual void* GetProcAddress(char* proc) = 0; -}; - -AVNCOM(IAvnGlContext, 14) : IUnknown -{ - virtual HRESULT MakeCurrent(IUnknown** ppv) = 0; - virtual HRESULT LegacyMakeCurrent() = 0; - virtual int GetSampleCount() = 0; - virtual int GetStencilSize() = 0; - virtual void* GetNativeHandle() = 0; -}; - -AVNCOM(IAvnGlSurfaceRenderTarget, 15) : IUnknown -{ - virtual HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret) = 0; -}; - -AVNCOM(IAvnGlSurfaceRenderingSession, 16) : IUnknown -{ - virtual HRESULT GetPixelSize(AvnPixelSize* ret) = 0; - virtual HRESULT GetScaling(double* ret) = 0; -}; - -AVNCOM(IAvnMenu, 17) : IUnknown -{ - virtual HRESULT InsertItem (int index, IAvnMenuItem* item) = 0; - virtual HRESULT RemoveItem (IAvnMenuItem* item) = 0; - virtual HRESULT SetTitle (void* utf8String) = 0; - virtual HRESULT Clear () = 0; -}; - -AVNCOM(IAvnPredicateCallback, 18) : IUnknown -{ - virtual bool Evaluate() = 0; -}; - -AVNCOM(IAvnMenuItem, 19) : IUnknown -{ - virtual HRESULT SetSubMenu (IAvnMenu* menu) = 0; - virtual HRESULT SetTitle (void* utf8String) = 0; - virtual HRESULT SetGesture (void* utf8String, AvnInputModifiers modifiers) = 0; - virtual HRESULT SetAction (IAvnPredicateCallback* predicate, IAvnActionCallback* callback) = 0; - virtual HRESULT SetIsChecked (bool isChecked) = 0; - virtual HRESULT SetToggleType (AvnMenuItemToggleType toggleType) = 0; - virtual HRESULT SetIcon (void* data, size_t length) = 0; -}; - -AVNCOM(IAvnMenuEvents, 1A) : IUnknown -{ - /** - * NeedsUpdate - */ - virtual void NeedsUpdate () = 0; -}; - -AVNCOM(IAvnStringArray, 20) : IUnknown -{ - virtual unsigned int GetCount() = 0; - virtual HRESULT Get(unsigned int index, IAvnString**ppv) = 0; -}; - -AVNCOM(IAvnDndResultCallback, 21) : IUnknown -{ - virtual void OnDragAndDropComplete(AvnDragDropEffects effecct) = 0; -}; - -AVNCOM(IAvnGCHandleDeallocatorCallback, 22) : IUnknown -{ - virtual void FreeGCHandle(void* handle) = 0; -}; - -AVNCOM(IAvnNativeControlHost, 20) : IUnknown -{ - virtual HRESULT CreateDefaultChild(void* parent, void** retOut) = 0; - virtual IAvnNativeControlHostTopLevelAttachment* CreateAttachment() = 0; - virtual void DestroyDefaultChild(void* child) = 0; -}; - -AVNCOM(IAvnNativeControlHostTopLevelAttachment, 21) : IUnknown -{ - virtual void* GetParentHandle() = 0; - virtual HRESULT InitializeWithChildHandle(void* child) = 0; - virtual HRESULT AttachTo(IAvnNativeControlHost* host) = 0; - virtual void ShowInBounds(float x, float y, float width, float height) = 0; - virtual void HideWithSize(float width, float height) = 0; - virtual void ReleaseChild() = 0; -}; - - -extern "C" IAvaloniaNativeFactory* CreateAvaloniaNative(); diff --git a/native/Avalonia.Native/src/OSX/clipboard.mm b/native/Avalonia.Native/src/OSX/clipboard.mm index 116a08670e..303f727317 100644 --- a/native/Avalonia.Native/src/OSX/clipboard.mm +++ b/native/Avalonia.Native/src/OSX/clipboard.mm @@ -67,7 +67,7 @@ public: } } - virtual HRESULT SetText (char* type, void* utf8String) override + virtual HRESULT SetText (char* type, char* utf8String) override { Clear(); @autoreleasepool diff --git a/native/Avalonia.Native/src/OSX/main.mm b/native/Avalonia.Native/src/OSX/main.mm index e6c4a861fd..cd6ef73826 100644 --- a/native/Avalonia.Native/src/OSX/main.mm +++ b/native/Avalonia.Native/src/OSX/main.mm @@ -104,9 +104,9 @@ class MacOptions : public ComSingleObject public: FORWARD_IUNKNOWN() - virtual HRESULT SetApplicationTitle(void* utf8String) override + virtual HRESULT SetApplicationTitle(char* utf8String) override { - auto appTitle = [NSString stringWithUTF8String:(const char*)utf8String]; + auto appTitle = [NSString stringWithUTF8String: utf8String]; [[NSProcessInfo processInfo] setProcessName:appTitle]; diff --git a/native/Avalonia.Native/src/OSX/menu.h b/native/Avalonia.Native/src/OSX/menu.h index bfbc6801f8..0e43b22846 100644 --- a/native/Avalonia.Native/src/OSX/menu.h +++ b/native/Avalonia.Native/src/OSX/menu.h @@ -43,9 +43,9 @@ public: virtual HRESULT SetSubMenu (IAvnMenu* menu) override; - virtual HRESULT SetTitle (void* utf8String) override; + virtual HRESULT SetTitle (char* utf8String) override; - virtual HRESULT SetGesture (void* key, AvnInputModifiers modifiers) override; + virtual HRESULT SetGesture (char* key, AvnInputModifiers modifiers) override; virtual HRESULT SetAction (IAvnPredicateCallback* predicate, IAvnActionCallback* callback) override; @@ -80,7 +80,7 @@ public: virtual HRESULT RemoveItem (IAvnMenuItem* item) override; - virtual HRESULT SetTitle (void* utf8String) override; + virtual HRESULT SetTitle (char* utf8String) override; virtual HRESULT Clear () override; }; diff --git a/native/Avalonia.Native/src/OSX/menu.mm b/native/Avalonia.Native/src/OSX/menu.mm index dc1245cd23..1356388b85 100644 --- a/native/Avalonia.Native/src/OSX/menu.mm +++ b/native/Avalonia.Native/src/OSX/menu.mm @@ -109,7 +109,7 @@ HRESULT AvnAppMenuItem::SetSubMenu (IAvnMenu* menu) } } -HRESULT AvnAppMenuItem::SetTitle (void* utf8String) +HRESULT AvnAppMenuItem::SetTitle (char* utf8String) { @autoreleasepool { @@ -122,7 +122,7 @@ HRESULT AvnAppMenuItem::SetTitle (void* utf8String) } } -HRESULT AvnAppMenuItem::SetGesture (void* key, AvnInputModifiers modifiers) +HRESULT AvnAppMenuItem::SetGesture (char* key, AvnInputModifiers modifiers) { @autoreleasepool { @@ -296,7 +296,7 @@ HRESULT AvnAppMenu::RemoveItem (IAvnMenuItem* item) } } -HRESULT AvnAppMenu::SetTitle (void* utf8String) +HRESULT AvnAppMenu::SetTitle (char* utf8String) { @autoreleasepool { diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index 67b1ea50a6..e3996a1fae 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -768,7 +768,7 @@ private: } } - virtual HRESULT SetTitle (void* utf8title) override + virtual HRESULT SetTitle (char* utf8title) override { @autoreleasepool { diff --git a/nukebuild/MicroComGen.cs b/nukebuild/MicroComGen.cs new file mode 100644 index 0000000000..06c8acbf23 --- /dev/null +++ b/nukebuild/MicroComGen.cs @@ -0,0 +1,14 @@ +using System.IO; +using MicroComGenerator; +using Nuke.Common; + +partial class Build : NukeBuild +{ + Target GenerateCppHeaders => _ => _.Executes(() => + { + var text = File.ReadAllText(RootDirectory / "src" / "Avalonia.Native" / "avn.idl"); + var ast = AstParser.Parse(text); + File.WriteAllText(RootDirectory / "native" / "Avalonia.Native" / "inc" / "avalonia-native.h", + CppGen.GenerateCpp(ast)); + }); +} \ No newline at end of file diff --git a/nukebuild/_build.csproj b/nukebuild/_build.csproj index 77cfb83427..745c727be2 100644 --- a/nukebuild/_build.csproj +++ b/nukebuild/_build.csproj @@ -39,4 +39,8 @@ + + + + diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index dc139cf8e3..1d36cce20d 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -254,13 +254,13 @@ interface IAvnWindowBase : IUnknown HRESULT SetBlurEnabled(bool enable); } -[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91)] +[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91), cpp-virtual-inherits] interface IAvnPopup : IAvnWindowBase { } -[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d)] +[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d), cpp-virtual-inherits] interface IAvnWindow : IAvnWindowBase { HRESULT SetEnabled(bool enable); @@ -285,7 +285,7 @@ interface IAvnWindowBaseEvents : IUnknown void Closed(); void Activated(); void Deactivated(); - void Resized([const] AvnSize* size); + void Resized([const] AvnSize& size); void PositionChanged(AvnPoint position); void RawMouseEvent(AvnRawMouseEventType type, uint timeStamp, diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs index 2c366b143d..e9a55308be 100644 --- a/src/tools/MicroComGenerator/Ast.cs +++ b/src/tools/MicroComGenerator/Ast.cs @@ -83,10 +83,16 @@ namespace MicroComGenerator.Ast { public string Name { get; set; } public int PointerLevel { get; set; } + public bool IsLink { get; set; } - public string Format() => Name + new string('*', PointerLevel); + public string Format() => Name + new string('*', PointerLevel) + + (IsLink ? "&" : ""); public override string ToString() => Format(); - public AstTypeNode Clone() => new AstTypeNode() { Name = Name, PointerLevel = PointerLevel }; + public AstTypeNode Clone() => new AstTypeNode() { + Name = Name, + PointerLevel = PointerLevel, + IsLink = IsLink + }; } public class AstStructMemberNode : IAstNodeWithAttributes diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs index a003fb3096..732c0496b3 100644 --- a/src/tools/MicroComGenerator/AstParser.cs +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -146,6 +146,8 @@ namespace MicroComGenerator var t = new AstTypeNode { Name = ident }; while (parser.TryConsume('*')) t.PointerLevel++; + if (parser.TryConsume("&")) + t.IsLink = true; return t; } diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 8806531b19..688036ffc2 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -53,6 +53,17 @@ namespace MicroComGenerator base.VisitStructMember(member); } + protected override void VisitType(AstTypeNode type) + { + if (type.IsLink) + { + type.PointerLevel++; + type.IsLink = false; + } + + base.VisitType(type); + } + protected override void VisitArgument(AstInterfaceMemberArgumentNode argument) { if (argument.HasAttribute("intptr")) diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs index f2b748787f..68192ebffe 100644 --- a/src/tools/MicroComGenerator/CppGen.cs +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -35,7 +35,6 @@ namespace MicroComGenerator sb.Append("enum "); if (en.Attributes.Any(a => a.Name == "class-enum")) sb.Append("class "); - sb.Append(en.Name).Append(" "); sb.AppendLine(en.Name).AppendLine("{"); foreach (var m in en) @@ -73,30 +72,42 @@ namespace MicroComGenerator sb.Append(", ").Append(guid.Substring(16 + c * 2, 2)); } - sb.Append(") : ") - .AppendLine(i.Inherits ?? "IUnknown") + sb.Append(") : "); + if (i.HasAttribute("cpp-virtual-inherits")) + sb.Append("virtual "); + sb.AppendLine(i.Inherits ?? "IUnknown") .AppendLine("{"); foreach (var m in i) { - sb.Append(" ").Append(ConvertType(m.ReturnType)).Append(" ").Append(m.Name).AppendLine(" ("); - for (var c = 0; c < m.Count; c++) + sb.Append(" ") + .Append("virtual ") + .Append(ConvertType(m.ReturnType)) + .Append(" ").Append(m.Name).Append(" ("); + if (m.Count == 0) + sb.AppendLine(") = 0;"); + else { - var arg = m[c]; - sb.Append(" "); - if (arg.Attributes.Any(a => a.Name == "const")) - sb.Append("const "); - sb.Append(ConvertType(arg.Type)) - .Append(" ") - .Append(arg.Name); - if (c != m.Count - 1) - sb.Append(", "); sb.AppendLine(); - sb.AppendLine(" );"); + for (var c = 0; c < m.Count; c++) + { + var arg = m[c]; + sb.Append(" "); + if (arg.Attributes.Any(a => a.Name == "const")) + sb.Append("const "); + sb.Append(ConvertType(arg.Type)) + .Append(" ") + .Append(arg.Name); + if (c != m.Count - 1) + sb.Append(", "); + sb.AppendLine(); + } + + sb.AppendLine(" ) = 0;"); } } - sb.AppendLine("}"); + sb.AppendLine("};"); } return sb.ToString(); From 72be5e3f016e0580f721e98f718319365cfa885e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 20:52:43 +0300 Subject: [PATCH 31/35] Build --- azure-pipelines.yml | 7 ------- src/Avalonia.MicroCom/Avalonia.MicroCom.csproj | 7 +++++++ src/Avalonia.Native/Avalonia.Native.csproj | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d6c561bc6..ac1944b171 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,13 +3,6 @@ jobs: pool: vmImage: 'ubuntu-16.04' steps: - - task: CmdLine@2 - displayName: 'Install CastXML' - inputs: - script: | - sudo apt-get update - sudo apt-get install castxml - - task: CmdLine@2 displayName: 'Install Nuke' inputs: diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj index 7994a74f76..6af3b4347a 100644 --- a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -6,5 +6,12 @@ <_AvaloniaPatchComInterop>true + + + false + all + true + + diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index f0c747504b..a08dc0f28f 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -5,10 +5,7 @@ $(PackAvaloniaNative) true netstandard2.0 - /usr/bin/castxml - /usr/local/bin/castxml true - false From 2afd29e9c879ce0693f96d85dcd373ceda21d043 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 31 Oct 2020 16:07:23 +0100 Subject: [PATCH 32/35] Use existing OnDataContextChanged method. --- src/Avalonia.ReactiveUI/ReactiveUserControl.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 40d9666c3e..f4824ade0a 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -28,7 +28,6 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } @@ -47,16 +46,9 @@ namespace Avalonia.ReactiveUI set => ViewModel = (TViewModel)value; } - private void OnDataContextChanged(object value) + protected override void OnDataContextChanged(EventArgs e) { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } + ViewModel = DataContext as TViewModel; } private void OnViewModelChanged(object value) From 7f904f6c892e91138b531791452fd8c189f1924c Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 18:03:56 +0300 Subject: [PATCH 33/35] Emit IgnoresAccessChecksToAttribute for runtime-generated XAML --- build.sh | 2 +- .../AvaloniaXamlIlRuntimeCompiler.cs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a40e00f815..bd162fab9b 100755 --- a/build.sh +++ b/build.sh @@ -47,7 +47,7 @@ if [ -f "$DOTNET_GLOBAL_FILE" ]; then fi # If dotnet is installed locally, and expected version is not set or installation matches the expected version -if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") ]]; then +if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") || "$SKIP_DOTNET_DOWNLOAD" == "1" ]]; then export DOTNET_EXE="$(command -v dotnet)" else DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index d9b4cd70da..c69a651af2 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -26,6 +26,7 @@ namespace Avalonia.Markup.Xaml.XamlIl { #if !RUNTIME_XAML_CECIL private static SreTypeSystem _sreTypeSystem; + private static Type _ignoresAccessChecksFromAttribute; private static ModuleBuilder _sreBuilder; private static IXamlType _sreContextType; private static XamlLanguageTypeMappings _sreMappings; @@ -94,8 +95,58 @@ namespace Avalonia.Markup.Xaml.XamlIl _sreTypeSystem.CreateTypeBuilder( _sreBuilder.DefineType("XamlIlContext")), _sreTypeSystem, _sreMappings, _sreEmitMappings); + if (_ignoresAccessChecksFromAttribute == null) + _ignoresAccessChecksFromAttribute = EmitIgnoresAccessCheckAttributeDefinition(_sreBuilder); } + static Type EmitIgnoresAccessCheckAttributeDefinition(ModuleBuilder builder) + { + var tb = builder.DefineType("System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute", + TypeAttributes.Class | TypeAttributes.Public, typeof(Attribute)); + var field = tb.DefineField("_name", typeof(string), FieldAttributes.Private); + var propGet = tb.DefineMethod("get_AssemblyName", MethodAttributes.Public, typeof(string), + Array.Empty()); + var propGetIl = propGet.GetILGenerator(); + propGetIl.Emit(OpCodes.Ldarg_0); + propGetIl.Emit(OpCodes.Ldfld, field); + propGetIl.Emit(OpCodes.Ret); + var prop = tb.DefineProperty("AssemblyName", PropertyAttributes.None, typeof(string), Array.Empty()); + prop.SetGetMethod(propGet); + + + var ctor = tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, + new[] { typeof(string) }); + var ctorIl = ctor.GetILGenerator(); + ctorIl.Emit(OpCodes.Ldarg_0); + ctorIl.Emit(OpCodes.Ldarg_1); + ctorIl.Emit(OpCodes.Stfld, field); + ctorIl.Emit(OpCodes.Ldarg_0); + ctorIl.Emit(OpCodes.Call, typeof(Attribute) + .GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) + .First(x => x.GetParameters().Length == 0)); + + ctorIl.Emit(OpCodes.Ret); + + tb.SetCustomAttribute(new CustomAttributeBuilder( + typeof(AttributeUsageAttribute).GetConstructor(new[] { typeof(AttributeTargets) }), + new object[] { AttributeTargets.Assembly }, + new[] { typeof(AttributeUsageAttribute).GetProperty("AllowMultiple") }, + new object[] { true })); + + return tb.CreateTypeInfo(); + } + + static void EmitIgnoresAccessCheckToAttribute(AssemblyName assemblyName) + { + var name = assemblyName.Name; + var key = assemblyName.GetPublicKey(); + if (key != null) + name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); + _sreAsm.SetCustomAttribute(new CustomAttributeBuilder( + _ignoresAccessChecksFromAttribute.GetConstructors()[0], + new object[] { name })); + } + static object LoadSre(string xaml, Assembly localAssembly, object rootInstance, Uri uri, bool isDesignMode) { @@ -118,6 +169,8 @@ namespace Avalonia.Markup.Xaml.XamlIl { InitializeSre(); + if (localAssembly?.FullName != null) + EmitIgnoresAccessCheckToAttribute(localAssembly.GetName()); var asm = localAssembly == null ? null : _sreTypeSystem.GetAssembly(localAssembly); var tb = _sreBuilder.DefineType("Builder_" + Guid.NewGuid().ToString("N") + "_" + uri); var clrPropertyBuilder = tb.DefineNestedType("ClrProperties_" + Guid.NewGuid().ToString("N")); From 8f6107969cdbe487c58b28d4f6ba6620a9fbd542 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 19:16:56 +0300 Subject: [PATCH 34/35] Extra checks --- .../AvaloniaXamlIlRuntimeCompiler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index c69a651af2..75de1f55ce 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -139,6 +139,8 @@ namespace Avalonia.Markup.Xaml.XamlIl static void EmitIgnoresAccessCheckToAttribute(AssemblyName assemblyName) { var name = assemblyName.Name; + if(string.IsNullOrWhiteSpace(name)) + return; var key = assemblyName.GetPublicKey(); if (key != null) name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); @@ -169,7 +171,7 @@ namespace Avalonia.Markup.Xaml.XamlIl { InitializeSre(); - if (localAssembly?.FullName != null) + if (localAssembly?.GetName() != null) EmitIgnoresAccessCheckToAttribute(localAssembly.GetName()); var asm = localAssembly == null ? null : _sreTypeSystem.GetAssembly(localAssembly); var tb = _sreBuilder.DefineType("Builder_" + Guid.NewGuid().ToString("N") + "_" + uri); From 6b662026ef1aa4d303c83d087b74733d2d951e79 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 20:35:56 +0300 Subject: [PATCH 35/35] Fix support for packages without strong name --- .../AvaloniaXamlIlRuntimeCompiler.cs | 2 +- .../DesignerSupportTests.cs | 61 ++++++++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index 75de1f55ce..ece90762cb 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -142,7 +142,7 @@ namespace Avalonia.Markup.Xaml.XamlIl if(string.IsNullOrWhiteSpace(name)) return; var key = assemblyName.GetPublicKey(); - if (key != null) + if (key != null && key.Length != 0) name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); _sreAsm.SetCustomAttribute(new CustomAttributeBuilder( _ignoresAccessChecksFromAttribute.GetConstructors()[0], diff --git a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs index dd704bc775..d76ed9042f 100644 --- a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs +++ b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Designer; +using Avalonia.Remote.Protocol.Viewport; using Xunit; using Xunit.Extensions; @@ -31,19 +32,38 @@ namespace Avalonia.DesignerSupport.Tests @"..\..\..\..\..\tests/Avalonia.DesignerSupport.TestApp/bin/$BUILD/netcoreapp3.1/", "Avalonia.DesignerSupport.TestApp", "Avalonia.DesignerSupport.TestApp.dll", - @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml"), + @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml", + "win32"), InlineData( @"..\..\..\..\..\samples\ControlCatalog.NetCore\bin\$BUILD\netcoreapp3.1\", "ControlCatalog.NetCore", "ControlCatalog.dll", - @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml")] + @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml", + "win32"), + InlineData( + @"..\..\..\..\..\tests/Avalonia.DesignerSupport.TestApp/bin/$BUILD/netcoreapp3.1/", + "Avalonia.DesignerSupport.TestApp", + "Avalonia.DesignerSupport.TestApp.dll", + @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml", + "avalonia-remote"), + InlineData( + @"..\..\..\..\..\samples\ControlCatalog.NetCore\bin\$BUILD\netcoreapp3.1\", + "ControlCatalog.NetCore", + "ControlCatalog.dll", + @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml", + "avalonia-remote")] public async Task Designer_In_Win32_Mode_Should_Provide_Valid_Hwnd( string outputDir, string executableName, string assemblyName, - string xamlFile) + string xamlFile, + string method) { - Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + outputDir = Path.GetFullPath(outputDir.Replace('\\', Path.DirectorySeparatorChar)); + xamlFile = Path.GetFullPath(xamlFile.Replace('\\', Path.DirectorySeparatorChar)); + + if (method == "win32") + Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); var xaml = File.ReadAllText(xamlFile); string buildType; @@ -56,6 +76,8 @@ namespace Avalonia.DesignerSupport.Tests var sessionId = Guid.NewGuid(); long handle = 0; + bool success = false; + string error = null; var resultMessageReceivedToken = new CancellationTokenSource(); @@ -71,6 +93,18 @@ namespace Avalonia.DesignerSupport.Tests if (msg is StartDesignerSessionMessage start) { Assert.Equal(sessionId, Guid.Parse(start.SessionId)); + if (method == "avalonia-remote") + { + await conn.Send(new ClientSupportedPixelFormatsMessage + { + Formats = new[] { PixelFormat.Rgba8888 } + }); + await conn.Send(new ClientViewportAllocatedMessage + { + DpiX = 96, DpiY = 96, Width = 1024, Height = 768 + }); + } + await conn.Send(new UpdateXamlMessage { AssemblyPath = Path.Combine(outputDir, assemblyName), @@ -80,8 +114,14 @@ namespace Avalonia.DesignerSupport.Tests else if (msg is UpdateXamlResultMessage result) { if (result.Error != null) + { + error = result.Error; outputHelper.WriteLine(result.Error); - handle = result.Handle != null ? long.Parse(result.Handle) : 0; + } + else + success = true; + if (method == "win32") + handle = result.Handle != null ? long.Parse(result.Handle) : 0; resultMessageReceivedToken.Cancel(); conn.Dispose(); } @@ -91,7 +131,7 @@ namespace Avalonia.DesignerSupport.Tests var cmdline = $"exec --runtimeconfig \"{outputDir}{executableName}.runtimeconfig.json\" --depsfile \"{outputDir}{executableName}.deps.json\" " + $" \"{DesignerAppPath.Replace("$BUILD", buildType)}\" " - + $"--transport tcp-bson://127.0.0.1:{port}/ --session-id {sessionId} --method win32 \"{outputDir}{executableName}.dll\""; + + $"--transport tcp-bson://127.0.0.1:{port}/ --session-id {sessionId} --method {method} \"{outputDir}{executableName}.dll\""; using (var proc = new Process { @@ -128,10 +168,15 @@ namespace Avalonia.DesignerSupport.Tests } proc.WaitForExit(); + var stdout = proc.StandardOutput.ReadToEnd(); + var stderr = proc.StandardError.ReadToEnd(); Assert.True(cancelled, $"Message Not Received.\n" + proc.StandardOutput.ReadToEnd() + "\n" + - proc.StandardError.ReadToEnd()); - Assert.NotEqual(0, handle); + stderr + "\n" + stdout); + Assert.True(success, error); + if (method == "win32") + Assert.NotEqual(0, handle); + } }