[fidl] Always generate coding tables for interface message structs
TO-894 #done
Change-Id: Icf6b89ac1cc14db7d3089b4cfa989801aa8fd1e9
diff --git a/system/host/fidl/include/fidl/coded_ast.h b/system/host/fidl/include/fidl/coded_ast.h
index 7bc41f0..b069b68 100644
--- a/system/host/fidl/include/fidl/coded_ast.h
+++ b/system/host/fidl/include/fidl/coded_ast.h
@@ -115,8 +115,8 @@
};
struct StructType : public Type {
- StructType(std::string name, std::vector<Field> fields, uint32_t size)
- : Type(Kind::kStruct, std::move(name), SomeFieldIsNeeded(fields)), fields(std::move(fields)), size(size) {}
+ StructType(std::string name, std::vector<Field> fields, uint32_t size, CodingNeeded coding_needed)
+ : Type(Kind::kStruct, std::move(name), coding_needed), fields(std::move(fields)), size(size) {}
const std::vector<Field> fields;
const uint32_t size;
diff --git a/system/host/fidl/lib/tables_generator.cpp b/system/host/fidl/lib/tables_generator.cpp
index 17a4a7e..abaeb83 100644
--- a/system/host/fidl/lib/tables_generator.cpp
+++ b/system/host/fidl/lib/tables_generator.cpp
@@ -390,7 +390,7 @@
if (coded_parameter_type->coding_needed == coded::CodingNeeded::kNeeded)
request_fields.emplace_back(coded_parameter_type, parameter.fieldshape.Offset());
}
- coded_types_.push_back(std::make_unique<coded::StructType>(std::move(request_name), std::move(request_fields), message.typeshape.Size()));
+ coded_types_.push_back(std::make_unique<coded::StructType>(std::move(request_name), std::move(request_fields), message.typeshape.Size(), coded::CodingNeeded::kNeeded));
};
if (method.maybe_request) {
CreateMessage(*method.maybe_request, types::MessageKind::kRequest);
@@ -412,7 +412,8 @@
if (coded_member_type->coding_needed == coded::CodingNeeded::kNeeded)
struct_fields.emplace_back(coded_member_type, member.fieldshape.Offset());
}
- coded_types_.push_back(std::make_unique<coded::StructType>(std::move(struct_name), std::move(struct_fields), struct_decl->typeshape.Size()));
+ auto coding_needed = SomeFieldIsNeeded(struct_fields);
+ coded_types_.push_back(std::make_unique<coded::StructType>(std::move(struct_name), std::move(struct_fields), struct_decl->typeshape.Size(), coding_needed));
named_type_map_[&decl->name] = coded_types_.back().get();
break;
}