fix tars2node bug for json_support

This commit is contained in:
kivenchen 2021-10-13 19:43:00 +08:00 committed by ruanshudong
parent f5240831e3
commit 4721f4ffc3
2 changed files with 61 additions and 8 deletions

View File

@ -212,15 +212,42 @@ string CodeGenerator::generateDispatch(const NamespacePtr &nPtr, const Interface
{
if (vParamDecl[i]->isOut())
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
//_data_.rsp ? rsp.readFromObject(_data_.rsp) : rsp;
StructPtr sPtr = StructPtr::dynamicCast(vParamDecl[i]->getTypeIdPtr()->getTypePtr());
if (sPtr)
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
dstr << TAB << "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << " ? " << vParamDecl[i]->getTypeIdPtr()->getId() << ".readFromObject("
<< "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << ") : " << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId() << " || " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
}
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
StructPtr sPtr = StructPtr::dynamicCast(vParamDecl[i]->getTypeIdPtr()->getTypePtr());
if (sPtr)
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId() << ".readFromObject("
<< "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << ")"
<< ";" << endl;
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
}
}
}
DEL_TAB;

View File

@ -200,15 +200,41 @@ string CodeGenerator::generateTSServerDispatch(const NamespacePtr &nPtr, const I
{
if (vParamDecl[i]->isOut())
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
StructPtr sPtr = StructPtr::dynamicCast(vParamDecl[i]->getTypeIdPtr()->getTypePtr());
if (sPtr)
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
dstr << TAB << "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << " ? " << vParamDecl[i]->getTypeIdPtr()->getId() << ".readFromObject("
<< "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << ") : " << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId() << " || " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
}
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
StructPtr sPtr = StructPtr::dynamicCast(vParamDecl[i]->getTypeIdPtr()->getTypePtr());
if (sPtr)
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = " << getDefault(vParamDecl[i]->getTypeIdPtr(), "", nPtr->getId(), true)
<< ";" << endl;
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId() << ".readFromObject("
<< "_data_." << vParamDecl[i]->getTypeIdPtr()->getId() << ")"
<< ";" << endl;
}
else
{
dstr << TAB << vParamDecl[i]->getTypeIdPtr()->getId()
<< " = _data_." << vParamDecl[i]->getTypeIdPtr()->getId()
<< ";" << endl;
}
}
}
DEL_TAB;