Changeset 1276 in Sophya for trunk/SophyaPI/PIext/basexecut.cc


Ignore:
Timestamp:
Nov 2, 2000, 11:18:50 AM (25 years ago)
Author:
ercodmgr
Message:

Amelioration de la syntaxe de l'interpreteur, gestion de quotes, ligne suite
Commande linkff2 (2eme groupe de link, pour utilisation par CxxExecutor
Amelioration de la gestion de TMPDIR

Reza 2/11/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/basexecut.cc

    r1268 r1276  
    3434mImgApp = app;
    3535dynlink = NULL;
     36dynlink2 = NULL;
    3637RegisterCommands();
    3738}
     
    3940PIABaseExecutor::~PIABaseExecutor()
    4041{
     42  if (dynlink) delete dynlink;
     43  if (dynlink2) delete dynlink2;
    4144}
    4245
     
    124127  if (rc == 0)  cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
    125128}
     129else if (kw == "linkff2" ) {
     130  if (tokens.size() < 2) { cout << "Usage: linkff2 fnameso f1 [f2 f3]" << endl;  return(0); }
     131  string sph = "";
     132  for(int gg=0; gg<5; gg++)   tokens.push_back(sph);
     133  int rc = LinkUserFuncs2(tokens[0], tokens[1], tokens[2], tokens[3]);
     134  if (rc == 0)  cout << "PIABaseExecutor: Link2 from " << tokens[0] << " OK " << endl;
     135}
    126136else if (kw == "call" ) {
    127137  if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
    128   UsFmap::iterator it = usfmap.find(tokens[0]);
    129   if (it == usfmap.end()) {
     138  UsFmap::iterator it;
     139  UsFmap::iterator it1 = usfmap.find(tokens[0]);
     140  UsFmap::iterator it2 = usfmap2.find(tokens[0]);
     141  if ((it1 == usfmap.end()) && (it2 == usfmap2.end()) ) {
    130142    cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
    131143    return(0);
    132144  }
     145  if (it1 == usfmap.end())  it = it2;
     146  else it = it1;
    133147  cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
    134148// on est oblige de faire un cast  etant donne qu'on
     
    138152  bool red = mImgApp->HasRedirectedStdOutErr();
    139153  mImgApp->RedirectStdOutErr(false);
     154#ifdef SANS_EVOLPLANCK
    140155  TRY {
    141156    tokens.erase(tokens.begin());
     
    143158  }  CATCH(merr) {
    144159    fflush(stdout);
     160    string es = PeidaExc(merr);
     161    cerr << "\n PIABaseExecutor: Call UserFunc  Exception :" << merr << es;
    145162    cout << endl;
    146     cerr << endl;
    147 //CMV_A_FAIRE    string es = PeidaExc(merr);
    148 //CMV_A_FAIRE    cerr << "PIABaseExecutor: Call UserFunc  Exception :" << merr << es;
    149     }
     163    }
     164#else
     165  try {
     166    tokens.erase(tokens.begin());
     167    fuf(tokens);
     168  }
     169  catch ( PThrowable & exc ) {
     170    cerr << "\n PIABaseExecutor: Call / Catched Exception :"
     171         << (string)typeid(exc).name() << " Msg= "
     172         << exc.Msg() << endl;
     173    cout << endl;
     174  }
     175  catch ( ... ) {
     176    cerr << "\n PIABaseExecutor: Call / Catched Exception ... "
     177         << endl;
     178    cout << endl;
     179  }
     180#endif
    150181  mImgApp->RedirectStdOutErr(red);
    151182}
     
    677708usage = "Dynamic linking of compiled user functions \n  Usage: link fnameso f1 [f2 f3]";
    678709usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names ";
    679 usage += "\n  Related commands: call loadmodule"; 
     710usage += "\n  Related commands: call loadmodule linkff2"; 
     711mpiac->RegisterCommand(kw, usage, this, "External Modules");
     712kw = "linkff2";
     713usage = "Dynamic linking of compiled user functions (Set 2)\n  Usage: linkff2 fnameso f1 [f2 f3]";
     714usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names ";
     715usage += "\n  Related commands: call link loadmodule"; 
    680716mpiac->RegisterCommand(kw, usage, this, "External Modules");
    681717kw = "call";
     
    10981134}
    10991135
     1136/* --Methode-- */
     1137int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3)
     1138{
     1139string cmd;
     1140
     1141if (dynlink2) delete dynlink2;    dynlink2 = NULL;
     1142usfmap2.clear();
     1143
     1144dynlink2 = new PDynLinkMgr(fnameso, true);
     1145if (dynlink2 == NULL) {
     1146  string sn = fnameso;
     1147  cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl;
     1148  return(2);
     1149  }
     1150
     1151int nok=0;
     1152// on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
     1153// DlUserProcFunction f = NULL;
     1154DlFunction f = NULL;
     1155if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
     1156f = dynlink2->GetFunction(func1);
     1157if (f) { nok++;  usfmap2[func1] = f; }
     1158else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl;
     1159
     1160if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
     1161f = dynlink2->GetFunction(func2);
     1162if (f) { nok++;  usfmap2[func2] = f; }
     1163else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl;
     1164
     1165if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
     1166f = dynlink2->GetFunction(func3);
     1167if (f) { nok++;  usfmap2[func3] = f; }
     1168else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl;
     1169
     1170fin:
     1171if (nok < 1) { if (dynlink2) delete dynlink2;    dynlink2 = NULL;  return(3); }
     1172else return(0);
     1173}
     1174
    11001175/* Nouvelle-Fonction */
    11011176void RegisterPIGraphicsHelp(PIACmd* piac)
Note: See TracChangeset for help on using the changeset viewer.