| OLD | NEW |
| 1 # Accessing C++ Enums In Java | 1 # Accessing C++ Enums In Java |
| 2 | 2 |
| 3 [TOC] | 3 [TOC] |
| 4 | 4 |
| 5 ## Introduction | 5 ## Introduction |
| 6 | 6 |
| 7 Accessing C++ enums in Java is implemented via a Python script which analyzes | 7 Accessing C++ enums in Java is implemented via a Python script which analyzes |
| 8 the C++ enum and spits out the corresponding Java class. The enum needs to be | 8 the C++ enum and spits out the corresponding Java class. The enum needs to be |
| 9 annotated in a particular way. By default, the generated class name will be the | 9 annotated in a particular way. By default, the generated class name will be the |
| 10 same as the name of the enum. If all the names of the enum values are prefixed | 10 same as the name of the enum. If all the names of the enum values are prefixed |
| 11 with the MACRO\_CASED\_ name of the enum those prefixes will be stripped from | 11 with the MACRO\_CASED\_ name of the enum those prefixes will be stripped from |
| 12 the Java version. | 12 the Java version. |
| 13 | 13 |
| 14 ## Features | 14 ## Features |
| 15 * Customize the package name of the generated class using the | 15 * Customize the package name of the generated class using the |
| 16 `GENERATED_JAVA_ENUM_PACKAGE` directive (required) | 16 `GENERATED_JAVA_ENUM_PACKAGE` directive (required) |
| 17 * Customize the class name using the `GENERATED_JAVA_CLASS_NAME_OVERRIDE` | 17 * Customize the class name using the `GENERATED_JAVA_CLASS_NAME_OVERRIDE` |
| 18 directive (optional) | 18 directive (optional) |
| 19 * Strip enum entry prefixes to make the generated classes less verbose using | 19 * Strip enum entry prefixes to make the generated classes less verbose using |
| 20 the `GENERATED_JAVA_PREFIX_TO_STRIP` directive (optional) | 20 the `GENERATED_JAVA_PREFIX_TO_STRIP` directive (optional) |
| 21 * Supports | 21 * Supports |
| 22 [`@IntDef`](https://developer.android.com/reference/android/support/annotation/I
ntDef.html) | 22 [`@IntDef`](https://developer.android.com/reference/android/support/annotation/I
ntDef.html) |
| 23 * Copies comments that directly preceed enum entries into the generated Java | 23 * Copies comments that directly precede enum entries into the generated Java |
| 24 class | 24 class |
| 25 | 25 |
| 26 ## Usage | 26 ## Usage |
| 27 | 27 |
| 28 1. Add directives to your C++ enum | 28 1. Add directives to your C++ enum |
| 29 | 29 |
| 30 ```cpp | 30 ```cpp |
| 31 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome | 31 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome |
| 32 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: FooBar | 32 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: FooBar |
| 33 // GENERATED_JAVA_PREFIX_TO_STRIP: BAR_ | 33 // GENERATED_JAVA_PREFIX_TO_STRIP: BAR_ |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 ``` | 142 ``` |
| 143 | 143 |
| 144 ## Code | 144 ## Code |
| 145 * [Generator | 145 * [Generator |
| 146 code](https://cs.chromium.org/chromium/src/build/android/gyp/java_cpp_enum.py?dr
=C&sq=package:chromium) | 146 code](https://cs.chromium.org/chromium/src/build/android/gyp/java_cpp_enum.py?dr
=C&sq=package:chromium) |
| 147 and | 147 and |
| 148 [Tests](https://cs.chromium.org/chromium/src/build/android/gyp/java_cpp_enum_tes
ts.py?dr=C&q=java_cpp_enum_tests&sq=package:chromium&l=1) | 148 [Tests](https://cs.chromium.org/chromium/src/build/android/gyp/java_cpp_enum_tes
ts.py?dr=C&q=java_cpp_enum_tests&sq=package:chromium&l=1) |
| 149 * [GN | 149 * [GN |
| 150 template](https://cs.chromium.org/chromium/src/build/config/android/rules.gni?q=
java_cpp_enum.py&sq=package:chromium&dr=C&l=458) | 150 template](https://cs.chromium.org/chromium/src/build/config/android/rules.gni?q=
java_cpp_enum.py&sq=package:chromium&dr=C&l=458) |
| OLD | NEW |