ConstantValueDecorator with strings
ConstantValueDecorator now handles array-type values better. Previously,
array values are passed to ConstantValueDecorator after joining into a
single string, which makes it difficult to handle array values because
it should rely on formatting ("{", Join(), "}) and "wrong" type.
Now, when the type is an array, raw_value is passed as vector<string>.
This is a preparation step for multi-dimensional fixed-size arrays.
Nested constant arrays like "{{1,2,3}, {4,5,6}}" will be used as a
default value for fixed-size arrays.
Bug: 204116012
Bug: 207087196
Test: aidl_unittests
Change-Id: I15353816dafcc80b55f1878f6bcc923e21cd12e8
diff --git a/aidl_to_cpp.h b/aidl_to_cpp.h
index eab471e..73b79bb 100644
--- a/aidl_to_cpp.h
+++ b/aidl_to_cpp.h
@@ -23,7 +23,9 @@
// This header provides functions that translate AIDL things to cpp things.
-std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value);
+std::string ConstantValueDecorator(
+ const AidlTypeSpecifier& type,
+ const std::variant<std::string, std::vector<std::string>>& raw_value);
struct CodeGeneratorContext {
CodeWriter& writer;