From: jfa Date: Mon, 17 Sep 2007 10:18:48 +0000 (+0000) Subject: NPAL16955: syntax storage in a python supervisiongraph. X-Git-Tag: T_24092007~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a59e11e369d544fc1bba71e3630338b4e745cebc;p=modules%2Fsuperv.git NPAL16955: syntax storage in a python supervisiongraph. --- diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 264719f..51b902f 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -31,6 +31,18 @@ using namespace std; #include "DataFlowBase_StreamGraph.hxx" //#include "DataFlowBase_LoopNode.hxx" +// Screen single quotes +static string protectQuotes (const string theText) +{ + string aRes (theText); + for (unsigned int pos = 0; pos < aRes.size(); pos+=2) { + pos = aRes.find("'", pos); + if (pos < 0 || pos > aRes.size()) break; + aRes.replace(pos, 1, "\\\'"); + } + return aRes; +} + static void InitFields( //SUPERV::KindOfNode &_Kind , SUPERV::SDate &_FirstCreation , SUPERV::SDate &_LastModification , @@ -1612,7 +1624,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , if ( PythonFunctions.size() ) { aPyFunc = *PythonFunctions[0] ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; + f << " " << "Py" << Name() << ".append( '" << protectQuotes(aPyFunc[i].in()) << "' )" << endl; } } if ( IsInLineNode() ) { @@ -1652,12 +1664,15 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ; SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ; f << " " << "PyMore" << Name() << " = []" << endl ; + for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) { - f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ; + f << " " << "PyMore" << Name() << ".append( '" + << protectQuotes(aPyMore[i].in()) << "' )" << endl; } f << " " << "PyNext" << Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) { - f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ; + f << " " << "PyNext" << Name() << ".append( '" + << protectQuotes(aPyNext[i].in()) << "' )" << endl ; } f << " " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '" << FuncNames[0].c_str() << "' , Py" << Name() << " , '" @@ -1672,8 +1687,8 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ; f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" - << endl ; + f << " " << "Py" << aCoupledNode->Name() << ".append( '" + << protectQuotes(aPyFunc[i].in()) << "' )" << endl; } f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { @@ -1782,8 +1797,8 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ; f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ; for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) { - f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" - << endl ; + f << " " << "Py" << aCoupledNode->Name() << ".append( '" + << protectQuotes(aPyFunc[i].in()) << "' )" << endl; } f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {