From f78990cd1675239138c21287acb372eb56ffbc68 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 5 Nov 2023 13:51:35 +0100 Subject: [PATCH] Add AttributesGenerator type to emit attributes --- src/dnne-analyzers/AttributesGenerator.cs | 65 +++++++++++++++++++++++ src/dnne-analyzers/Class1.cs | 9 ---- 2 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 src/dnne-analyzers/AttributesGenerator.cs delete mode 100644 src/dnne-analyzers/Class1.cs diff --git a/src/dnne-analyzers/AttributesGenerator.cs b/src/dnne-analyzers/AttributesGenerator.cs new file mode 100644 index 0000000..e5ac099 --- /dev/null +++ b/src/dnne-analyzers/AttributesGenerator.cs @@ -0,0 +1,65 @@ +using Microsoft.CodeAnalysis; + +namespace DNNE; + +/// +/// A generator that generates all the necessary DNNE attributes. +/// +[Generator(LanguageNames.CSharp)] +public sealed class AttributesGenerator : IIncrementalGenerator +{ + /// + public void Initialize(IncrementalGeneratorInitializationContext context) + { + context.RegisterPostInitializationOutput(static context => + { + context.AddSource("DnneAttributes.g.cs", """ + // + #pragma warning disable + + namespace DNNE + { + /// + /// Provides C code to be defined early in the generated C header file. + /// + /// + /// 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. + /// + /// stddef.h + /// stdint.h + /// dnne.h + /// + /// + internal sealed class C99DeclCodeAttribute : global::System.Attribute + { + /// + /// Creates a new instance with the specified parameters. + /// + /// The C code to be defined in the generated C header file. + public C99DeclCodeAttribute(string code) + { + } + } + + /// + /// Defines the C type to be used. + /// + /// + /// The level of indirection should be included in the supplied string. + /// + internal sealed class C99TypeAttribute : global::System.Attribute + { + /// + /// Creates a new instance with the specified parameters. + /// + /// The C type to be used. + public C99TypeAttribute(string code) + { + } + } + } + """); + }); + } +} diff --git a/src/dnne-analyzers/Class1.cs b/src/dnne-analyzers/Class1.cs deleted file mode 100644 index 16eee1c..0000000 --- a/src/dnne-analyzers/Class1.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace dnne_analyzers -{ - public class Class1 - { - - } -}