summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Sears <bsears@google.com>2015-11-24 06:41:40 +0000
committerBart Sears <bsears@google.com>2015-11-24 06:41:40 +0000
commiteedb29f028af472b90fa528c84d0d89100346e5c (patch)
tree2a5de9ce5748259d74cc2cc5d78d841e61373241
parentb696437d842d59c0cc26411fa3d71cb91897c572 (diff)
downloadandroid_system_tools_aidl-eedb29f028af472b90fa528c84d0d89100346e5c.tar.gz
android_system_tools_aidl-eedb29f028af472b90fa528c84d0d89100346e5c.tar.bz2
android_system_tools_aidl-eedb29f028af472b90fa528c84d0d89100346e5c.zip
Revert "Refactor top-level AST nodes"
This reverts commit b696437d842d59c0cc26411fa3d71cb91897c572. Change-Id: Id5c716536299cfad4d13c5891d9be8b1fa2aceae
-rw-r--r--aidl.cpp140
-rw-r--r--aidl.h4
-rw-r--r--aidl_language.cpp23
-rw-r--r--aidl_language.h43
-rw-r--r--aidl_language_y.y16
-rw-r--r--aidl_unittest.cpp18
-rw-r--r--generate_java.cpp6
-rw-r--r--main_java.cpp4
-rw-r--r--options.h4
-rw-r--r--type_cpp.cpp6
-rw-r--r--type_cpp.h4
-rw-r--r--type_java.cpp24
-rw-r--r--type_java.h4
-rw-r--r--type_java_unittest.cpp2
-rw-r--r--type_namespace.h4
15 files changed, 152 insertions, 150 deletions
diff --git a/aidl.cpp b/aidl.cpp
index e0e983e..6221846 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -145,39 +145,40 @@ bool check_filename(const std::string& filename,
return valid;
}
-bool check_filenames(const std::string& filename, const AidlDocument* doc) {
- if (!doc)
+bool check_filenames(const std::string& filename, const AidlDocumentItem* items) {
+ if (! items)
return true;
- const AidlInterface* interface = doc->GetInterface();
-
- if (interface) {
- return check_filename(filename, interface->GetPackage(),
- interface->GetName(), interface->GetLine());
+ if (items->item_type == INTERFACE_TYPE_BINDER) {
+ const AidlInterface* c = reinterpret_cast<const AidlInterface*>(items);
+ return check_filename(filename, c->GetPackage(), c->GetName(), c->GetLine());
}
bool success = true;
- for (const auto& item : doc->GetParcelables()) {
- success &= check_filename(filename, item->GetPackage(), item->GetName(),
- item->GetLine());
- }
+ for (const AidlParcelable* p = reinterpret_cast<const AidlParcelable*>(items);
+ p; p = p->next)
+ success &= check_filename(filename, p->GetPackage(), p->GetName(),
+ p->GetLine());
return success;
}
bool gather_types(const std::string& filename,
- const AidlDocument* doc,
+ const AidlDocumentItem* all_items,
TypeNamespace* types) {
bool success = true;
- const AidlInterface* interface = doc->GetInterface();
+ if (! all_items)
+ return true;
- if (interface)
- return types->AddBinderType(*interface, filename);
+ if (all_items->item_type == INTERFACE_TYPE_BINDER)
+ return types->AddBinderType(reinterpret_cast<const AidlInterface *>(all_items), filename);
- for (const auto& item : doc->GetParcelables()) {
- success &= types->AddParcelableType(*item, filename);
+ for (const AidlParcelable* item =
+ reinterpret_cast<const AidlParcelable *>(all_items);
+ item; item = item->next) {
+ success &= types->AddParcelableType(item, filename);
}
return success;
@@ -439,11 +440,11 @@ bool parse_preprocessed_file(const IoDelegate& io_delegate,
if (decl == "parcelable") {
AidlParcelable doc(new AidlQualifiedName(class_name, ""),
lineno, package);
- types->AddParcelableType(doc, filename);
+ types->AddParcelableType(&doc, filename);
} else if (decl == "interface") {
auto temp = new std::vector<std::unique_ptr<AidlMethod>>();
AidlInterface doc(class_name, lineno, "", false, temp, package);
- types->AddBinderType(doc, filename);
+ types->AddBinderType(&doc, filename);
} else {
success = false;
break;
@@ -467,7 +468,7 @@ AidlError load_and_validate_aidl(
std::vector<std::unique_ptr<AidlImport>>* returned_imports) {
AidlError err = AidlError::OK;
- std::map<AidlImport*,std::unique_ptr<AidlDocument>> docs;
+ std::map<AidlImport*,std::unique_ptr<AidlDocumentItem>> docs;
// import the preprocessed file
for (const string& s : preprocessed_files) {
@@ -485,19 +486,19 @@ AidlError load_and_validate_aidl(
return AidlError::PARSE_ERROR;
}
- AidlDocument* parsed_doc = p.GetDocument();
+ AidlDocumentItem* parsed_doc = p.GetDocument();
if (parsed_doc == nullptr) {
return AidlError::PARSE_ERROR;
}
-
- unique_ptr<AidlInterface> interface(parsed_doc->ReleaseInterface());
-
- if (interface.get() == nullptr) {
+ if (parsed_doc->item_type != INTERFACE_TYPE_BINDER) {
LOG(ERROR) << "refusing to generate code from aidl file defining "
"parcelable";
return AidlError::FOUND_PARCELABLE;
}
+ unique_ptr<AidlInterface> interface(
+ reinterpret_cast<AidlInterface*>(parsed_doc));
+
if (!check_filename(input_file_name.c_str(), interface->GetPackage(),
interface->GetName(), interface->GetLine()) ||
!types->IsValidPackage(interface->GetPackage())) {
@@ -533,17 +534,17 @@ AidlError load_and_validate_aidl(
continue;
}
- AidlDocument* document = p.GetDocument();
+ AidlDocumentItem* document = p.GetDocument();
if (!check_filenames(import->GetFilename(), document))
err = AidlError::BAD_IMPORT;
- docs[import.get()] = std::unique_ptr<AidlDocument>(document);
+ docs[import.get()] = std::unique_ptr<AidlDocumentItem>(document);
}
if (err != AidlError::OK) {
return err;
}
// gather the types that have been declared
- if (!types->AddBinderType(*interface.get(), input_file_name)) {
+ if (!gather_types(input_file_name.c_str(), parsed_doc, types)) {
err = AidlError::BAD_TYPE;
}
for (const auto& import : p.GetImports()) {
@@ -651,35 +652,70 @@ int compile_aidl_to_java(const JavaOptions& options,
interface.get(), types.get(), io_delegate);
}
-bool preprocess_aidl(const JavaOptions& options,
- const IoDelegate& io_delegate) {
- unique_ptr<CodeWriter> writer =
- io_delegate.GetCodeWriter(options.output_file_name_);
-
- for (const auto& file : options.files_to_preprocess_) {
- Parser p{io_delegate};
- if (!p.ParseFile(file))
- return false;
- AidlDocument* doc = p.GetDocument();
- string line;
-
- const AidlInterface* interface = doc->GetInterface();
+int preprocess_aidl(const JavaOptions& options,
+ const IoDelegate& io_delegate) {
+ vector<string> lines;
+
+ // read files
+ int N = options.files_to_preprocess_.size();
+ for (int i=0; i<N; i++) {
+ Parser p{io_delegate};
+ if (!p.ParseFile(options.files_to_preprocess_[i]))
+ return 1;
+ AidlDocumentItem* doc = p.GetDocument();
+ string line;
+ if (doc->item_type == USER_DATA_TYPE) {
+ AidlParcelable* parcelable = reinterpret_cast<AidlParcelable*>(doc);
+
+ line = "parcelable ";
+
+ if (! parcelable->GetPackage().empty()) {
+ line += parcelable->GetPackage();
+ line += '.';
+ }
+ line += parcelable->GetName();
+ } else {
+ line = "interface ";
+ AidlInterface* iface = reinterpret_cast<AidlInterface*>(doc);
+ if (!iface->GetPackage().empty()) {
+ line += iface->GetPackage();
+ line += '.';
+ }
+ line += iface->GetName();
+ }
+ line += ";\n";
+ lines.push_back(line);
+ }
- if (interface != nullptr &&
- !writer->Write("interface %s;\n",
- interface->GetCanonicalName().c_str())) {
- return false;
+ // write preprocessed file
+ int fd = open( options.output_file_name_.c_str(),
+ O_RDWR|O_CREAT|O_TRUNC|O_BINARY,
+#ifdef _WIN32
+ _S_IREAD|_S_IWRITE);
+#else
+ S_IRUSR|S_IWUSR|S_IRGRP);
+#endif
+ if (fd == -1) {
+ fprintf(stderr, "aidl: could not open file for write: %s\n",
+ options.output_file_name_.c_str());
+ return 1;
}
- for (const auto& parcelable : doc->GetParcelables()) {
- if (!writer->Write("parcelable %s;\n",
- parcelable->GetCanonicalName().c_str())) {
- return false;
- }
+ N = lines.size();
+ for (int i=0; i<N; i++) {
+ const string& s = lines[i];
+ int len = s.length();
+ if (len != write(fd, s.c_str(), len)) {
+ fprintf(stderr, "aidl: error writing to file %s\n",
+ options.output_file_name_.c_str());
+ close(fd);
+ unlink(options.output_file_name_.c_str());
+ return 1;
+ }
}
- }
- return writer->Close();
+ close(fd);
+ return 0;
}
} // namespace android
diff --git a/aidl.h b/aidl.h
index 29f0569..e5fd4ac 100644
--- a/aidl.h
+++ b/aidl.h
@@ -48,8 +48,8 @@ int compile_aidl_to_cpp(const CppOptions& options,
const IoDelegate& io_delegate);
int compile_aidl_to_java(const JavaOptions& options,
const IoDelegate& io_delegate);
-bool preprocess_aidl(const JavaOptions& options,
- const IoDelegate& io_delegate);
+int preprocess_aidl(const JavaOptions& options,
+ const IoDelegate& io_delegate);
namespace internals {
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 02eb27d..29778a9 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -128,19 +128,13 @@ AidlParcelable::AidlParcelable(AidlQualifiedName* name, unsigned line,
if (cpp_header_.length() >= 2) {
cpp_header_ = cpp_header_.substr(1, cpp_header_.length() - 2);
}
+ item_type = USER_DATA_TYPE;
}
std::string AidlParcelable::GetPackage() const {
return Join(package_, '.');
}
-std::string AidlParcelable::GetCanonicalName() const {
- if (package_.empty()) {
- return GetName();
- }
- return GetPackage() + "." + GetName();
-}
-
AidlInterface::AidlInterface(const std::string& name, unsigned line,
const std::string& comments, bool oneway,
std::vector<std::unique_ptr<AidlMethod>>* methods,
@@ -151,6 +145,7 @@ AidlInterface::AidlInterface(const std::string& name, unsigned line,
oneway_(oneway),
methods_(std::move(*methods)),
package_(package) {
+ item_type = INTERFACE_TYPE_BINDER;
delete methods;
}
@@ -165,9 +160,6 @@ std::string AidlInterface::GetCanonicalName() const {
return GetPackage() + "." + GetName();
}
-AidlDocument::AidlDocument(AidlInterface* interface)
- : interface_(interface) {}
-
AidlQualifiedName::AidlQualifiedName(std::string term,
std::string comments)
: terms_({term}),
@@ -221,18 +213,13 @@ bool Parser::ParseFile(const string& filename) {
filename_ = filename;
package_.reset();
error_ = 0;
- document_.reset();
+ document_ = nullptr;
buffer_ = yy_scan_buffer(&(*raw_buffer_)[0], raw_buffer_->length(), scanner_);
- if (yy::parser(this).parse() != 0 || error_ != 0) {
- return false;}
-
- if (document_.get() != nullptr)
- return true;
+ int ret = yy::parser(this).parse();
- LOG(ERROR) << "Parser succeeded but yielded no document!";
- return false;
+ return ret == 0 && error_ == 0;
}
void Parser::ReportError(const string& err, unsigned line) {
diff --git a/aidl_language.h b/aidl_language.h
index db5a8ec..f291a2f 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -134,30 +134,20 @@ class AidlMethod {
DISALLOW_COPY_AND_ASSIGN(AidlMethod);
};
-class AidlParcelable;
-class AidlInterface;
-class AidlDocument : public AidlNode {
+enum {
+ USER_DATA_TYPE = 12,
+ INTERFACE_TYPE_BINDER
+};
+
+class AidlDocumentItem : public AidlNode {
public:
- AidlDocument() = default;
- AidlDocument(AidlInterface* interface);
- virtual ~AidlDocument() = default;
+ AidlDocumentItem() = default;
+ virtual ~AidlDocumentItem() = default;
- const AidlInterface* GetInterface() const { return interface_.get(); }
- AidlInterface* ReleaseInterface() { return interface_.release(); }
-
- const std::vector<std::unique_ptr<AidlParcelable>>& GetParcelables() const {
- return parcelables_;
- }
-
- void AddParcelable(AidlParcelable* parcelable) {
- parcelables_.push_back(std::unique_ptr<AidlParcelable>(parcelable));
- }
+ unsigned item_type;
private:
- std::vector<std::unique_ptr<AidlParcelable>> parcelables_;
- std::unique_ptr<AidlInterface> interface_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlDocument);
+ DISALLOW_COPY_AND_ASSIGN(AidlDocumentItem);
};
class AidlQualifiedName : public AidlNode {
@@ -178,7 +168,7 @@ class AidlQualifiedName : public AidlNode {
DISALLOW_COPY_AND_ASSIGN(AidlQualifiedName);
};
-class AidlParcelable : public AidlNode {
+class AidlParcelable : public AidlDocumentItem {
public:
AidlParcelable(AidlQualifiedName* name, unsigned line,
const std::vector<std::string>& package,
@@ -190,7 +180,8 @@ class AidlParcelable : public AidlNode {
std::string GetPackage() const;
const std::vector<std::string>& GetSplitPackage() const { return package_; }
std::string GetCppHeader() const { return cpp_header_; }
- std::string GetCanonicalName() const;
+
+ AidlParcelable* next = nullptr;
private:
std::unique_ptr<AidlQualifiedName> name_;
@@ -201,7 +192,7 @@ class AidlParcelable : public AidlNode {
DISALLOW_COPY_AND_ASSIGN(AidlParcelable);
};
-class AidlInterface : public AidlNode {
+class AidlInterface : public AidlDocumentItem {
public:
AidlInterface(const std::string& name, unsigned line,
const std::string& comments, bool oneway_,
@@ -266,14 +257,14 @@ class Parser {
const std::string& FileName() const { return filename_; }
void* Scanner() const { return scanner_; }
- void SetDocument(AidlDocument* items) { document_ = items; };
+ void SetDocument(AidlDocumentItem* items) { document_ = items; };
void AddImport(AidlQualifiedName* name, unsigned line);
std::vector<std::string> Package() const;
void SetPackage(AidlQualifiedName* name) { package_.reset(name); }
- AidlDocument* GetDocument() const { return document_; }
+ AidlDocumentItem* GetDocument() const { return document_; }
const std::vector<std::unique_ptr<AidlImport>>& GetImports() {
return imports_;
}
@@ -289,7 +280,7 @@ class Parser {
std::string filename_;
std::unique_ptr<AidlQualifiedName> package_;
void* scanner_ = nullptr;
- AidlDocument* document_ = nullptr;
+ AidlDocumentItem* document_ = nullptr;
std::vector<std::unique_ptr<AidlImport>> imports_;
std::unique_ptr<std::string> raw_buffer_;
YY_BUFFER_STATE buffer_;
diff --git a/aidl_language_y.y b/aidl_language_y.y
index 789edab..ccf9d82 100644
--- a/aidl_language_y.y
+++ b/aidl_language_y.y
@@ -29,8 +29,7 @@ int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
std::vector<std::unique_ptr<AidlMethod>>* methods;
AidlQualifiedName* qname;
AidlInterface* interface_obj;
- AidlParcelable* parcelable;
- AidlDocument* parcelable_list;
+ AidlParcelable* user_data;
}
%token<token> IDENTIFIER INTERFACE ONEWAY C_STR
@@ -39,8 +38,7 @@ int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
%token '(' ')' ',' '=' '[' ']' '<' '>' '.' '{' '}' ';'
%token IN OUT INOUT PACKAGE IMPORT PARCELABLE FROM
-%type<parcelable_list> parcelable_decls
-%type<parcelable> parcelable_decl
+%type<user_data> parcelable_decl parcelable_decls
%type<methods> methods
%type<interface_obj> interface_decl
%type<method> method_decl
@@ -57,7 +55,7 @@ document
: package imports parcelable_decls
{ ps->SetDocument($3); }
| package imports interface_decl
- { ps->SetDocument(new AidlDocument($3)); };
+ { ps->SetDocument($3); };
/* A couple of tokens that are keywords elsewhere are identifiers when
* occurring in the identifier position. Therefore identifier is a
@@ -95,10 +93,14 @@ qualified_name
parcelable_decls
:
- { $$ = new AidlDocument(); }
+ { $$ = NULL; }
| parcelable_decls parcelable_decl {
$$ = $1;
- $$->AddParcelable($2);
+ AidlParcelable **pos = &$$;
+ while (*pos)
+ pos = &(*pos)->next;
+ if ($2)
+ *pos = $2;
}
| parcelable_decls error {
fprintf(stderr, "%s:%d: syntax error don't know what to do with \"%s\"\n",
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index e91d89e..24475ca 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -154,24 +154,6 @@ TEST_F(AidlTest, PreferImportToPreprocessed) {
EXPECT_EQ("one.IBar", type->QualifiedName());
}
-TEST_F(AidlTest, WritePreprocessedFile) {
- io_delegate_.SetFileContents("p/Outer.aidl",
- "package p; parcelable Outer.Inner;");
- io_delegate_.SetFileContents("one/IBar.aidl", "package one; import p.Outer;"
- "interface IBar {}");
-
- JavaOptions options;
- options.output_file_name_ = "preprocessed";
- options.files_to_preprocess_.resize(2);
- options.files_to_preprocess_[0] = "p/Outer.aidl";
- options.files_to_preprocess_[1] = "one/IBar.aidl";
- EXPECT_TRUE(::android::aidl::preprocess_aidl(options, io_delegate_));
-
- string output;
- EXPECT_TRUE(io_delegate_.GetWrittenContents("preprocessed", &output));
- EXPECT_EQ("parcelable p.Outer.Inner;\ninterface one.IBar;\n", output);
-}
-
TEST_F(AidlTest, RequireOuterClass) {
io_delegate_.SetFileContents("p/Outer.aidl",
"package p; parcelable Outer.Inner;");
diff --git a/generate_java.cpp b/generate_java.cpp
index b6054c8..55fa791 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -52,7 +52,11 @@ generate_java(const string& filename, const string& originalSrc,
AidlInterface* iface, JavaTypeNamespace* types,
const IoDelegate& io_delegate)
{
- Class* cl = generate_binder_interface_class(iface, types);
+ Class* cl;
+
+ if (iface->item_type == INTERFACE_TYPE_BINDER) {
+ cl = generate_binder_interface_class(iface, types);
+ }
Document* document = new Document;
document->comment = "";
diff --git a/main_java.cpp b/main_java.cpp
index 7d32b24..fc2d748 100644
--- a/main_java.cpp
+++ b/main_java.cpp
@@ -37,9 +37,7 @@ int main(int argc, char** argv) {
case JavaOptions::COMPILE_AIDL_TO_JAVA:
return android::aidl::compile_aidl_to_java(*options, io_delegate);
case JavaOptions::PREPROCESS_AIDL:
- if (android::aidl::preprocess_aidl(*options, io_delegate))
- return 0;
- return 1;
+ return android::aidl::preprocess_aidl(*options, io_delegate);
}
std::cerr << "aidl: internal error" << std::endl;
return 1;
diff --git a/options.h b/options.h
index cd30624..230c7e5 100644
--- a/options.h
+++ b/options.h
@@ -55,12 +55,14 @@ class JavaOptions final {
bool auto_dep_file_{false};
std::vector<std::string> files_to_preprocess_;
+ // TODO: Mock file IO and remove this (b/24816077)
+ std::string output_file_name_for_deps_test_;
+
private:
JavaOptions() = default;
FRIEND_TEST(EndToEndTest, IExampleInterface);
FRIEND_TEST(AidlTest, FailOnParcelable);
- FRIEND_TEST(AidlTest, WritePreprocessedFile);
DISALLOW_COPY_AND_ASSIGN(JavaOptions);
};
diff --git a/type_cpp.cpp b/type_cpp.cpp
index 0e5771c..4312210 100644
--- a/type_cpp.cpp
+++ b/type_cpp.cpp
@@ -262,16 +262,16 @@ void TypeNamespace::Init() {
Add(void_type_);
}
-bool TypeNamespace::AddParcelableType(const AidlParcelable& /* p */,
+bool TypeNamespace::AddParcelableType(const AidlParcelable* /* p */,
const string& /* filename */) {
// TODO Support parcelables b/23600712
LOG(ERROR) << "Passing parcelables in unimplemented in C++ generation.";
return true;
}
-bool TypeNamespace::AddBinderType(const AidlInterface& b,
+bool TypeNamespace::AddBinderType(const AidlInterface* b,
const string& file_name) {
- Add(new BinderType(b, file_name));
+ Add(new BinderType(*b, file_name));
return true;
}
diff --git a/type_cpp.h b/type_cpp.h
index ad3bda7..99a6d4e 100644
--- a/type_cpp.h
+++ b/type_cpp.h
@@ -90,9 +90,9 @@ class TypeNamespace : public ::android::aidl::LanguageTypeNamespace<Type> {
virtual ~TypeNamespace() = default;
void Init() override;
- bool AddParcelableType(const AidlParcelable& p,
+ bool AddParcelableType(const AidlParcelable* p,
const std::string& filename) override;
- bool AddBinderType(const AidlInterface& b,
+ bool AddBinderType(const AidlInterface* b,
const std::string& filename) override;
bool AddListType(const std::string& type_name) override;
bool AddMapType(const std::string& key_type_name,
diff --git a/type_java.cpp b/type_java.cpp
index 730d87f..ff05440 100644
--- a/type_java.cpp
+++ b/type_java.cpp
@@ -796,27 +796,27 @@ const Type* JavaTypeNamespace::Find(const char* package,
return Find(s);
}
-bool JavaTypeNamespace::AddParcelableType(const AidlParcelable& p,
+bool JavaTypeNamespace::AddParcelableType(const AidlParcelable* p,
const std::string& filename) {
Type* type =
- new UserDataType(this, p.GetPackage(), p.GetName(), false,
- true, filename, p.GetLine());
+ new UserDataType(this, p->GetPackage(), p->GetName(), false,
+ true, filename, p->GetLine());
return Add(type);
}
-bool JavaTypeNamespace::AddBinderType(const AidlInterface& b,
+bool JavaTypeNamespace::AddBinderType(const AidlInterface* b,
const std::string& filename) {
// for interfaces, add the stub, proxy, and interface types.
Type* type =
- new InterfaceType(this, b.GetPackage(), b.GetName(), false,
- b.IsOneway(), filename, b.GetLine());
- Type* stub = new Type(this, b.GetPackage(),
- b.GetName() + ".Stub", ValidatableType::KIND_GENERATED,
- false, false, filename, b.GetLine());
- Type* proxy = new Type(this, b.GetPackage(),
- b.GetName() + ".Stub.Proxy",
+ new InterfaceType(this, b->GetPackage(), b->GetName(), false,
+ b->IsOneway(), filename, b->GetLine());
+ Type* stub = new Type(this, b->GetPackage(),
+ b->GetName() + ".Stub", ValidatableType::KIND_GENERATED,
+ false, false, filename, b->GetLine());
+ Type* proxy = new Type(this, b->GetPackage(),
+ b->GetName() + ".Stub.Proxy",
ValidatableType::KIND_GENERATED,
- false, false, filename, b.GetLine());
+ false, false, filename, b->GetLine());
bool success = true;
success &= Add(type);
diff --git a/type_java.h b/type_java.h
index 6a9860a..a5e0e0a 100644
--- a/type_java.h
+++ b/type_java.h
@@ -369,9 +369,9 @@ class JavaTypeNamespace : public LanguageTypeNamespace<Type> {
virtual ~JavaTypeNamespace() = default;
void Init() override;
- bool AddParcelableType(const AidlParcelable& p,
+ bool AddParcelableType(const AidlParcelable* p,
const string& filename) override;
- bool AddBinderType(const AidlInterface& b,
+ bool AddBinderType(const AidlInterface* b,
const string& filename) override;
bool AddListType(const std::string& contained_type_name) override;
bool AddMapType(const std::string& key_type_name,
diff --git a/type_java_unittest.cpp b/type_java_unittest.cpp
index ee4397f..4c18896 100644
--- a/type_java_unittest.cpp
+++ b/type_java_unittest.cpp
@@ -48,7 +48,7 @@ TEST_F(JavaTypeNamespaceTest, ContainerTypeCreation) {
unique_ptr<AidlParcelable> parcelable(
new AidlParcelable(new AidlQualifiedName("Foo", ""), 0, {"a", "goog"}));
// Add the parcelable type we care about.
- EXPECT_TRUE(types_.AddParcelableType(*parcelable.get(), __FILE__));
+ EXPECT_TRUE(types_.AddParcelableType(parcelable.get(), __FILE__));
// Now we can find the parcelable type, but not the List of them.
EXPECT_NE(types_.Find("Foo"), nullptr);
EXPECT_EQ(types_.Find("List<Foo>"), nullptr);
diff --git a/type_namespace.h b/type_namespace.h
index a235a79..7aaba7b 100644
--- a/type_namespace.h
+++ b/type_namespace.h
@@ -72,9 +72,9 @@ class TypeNamespace {
virtual void Init() = 0;
// Load this TypeNamespace with user defined types.
- virtual bool AddParcelableType(const AidlParcelable& p,
+ virtual bool AddParcelableType(const AidlParcelable* p,
const std::string& filename) = 0;
- virtual bool AddBinderType(const AidlInterface& b,
+ virtual bool AddBinderType(const AidlInterface* b,
const std::string& filename) = 0;
// We dynamically create container types as we discover them in the parse
// tree. Returns false if the contained types cannot be canonicalized.