2 * Copyright (C) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <type_traits>
24 // Art Offset file dependencies
25 #define DEFINE_INCLUDE_DEPENDENCIES
26 #include "offsets_all.def"
28 std::string to_upper(std::string input) {
29 std::transform(input.begin(), input.end(), input.begin(), ::toupper);
33 template <typename T, typename = void>
34 typename std::enable_if<!std::is_signed<T>::value, std::string>::type
35 pretty_format(T value) {
36 // Print most values as hex.
38 ss << std::showbase << std::hex << value;
42 template <typename T, typename = void>
43 typename std::enable_if<std::is_signed<T>::value, std::string>::type
44 pretty_format(T value) {
45 // Print "signed" values as decimal so that the negativity doesn't get lost.
48 // For negative values add a (). Omit it from positive values for conciseness.
62 void cpp_define(const std::string& name, T value) {
63 std::cout << "#define " << name << " " << pretty_format(value) << std::endl;
67 void emit_check_eq(T value, const std::string& expr) {
68 std::cout << "DEFINE_CHECK_EQ(" << value << ", (" << expr << "))" << std::endl;
71 const char *kFileHeader = /* // NOLINT [readability/multiline_string] [5] */ R"L1C3NS3(
73 * Copyright (C) 2016 The Android Open Source Project
75 * Licensed under the Apache License, Version 2.0 (the "License");
76 * you may not use this file except in compliance with the License.
77 * You may obtain a copy of the License at
79 * http://www.apache.org/licenses/LICENSE-2.0
81 * Unless required by applicable law or agreed to in writing, software
82 * distributed under the License is distributed on an "AS IS" BASIS,
83 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
84 * See the License for the specific language governing permissions and
85 * limitations under the License.
88 #ifndef ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_
89 #define ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_
91 // This file has been auto-generated by cpp-define-generator; do not edit directly.
92 )L1C3NS3"; // NOLINT [readability/multiline_string] [5]
94 const char *kFileFooter = /* // NOLINT [readability/multiline_string] [5] */ R"F00T3R(
95 #endif // ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_
96 )F00T3R"; // NOLINT [readability/multiline_string] [5]
98 #define MACROIZE(holder_type, field_name) to_upper(#holder_type "_" #field_name "_OFFSET")
101 std::cout << kFileHeader << std::endl;
105 // Print every constant expression to stdout as a #define or a CHECK_EQ
106 #define DEFINE_EXPR(macro_name, field_type, expr) \
107 cpp_define(to_upper(#macro_name), static_cast<field_type>(expr)); \
108 emit_check_eq(z + "static_cast<" #field_type ">(" + to_upper(#macro_name) + ")", \
109 "static_cast<" #field_type ">(" #expr ")");
110 #include "offsets_all.def"
112 std::cout << kFileFooter << std::endl;