<< NLine(1);
stream << Tab(1) << "for (const auto& i : c) ";
GenBrace(stream, TAB_SIZE, [&]() {
- auto& mt = *type.GetMetaType();
+ auto* ptr = type.GetMetaType();
+ if (ptr == nullptr)
+ return;
+
+ auto& mt = *ptr;
stream << AddIndent(TAB_SIZE * 2, ConvertTypeToSerializer(mt, "i", "h"));
}, false);
stream << Tab(1) << "return h;" << NLine(1);
<< NLine(1);
stream << Tab(4) << "foreach (var i in param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
- auto& mt = *type.GetMetaType();
+ auto* ptr = type.GetMetaType();
+ if (ptr == nullptr) return;
+
+ auto& mt = *ptr;
if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) {
stream << Tab(5) << "h.Write"
<< ConvertTypeToParcelType(mt.ToString())
TEST_F(BaseTypeTest, BaseType_SetMetaType) {
tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
customType->SetMetaType(new tidl::BaseType("int", ""));
+ EXPECT_NE(customType->GetMetaType(), nullptr);
EXPECT_EQ(customType->GetMetaType()->ToString(), "int");
delete customType;
}
TEST_F(BaseTypeTest, BaseType_GetMetaType) {
tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
customType->SetMetaType(new tidl::BaseType("string", ""));
+ EXPECT_NE(customType->GetMetaType(), nullptr);
EXPECT_EQ(customType->GetMetaType()->ToString(), "string");
delete customType;
}