Merge "Use 4 spaces of indentation for hidl-gen and c2hal."
diff --git a/ArrayType.cpp b/ArrayType.cpp
index 9d3f8ff..6b4a01b 100644
--- a/ArrayType.cpp
+++ b/ArrayType.cpp
@@ -36,7 +36,7 @@
}
void ArrayType::addDimension(ConstantExpression *size) {
- mSizes.insert(mSizes.begin(), size->cast<size_t>());
+ mSizes.insert(mSizes.begin(), size->castSizeT());
mSizeComments.insert(mSizeComments.begin(), size->description());
}
diff --git a/ConstantExpression.cpp b/ConstantExpression.cpp
index 680a5d2..9c98046 100644
--- a/ConstantExpression.cpp
+++ b/ConstantExpression.cpp
@@ -400,6 +400,10 @@
SWITCH_KIND(mValueKind, CASE_CAST_T, SHOULD_NOT_REACH(); return 0; );
}
+size_t ConstantExpression::castSizeT() const {
+ return this->cast<size_t>();
+}
+
/*
Evaluating expressions in HIDL language
diff --git a/ConstantExpression.h b/ConstantExpression.h
index 2e859b0..ba1ca14 100644
--- a/ConstantExpression.h
+++ b/ConstantExpression.h
@@ -73,12 +73,8 @@
ConstantExpression addOne() const;
/* Assignment operator. */
ConstantExpression& operator=(const ConstantExpression& other);
- /*
- * Return the value casted to the given type.
- * First cast it according to mValueKind, then cast it to T.
- * Assumes !containsIdentifiers()
- */
- template <typename T> T cast() const;
+
+ size_t castSizeT() const;
private:
/* The formatted expression. */
@@ -98,6 +94,13 @@
std::string rawValue(ScalarType::Kind castKind) const;
/* Trim unnecessary information. Only mValue and mValueKind is kept. */
ConstantExpression &toLiteral();
+
+ /*
+ * Return the value casted to the given type.
+ * First cast it according to mValueKind, then cast it to T.
+ * Assumes !containsIdentifiers()
+ */
+ template <typename T> T cast() const;
};
} // namespace android
diff --git a/c2hal/c2hal_y.yy b/c2hal/c2hal_y.yy
index ef66a61..2c05b95 100644
--- a/c2hal/c2hal_y.yy
+++ b/c2hal/c2hal_y.yy
@@ -75,6 +75,13 @@
%pure-parser
%glr-parser
+/* These have to do with the fact that
+ * struct_or_enum_declaration and enum_declaration
+ * both start with STRUCT/UNION/ENUM opt_id
+ * and type_qualifiers contain these.
+ */
+%expect 3
+
%token START_HEADER
%token START_EXPR