private static void BuildEnumDeclaration(EnumDecl decl, CodeWriter writer) { var settings = GeneratorSettingsProvider.Get(decl.Module.ModuleName); var type = decl.Name.Underscore(); writer.AppendNewLineWithoutIndent(); writer.AppendLines(CommentHelper.FormatComment(decl.Comment)); writer.AppendLine($"class {settings.DeclSpec} {type} : public dot::enum_base"); writer.AppendLine("{"); writer.PushIndent(); writer.AppendLine($"typedef {type} self;"); writer.PopIndent(); writer.AppendNewLineWithoutIndent(); var elements = decl.Items; writer.AppendLine("public:"); writer.AppendNewLineWithoutIndent(); writer.PushIndent(); writer.AppendLine("enum enum_type {"); writer.PushIndent(); foreach (EnumItem item in elements) { writer.AppendLines(CommentHelper.FormatComment(item.Comment)); writer.AppendLine($"{item.Name.Underscore()},"); // Do not add new line after last item if (elements.IndexOf(item) != elements.Count - 1) { writer.AppendNewLineWithoutIndent(); } } writer.PopIndent(); writer.AppendLine("};"); writer.AppendNewLineWithoutIndent(); writer.PopIndent(); writer.AppendLines(@"private: static dot::object make_self() { return self(); } public: typedef self element_type; typedef dot::struct_wrapper_impl<self>* pointer_type; using dot::enum_base::enum_base; operator dot::object(); operator int() const; self& operator=(int rhs); self& operator=(const self& other); virtual dot::type_t type(); static dot::type_t typeof(); protected: virtual dot::dictionary<dot::string, int> get_enum_map() override;"); writer.AppendLine("};"); }