-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Id and Entity method extension code generator
- Loading branch information
1 parent
3b3fe56
commit 3370be6
Showing
200 changed files
with
119,171 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Flecs.NET.Codegen.Helpers; | ||
|
||
namespace Flecs.NET.Codegen.Generators; | ||
|
||
public class Alert : GeneratorBase | ||
{ | ||
public override void Generate() | ||
{ | ||
AddSource($"Alert.Id.g.cs", Id.GenerateExtensions(Type.Alert)); | ||
AddSource($"Alert.Entity.g.cs", Entity.GenerateExtensions(Type.Alert)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Flecs.NET.Codegen.Helpers; | ||
|
||
namespace Flecs.NET.Codegen.Generators; | ||
|
||
public class Component : GeneratorBase | ||
{ | ||
public override void Generate() | ||
{ | ||
AddSource($"Component.Id.g.cs", Id.GenerateExtensions(Type.Component)); | ||
AddSource($"Component.Entity.g.cs", Entity.GenerateExtensions(Type.Component)); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using Flecs.NET.Codegen.Helpers; | ||
|
||
namespace Flecs.NET.Codegen.Generators; | ||
|
||
public static class Id | ||
{ | ||
public static string GenerateExtensions(Type type, int i = -1) | ||
{ | ||
return $$""" | ||
namespace Flecs.NET.Core; | ||
public unsafe partial struct {{Generator.GetTypeName(type, i)}} | ||
{ | ||
/// <inheritdoc cref="Id.IsPair()"/> | ||
public bool IsPair() | ||
{ | ||
return Id.IsPair(); | ||
} | ||
/// <inheritdoc cref="Id.IsWildCard()"/> | ||
public bool IsWildCard() | ||
{ | ||
return Id.IsWildCard(); | ||
} | ||
/// <inheritdoc cref="Id.IsEntity()"/> | ||
public bool IsEntity() | ||
{ | ||
return Id.IsEntity(); | ||
} | ||
/// <inheritdoc cref="Id.ToEntity()"/> | ||
public Entity ToEntity() | ||
{ | ||
return Id.ToEntity(); | ||
} | ||
/// <inheritdoc cref="Id.AddFlags(ulong)"/> | ||
public Entity AddFlags(ulong flags) | ||
{ | ||
return Id.AddFlags(flags); | ||
} | ||
/// <inheritdoc cref="Id.RemoveFlags(ulong)"/> | ||
public Entity RemoveFlags(ulong flags) | ||
{ | ||
return Id.RemoveFlags(flags); | ||
} | ||
/// <inheritdoc cref="Id.RemoveFlags()"/> | ||
public Entity RemoveFlags() | ||
{ | ||
return Id.RemoveFlags(); | ||
} | ||
/// <inheritdoc cref="Id.RemoveGeneration()"/> | ||
public Entity RemoveGeneration() | ||
{ | ||
return Id.RemoveGeneration(); | ||
} | ||
/// <inheritdoc cref="Id.TypeId()"/> | ||
public Entity TypeId() | ||
{ | ||
return Id.TypeId(); | ||
} | ||
/// <inheritdoc cref="Id.HasFlags(ulong)"/> | ||
public bool HasFlags(ulong flags) | ||
{ | ||
return Id.HasFlags(flags); | ||
} | ||
/// <inheritdoc cref="Id.HasFlags()"/> | ||
public bool HasFlags() | ||
{ | ||
return Id.HasFlags(); | ||
} | ||
/// <inheritdoc cref="Id.Flags()"/> | ||
public Entity Flags() | ||
{ | ||
return Id.Flags(); | ||
} | ||
/// <inheritdoc cref="Id.HasRelation(ulong)"/> | ||
public bool HasRelation(ulong first) | ||
{ | ||
return Id.HasRelation(first); | ||
} | ||
/// <inheritdoc cref="Id.First()"/> | ||
public Entity First() | ||
{ | ||
return Id.First(); | ||
} | ||
/// <inheritdoc cref="Id.Second()"/> | ||
public Entity Second() | ||
{ | ||
return Id.Second(); | ||
} | ||
/// <inheritdoc cref="Id.Str()"/> | ||
public string Str() | ||
{ | ||
return Id.Str(); | ||
} | ||
/// <inheritdoc cref="Id.FlagsStr()"/> | ||
public string FlagsStr() | ||
{ | ||
return Id.FlagsStr(); | ||
} | ||
/// <inheritdoc cref="Id.CsWorld()"/> | ||
public World CsWorld() | ||
{ | ||
return Id.CsWorld(); | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Flecs.NET.Codegen.Helpers; | ||
|
||
namespace Flecs.NET.Codegen.Generators; | ||
|
||
public class TimerEntity : GeneratorBase | ||
{ | ||
public override void Generate() | ||
{ | ||
AddSource($"TimerEntity.Id.g.cs", Id.GenerateExtensions(Type.TimerEntity)); | ||
AddSource($"TimerEntity.Entity.g.cs", Entity.GenerateExtensions(Type.TimerEntity)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Flecs.NET.Codegen.Helpers; | ||
|
||
namespace Flecs.NET.Codegen.Generators; | ||
|
||
public class UntypedComponent : GeneratorBase | ||
{ | ||
public override void Generate() | ||
{ | ||
AddSource($"UntypedComponent.Id.g.cs", Id.GenerateExtensions(Type.UntypedComponent)); | ||
AddSource($"UntypedComponent.Entity.g.cs", Entity.GenerateExtensions(Type.UntypedComponent)); | ||
} | ||
} |
Oops, something went wrong.