hidl-gen: remove support for anonymous enums.
* There is no anonymous things allow in HIDL.
Scope::pickUniqueAnonymousName is removed.
Test: hidl_test
Test: cd system/tools/hidl && mma
Test: cd hardware/interfaces && mma
Change-Id: Iebcb001b34e05b32378dbcb8b2b06e045d8c221a
diff --git a/Scope.cpp b/Scope.cpp
index c4d07c2..8caf9c9 100644
--- a/Scope.cpp
+++ b/Scope.cpp
@@ -115,20 +115,6 @@
return false;
}
-std::string Scope::pickUniqueAnonymousName() const {
- static size_t sNextID = 0;
-
- for (;;) {
- std::string anonName = "_hidl_Anon_" + std::to_string(sNextID++);
-
- auto it = mTypeIndexByName.find(anonName);
-
- if (it == mTypeIndexByName.end()) {
- return anonName;
- }
- }
-}
-
status_t Scope::emitTypeDeclarations(Formatter &out) const {
for (size_t i = 0; i < mTypes.size(); ++i) {
status_t err = mTypes[i]->emitTypeDeclarations(out);
diff --git a/Scope.h b/Scope.h
index fd6074c..8d26cac 100644
--- a/Scope.h
+++ b/Scope.h
@@ -49,8 +49,6 @@
bool containsSingleInterface(std::string *ifaceName) const;
bool containsInterfaces() const;
- std::string pickUniqueAnonymousName() const;
-
status_t emitTypeDeclarations(Formatter &out) const override;
status_t emitGlobalTypeDeclarations(Formatter &out) const override;
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index b606564..1b6ae5c 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -98,12 +98,11 @@
/* Precedence level 3, RTL; but we have to use %left here */
%left UNARY_MINUS UNARY_PLUS '!' '~'
-%type<str> optIdentifier package
+%type<str> package
%type<fqName> fqname
%type<type> fqtype
%type<type> type opt_storage_type
-%type<type> enum_declaration
%type<type> opt_extends
%type<type> type_declaration_body interface_declaration typedef_declaration
%type<type> named_struct_or_union_declaration named_enum_declaration
@@ -590,7 +589,7 @@
compound_declaration
: named_struct_or_union_declaration { $$ = $1; }
- | enum_declaration { $$ = $1; }
+ | named_enum_declaration { $$ = $1; }
;
opt_storage_type
@@ -633,46 +632,6 @@
}
;
-enum_declaration
- : ENUM
- {
- std::string anonName = ast->scope()->pickUniqueAnonymousName();
- ast->enterScope(new EnumType(anonName.c_str()));
- }
- enum_declaration_body
- {
-
- EnumType *enumType = static_cast<EnumType *>(ast->scope());
- ast->leaveScope();
-
- std::string errorMsg;
- if (!ast->addScopedType(enumType, &errorMsg)) {
- // This should never fail.
- std::cerr << "ERROR: " << errorMsg << "\n";
- YYERROR;
- }
-
- $$ = enumType;
- }
- | ENUM IDENTIFIER opt_storage_type
- {
- ast->enterScope(new EnumType($2, $3));
- }
- enum_declaration_body
- {
- EnumType *enumType = static_cast<EnumType *>(ast->scope());
- ast->leaveScope();
-
- std::string errorMsg;
- if (!ast->addScopedType(enumType, &errorMsg)) {
- std::cerr << "ERROR: " << errorMsg << " at " << @2 << "\n";
- YYERROR;
- }
-
- $$ = enumType;
- }
- ;
-
enum_declaration_body
: '{' enum_values opt_comma '}' { $$ = $2; }
;
@@ -739,11 +698,6 @@
| INTERFACE { $$ = new GenericBinder; }
;
-optIdentifier
- : /* empty */ { $$ = NULL; }
- | IDENTIFIER { $$ = $1; }
- ;
-
%%
#include <android-base/logging.h>