diff options
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator.h')
-rw-r--r-- | tools/aapt2/java/JavaClassGenerator.h | 116 |
1 files changed, 59 insertions, 57 deletions
diff --git a/tools/aapt2/java/JavaClassGenerator.h b/tools/aapt2/java/JavaClassGenerator.h index 901a86ed5b1d..2fdf2682a162 100644 --- a/tools/aapt2/java/JavaClassGenerator.h +++ b/tools/aapt2/java/JavaClassGenerator.h @@ -31,72 +31,74 @@ class AnnotationProcessor; class ClassDefinition; struct JavaClassGeneratorOptions { - /* - * Specifies whether to use the 'final' modifier - * on resource entries. Default is true. - */ - bool useFinal = true; - - enum class SymbolTypes { - kAll, - kPublicPrivate, - kPublic, - }; - - SymbolTypes types = SymbolTypes::kAll; - - /** - * A list of JavaDoc annotations to add to the comments of all generated classes. - */ - std::vector<std::string> javadocAnnotations; + /* + * Specifies whether to use the 'final' modifier + * on resource entries. Default is true. + */ + bool useFinal = true; + + enum class SymbolTypes { + kAll, + kPublicPrivate, + kPublic, + }; + + SymbolTypes types = SymbolTypes::kAll; + + /** + * A list of JavaDoc annotations to add to the comments of all generated + * classes. + */ + std::vector<std::string> javadocAnnotations; }; /* * Generates the R.java file for a resource table. */ class JavaClassGenerator { -public: - JavaClassGenerator(IAaptContext* context, ResourceTable* table, - const JavaClassGeneratorOptions& options); - - /* - * Writes the R.java file to `out`. Only symbols belonging to `package` are written. - * All symbols technically belong to a single package, but linked libraries will - * have their names mangled, denoting that they came from a different package. - * We need to generate these symbols in a separate file. - * Returns true on success. - */ - bool generate(const StringPiece& packageNameToGenerate, std::ostream* out); - - bool generate(const StringPiece& packageNameToGenerate, - const StringPiece& outputPackageName, - std::ostream* out); - - const std::string& getError() const; - -private: - bool addMembersToTypeClass(const StringPiece& packageNameToGenerate, - const ResourceTablePackage* package, - const ResourceTableType* type, - ClassDefinition* outTypeClassDef); - - void addMembersToStyleableClass(const StringPiece& packageNameToGenerate, - const std::string& entryName, - const Styleable* styleable, - ClassDefinition* outStyleableClassDef); - - bool skipSymbol(SymbolState state); - - IAaptContext* mContext; - ResourceTable* mTable; - JavaClassGeneratorOptions mOptions; - std::string mError; + public: + JavaClassGenerator(IAaptContext* context, ResourceTable* table, + const JavaClassGeneratorOptions& options); + + /* + * Writes the R.java file to `out`. Only symbols belonging to `package` are + * written. + * All symbols technically belong to a single package, but linked libraries + * will + * have their names mangled, denoting that they came from a different package. + * We need to generate these symbols in a separate file. + * Returns true on success. + */ + bool generate(const StringPiece& packageNameToGenerate, std::ostream* out); + + bool generate(const StringPiece& packageNameToGenerate, + const StringPiece& outputPackageName, std::ostream* out); + + const std::string& getError() const; + + private: + bool addMembersToTypeClass(const StringPiece& packageNameToGenerate, + const ResourceTablePackage* package, + const ResourceTableType* type, + ClassDefinition* outTypeClassDef); + + void addMembersToStyleableClass(const StringPiece& packageNameToGenerate, + const std::string& entryName, + const Styleable* styleable, + ClassDefinition* outStyleableClassDef); + + bool skipSymbol(SymbolState state); + + IAaptContext* mContext; + ResourceTable* mTable; + JavaClassGeneratorOptions mOptions; + std::string mError; }; inline const std::string& JavaClassGenerator::getError() const { - return mError; + return mError; } -} // namespace aapt +} // namespace aapt -#endif // AAPT_JAVA_CLASS_GENERATOR_H +#endif // AAPT_JAVA_CLASS_GENERATOR_H |