From f6b922fdccece55ba49b5828116272bfe62c4ead Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 9 Jan 2025 15:09:06 -0500 Subject: [PATCH] Remove cpp:unscoped --- cpp/src/slice2cpp/CPlusPlusUtil.cpp | 4 --- cpp/src/slice2cpp/Gen.cpp | 38 +++++------------------------ 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/cpp/src/slice2cpp/CPlusPlusUtil.cpp b/cpp/src/slice2cpp/CPlusPlusUtil.cpp index 84a405233ed..52d65b2176e 100644 --- a/cpp/src/slice2cpp/CPlusPlusUtil.cpp +++ b/cpp/src/slice2cpp/CPlusPlusUtil.cpp @@ -991,10 +991,6 @@ Slice::findMetadata(const MetadataList& metadata, TypeContext typeCtx) return "%array"; } } - else if (directive == "cpp:unscoped") // TODO: The 'else if' here seems dubious. Should probably just be 'if'. - { - return "%unscoped"; - } } return ""; } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 4f978015052..28f68ed835d 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -140,17 +140,7 @@ namespace { EnumeratorPtr enumerator = dynamic_pointer_cast(valueType); assert(enumerator); - - bool unscoped = findMetadata(ep->getMetadata()) == "%unscoped"; - - if (unscoped) - { - out << getUnqualified(fixKwd(ep->scope() + enumerator->name()), scope); - } - else - { - out << getUnqualified(fixKwd(enumerator->scoped()), scope); - } + out << getUnqualified(fixKwd(enumerator->scoped()), scope); } else if (!ep) { @@ -943,13 +933,6 @@ Slice::Gen::validateMetadata(const UnitPtr& u) }; knownMetadata.emplace("cpp:source-include", std::move(sourceIncludeInfo)); - // "cpp:unscoped" - MetadataInfo unscopedInfo = { - .validOn = {typeid(Enum)}, - .acceptedArgumentKind = MetadataArgumentKind::NoArguments, - }; - knownMetadata.emplace("cpp:unscoped", std::move(unscopedInfo)); - // "cpp:view-type" MetadataInfo viewTypeInfo = { .validOn = {typeid(Sequence), typeid(Dictionary)}, @@ -1098,22 +1081,13 @@ Slice::Gen::ForwardDeclVisitor::visitInterfaceDecl(const InterfaceDeclPtr& p) void Slice::Gen::ForwardDeclVisitor::visitEnum(const EnumPtr& p) { - bool unscoped = findMetadata(p->getMetadata()) == "%unscoped"; writeDocSummary(H, p); - H << nl << "enum "; - if (!unscoped) - { - H << "class "; - } - H << getDeprecatedAttribute(p) << fixKwd(p->name()); - if (!unscoped) - { - H << " : ::std::" << (p->maxValue() <= numeric_limits::max() ? "uint8_t" : "int32_t"); + H << nl << "enum class " << getDeprecatedAttribute(p) << fixKwd(p->name()); + H << " : ::std::" << (p->maxValue() <= numeric_limits::max() ? "uint8_t" : "int32_t"); - if (p->maxValue() > numeric_limits::max() && p->maxValue() <= numeric_limits::max()) - { - H << " // NOLINT:performance-enum-size"; - } + if (p->maxValue() > numeric_limits::max() && p->maxValue() <= numeric_limits::max()) + { + H << " // NOLINT:performance-enum-size"; } H << sb;