private void GenerateEnum(CodeWriter cw, Enum Enum) { GenerateSummaty(cw, Enum); GenerateSourceInfo(cw, Enum); cw.WriteLine($"public enum {Enum.Name} : byte"); cw.OpenBlock(); foreach (var field in Enum.Fields) { GenerateSummaty(cw, field); cw.Write(field.Name); if (!string.IsNullOrEmpty(field.Value)) { cw.Write($" = {field.Value}"); } cw.WriteLine(","); } cw.CloseBlock(); cw.WriteLine(); }
public override object VisitEnumDeclaration(EnumDeclarationContext context) { if (_ignoreOfPragma) { return(null); } var name = context.type()?.GetText(); if (string.IsNullOrEmpty(name)) { return(null); } _currentEnum = Get <Enum>(context.type()); _currentEnum.SourceFile = _currentFile; _currentEnum.SourceLine = context.Start.Line; _currentEnum.UMeta = _currentUMeta ?? new Dictionary <string, string>(); _currentEnum.Description = _currentComment; _currentEnum.IsImplemented = true; _currentUMeta = null; _currentComment = ""; var body = context.enumElementList(); if (body != null) { VisitEnumElementList(body); } _currentEnum = null; return(null); }
public void Append(TranslationUnitContext translationunit, string file) { _preprocessorIfCount = 0; _ignoreOfAccessModifier = false; _ignoreOfPragma = false; _currentComment = ""; _currentFile = file; _currentDelegateVariable = null; _currentDelegate = null; _currentClass = null; _currentEnum = null; Visit(translationunit); }