Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1760)

Unified Diff: build/android/gyp/java_cpp_enum.py

Issue 2792583002: 📱 Simplify naming of generated java enums IntDefs (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/gyp/java_cpp_enum.py
diff --git a/build/android/gyp/java_cpp_enum.py b/build/android/gyp/java_cpp_enum.py
index f6d7ced4f43d85b0eb23c8666d8267fec7b9dbab..3cb70ce8cf17b4ed2c1f0895210fc1b88b6ea68d 100755
--- a/build/android/gyp/java_cpp_enum.py
+++ b/build/android/gyp/java_cpp_enum.py
@@ -329,17 +329,16 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-public class ${CLASS_NAME} {
- @IntDef({
+@IntDef({
${INT_DEF}
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface ${ANNOTATION} {}
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface ${CLASS_NAME} {
${ENUM_ENTRIES}
}
""")
- enum_template = Template(' public static final int ${NAME} = ${VALUE};')
+ enum_template = Template(' int ${NAME} = ${VALUE};')
enum_entries_string = []
enum_names = []
for enum_name, enum_value in enum_definition.entries.iteritems():
@@ -359,25 +358,20 @@ ${ENUM_ENTRIES}
'\n'.join(comments_line_wrapper.wrap(enum_comments)))
enum_entries_string.append(' */')
enum_entries_string.append(enum_template.substitute(values))
- enum_names.append(enum_name)
+ enum_names.append(enum_definition.class_name + '.' + enum_name)
enum_entries_string = '\n'.join(enum_entries_string)
- enum_names_indent = ' ' * 6
+ enum_names_indent = ' ' * 4
wrapper = textwrap.TextWrapper(initial_indent = enum_names_indent,
subsequent_indent = enum_names_indent,
width = 100)
enum_names_string = '\n'.join(wrapper.wrap(', '.join(enum_names)))
- annotation_template = Template('${NAME}Enum')
- annotation_values = { 'NAME': enum_definition.class_name, }
- annotation_name = annotation_template.substitute(annotation_values)
-
values = {
'CLASS_NAME': enum_definition.class_name,
'ENUM_ENTRIES': enum_entries_string,
'PACKAGE': enum_definition.enum_package,
'INT_DEF': enum_names_string,
- 'ANNOTATION': annotation_name,
'SCRIPT_NAME': GetScriptName(),
'SOURCE_PATH': source_path,
'YEAR': str(date.today().year)
« no previous file with comments | « base/android/java/src/org/chromium/base/ApplicationStatus.java ('k') | build/android/gyp/java_cpp_enum_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698