[&]()->std::string {
return GenTemplateString(CB_IF_STATEMENT,
[&]()->std::string {
- return handle + id + "[i]";
+ return handle + id + "[j]";
},
[&]()->std::string {
return GetDestructorString(*type.GetMetaType(),
- handle + id + "[i]", true) + NLine(1);
+ handle + id + "[j]", true) + NLine(1);
});
},
[&]()->std::string {
str += NLine(1);
str += GenTemplateString(ReplaceAll(CB_SETTER_ARRAY_BLOCK, "##", id),
[&]()->std::string {
- return GetSetterString(*type.GetMetaType(),
- "h->" + id + "[i]", id + "[i]");
+ std::string s;
+ s += "int __ret = ";
+ s += GetSetterString(*type.GetMetaType(), "h->" + id + "[i]",
+ id + "[i]");
+ s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
+ [&]()->std::string {
+ return "__ret != 0";
+ },
+ [&]()->std::string {
+ std::string r;
+ r += "_E(\"Failed to clone " + id + "\");" + NLine(1);
+ r += GetFinalizeString(id, type, "h->") + NLine(1);
+ r += GetSetterString("h->" + id, "NULL") + NLine(1);
+ r += "return -1;";
+ return r;
+ });
+ s += NLine(1);
+ return s;
});
} else {
str += GetSetterString(type, "h->" + id, id);
if (type.ToString() == "array") {
str += GenTemplateString(ReplaceAll(CB_GETTER_ARRAY_BLOCK, "##", id),
[&]()->std::string {
- return GetSetterString(*type.GetMetaType(),
+ std::string s;
+ s += "int __ret = ";
+ s += GetSetterString(*type.GetMetaType(),
"(*" + id + ")[i]", "h->" + id + "[i]");
+ s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
+ [&]()->std::string {
+ return "__ret != 0";
+ },
+ [&]()->std::string {
+ std::string r;
+ r += "_E(\"Failed to clone " + id + "\");" + NLine(1);
+ r += GetFinalizeString(id, type, "h->") + NLine(1);
+ r += GetSetterString("h->" + id, "NULL") + NLine(1);
+ r += "return -1;";
+ return r;
+ });
+ s += NLine(1);
+ return s;
});
} else {
if (type.IsUserDefinedType() ||
return GetStructIdWithNamespace(st);
},
[&]()->std::string {
- return GetSetterString(*type.GetMetaType(),
+ std::string s;
+ s += "int __ret = ";
+ s += GetSetterString(*type.GetMetaType(),
"handle->" + id + "[i]", "h->" + id + "[i]");
+ s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
+ [&]()->std::string {
+ return "__ret != 0";
+ },
+ [&]()->std::string {
+ std::string tmp;
+ tmp += "_E(\"Failed to clone " + id + "\");" + NLine(1);
+ tmp += "rpc_port_" + GetStructIdWithNamespace(st) +
+ "_destroy(handle);" + NLine(1);
+ tmp += "return -1;";
+ return tmp;
+ });
+ s += NLine(1);
+ return s;
});
} else {
str += GetSetterString(type, "handle->" + id, "h->" + id);