refactor: make "Autofill" explicit
Extracted "Autofill" (setting backing-type for enums) into a separate
method which is called by AidlTypenames::Autofill().
Now the processing steps are as follows: (see diagnostics_unittest.cpp)
- Parser::Parse(): load a doc into AST
- parser.Resolve(): type/reference resolution(link references to targets)
- typenames.Autofill(): fill or fix AST to be valid
- CheckValid: is AST valid?
- .. further processing ..
Bug: none
Test: m aidl_unittests
Change-Id: I70117aa6df8301b8665194f4a0466df1f271aa67
diff --git a/aidl_language.h b/aidl_language.h
index f19ef24..c4a61fc 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -256,7 +256,7 @@
const AidlAnnotation* UnsupportedAppUsage() const;
const AidlAnnotation* RustDerive() const;
- const AidlTypeSpecifier* BackingType(const AidlTypenames& typenames) const;
+ const AidlAnnotation* BackingType() const;
// ToString is for dumping AIDL.
// Returns string representation of annotations.
@@ -973,7 +973,7 @@
AidlEnumDeclaration& operator=(const AidlEnumDeclaration&) = delete;
AidlEnumDeclaration& operator=(AidlEnumDeclaration&&) = delete;
- void SetBackingType(std::unique_ptr<const AidlTypeSpecifier> type);
+ bool Autofill(const AidlTypenames&);
const AidlTypeSpecifier& GetBackingType() const { return *backing_type_; }
const std::vector<std::unique_ptr<AidlEnumerator>>& GetEnumerators() const {
return enumerators_;
@@ -990,11 +990,10 @@
const AidlEnumDeclaration* AsEnumDeclaration() const override { return this; }
private:
- void Autofill();
const std::string name_;
const std::vector<std::unique_ptr<AidlEnumerator>> enumerators_;
- std::unique_ptr<const AidlTypeSpecifier> backing_type_;
+ std::unique_ptr<AidlTypeSpecifier> backing_type_;
};
class AidlUnionDecl : public AidlParcelable {