str += GenTemplateString(ReplaceAll(CB_SETTER_ARRAY_BLOCK, "##", id),
[&]()->std::string {
std::string s;
- s += "int __ret = ";
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array")
+ 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;
- });
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array") {
+ 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;
});
str += GenTemplateString(ReplaceAll(CB_GETTER_ARRAY_BLOCK, "##", id),
[&]()->std::string {
std::string s;
- s += "int __ret = ";
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array")
+ 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;
- });
+
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array") {
+ 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;
});
},
[&]()->std::string {
std::string s;
- s += "int __ret = ";
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array")
+ 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;
- });
+
+ if (type.GetMetaType()->IsUserDefinedType() ||
+ type.GetMetaType()->ToString() == "list" ||
+ type.GetMetaType()->ToString() == "array") {
+ 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;
});