Changeset 1269 in Sophya for trunk/SophyaPI/PIext/cxxexecutor.cc
- Timestamp:
- Nov 1, 2000, 6:30:27 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/cxxexecutor.cc
r1268 r1269 13 13 CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */) 14 14 : mUserCodeFn(""), mUserFctFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("") 15 , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx") 15 , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(1) 16 16 { 17 17 mIncList.resize(0); … … 121 121 return(1); 122 122 } 123 rc = FillUserCode(toks,0); if(rc) return(1); 124 rc = CrFile(); if(rc) return(1); 125 rc = Compile(); if(rc) return(1); 126 rc = Link(); if(rc) return(1); 127 rc = Call(); if(rc) return(1); 123 rc = ExecuteCXX(toks); if(rc) return(1); 128 124 129 125 } else if(kw == "c++execfrf") { … … 132 128 return(1); 133 129 } 134 if(tokens.size()>1) rc = FillUserCode(tokens[0],tokens[1]); 135 else rc = FillUserCode(tokens[0]); 136 if(rc) return(1); 130 rc = FillUserCode(tokens[0]); if(rc) return(1); 131 if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]); 137 132 rc = CrFile(); if(rc) return(1); 138 133 rc = Compile(); if(rc) return(1); … … 158 153 return(1); 159 154 } 160 if(tokens.size()>3) rc = FillUserCode(tokens[2],tokens[3]); 161 else rc = FillUserCode(tokens[2]); 162 if(rc) return(1); 155 rc = FillUserCode(tokens[2]); if(rc) return(1); 156 if(tokens.size()>3) FillUserFctFrF(tokens[3]); 163 157 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1); 164 158 … … 199 193 200 194 /* --Methode-- */ 195 int CxxExecutor::ExecuteCXX(string usercode,string userfct) 196 { 197 int rc=0; 198 rc = FillUserCode(usercode,0); if(rc) return(1); 199 rc = FillUserFctFrS(userfct); 200 rc = CrFile(); if(rc) return(1); 201 rc = Compile(); if(rc) return(1); 202 rc = Link(); if(rc) return(1); 203 rc = Call(); if(rc) return(1); 204 return 0; 205 } 206 207 /* --Methode-- */ 201 208 int CxxExecutor::CrFile(string cfilename,string func) 202 209 { … … 216 223 217 224 os<<"//-------------------------------------------------//"<<endl; 218 os<<"//------------- Fonctions utilisateur-------------//"<<endl;225 os<<"//----------------- User Functions ----------------//"<<endl; 219 226 os<<"//-------------------------------------------------//"<<endl; 220 227 if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl; … … 239 246 240 247 os<<"//--------------------------------------------//"<<endl; 241 os<<"//------------- Code utilisateur-------------//"<<endl;248 os<<"//----------------- User Code ----------------//"<<endl; 242 249 os<<"//--------------------------------------------//"<<endl; 243 os<<endl; 244 os<<"#include \""<<mUserCodeFn<<"\""<<endl; 250 if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl; 245 251 os<<endl; 246 252 … … 248 254 os<<"}"<<endl; 249 255 250 cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl; 251 cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl; 256 if(mPrtLevel) 257 cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl; 258 if(mPrtLevel && mUserCodeFn.size()>0) 259 cout<<" User code was in file "<<mUserCodeFn<<endl; 260 if(mPrtLevel && mUserFctFn.size()>0) 261 cout<<" User function code was in file "<<mUserFctFn<<endl; 252 262 return 0; 253 263 } … … 364 374 { 365 375 mUserCodeFn = ""; 366 mUserFctFn = "";367 376 368 377 // get the string part which is after word "first" … … 389 398 if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open " 390 399 <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;} 391 os<<" "<<code; 392 cout<<"User code filled from standard input into "<<mUserCodeFn<<endl; 393 return 0; 394 } 395 396 /* --Methode-- */ 397 int CxxExecutor::FillUserCode(string filename,string filefctname) 398 // User code is read from "filename" an optionally from filefctname. 400 os<<code<<endl; 401 if(mPrtLevel) 402 cout<<"User code filled from standard input into "<<mUserCodeFn<<endl; 403 return 0; 404 } 405 406 /* --Methode-- */ 407 int CxxExecutor::FillUserFctFrS(string userfct) 408 // - Fill user Fonction code from string "userfct" 409 // It is put into file "TmpDir/cxx_spiapp_fct.h". 410 { 411 mUserFctFn = ""; 412 if(userfct.size()<1) return 0; 413 mUserFctFn = mDefTmp + mDefRoot + "_fct.h"; 414 ofstream os(mUserFctFn.c_str(),ios::out); 415 if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open " 416 <<mUserFctFn<<endl; mUserFctFn = ""; return 1;} 417 os<<userfct<<endl; 418 if(mPrtLevel) 419 cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl; 420 return 0; 421 } 422 423 /* --Methode-- */ 424 int CxxExecutor::FillUserCode(string filename) 425 // User code is read from "filename". 399 426 { 400 427 mUserCodeFn = filename; 401 mUserFctFn = filefctname; 402 cout<<"User code filled from file "<<filename<<endl; 428 if(mPrtLevel && mUserCodeFn.size()>0) 429 cout<<"User code filled from file "<<mUserCodeFn<<endl; 430 return 0; 431 } 432 433 /* --Methode-- */ 434 int CxxExecutor::FillUserFctFrF(string filefctname="") 435 { 436 mUserFctFn = filefctname; 437 if(mPrtLevel && mUserFctFn.size()>0) 438 cout<<"User Function code filled from file "<<mUserFctFn<<endl; 403 439 return 0; 404 440 } … … 408 444 { 409 445 if(rootfilename.size()<1) rootfilename = mDefRoot; 410 cout<<"Compile: "<<rootfilename<<endl;446 if(mPrtLevel) cout<<"Compile: "<<rootfilename<<endl; 411 447 int rc = 0; 412 448 rc = CrMakefile(); … … 477 513 string toks = libname + " " + func; 478 514 int rc = mpiac->ExecuteCommand(key,arg,toks); 479 cout<<"Link from "<<libname<<" for function "<<func480 <<" (rc="<<rc<<")"<<endl;515 if(mPrtLevel) cout<<"Link from "<<libname<<" for function "<<func 516 <<" (rc="<<rc<<")"<<endl; 481 517 return 0; 482 518 }
Note:
See TracChangeset
for help on using the changeset viewer.