Skip to content

Commit

Permalink
Add AttributesGenerator type to emit attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 5, 2023
1 parent 1a62db3 commit f78990c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
65 changes: 65 additions & 0 deletions src/dnne-analyzers/AttributesGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Microsoft.CodeAnalysis;

namespace DNNE;

/// <summary>
/// A generator that generates all the necessary DNNE attributes.
/// </summary>
[Generator(LanguageNames.CSharp)]
public sealed class AttributesGenerator : IIncrementalGenerator
{
/// <inheritdoc/>
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterPostInitializationOutput(static context =>
{
context.AddSource("DnneAttributes.g.cs", """
// <auto-generated/>
#pragma warning disable
namespace DNNE
{
/// <summary>
/// Provides C code to be defined early in the generated C header file.
/// </summary>
/// <remarks>
/// This attribute is respected on an exported method declaration or on a parameter for the method.
/// The following header files will be included prior to the code being defined.
/// <list type="bullet">
/// <item><c>stddef.h</c></item>
/// <item><c>stdint.h</c></item>
/// <item><c>dnne.h</c></item>
/// </list>
/// </remarks>
internal sealed class C99DeclCodeAttribute : global::System.Attribute
{
/// <summary>
/// Creates a new <see cref="C99DeclCodeAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="code">The C code to be defined in the generated C header file.</param>
public C99DeclCodeAttribute(string code)
{
}
}
/// <summary>
/// Defines the C type to be used.
/// </summary>
/// <remarks>
/// The level of indirection should be included in the supplied string.
/// </remarks>
internal sealed class C99TypeAttribute : global::System.Attribute
{
/// <summary>
/// Creates a new <see cref="C99TypeAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="code">The C type to be used.</param>
public C99TypeAttribute(string code)
{
}
}
}
""");
});
}
}
9 changes: 0 additions & 9 deletions src/dnne-analyzers/Class1.cs

This file was deleted.

0 comments on commit f78990c

Please sign in to comment.