You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
C#: Add global class support
Co-authored-by: willnationsdev <willnationsdev@gmail.com>
This commit is contained in:
@@ -241,6 +241,9 @@ namespace Godot.SourceGenerators
|
||||
public static bool IsGodotClassNameAttribute(this INamedTypeSymbol symbol)
|
||||
=> symbol.ToString() == GodotClasses.GodotClassNameAttr;
|
||||
|
||||
public static bool IsGodotGlobalClassAttribute(this INamedTypeSymbol symbol)
|
||||
=> symbol.ToString() == GodotClasses.GlobalClassAttr;
|
||||
|
||||
public static bool IsSystemFlagsAttribute(this INamedTypeSymbol symbol)
|
||||
=> symbol.ToString() == GodotClasses.SystemFlagsAttr;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Godot.SourceGenerators
|
||||
public const string SignalAttr = "Godot.SignalAttribute";
|
||||
public const string MustBeVariantAttr = "Godot.MustBeVariantAttribute";
|
||||
public const string GodotClassNameAttr = "Godot.GodotClassNameAttribute";
|
||||
public const string GlobalClassAttr = "Godot.GlobalClassAttribute";
|
||||
public const string SystemFlagsAttr = "System.FlagsAttribute";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,25 +547,32 @@ namespace Godot.SourceGenerators
|
||||
{
|
||||
if (memberNamedType.InheritsFrom("GodotSharp", "Godot.Resource"))
|
||||
{
|
||||
string nativeTypeName = memberNamedType.GetGodotScriptNativeClassName()!;
|
||||
|
||||
hint = PropertyHint.ResourceType;
|
||||
hintString = nativeTypeName;
|
||||
hintString = GetTypeName(memberNamedType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (memberNamedType.InheritsFrom("GodotSharp", "Godot.Node"))
|
||||
{
|
||||
string nativeTypeName = memberNamedType.GetGodotScriptNativeClassName()!;
|
||||
|
||||
hint = PropertyHint.NodeType;
|
||||
hintString = nativeTypeName;
|
||||
hintString = GetTypeName(memberNamedType);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static string GetTypeName(INamedTypeSymbol memberSymbol)
|
||||
{
|
||||
if (memberSymbol.GetAttributes()
|
||||
.Any(a => a.AttributeClass?.IsGodotGlobalClassAttribute() ?? false))
|
||||
{
|
||||
return memberSymbol.Name;
|
||||
}
|
||||
|
||||
return memberSymbol.GetGodotScriptNativeClassName()!;
|
||||
}
|
||||
|
||||
static bool GetStringArrayEnumHint(VariantType elementVariantType,
|
||||
AttributeData exportAttr, out string? hintString)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user