Support multiple types in an AIDL file / multiple AIDL files

AIDL compiler now accepts multiple types in a single AIDL file and also
handles multiple input AIDL files in a single run.

Multiple types in a single AIDL file can be defined as follows:

package foo.bar;
interface IFoo { void doSomething(IBar bar);}
interface IBar { void doAnotherThing(IFoo foo, Data, d);}
parcelable Data { int x; IFoo foo; IBar bar;}

The types must be within the same package. And they can reference with
each other without using the import statement.

When multiple types exist in a single AIDL file, the output files are
created by their type names. For example, for an interface IFoo in
foo.bar. package,

<out>/foo/bar/IFoo.java

is created for Java and

<out>/IFoo.cpp
<header>/foo/bar/IFoo.h, BpFoo.h, BnFoo.h

are created for C++ where <out> is the directory specified with -o or
--out and <header> is the directory specified with -h or --header_out
options.

It is also possible to give multiple input AIDL files each of which can
have multiple types. In order to give multiple input files, the new
cmdline syntax should be used:

aidl --lang=[java|cpp] [option]... input1.aidl input2.aidl ...

In this case, the input files are automatically added to the import
path, so one can reference types defined in other input file just by
using the import statement and there is no need to explicitly set
the import path via -I or --include option.

Bug: 112017361
Test: m -j
Test: runtests.sh

Change-Id: Ifc970ca19ac6b7178ef2846996ada3178972fd98
diff --git a/aidl_typenames.h b/aidl_typenames.h
index f15e33f..11968dd 100644
--- a/aidl_typenames.h
+++ b/aidl_typenames.h
@@ -51,7 +51,8 @@
 class AidlTypenames final {
  public:
   AidlTypenames() = default;
-  bool AddDefinedType(const AidlDefinedType* type);
+  void Reset();
+  bool AddDefinedType(unique_ptr<AidlDefinedType> type);
   bool AddPreprocessedType(unique_ptr<AidlDefinedType> type);
   static bool IsBuiltinTypename(const string& type_name);
   const AidlDefinedType* TryGetDefinedType(const string& type_name) const;
@@ -62,7 +63,7 @@
   void IterateTypes(const std::function<void(const AidlDefinedType&)>& body) const;
 
  private:
-  map<string, const AidlDefinedType*> defined_types_;
+  map<string, unique_ptr<AidlDefinedType>> defined_types_;
   map<string, unique_ptr<AidlDefinedType>> preprocessed_types_;
 };