e22dd3bc6a
Previously, we added source generators for invoking/accessing methods, properties and fields in scripts. This freed us from the overhead of reflection. However, the generated code still used our dynamic marshaling functions, which do runtime type checking and box value types. This commit changes the bindings and source generators to include 'static' marshaling. Based on the types known at compile time, now we generate the appropriate marshaling call for each type.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis;
|
|
|
|
namespace Godot.SourceGenerators
|
|
{
|
|
public struct GodotMethodData
|
|
{
|
|
public GodotMethodData(IMethodSymbol method, ImmutableArray<MarshalType> paramTypes,
|
|
ImmutableArray<ITypeSymbol> paramTypeSymbols, MarshalType? retType, ITypeSymbol? retSymbol)
|
|
{
|
|
Method = method;
|
|
ParamTypes = paramTypes;
|
|
ParamTypeSymbols = paramTypeSymbols;
|
|
RetType = retType;
|
|
RetSymbol = retSymbol;
|
|
}
|
|
|
|
public IMethodSymbol Method { get; }
|
|
public ImmutableArray<MarshalType> ParamTypes { get; }
|
|
public ImmutableArray<ITypeSymbol> ParamTypeSymbols { get; }
|
|
public MarshalType? RetType { get; }
|
|
public ITypeSymbol? RetSymbol { get; }
|
|
}
|
|
|
|
public struct GodotPropertyData
|
|
{
|
|
public GodotPropertyData(IPropertySymbol propertySymbol, MarshalType type)
|
|
{
|
|
PropertySymbol = propertySymbol;
|
|
Type = type;
|
|
}
|
|
|
|
public IPropertySymbol PropertySymbol { get; }
|
|
public MarshalType Type { get; }
|
|
}
|
|
|
|
public struct GodotFieldData
|
|
{
|
|
public GodotFieldData(IFieldSymbol fieldSymbol, MarshalType type)
|
|
{
|
|
FieldSymbol = fieldSymbol;
|
|
Type = type;
|
|
}
|
|
|
|
public IFieldSymbol FieldSymbol { get; }
|
|
public MarshalType Type { get; }
|
|
}
|
|
}
|