Refactor top-level AST nodes v2
The previous version of this patch was tainted by parts of another
change to remove a memory leak, and ended up trying to treat a bare
pointer like a unique_ptr in a few places. This combines both changes in
to one.
Previous patch was b696437d842d59c0cc26411fa3d71cb91897c572:
We now return an AidlDocument from parsing. This type is non-polymorphic
and contains either a vector of parcelables or an interface. This gets
rid of all of our reinterpret_cast calls and the public item_type field.
Change-Id: I77fbb1d8448343bd02484d896289a514d636df25
Test: Unit tests pass
Bug: none
Signed-off-by: Casey Dahlin <sadmac@google.com>
diff --git a/type_java.cpp b/type_java.cpp
index ff05440..730d87f 100644
--- a/type_java.cpp
+++ b/type_java.cpp
@@ -796,27 +796,27 @@
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);