Add back KnownType to handle non-partial leafs

This commit is contained in:
Dan Balasescu
2023-06-15 16:47:12 +09:00
parent 34574f5e55
commit 879f241576
43 changed files with 67 additions and 12 deletions

View File

@@ -4,5 +4,6 @@
partial class AcceptsFocusProperty : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::AcceptsFocusProperty);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -6,6 +6,7 @@ namespace osu.Framework.Graphics
{
partial class Drawable : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::osu.Framework.Graphics.Drawable);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => false;
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => false;
}

View File

@@ -0,0 +1,9 @@
namespace osu.Framework.Input
{
public interface ISourceGeneratedHandleInputCache
{
protected internal System.Type KnownType => typeof(object);
protected internal bool RequestsPositionalInput => false;
protected internal bool RequestsNonPositionalInput => false;
}
}

View File

@@ -1,8 +0,0 @@
namespace osu.Framework.Input
{
public interface ISourceGeneratedHandleInputCache
{
protected internal bool RequestsPositionalInput { get; }
protected internal bool RequestsNonPositionalInput { get; }
}
}

View File

@@ -4,6 +4,7 @@
partial class HandleMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::HandleMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class HandleNonPositionalInputProperty : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::HandleNonPositionalInputProperty);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class HandlePositionalInputProperty : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::HandlePositionalInputProperty);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class IHasContextMenuInterface : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::IHasContextMenuInterface);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class IHasCustomTooltipInterface : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::IHasCustomTooltipInterface);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class IHasPopoverInterface : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::IHasPopoverInterface);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class IHasTooltipInterface : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::IHasTooltipInterface);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class IKeyBindingHandlerInterface : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::IKeyBindingHandlerInterface);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,6 +4,7 @@
partial class PartialClass : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::PartialClass);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnClickMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnClickMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnDoubleClickMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnDoubleClickMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnDragEndMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnDragEndMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnDragMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnDragMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnDragStartMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnDragStartMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,6 +4,7 @@
partial class OnFocusLostMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnFocusLostMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,6 +4,7 @@
partial class OnFocusMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnFocusMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnHoverLostMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnHoverLostMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnHoverMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnHoverMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnJoystickAxisMoveMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnJoystickAxisMoveMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnJoystickPressMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnJoystickPressMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnJoystickReleaseMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnJoystickReleaseMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnKeyDownMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnKeyDownMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnKeyUpMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnKeyUpMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnMidiDownMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnMidiDownMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnMidiUpMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnMidiUpMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnMouseDownMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnMouseDownMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnMouseMoveMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnMouseMoveMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnMouseUpMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnMouseUpMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnScrollMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnScrollMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTabletAuxiliaryButtonPressMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTabletAuxiliaryButtonPressMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTabletAuxiliaryButtonReleaseMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTabletAuxiliaryButtonReleaseMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsNonPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTabletPenButtonPressMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTabletPenButtonPressMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTabletPenButtonReleaseMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTabletPenButtonReleaseMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTouchDownMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTouchDownMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTouchMoveMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTouchMoveMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -4,5 +4,6 @@
partial class OnTouchUpMethod : global::osu.Framework.Input.ISourceGeneratedHandleInputCache
{
global::System.Type global::osu.Framework.Input.ISourceGeneratedHandleInputCache.KnownType => typeof(global::OnTouchUpMethod);
bool global::osu.Framework.Input.ISourceGeneratedHandleInputCache.RequestsPositionalInput => true;
}

View File

@@ -36,6 +36,19 @@ namespace osu.Framework.SourceGeneration.Generators.HandleInput
// Drawable is the base type which always needs to have the members defined.
bool isDrawable = Target.FullyQualifiedTypeName == "osu.Framework.Graphics.Drawable";
yield return SyntaxFactory.PropertyDeclaration(
SyntaxFactory.ParseTypeName("global::System.Type"),
SyntaxFactory.Identifier("KnownType"))
.WithExplicitInterfaceSpecifier(
SyntaxFactory.ExplicitInterfaceSpecifier(
SyntaxFactory.IdentifierName(interface_name)))
.WithExpressionBody(
SyntaxFactory.ArrowExpressionClause(
SyntaxFactory.TypeOfExpression(
SyntaxFactory.ParseTypeName(Target.GlobalPrefixedTypeName))))
.WithSemicolonToken(
SyntaxFactory.Token(SyntaxKind.SemicolonToken));
if (Target.RequestsPositionalInput || isDrawable)
yield return createInputMember("RequestsPositionalInput", Target.RequestsPositionalInput);

View File

@@ -86,7 +86,7 @@ namespace osu.Framework.Graphics
public static bool RequestsPositionalInput(Drawable drawable)
{
if (drawable is ISourceGeneratedHandleInputCache sgInput)
if (drawable is ISourceGeneratedHandleInputCache sgInput && sgInput.KnownType == drawable.GetType())
return sgInput.RequestsPositionalInput;
return getViaReflection(drawable, positional_cached_values, true);
@@ -94,7 +94,7 @@ namespace osu.Framework.Graphics
public static bool RequestsNonPositionalInput(Drawable drawable)
{
if (drawable is ISourceGeneratedHandleInputCache sgInput)
if (drawable is ISourceGeneratedHandleInputCache sgInput && sgInput.KnownType == drawable.GetType())
return sgInput.RequestsNonPositionalInput;
return getViaReflection(drawable, non_positional_cached_values, false);

View File

@@ -1,11 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
namespace osu.Framework.Input
{
public interface ISourceGeneratedHandleInputCache
{
protected internal bool RequestsPositionalInput { get; }
protected internal bool RequestsNonPositionalInput { get; }
protected internal Type KnownType => typeof(object);
protected internal bool RequestsPositionalInput => false;
protected internal bool RequestsNonPositionalInput => false;
}
}