Keeping track of imported names, resolve enum storage types, some finetuning.
diff --git a/ScalarType.cpp b/ScalarType.cpp
index c498f8c..14fa4e2 100644
--- a/ScalarType.cpp
+++ b/ScalarType.cpp
@@ -16,6 +16,10 @@
     out << kName[mKind];
 }
 
+const ScalarType *ScalarType::resolveToScalarType() const {
+    return this;
+}
+
 std::string ScalarType::getCppType(StorageMode, std::string *extra) const {
     static const char *const kName[] = {
         "char",
@@ -45,6 +49,24 @@
         bool parcelObjIsPointer,
         bool isReader,
         ErrorMode mode) const {
+    emitReaderWriterWithCast(
+            out,
+            name,
+            parcelObj,
+            parcelObjIsPointer,
+            isReader,
+            mode,
+            false /* needsCast */);
+}
+
+void ScalarType::emitReaderWriterWithCast(
+        Formatter &out,
+        const std::string &name,
+        const std::string &parcelObj,
+        bool parcelObjIsPointer,
+        bool isReader,
+        ErrorMode mode,
+        bool needsCast) const {
     static const char *const kSuffix[] = {
         "Uint8",
         "Uint8",
@@ -70,6 +92,14 @@
         << kSuffix[mKind]
         << "(";
 
+    if (needsCast) {
+        std::string extra;
+
+        out << "("
+            << Type::getCppType(&extra)
+            << (isReader ? " *)" : ")");
+    }
+
     if (isReader) {
         out << "&";
     }