diff options
author | Christopher Wiley <wiley@google.com> | 2015-09-25 15:16:13 -0700 |
---|---|---|
committer | Christopher Wiley <wiley@google.com> | 2015-09-28 23:33:49 +0000 |
commit | fb4b22dfbe0f87aaad492dc8a25201179c235bae (patch) | |
tree | 812620ab352f46630a5b3bc945a95498eef2fbc5 /type_namespace.h | |
parent | b992b450093546d275d2da4b544a611700536e29 (diff) | |
download | android_system_tools_aidl-fb4b22dfbe0f87aaad492dc8a25201179c235bae.tar.gz android_system_tools_aidl-fb4b22dfbe0f87aaad492dc8a25201179c235bae.tar.bz2 android_system_tools_aidl-fb4b22dfbe0f87aaad492dc8a25201179c235bae.zip |
Explicitly create container types
Now we explicitly give ourselves a change to create each
container type before attempting to resolve a type name
to an instance of Type. In the process we finally remove
all knowledge of specific types from aidl.cpp by moving
logic into the TypeNamespace itself.
Bug: 24303749
Test: Compiles, unittests, clean build of aosp_arm passes.
Change-Id: Ie5e1b29020618863dac9417e0a60730ddb0dfc02
Diffstat (limited to 'type_namespace.h')
-rw-r--r-- | type_namespace.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/type_namespace.h b/type_namespace.h index b53650a..7865767 100644 --- a/type_namespace.h +++ b/type_namespace.h @@ -22,12 +22,24 @@ #include <base/macros.h> -struct user_data_type; -struct interface_type; +#include "aidl_language.h" namespace android { namespace aidl { +class ValidatableType { + public: + ValidatableType() = default; + virtual ~ValidatableType() = default; + + virtual bool CanBeArray() const = 0; + virtual bool CanBeOutParameter() const = 0; + virtual bool CanWriteToParcel() const = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(ValidatableType); +}; + class TypeNamespace { public: // Load this TypeNamespace with user defined types. @@ -35,17 +47,30 @@ class TypeNamespace { const std::string& filename) = 0; virtual bool AddBinderType(const interface_type* b, const std::string& filename) = 0; + // We dynamically create container types as we discover them in the parse + // tree. Returns false iff this is an invalid type. Silently discards + // duplicates and non-container types. virtual bool AddContainerType(const std::string& type_name) = 0; - // Search for a type by inexact match with |name|. - virtual const Type* Search(const std::string& name) = 0; - // Search for a type by exact match with |name|. - virtual const Type* Find(const std::string& name) const = 0; + // Returns true iff this has a type for |type_name|. + virtual bool HasType(const std::string& type_name) const; + + // Returns true iff |raw_type| is a valid return type. + virtual bool IsValidReturnType(const type_type* raw_type, + const std::string& filename) const; + + // Returns true iff |arg_type| is a valid method argument. + virtual bool IsValidArg(const arg_type* a, + int arg_index, + const std::string& filename) const; protected: TypeNamespace() = default; virtual ~TypeNamespace() = default; + virtual const ValidatableType* GetValidatableType( + const std::string& name) const = 0; + private: DISALLOW_COPY_AND_ASSIGN(TypeNamespace); }; |