Changeset 1b95be3 in tol


Ignore:
Timestamp:
Dec 10, 2010, 7:21:09 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
d9ed9cc
Parents:
e42f177
Message:

Refs #1029
New error handler Cint_errmsgcallback
New function Cint.exec_text
Enhanced documentation

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2779 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/contrib/cint/tolCint.cpp

    re42f177 r1b95be3  
    22
    33   http://root.cern.ch/drupal/content/cint
     4   http://root.cern.ch/viewvc/trunk/cint/doc/ref.txt
    45
    56   Copyright (C) 2010 - Bayes Decision, SL (Spain [EU])
    … …  
    3738/*
    3839
    39 extern G__EXPORT G__value G__calc G__P((G__CONST char *expr));
    40 extern G__EXPORT int  G__loadfile G__P((G__CONST char* filename));
    41 extern G__EXPORT int  G__unloadfile G__P((G__CONST char* filename));
    42 extern G__EXPORT G__value G__exec_tempfile G__P((G__CONST char *file));
     40G__scratch_all()
    4341
    4442*/
    4543
    46 static int G__init_cint__ = G__init_cint("cint");
    4744
     45//--------------------------------------------------------------------
     46void Cint_errmsgcallback(char *msg)
     47//--------------------------------------------------------------------
     48{
     49  BText filename = G__lasterror_filename();
     50  BText linenum = G__lasterror_linenum();
     51  BText locInfo = "";
     52  if(filename.HasName())
     53  {
     54    locInfo = BText("\nIn file ")+filename+" line "+linenum;
     55  }
     56  Error(BText("\n[Cint] ")+locInfo+msg);
     57}
     58
     59
     60//--------------------------------------------------------------------
     61int Cint_initialize()
     62//--------------------------------------------------------------------
     63{
     64  int G__init_cint_ = G__init_cint("cint");
     65  G__set_errmsgcallback(Cint_errmsgcallback);
     66  return(G__init_cint_);
     67};
     68
     69//--------------------------------------------------------------------
     70static int G__init_cint__ = Cint_initialize();
     71//--------------------------------------------------------------------
     72
     73//--------------------------------------------------------------------
    4874static BText cint_url_link = I2(
     75//--------------------------------------------------------------------
    4976  "\nSee more about the C/C++ interpreter CINT at ",
    5077  "\nMás detalles acerca del intérprete CINT para C/C++ en ")+
    51   "\n  http://root.cern.ch/drupal/content/cint\n";
     78  "\n  http://root.cern.ch/drupal/content/cint\n"
     79  "\n  http://root.cern.ch/viewvc/trunk/cint/doc/ref.txt\n";
    5280
    5381//--------------------------------------------------------------------
    … …  
    87115//--------------------------------------------------------------------
    88116  DeclareContensClass(BDat, BDatTemporary, BDatCINT_exec_tempfile);
    89   DefExtOpr(1, BDatCINT_exec_tempfile, "Cint.exec_tempfile", 1, 1, "Text",
    90   "(Text filePath)",
    91   I2(".",
    92      "."),
     117  DefExtOpr(1, BDatCINT_exec_tempfile, "Cint.exec_text", 1, 1, "Text",
     118  "(Text expression)",
     119    I2("Executes any C/C++ expression or set of expressions, such that the "
     120     "last one returns an integer or double value.\n"
     121     "Functions loaded with Cint.loadfile can be callable.\n"
     122     "Unlike Cint.calc API, Cint.exec_text can evaluate declaration and "
     123     "conditional statement. However, because Cint.exec_text uses temporary "
     124     "file, execution can be slower than Cint.calc\n",
     125     "Ejecuta una expresión C/C++ o grupo de expresiones tales que la última "
     126     "de ellas devuelve un resultado de tipo integer o double.\n"
     127     "Se pueden usar las funciones previamente cargadas con Cint.loadfile\n"
     128     "Al contrario que con Cint.calc sí se pueden declarar variables y "
     129     "funciones y usar ciclos o sentencias condicionales, pero debido a "
     130     "que internamente se usa un fichero temporal en disco puede resultar "
     131     "más lento en ejecución.")+
     132     cint_url_link,
    93133     BOperClassify::Conversion_);
    94134  void BDatCINT_exec_tempfile::CalcContens()
    95135//--------------------------------------------------------------------
    96136{
    97   if(CheckNonDeclarativeAction("Cint.exec_tempfile")) { return; }
    98   BText& filePath = Text(Arg(1));
    99   const char* str = filePath.String();
    100   G__value g = G__exec_tempfile(str);
     137  if(CheckNonDeclarativeAction("Cint.exec_text")) { return; }
     138  BText& expression = Text(Arg(1));
     139  G__value g = G__exec_text(expression);
    101140  switch (g.type)
    102141  {
Note: See TracChangeset for help on using the changeset viewer.