diff options
author | Jooyung Han <jooyung@google.com> | 2019-12-17 14:18:15 +0000 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2019-12-17 14:18:15 +0000 |
commit | 7a9aceb534b65667007c86317493dc666a60be08 (patch) | |
tree | 5821fbb44b9781a4393cdb92f2e91c46cf35a803 /aidl_to_cpp_common.cpp | |
parent | 45ebdaeefe6d3984fada32f6955f58169e926772 (diff) | |
download | aidl-7a9aceb534b65667007c86317493dc666a60be08.tar.gz |
Revert submission
Reason for revert: Trying to reland the changes with fix for build errors.
Change-Id: I049e0f0e7db6acca5ef9dde4573fe321c6e42842
Diffstat (limited to 'aidl_to_cpp_common.cpp')
-rw-r--r-- | aidl_to_cpp_common.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp index 89783110..7c566112 100644 --- a/aidl_to_cpp_common.cpp +++ b/aidl_to_cpp_common.cpp @@ -13,13 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "aidl_to_cpp_common.h" +#include <android-base/strings.h> #include <unordered_map> -#include "aidl_to_cpp_common.h" +#include "ast_cpp.h" #include "logging.h" #include "os.h" +using ::android::base::Join; + namespace android { namespace aidl { namespace cpp { @@ -352,6 +356,23 @@ const string GenLogAfterExecute(const string className, const AidlInterface& int return code; } +std::string GenerateEnumValues(const AidlEnumDeclaration& enum_decl, + const std::vector<std::string>& enclosing_namespaces_of_enum_decl) { + const auto fq_name = + Join(Append(enclosing_namespaces_of_enum_decl, enum_decl.GetSplitPackage()), "::") + + "::" + enum_decl.GetName(); + const auto size = enum_decl.GetEnumerators().size(); + std::ostringstream code; + code << "template <>\n"; + code << "constexpr inline std::array<" << fq_name << ", " << size << "> enum_values<" << fq_name + << "> = {\n"; + for (const auto& enumerator : enum_decl.GetEnumerators()) { + code << " " << fq_name << "::" << enumerator->GetName() << ",\n"; + } + code << "};\n"; + return code.str(); +} + } // namespace cpp } // namespace aidl } // namespace android |