Revert "Revert "Add automatic default value for char-type field""
This reverts commit ac1cb3eb26525c868fd7dfeba90b6ee85161c9d8.
Original commit message:
Add automatic default value for char-type field
char type fields are auto-initialized with '\0' when not specified.
Ignore-AOSP-First: security fix
Bug: 206718630
Test: aidl_unittests
Reason for re-submit:
Conflicts resolved in the downstream branches.
Merged-In: I0001331785c0f11e6a1ebab7fef10e690392d417
Merged-In: I69d049f38a71a2c052fc8a7b098dc8525c940505
Change-Id: Ib0ce80da13419192ec8aada05445f2fb2ba5d6ea
(cherry picked from commit 6466daabe5cadd58674ea2c96b7f92255834dc42)
Merged-In:Ib0ce80da13419192ec8aada05445f2fb2ba5d6ea
diff --git a/aidl_language.h b/aidl_language.h
index e0c28a0..931c606 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -608,7 +608,7 @@
} else if constexpr (is_one_of<T, int8_t, int32_t, int64_t>::value) {
AIDL_FATAL_IF(final_type_ < Type::INT8 && final_type_ > Type::INT64, this);
return static_cast<T>(final_value_);
- } else if constexpr (std::is_same<T, char>::value) {
+ } else if constexpr (std::is_same<T, char16_t>::value) {
AIDL_FATAL_IF(final_type_ != Type::CHARACTER, this);
return final_string_value_.at(1); // unquote '
} else if constexpr (std::is_same<T, bool>::value) {
@@ -633,9 +633,9 @@
static AidlConstantValue* Default(const AidlTypeSpecifier& specifier);
static AidlConstantValue* Boolean(const AidlLocation& location, bool value);
- static AidlConstantValue* Character(const AidlLocation& location, char value);
+ static AidlConstantValue* Character(const AidlLocation& location, const std::string& value);
// example: 123, -5498, maybe any size
- static AidlConstantValue* Integral(const AidlLocation& location, const string& value);
+ static AidlConstantValue* Integral(const AidlLocation& location, const std::string& value);
static AidlConstantValue* Floating(const AidlLocation& location, const std::string& value);
static AidlConstantValue* Array(const AidlLocation& location,
std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values);