Cleanup way elidable types are determined.

After adding the pointer type, it didn't make sense for elidable types
to be specified in canElideCallback. Now the decision as to whether a
specific type is elidable has been moved into 'isElidableType' on the
Type class.

Bug: 33298401
Test: mma in hardware/interfaces
Change-Id: I66cbaed4c533013a52e59fc8e7edcdabc9ab9f20
diff --git a/EnumType.cpp b/EnumType.cpp
index 92cb3a7..c88ecf7 100644
--- a/EnumType.cpp
+++ b/EnumType.cpp
@@ -60,6 +60,10 @@
     mValues.push_back(value);
 }
 
+bool EnumType::isElidableType() const {
+    return mStorageType->isElidableType();
+}
+
 const ScalarType *EnumType::resolveToScalarType() const {
     return mStorageType->resolveToScalarType();
 }
diff --git a/EnumType.h b/EnumType.h
index e810ed3..04d8b61 100644
--- a/EnumType.h
+++ b/EnumType.h
@@ -38,6 +38,7 @@
 
     LocalIdentifier *lookupIdentifier(const std::string &name) const override;
 
+    bool isElidableType() const override;
     const ScalarType *resolveToScalarType() const override;
 
     std::string typeName() const override;
diff --git a/Method.cpp b/Method.cpp
index 502591c..284339e 100644
--- a/Method.cpp
+++ b/Method.cpp
@@ -202,21 +202,14 @@
 }
 
 const TypedVar* Method::canElideCallback() const {
-    auto &res = results();
-
     // Can't elide callback for void or tuple-returning methods
-    if (res.size() != 1) {
+    if (mResults->size() != 1) {
         return nullptr;
     }
 
-    const TypedVar *typedVar = res.at(0);
+    const TypedVar *typedVar = mResults->at(0);
 
-    // We only elide callbacks for methods returning a single scalar.
-    if (typedVar->type().resolveToScalarType() != nullptr) {
-        return typedVar;
-    }
-
-    if (typedVar->type().isPointer()) {
+    if (typedVar->type().isElidableType()) {
         return typedVar;
     }
 
diff --git a/PointerType.cpp b/PointerType.cpp
index 14bc010..8349cfd 100644
--- a/PointerType.cpp
+++ b/PointerType.cpp
@@ -27,6 +27,10 @@
     return true;
 }
 
+bool PointerType::isElidableType() const {
+    return true;
+}
+
 void PointerType::addNamedTypesToSet(std::set<const FQName> &) const {
     // do nothing
 }
diff --git a/PointerType.h b/PointerType.h
index 242cc63..cd0f839 100644
--- a/PointerType.h
+++ b/PointerType.h
@@ -27,6 +27,8 @@
 
     bool isPointer() const override;
 
+    bool isElidableType() const override;
+
     void addNamedTypesToSet(std::set<const FQName> &set) const override;
 
     std::string getCppType(
diff --git a/ScalarType.cpp b/ScalarType.cpp
index fccebd6..042178b 100644
--- a/ScalarType.cpp
+++ b/ScalarType.cpp
@@ -41,6 +41,10 @@
     return true;
 }
 
+bool ScalarType::isElidableType() const {
+    return true;
+}
+
 std::string ScalarType::typeName() const {
     return getCppStackType();
 }
diff --git a/ScalarType.h b/ScalarType.h
index 0ff8ec5..80bc9a0 100644
--- a/ScalarType.h
+++ b/ScalarType.h
@@ -41,6 +41,7 @@
 
     bool isScalar() const override;
 
+    bool isElidableType() const override;
     const ScalarType *resolveToScalarType() const override;
 
     std::string typeName() const override;
diff --git a/Type.cpp b/Type.cpp
index c5e55a9..107e502 100644
--- a/Type.cpp
+++ b/Type.cpp
@@ -116,6 +116,10 @@
     return scalarType->isValidEnumStorageType();
 }
 
+bool Type::isElidableType() const {
+    return false;
+}
+
 std::string Type::getCppType(StorageMode, bool) const {
     CHECK(!"Should not be here");
     return std::string();
diff --git a/Type.h b/Type.h
index 7f53339..a9412d4 100644
--- a/Type.h
+++ b/Type.h
@@ -56,6 +56,7 @@
     virtual std::string typeName() const;
 
     bool isValidEnumStorageType() const;
+    virtual bool isElidableType() const;
 
     enum StorageMode {
         StorageMode_Stack,