1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

C#: Add source generator for signals as events

Changed the signal declaration signal to:

```
// The following generates a MySignal event
[Signal] public delegate void MySignalEventHandler(int param);
```
This commit is contained in:
Ignacio Roldán Etcheverry
2022-07-28 17:41:47 +02:00
parent f033764ffe
commit 97713ff77a
31 changed files with 997 additions and 523 deletions

View File

@@ -146,7 +146,7 @@ namespace Godot.SourceGenerators
source.Append(" }\n"); // class GodotInternal
// Generate GetGodotPropertiesMetadata
// Generate GetGodotPropertyList
if (godotClassProperties.Length > 0 || godotClassFields.Length > 0)
{
@@ -156,7 +156,7 @@ namespace Godot.SourceGenerators
source.Append(" internal new static ")
.Append(dictionaryType)
.Append(" GetGodotPropertiesMetadata()\n {\n");
.Append(" GetGodotPropertyList()\n {\n");
source.Append(" var properties = new ")
.Append(dictionaryType)
@@ -164,7 +164,7 @@ namespace Godot.SourceGenerators
foreach (var property in godotClassProperties)
{
var propertyInfo = GetPropertyMetadata(context, typeCache,
var propertyInfo = DeterminePropertyInfo(context, typeCache,
property.PropertySymbol, property.Type);
if (propertyInfo == null)
@@ -175,7 +175,7 @@ namespace Godot.SourceGenerators
foreach (var field in godotClassFields)
{
var propertyInfo = GetPropertyMetadata(context, typeCache,
var propertyInfo = DeterminePropertyInfo(context, typeCache,
field.FieldSymbol, field.Type);
if (propertyInfo == null)
@@ -229,28 +229,7 @@ namespace Godot.SourceGenerators
.Append("));\n");
}
private struct PropertyInfo
{
public PropertyInfo(VariantType type, string name, PropertyHint hint,
string? hintString, PropertyUsageFlags usage, bool exported)
{
Type = type;
Name = name;
Hint = hint;
HintString = hintString;
Usage = usage;
Exported = exported;
}
public VariantType Type { get; }
public string Name { get; }
public PropertyHint Hint { get; }
public string? HintString { get; }
public PropertyUsageFlags Usage { get; }
public bool Exported { get; }
}
private static PropertyInfo? GetPropertyMetadata(
private static PropertyInfo? DeterminePropertyInfo(
GeneratorExecutionContext context,
MarshalUtils.TypeCache typeCache,
ISymbol memberSymbol,